]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
6.5-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 13 Sep 2023 08:22:13 +0000 (10:22 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 13 Sep 2023 08:22:13 +0000 (10:22 +0200)
added patches:
drm-virtio-conditionally-allocate-virtio_gpu_fence.patch

queue-6.5/drm-virtio-conditionally-allocate-virtio_gpu_fence.patch [new file with mode: 0644]
queue-6.5/series

diff --git a/queue-6.5/drm-virtio-conditionally-allocate-virtio_gpu_fence.patch b/queue-6.5/drm-virtio-conditionally-allocate-virtio_gpu_fence.patch
new file mode 100644 (file)
index 0000000..ff3b174
--- /dev/null
@@ -0,0 +1,101 @@
+From 70d1ace56db6c79d39dbe9c0d5244452b67e2fde Mon Sep 17 00:00:00 2001
+From: Gurchetan Singh <gurchetansingh@chromium.org>
+Date: Fri, 7 Jul 2023 14:31:24 -0700
+Subject: drm/virtio: Conditionally allocate virtio_gpu_fence
+
+From: Gurchetan Singh <gurchetansingh@chromium.org>
+
+commit 70d1ace56db6c79d39dbe9c0d5244452b67e2fde upstream.
+
+We don't want to create a fence for every command submission.  It's
+only necessary when userspace provides a waitable token for submission.
+This could be:
+
+1) bo_handles, to be used with VIRTGPU_WAIT
+2) out_fence_fd, to be used with dma_fence apis
+3) a ring_idx provided with VIRTGPU_CONTEXT_PARAM_POLL_RINGS_MASK
+   + DRM event API
+4) syncobjs in the future
+
+The use case for just submitting a command to the host, and expecting
+no response.  For example, gfxstream has GFXSTREAM_CONTEXT_PING that
+just wakes up the host side worker threads.  There's also
+CROSS_DOMAIN_CMD_SEND which just sends data to the Wayland server.
+
+This prevents the need to signal the automatically created
+virtio_gpu_fence.
+
+In addition, VIRTGPU_EXECBUF_RING_IDX is checked when creating a
+DRM event object.  VIRTGPU_CONTEXT_PARAM_POLL_RINGS_MASK is
+already defined in terms of per-context rings.  It was theoretically
+possible to create a DRM event on the global timeline (ring_idx == 0),
+if the context enabled DRM event polling.  However, that wouldn't
+work and userspace (Sommelier).  Explicitly disallow it for
+clarity.
+
+Signed-off-by: Gurchetan Singh <gurchetansingh@chromium.org>
+Reviewed-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
+Tested-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
+Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com> # edited coding style
+Link: https://patchwork.freedesktop.org/patch/msgid/20230707213124.494-1-gurchetansingh@chromium.org
+Signed-off-by: Alyssa Ross <hi@alyssa.is>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/gpu/drm/virtio/virtgpu_submit.c |   32 ++++++++++++++++++++------------
+ 1 file changed, 20 insertions(+), 12 deletions(-)
+
+--- a/drivers/gpu/drm/virtio/virtgpu_submit.c
++++ b/drivers/gpu/drm/virtio/virtgpu_submit.c
+@@ -64,13 +64,9 @@ static int virtio_gpu_fence_event_create
+                                        struct virtio_gpu_fence *fence,
+                                        u32 ring_idx)
+ {
+-      struct virtio_gpu_fpriv *vfpriv = file->driver_priv;
+       struct virtio_gpu_fence_event *e = NULL;
+       int ret;
+-      if (!(vfpriv->ring_idx_mask & BIT_ULL(ring_idx)))
+-              return 0;
+-
+       e = kzalloc(sizeof(*e), GFP_KERNEL);
+       if (!e)
+               return -ENOMEM;
+@@ -164,18 +160,30 @@ static int virtio_gpu_init_submit(struct
+       struct virtio_gpu_fpriv *vfpriv = file->driver_priv;
+       struct virtio_gpu_device *vgdev = dev->dev_private;
+       struct virtio_gpu_fence *out_fence;
++      bool drm_fence_event;
+       int err;
+       memset(submit, 0, sizeof(*submit));
+-      out_fence = virtio_gpu_fence_alloc(vgdev, fence_ctx, ring_idx);
+-      if (!out_fence)
+-              return -ENOMEM;
+-
+-      err = virtio_gpu_fence_event_create(dev, file, out_fence, ring_idx);
+-      if (err) {
+-              dma_fence_put(&out_fence->f);
+-              return err;
++      if ((exbuf->flags & VIRTGPU_EXECBUF_RING_IDX) &&
++          (vfpriv->ring_idx_mask & BIT_ULL(ring_idx)))
++              drm_fence_event = true;
++      else
++              drm_fence_event = false;
++
++      if ((exbuf->flags & VIRTGPU_EXECBUF_FENCE_FD_OUT) ||
++          exbuf->num_bo_handles ||
++          drm_fence_event)
++              out_fence = virtio_gpu_fence_alloc(vgdev, fence_ctx, ring_idx);
++      else
++              out_fence = NULL;
++
++      if (drm_fence_event) {
++              err = virtio_gpu_fence_event_create(dev, file, out_fence, ring_idx);
++              if (err) {
++                      dma_fence_put(&out_fence->f);
++                      return err;
++              }
+       }
+       submit->out_fence = out_fence;
index 4cc532a75f9bb56ec7e723792793bc38eaa16976..20dabc16bc577af45c8f7eedf1c94929e401f913 100644 (file)
@@ -1 +1,2 @@
 net-ipv6-skb-symmetric-hash-should-incorporate-transport-ports.patch
+drm-virtio-conditionally-allocate-virtio_gpu_fence.patch