From: Chia-I Wu <olvaffe@gmail.com>
To: dri-devel@lists.freedesktop.org
Cc: kraxel@redhat.com, gurchetansingh@chromium.org
Subject: [PATCH v2 1/3] drm/virtio: remove the global pending_notify state
Date: Fri, 7 Feb 2020 14:13:57 -0800 [thread overview]
Message-ID: <20200207221359.187340-2-olvaffe@gmail.com> (raw)
In-Reply-To: <20200207221359.187340-1-olvaffe@gmail.com>
Call virtqueue_kick_prepare once in virtio_gpu_enable_notify, not
whenever a command is added. This should be more efficient since
the intention is to batch commands.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
---
drivers/gpu/drm/virtio/virtgpu_drv.h | 1 -
drivers/gpu/drm/virtio/virtgpu_vq.c | 34 ++++++++++++++++++----------
2 files changed, 22 insertions(+), 13 deletions(-)
diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/virtgpu_drv.h
index d278c8c50f394..d3fcc25068132 100644
--- a/drivers/gpu/drm/virtio/virtgpu_drv.h
+++ b/drivers/gpu/drm/virtio/virtgpu_drv.h
@@ -178,7 +178,6 @@ struct virtio_gpu_device {
bool vqs_ready;
bool disable_notify;
- bool pending_notify;
struct ida resource_ida;
diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c
index cc02fc4bab2a5..0c9be2142ba1a 100644
--- a/drivers/gpu/drm/virtio/virtgpu_vq.c
+++ b/drivers/gpu/drm/virtio/virtgpu_vq.c
@@ -367,16 +367,13 @@ static void virtio_gpu_queue_ctrl_sgs(struct virtio_gpu_device *vgdev,
trace_virtio_gpu_cmd_queue(vq, virtio_gpu_vbuf_ctrl_hdr(vbuf));
- notify = virtqueue_kick_prepare(vq);
+ if (!vgdev->disable_notify)
+ notify = virtqueue_kick_prepare(vq);
spin_unlock(&vgdev->ctrlq.qlock);
- if (notify) {
- if (vgdev->disable_notify)
- vgdev->pending_notify = true;
- else
- virtqueue_notify(vq);
- }
+ if (notify)
+ virtqueue_notify(vq);
}
static void virtio_gpu_queue_fenced_ctrl_buffer(struct virtio_gpu_device *vgdev,
@@ -432,6 +429,23 @@ static void virtio_gpu_queue_fenced_ctrl_buffer(struct virtio_gpu_device *vgdev,
}
}
+static void virtio_gpu_commit_ctrl(struct virtio_gpu_device *vgdev)
+{
+ struct virtqueue *vq = vgdev->ctrlq.vq;
+ bool notify;
+
+ spin_lock(&vgdev->ctrlq.qlock);
+ notify = virtqueue_kick_prepare(vq);
+ spin_unlock(&vgdev->ctrlq.qlock);
+
+ /* Do not call virtqueue_notify with the lock held because
+ * virtio_gpu_dequeue_ctrl_func may contend for the lock if an irq is
+ * generated while we are in virtqueue_notify.
+ */
+ if (notify)
+ virtqueue_notify(vq);
+}
+
void virtio_gpu_disable_notify(struct virtio_gpu_device *vgdev)
{
vgdev->disable_notify = true;
@@ -440,11 +454,7 @@ void virtio_gpu_disable_notify(struct virtio_gpu_device *vgdev)
void virtio_gpu_enable_notify(struct virtio_gpu_device *vgdev)
{
vgdev->disable_notify = false;
-
- if (!vgdev->pending_notify)
- return;
- vgdev->pending_notify = false;
- virtqueue_notify(vgdev->ctrlq.vq);
+ virtio_gpu_commit_ctrl(vgdev);
}
static void virtio_gpu_queue_ctrl_buffer(struct virtio_gpu_device *vgdev,
--
2.25.0.341.g760bfbb309-goog
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2020-02-07 22:14 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-06 19:22 [PATCH 0/2] drm/virtio: rework command batching Chia-I Wu
2020-02-06 19:22 ` [PATCH 1/2] drm/virtio: remove the global pending_notify state Chia-I Wu
2020-02-06 19:22 ` [PATCH 2/2] drm/virtio: remove the global disable_notify state Chia-I Wu
2020-02-07 8:22 ` Gerd Hoffmann
2020-02-07 22:13 ` [PATCH v2 0/3] drm/virtio: rework command batching Chia-I Wu
2020-02-07 22:13 ` Chia-I Wu [this message]
2020-02-07 22:13 ` [PATCH v2 2/3] drm/virtio: never kick in virtio_gpu_queue_ctrl_sgs Chia-I Wu
2020-02-11 12:57 ` Gerd Hoffmann
2020-02-07 22:13 ` [PATCH v2 3/3] drm/virtio: remove the global disable_notify state Chia-I Wu
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=20200207221359.187340-2-olvaffe@gmail.com \
--to=olvaffe@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=gurchetansingh@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox