diff options
author | Michael S. Tsirkin <mst@redhat.com> | 2018-04-20 12:54:23 -0400 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2018-04-25 13:33:13 -0400 |
commit | 2855b33514d290c51d52d94e25d3ef942cd4d578 (patch) | |
tree | 7f68bc994955fa0e0e7fcfa2a349d671f87a9374 | |
parent | b40000325044433cd350725e2025214ae48b17fd (diff) |
virtio_console: don't tie bufs to a vq
an allocated buffer doesn't need to be tied to a vq -
only vq->vdev is ever used. Pass the function the
just what it needs - the vdev.
Cc: stable@vger.kernel.org
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
-rw-r--r-- | drivers/char/virtio_console.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c index 468f06134012..3e56f328b4cb 100644 --- a/drivers/char/virtio_console.c +++ b/drivers/char/virtio_console.c | |||
@@ -422,7 +422,7 @@ static void reclaim_dma_bufs(void) | |||
422 | } | 422 | } |
423 | } | 423 | } |
424 | 424 | ||
425 | static struct port_buffer *alloc_buf(struct virtqueue *vq, size_t buf_size, | 425 | static struct port_buffer *alloc_buf(struct virtio_device *vdev, size_t buf_size, |
426 | int pages) | 426 | int pages) |
427 | { | 427 | { |
428 | struct port_buffer *buf; | 428 | struct port_buffer *buf; |
@@ -445,16 +445,16 @@ static struct port_buffer *alloc_buf(struct virtqueue *vq, size_t buf_size, | |||
445 | return buf; | 445 | return buf; |
446 | } | 446 | } |
447 | 447 | ||
448 | if (is_rproc_serial(vq->vdev)) { | 448 | if (is_rproc_serial(vdev)) { |
449 | /* | 449 | /* |
450 | * Allocate DMA memory from ancestor. When a virtio | 450 | * Allocate DMA memory from ancestor. When a virtio |
451 | * device is created by remoteproc, the DMA memory is | 451 | * device is created by remoteproc, the DMA memory is |
452 | * associated with the grandparent device: | 452 | * associated with the grandparent device: |
453 | * vdev => rproc => platform-dev. | 453 | * vdev => rproc => platform-dev. |
454 | */ | 454 | */ |
455 | if (!vq->vdev->dev.parent || !vq->vdev->dev.parent->parent) | 455 | if (!vdev->dev.parent || !vdev->dev.parent->parent) |
456 | goto free_buf; | 456 | goto free_buf; |
457 | buf->dev = vq->vdev->dev.parent->parent; | 457 | buf->dev = vdev->dev.parent->parent; |
458 | 458 | ||
459 | /* Increase device refcnt to avoid freeing it */ | 459 | /* Increase device refcnt to avoid freeing it */ |
460 | get_device(buf->dev); | 460 | get_device(buf->dev); |
@@ -838,7 +838,7 @@ static ssize_t port_fops_write(struct file *filp, const char __user *ubuf, | |||
838 | 838 | ||
839 | count = min((size_t)(32 * 1024), count); | 839 | count = min((size_t)(32 * 1024), count); |
840 | 840 | ||
841 | buf = alloc_buf(port->out_vq, count, 0); | 841 | buf = alloc_buf(port->portdev->vdev, count, 0); |
842 | if (!buf) | 842 | if (!buf) |
843 | return -ENOMEM; | 843 | return -ENOMEM; |
844 | 844 | ||
@@ -957,7 +957,7 @@ static ssize_t port_fops_splice_write(struct pipe_inode_info *pipe, | |||
957 | if (ret < 0) | 957 | if (ret < 0) |
958 | goto error_out; | 958 | goto error_out; |
959 | 959 | ||
960 | buf = alloc_buf(port->out_vq, 0, pipe->nrbufs); | 960 | buf = alloc_buf(port->portdev->vdev, 0, pipe->nrbufs); |
961 | if (!buf) { | 961 | if (!buf) { |
962 | ret = -ENOMEM; | 962 | ret = -ENOMEM; |
963 | goto error_out; | 963 | goto error_out; |
@@ -1374,7 +1374,7 @@ static unsigned int fill_queue(struct virtqueue *vq, spinlock_t *lock) | |||
1374 | 1374 | ||
1375 | nr_added_bufs = 0; | 1375 | nr_added_bufs = 0; |
1376 | do { | 1376 | do { |
1377 | buf = alloc_buf(vq, PAGE_SIZE, 0); | 1377 | buf = alloc_buf(vq->vdev, PAGE_SIZE, 0); |
1378 | if (!buf) | 1378 | if (!buf) |
1379 | break; | 1379 | break; |
1380 | 1380 | ||