Commit 9c73f478 authored by Gerd Hoffmann's avatar Gerd Hoffmann

virtio-gpu: add virtio_gpu_queue_ctrl_buffer_locked

Add virtio_gpu_queue_ctrl_buffer_locked function, which does the same as
virtio_gpu_queue_ctrl_buffer but does not take the virtqueue lock.  The
caller must hold the lock instead.
Signed-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
parent 25cb62b7
...@@ -293,7 +293,7 @@ void virtio_gpu_dequeue_cursor_func(struct work_struct *work) ...@@ -293,7 +293,7 @@ void virtio_gpu_dequeue_cursor_func(struct work_struct *work)
wake_up(&vgdev->cursorq.ack_queue); wake_up(&vgdev->cursorq.ack_queue);
} }
static int virtio_gpu_queue_ctrl_buffer(struct virtio_gpu_device *vgdev, static int virtio_gpu_queue_ctrl_buffer_locked(struct virtio_gpu_device *vgdev,
struct virtio_gpu_vbuffer *vbuf) struct virtio_gpu_vbuffer *vbuf)
{ {
struct virtqueue *vq = vgdev->ctrlq.vq; struct virtqueue *vq = vgdev->ctrlq.vq;
...@@ -320,7 +320,6 @@ static int virtio_gpu_queue_ctrl_buffer(struct virtio_gpu_device *vgdev, ...@@ -320,7 +320,6 @@ static int virtio_gpu_queue_ctrl_buffer(struct virtio_gpu_device *vgdev,
incnt++; incnt++;
} }
spin_lock(&vgdev->ctrlq.qlock);
retry: retry:
ret = virtqueue_add_sgs(vq, sgs, outcnt, incnt, vbuf, GFP_ATOMIC); ret = virtqueue_add_sgs(vq, sgs, outcnt, incnt, vbuf, GFP_ATOMIC);
if (ret == -ENOSPC) { if (ret == -ENOSPC) {
...@@ -331,13 +330,23 @@ static int virtio_gpu_queue_ctrl_buffer(struct virtio_gpu_device *vgdev, ...@@ -331,13 +330,23 @@ static int virtio_gpu_queue_ctrl_buffer(struct virtio_gpu_device *vgdev,
} else { } else {
virtqueue_kick(vq); virtqueue_kick(vq);
} }
spin_unlock(&vgdev->ctrlq.qlock);
if (!ret) if (!ret)
ret = vq->num_free; ret = vq->num_free;
return ret; return ret;
} }
static int virtio_gpu_queue_ctrl_buffer(struct virtio_gpu_device *vgdev,
struct virtio_gpu_vbuffer *vbuf)
{
int rc;
spin_lock(&vgdev->ctrlq.qlock);
rc = virtio_gpu_queue_ctrl_buffer_locked(vgdev, vbuf);
spin_unlock(&vgdev->ctrlq.qlock);
return rc;
}
static int virtio_gpu_queue_cursor(struct virtio_gpu_device *vgdev, static int virtio_gpu_queue_cursor(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