Skip to contentSkip to conversation

virtio-gpu: get p2pdma distance

PATCH Superseded Julia Zhang 3 participants 4 messages Jan 14, 2025 – Feb 26, 2025

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 virtio-gpu: get p2pdma distance

PCI peer-to-peer DMA transaction may be used in guest for some scenes. For example, dGPU prime feature will let virtio-iGPU access to passthrough dGPU buffer.

To support P2P DMA transaction in guest, virtio-gpu needs to check the compatibility which is represented by p2pdma_distance. This defines a command VIRTIO_GPU_CMD_P2PDMA_DISTANCE to allow guest send virtual pci notation of two devices to host and get host physical p2pdma_distance of these two PCI devices.

---
Hi all,

We are trying to implement dGPU prime feature in guest which will let virtio-iGPU read rendered data of passthrough dGPU. Before that, virtio gpu driver needs to get p2pdma_distance to check if P2P DMA transaction is possible or not.

To implement getting p2pdma_distance, QEMU needs to handle the command from guest with virtual pci notations of two PCI devices and send it to host kernel and return host physical distance back to guest.

So this defines the new command follow the suggestion in
https://lore.kernel.org/all/[email protected]/

Regards,
Julia

---
 device-types/gpu/description.tex | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
device-types/gpu/description.tex +29 -0
index 4435248..9d0f30b 100644
@@ -223,6 +223,7 @@ \subsubsection{Device Operation: Request header}\label{sec:Device Types / GPU De
         VIRTIO_GPU_CMD_SUBMIT_3D,
         VIRTIO_GPU_CMD_RESOURCE_MAP_BLOB,
         VIRTIO_GPU_CMD_RESOURCE_UNMAP_BLOB,
+        VIRTIO_GPU_CMD_P2PDMA_DISTANCE,
 
         /* cursor commands */
         VIRTIO_GPU_CMD_UPDATE_CURSOR = 0x0300,
@@ -236,6 +237,7 @@ \subsubsection{Device Operation: Request header}\label{sec:Device Types / GPU De
         VIRTIO_GPU_RESP_OK_EDID,
         VIRTIO_GPU_RESP_OK_RESOURCE_UUID,
         VIRTIO_GPU_RESP_OK_MAP_INFO,
+        VIRTIO_GPU_RESP_OK_P2PDMA_DISTANCE,
 
         /* error responses */
         VIRTIO_GPU_RESP_ERR_UNSPEC = 0x1200,
@@ -791,6 +793,33 @@ \subsubsection{Device Operation: controlq (3d)}\label{sec:Device Types / GPU Dev
 };
 \end{lstlisting}
 
+\item[VIRTIO_GPU_CMD_P2PDMA_DISTANCE] calculates the cumulative distance
+  between two devices before Peer-to-Peer(P2P) transaction. Request data
+  is \field{struct virtio_gpu_device_p2pdma_distance}. Response type is
+  VIRTIO_GPU_RESP_OK_P2PDMA_DISTANCE. Response data is
+  \field{virtio_gpu_resp_distance}.
+
+\begin{lstlisting}
+struct virtio_gpu_device_p2pdma_distance {
+        struct virtio_gpu_ctrl_hdr hdr;
+        le32 provider_bus;
+        le32 provider_slot;
+        le32 provider_func;
+        le32 client_bus;
+        le32 client_slot;
+        le32 client_func;
+};
+
+struct virtio_gpu_resp_distance {
+        struct virtio_gpu_ctrl_hdr hdr;
+        le32 distance;
+}
+\end{lstlisting}
+
+The request data contains guest virtual pci notations of p2pdma provider
+and client. The response contains the distance between provider and client,
+which represents the compatibility of these two PCI devices.
+
 \end{description}
 
 \subsubsection{Device Operation: cursorq}\label{sec:Device Types / GPU Device / Device Operation / Device Operation: cursorq}
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 23 lines · Julia Zhang

PCI peer-to-peer DMA transaction may be used in guest for some scenes. For example, dGPU prime feature will let virtio-iGPU access to passthrough dGPU buffer.

To support P2P DMA transaction in guest, virtio-gpu needs to check the compatibility which is represented by p2pdma_distance. This defines a command VIRTIO_GPU_CMD_P2PDMA_DISTANCE to allow guest send virtual pci notation of two devices to host and get host physical p2pdma_distance of these two PCI devices.

---
Hi all,

We are trying to implement dGPU prime feature in guest which will let virtio-iGPU read rendered data of passthrough dGPU. Before that, virtio gpu driver needs to get p2pdma_distance to check if P2P DMA transaction is possible or not.

To implement getting p2pdma_distance, QEMU needs to handle the command from guest with virtual pci notations of two PCI devices and send it to host kernel and return host physical distance back to guest.

Quoted 9 lines

So this defines the new command follow the suggestion in
https://lore.kernel.org/all/[email protected]/

Regards,
Julia

---
 device-types/gpu/description.tex | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
#2 lore raw

Hi MST,

Quoted 27 lines · Matias Ezequiel Vara Larsen
Quoted 26 lines · Julia Zhang

PCI peer-to-peer DMA transaction may be used in guest for some scenes. For example, dGPU prime feature will let virtio-iGPU access to passthrough dGPU buffer.

To support P2P DMA transaction in guest, virtio-gpu needs to check the compatibility which is represented by p2pdma_distance. This defines a command VIRTIO_GPU_CMD_P2PDMA_DISTANCE to allow guest send virtual pci notation of two devices to host and get host physical p2pdma_distance of these two PCI devices.

---
Hi all,

We are trying to implement dGPU prime feature in guest which will let virtio-iGPU read rendered data of passthrough dGPU. Before that, virtio gpu driver needs to get p2pdma_distance to check if P2P DMA transaction is possible or not.

To implement getting p2pdma_distance, QEMU needs to handle the command from guest with virtual pci notations of two PCI devices and send it to host kernel and return host physical distance back to guest.

So this defines the new command follow the suggestion in
https://lore.kernel.org/all/[email protected]/

Quoted 9 lines
Quoted 6 lines

Regards,
Julia

---
  device-types/gpu/description.tex | 29 +++++++++++++++++++++++++++++
  1 file changed, 29 insertions(+)

Does this patch meet all requirements for merging? If not, what should I do next step? Should I create a MR on github?

Regards,
Julia

#3 lore raw
Quoted 37 lines · Julia

Hi MST,

Quoted 34 lines · Matias Ezequiel Vara Larsen
Quoted 32 lines · Julia Zhang

PCI peer-to-peer DMA transaction may be used in guest for some scenes. For example, dGPU prime feature will let virtio-iGPU access to passthrough dGPU buffer.

To support P2P DMA transaction in guest, virtio-gpu needs to check the compatibility which is represented by p2pdma_distance. This defines a command VIRTIO_GPU_CMD_P2PDMA_DISTANCE to allow guest send virtual pci notation of two devices to host and get host physical p2pdma_distance of these two PCI devices.

---
Hi all,

We are trying to implement dGPU prime feature in guest which will let virtio-iGPU read rendered data of passthrough dGPU. Before that, virtio gpu driver needs to get p2pdma_distance to check if P2P DMA transaction is possible or not.

To implement getting p2pdma_distance, QEMU needs to handle the command from guest with virtual pci notations of two PCI devices and send it to host kernel and return host physical distance back to guest.

So this defines the new command follow the suggestion in
https://lore.kernel.org/all/[email protected]/

Regards,
Julia

---
  device-types/gpu/description.tex | 29 +++++++++++++++++++++++++++++
  1 file changed, 29 insertions(+)
Quoted 7 lines
Quoted 2 lines

Does this patch meet all requirements for merging? If not, what should I do next step? Should I create a MR on github?

Regards,
Julia

No, here are the instructions:
https://github.com/oasis-tcs/virtio-spec/blob/master/README.md#use-of-github-issues