All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gurchetan Singh <gurchetansingh@chromium.org>
To: dri-devel@lists.freedesktop.org
Cc: chadversary@chromium.org,
	Gurchetan Singh <gurchetansingh@chromium.org>,
	kraxel@redhat.com, jbates@chromium.org
Subject: [RFC PATCH 8/8] drm/virtio: enable per context fencing
Date: Mon,  9 Mar 2020 18:08:18 -0700	[thread overview]
Message-ID: <20200310010818.569-9-gurchetansingh@chromium.org> (raw)
In-Reply-To: <20200310010818.569-1-gurchetansingh@chromium.org>

If there's a 3D context available, initialize the fence using
the 3D context's fence context.

We can't process just the largest fence id anymore, since it's
not the same as the sequence number now.

Signed-off-by: Gurchetan Singh <gurchetansingh@chromium.org>
---
 drivers/gpu/drm/virtio/virtgpu_fence.c | 15 ++++++++++++---
 drivers/gpu/drm/virtio/virtgpu_vq.c    |  4 +---
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/virtio/virtgpu_fence.c b/drivers/gpu/drm/virtio/virtgpu_fence.c
index a6c6f498e79e..bfcb41bcaa68 100644
--- a/drivers/gpu/drm/virtio/virtgpu_fence.c
+++ b/drivers/gpu/drm/virtio/virtgpu_fence.c
@@ -30,6 +30,8 @@
 #define to_virtio_fence(x) \
 	container_of(x, struct virtio_gpu_fence, f)
 
+static atomic_t fence_seq = ATOMIC_INIT(0);
+
 static const char *virtio_get_driver_name(struct dma_fence *f)
 {
 	return "virtio_gpu";
@@ -52,7 +54,7 @@ static bool virtio_fence_signaled(struct dma_fence *f)
 
 static void virtio_fence_value_str(struct dma_fence *f, char *str, int size)
 {
-	snprintf(str, size, "%llu", f->seqno);
+	snprintf(str, size, "[%llu, %llu]", f->context, f->seqno);
 }
 
 static void virtio_timeline_value_str(struct dma_fence *f, char *str, int size)
@@ -74,9 +76,11 @@ static const struct dma_fence_ops virtio_fence_ops = {
 struct virtio_gpu_fence *virtio_gpu_fence_alloc(struct virtio_gpu_device *vgdev,
 						struct virtio_gpu_fpriv *fpriv)
 {
+	uint64_t context;
 	struct virtio_gpu_fence_driver *drv = &vgdev->fence_drv;
 	struct virtio_gpu_fence *fence = kzalloc(sizeof(struct virtio_gpu_fence),
 							GFP_KERNEL);
+
 	if (!fence)
 		return fence;
 
@@ -86,7 +90,13 @@ struct virtio_gpu_fence *virtio_gpu_fence_alloc(struct virtio_gpu_device *vgdev,
 	 * unknown yet.  The fence must not be used outside of the driver
 	 * until virtio_gpu_fence_emit is called.
 	 */
-	dma_fence_init(&fence->f, &virtio_fence_ops, &drv->lock, drv->context, 0);
+	if (fpriv)
+		context = fpriv->fence_context;
+	else
+		context = drv->context;
+
+	dma_fence_init(&fence->f, &virtio_fence_ops, &drv->lock, context,
+		       atomic_inc_return(&fence_seq));
 
 	return fence;
 }
@@ -100,7 +110,6 @@ void virtio_gpu_fence_emit(struct virtio_gpu_device *vgdev,
 
 	spin_lock_irqsave(&drv->lock, irq_flags);
 	fence->fence_id = ++drv->current_fence_id;
-	fence->f.seqno = fence->fence_id;
 	dma_fence_get(&fence->f);
 	list_add_tail(&fence->node, &drv->fences);
 	spin_unlock_irqrestore(&drv->lock, irq_flags);
diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c
index 73854915ec34..e7d8b2398628 100644
--- a/drivers/gpu/drm/virtio/virtgpu_vq.c
+++ b/drivers/gpu/drm/virtio/virtgpu_vq.c
@@ -239,6 +239,7 @@ void virtio_gpu_dequeue_ctrl_func(struct work_struct *work)
 					  __func__, fence_id, f);
 			} else {
 				fence_id = f;
+				virtio_gpu_fence_event_process(vgdev, fence_id);
 			}
 		}
 		if (entry->resp_cb)
@@ -246,9 +247,6 @@ void virtio_gpu_dequeue_ctrl_func(struct work_struct *work)
 	}
 	wake_up(&vgdev->ctrlq.ack_queue);
 
-	if (fence_id)
-		virtio_gpu_fence_event_process(vgdev, fence_id);
-
 	list_for_each_entry_safe(entry, tmp, &reclaim_list, list) {
 		if (entry->objs)
 			virtio_gpu_array_put_free_delayed(vgdev, entry->objs);
-- 
2.25.1.481.gfbce0eb801-goog

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2020-03-10  1:08 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-10  1:08 [RFC PATCH 0/8] *** Per context fencing *** Gurchetan Singh
2020-03-10  1:08 ` [RFC PATCH 1/8] drm/virtio: use fence_id when processing fences Gurchetan Singh
2020-03-10  1:08 ` [RFC PATCH 2/8] drm/virtio: allocate a fence context for every 3D context Gurchetan Singh
2020-03-10  1:08 ` [RFC PATCH 3/8] drm/virtio: plumb virtio_gpu_fpriv to virtio_gpu_fence_alloc Gurchetan Singh
2020-03-10  1:08 ` [RFC PATCH 4/8] drm/virtio: rename sync_seq and last_seq Gurchetan Singh
2020-03-10  1:08 ` [RFC PATCH 5/8] drm/virtio: track fence_id in virtio_gpu_fence Gurchetan Singh
2020-03-10  1:08 ` [RFC PATCH 6/8] virtio/drm: rework virtio_fence_signaled Gurchetan Singh
2020-03-10  1:08 ` [RFC PATCH 7/8] drm/virtio: check context when signaling Gurchetan Singh
2020-03-10  1:08 ` Gurchetan Singh [this message]
2020-03-10  7:43 ` [RFC PATCH 0/8] *** Per context fencing *** Gerd Hoffmann
2020-03-10 22:57   ` Gurchetan Singh
2020-03-11 10:36     ` Gerd Hoffmann
2020-03-11 17:35       ` Chia-I Wu
2020-03-12  9:06         ` Gerd Hoffmann
2020-03-11 23:36       ` Gurchetan Singh
2020-03-12  0:43         ` Chia-I Wu
2020-03-12  9:10           ` Gerd Hoffmann
2020-03-12  9:29         ` Gerd Hoffmann
2020-03-12 23:08           ` Gurchetan Singh
2020-03-13 21:20             ` Chia-I Wu
2020-03-16  7:44               ` Gerd Hoffmann
2020-03-17 20:32                 ` Chia-I Wu
2020-03-18  6:40                   ` Gerd Hoffmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200310010818.569-9-gurchetansingh@chromium.org \
    --to=gurchetansingh@chromium.org \
    --cc=chadversary@chromium.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jbates@chromium.org \
    --cc=kraxel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.