Commit 7082e7a4 authored by Gerd Hoffmann's avatar Gerd Hoffmann

drm/virtio: batch display update commands.

When the driver submits multiple commands in a row it makes sense to
notify the host only after submitting the last one, so the host can
process them all at once, with a single vmexit.

Add functions to enable/disable notifications to allow that.  Use the
new functions for primary plane updates.
Signed-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
Reviewed-by: default avatarChia-I Wu <olvaffe@gmail.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20191212125346.8334-3-kraxel@redhat.com
parent 3954ff10
...@@ -183,6 +183,9 @@ struct virtio_gpu_device { ...@@ -183,6 +183,9 @@ struct virtio_gpu_device {
struct kmem_cache *vbufs; struct kmem_cache *vbufs;
bool vqs_ready; bool vqs_ready;
bool disable_notify;
bool pending_notify;
struct ida resource_ida; struct ida resource_ida;
wait_queue_head_t resp_wq; wait_queue_head_t resp_wq;
...@@ -335,6 +338,9 @@ void virtio_gpu_dequeue_ctrl_func(struct work_struct *work); ...@@ -335,6 +338,9 @@ void virtio_gpu_dequeue_ctrl_func(struct work_struct *work);
void virtio_gpu_dequeue_cursor_func(struct work_struct *work); void virtio_gpu_dequeue_cursor_func(struct work_struct *work);
void virtio_gpu_dequeue_fence_func(struct work_struct *work); void virtio_gpu_dequeue_fence_func(struct work_struct *work);
void virtio_gpu_disable_notify(struct virtio_gpu_device *vgdev);
void virtio_gpu_enable_notify(struct virtio_gpu_device *vgdev);
/* virtio_gpu_display.c */ /* virtio_gpu_display.c */
int virtio_gpu_framebuffer_init(struct drm_device *dev, int virtio_gpu_framebuffer_init(struct drm_device *dev,
struct virtio_gpu_framebuffer *vgfb, struct virtio_gpu_framebuffer *vgfb,
......
...@@ -146,6 +146,8 @@ static void virtio_gpu_primary_plane_update(struct drm_plane *plane, ...@@ -146,6 +146,8 @@ static void virtio_gpu_primary_plane_update(struct drm_plane *plane,
return; return;
} }
virtio_gpu_disable_notify(vgdev);
vgfb = to_virtio_gpu_framebuffer(plane->state->fb); vgfb = to_virtio_gpu_framebuffer(plane->state->fb);
bo = gem_to_virtio_gpu_obj(vgfb->base.obj[0]); bo = gem_to_virtio_gpu_obj(vgfb->base.obj[0]);
if (bo->dumb) if (bo->dumb)
...@@ -177,6 +179,8 @@ static void virtio_gpu_primary_plane_update(struct drm_plane *plane, ...@@ -177,6 +179,8 @@ static void virtio_gpu_primary_plane_update(struct drm_plane *plane,
plane->state->src_y >> 16, plane->state->src_y >> 16,
plane->state->src_w >> 16, plane->state->src_w >> 16,
plane->state->src_h >> 16); plane->state->src_h >> 16);
virtio_gpu_enable_notify(vgdev);
} }
static int virtio_gpu_cursor_prepare_fb(struct drm_plane *plane, static int virtio_gpu_cursor_prepare_fb(struct drm_plane *plane,
......
...@@ -404,8 +404,12 @@ static void virtio_gpu_queue_fenced_ctrl_buffer(struct virtio_gpu_device *vgdev, ...@@ -404,8 +404,12 @@ static void virtio_gpu_queue_fenced_ctrl_buffer(struct virtio_gpu_device *vgdev,
} }
notify = virtio_gpu_queue_ctrl_buffer_locked(vgdev, vbuf, vout); notify = virtio_gpu_queue_ctrl_buffer_locked(vgdev, vbuf, vout);
spin_unlock(&vgdev->ctrlq.qlock); spin_unlock(&vgdev->ctrlq.qlock);
if (notify) if (notify) {
virtqueue_notify(vgdev->ctrlq.vq); if (vgdev->disable_notify)
vgdev->pending_notify = true;
else
virtqueue_notify(vgdev->ctrlq.vq);
}
if (sgt) { if (sgt) {
sg_free_table(sgt); sg_free_table(sgt);
...@@ -413,6 +417,21 @@ static void virtio_gpu_queue_fenced_ctrl_buffer(struct virtio_gpu_device *vgdev, ...@@ -413,6 +417,21 @@ static void virtio_gpu_queue_fenced_ctrl_buffer(struct virtio_gpu_device *vgdev,
} }
} }
void virtio_gpu_disable_notify(struct virtio_gpu_device *vgdev)
{
vgdev->disable_notify = true;
}
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);
}
static void virtio_gpu_queue_ctrl_buffer(struct virtio_gpu_device *vgdev, static void virtio_gpu_queue_ctrl_buffer(struct virtio_gpu_device *vgdev,
struct virtio_gpu_vbuffer *vbuf) struct virtio_gpu_vbuffer *vbuf)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment