All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/1] virtio-gpu: get p2pdma distance
@ 2025-02-26  9:27 Julia Zhang
  2025-02-26 10:44 ` Matias Ezequiel Vara Larsen
  2025-02-26 10:51 ` Parav Pandit
  0 siblings, 2 replies; 21+ messages in thread
From: Julia Zhang @ 2025-02-26  9:27 UTC (permalink / raw)
  To: virtio-comment
  Cc: Michael S . Tsirkin, Chen Jiqian, Zhu Lingshan, Huang Rui,
	Julia Zhang, Matias Ezequiel Vara Larsen

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.

Fixes:https://github.com/oasis-tcs/virtio-spec/issues/217
Signed-off-by: Julia Zhang <julia.zhang@amd.com>
Reviewed-by: Matias Ezequiel Vara Larsen <mvaralar@redhat.com>
---
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/20241207105537.542441-4-julia.zhang@amd.com/

changes from v1:
 - add issue link to commit msg

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

diff --git a/device-types/gpu/description.tex b/device-types/gpu/description.tex
index 4435248..9d0f30b 100644
--- a/device-types/gpu/description.tex
+++ b/device-types/gpu/description.tex
@@ -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}
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2025-03-20 10:00 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-26  9:27 [PATCH v2 1/1] virtio-gpu: get p2pdma distance Julia Zhang
2025-02-26 10:44 ` Matias Ezequiel Vara Larsen
2025-02-26 10:51 ` Parav Pandit
2025-03-05 10:41   ` Zhang, Julia
2025-03-06  4:29     ` Parav Pandit
2025-03-06  7:16       ` Zhang, Julia
2025-03-10  3:48         ` Parav Pandit
2025-03-10  7:37           ` Zhang, Julia
2025-03-10 10:18             ` Parav Pandit
2025-03-11  3:27               ` Zhang, Julia
2025-03-11  4:00                 ` Parav Pandit
2025-03-11  7:29                   ` Zhang, Julia
2025-03-11 15:14                     ` Parav Pandit
2025-03-12  6:20                       ` Zhang, Julia
2025-03-12 10:11                         ` Parav Pandit
2025-03-13  3:31                           ` Zhang, Julia
2025-03-14  2:15                             ` Parav Pandit
2025-03-14  3:02                               ` Zhang, Julia
2025-03-19 10:45                                 ` Zhang, Julia
2025-03-19 12:23                                   ` Michael S. Tsirkin
2025-03-20 10:00                                     ` Zhang, Julia

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.