@@ -178,7 +178,6 @@ struct virtio_gpu_device {
bool vqs_ready;
bool disable_notify;
- bool pending_notify;
struct ida resource_ida;
@@ -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,
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(-)