Commit 7062cd86 authored by Michael S. Tsirkin's avatar Michael S. Tsirkin Committed by Kleber Sacilotto de Souza

virtio_console: don't tie bufs to a vq

BugLink: https://bugs.launchpad.net/bugs/1854855

[ Upstream commit 2855b335 ]

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: default avatarMichael S. Tsirkin <mst@redhat.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarConnor Kuehl <connor.kuehl@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent da524da2
...@@ -417,7 +417,7 @@ static void reclaim_dma_bufs(void) ...@@ -417,7 +417,7 @@ static void reclaim_dma_bufs(void)
} }
} }
static struct port_buffer *alloc_buf(struct virtqueue *vq, size_t buf_size, static struct port_buffer *alloc_buf(struct virtio_device *vdev, size_t buf_size,
int pages) int pages)
{ {
struct port_buffer *buf; struct port_buffer *buf;
...@@ -440,7 +440,7 @@ static struct port_buffer *alloc_buf(struct virtqueue *vq, size_t buf_size, ...@@ -440,7 +440,7 @@ static struct port_buffer *alloc_buf(struct virtqueue *vq, size_t buf_size,
return buf; return buf;
} }
if (is_rproc_serial(vq->vdev)) { if (is_rproc_serial(vdev)) {
/* /*
* Allocate DMA memory from ancestor. When a virtio * Allocate DMA memory from ancestor. When a virtio
* device is created by remoteproc, the DMA memory is * device is created by remoteproc, the DMA memory is
...@@ -450,9 +450,9 @@ static struct port_buffer *alloc_buf(struct virtqueue *vq, size_t buf_size, ...@@ -450,9 +450,9 @@ static struct port_buffer *alloc_buf(struct virtqueue *vq, size_t buf_size,
* DMA_MEMORY_INCLUDES_CHILDREN had been supported * DMA_MEMORY_INCLUDES_CHILDREN had been supported
* in dma-coherent.c * in dma-coherent.c
*/ */
if (!vq->vdev->dev.parent || !vq->vdev->dev.parent->parent) if (!vdev->dev.parent || !vdev->dev.parent->parent)
goto free_buf; goto free_buf;
buf->dev = vq->vdev->dev.parent->parent; buf->dev = vdev->dev.parent->parent;
/* Increase device refcnt to avoid freeing it */ /* Increase device refcnt to avoid freeing it */
get_device(buf->dev); get_device(buf->dev);
...@@ -835,7 +835,7 @@ static ssize_t port_fops_write(struct file *filp, const char __user *ubuf, ...@@ -835,7 +835,7 @@ static ssize_t port_fops_write(struct file *filp, const char __user *ubuf,
count = min((size_t)(32 * 1024), count); count = min((size_t)(32 * 1024), count);
buf = alloc_buf(port->out_vq, count, 0); buf = alloc_buf(port->portdev->vdev, count, 0);
if (!buf) if (!buf)
return -ENOMEM; return -ENOMEM;
...@@ -954,7 +954,7 @@ static ssize_t port_fops_splice_write(struct pipe_inode_info *pipe, ...@@ -954,7 +954,7 @@ static ssize_t port_fops_splice_write(struct pipe_inode_info *pipe,
if (ret < 0) if (ret < 0)
goto error_out; goto error_out;
buf = alloc_buf(port->out_vq, 0, pipe->nrbufs); buf = alloc_buf(port->portdev->vdev, 0, pipe->nrbufs);
if (!buf) { if (!buf) {
ret = -ENOMEM; ret = -ENOMEM;
goto error_out; goto error_out;
...@@ -1371,7 +1371,7 @@ static unsigned int fill_queue(struct virtqueue *vq, spinlock_t *lock) ...@@ -1371,7 +1371,7 @@ static unsigned int fill_queue(struct virtqueue *vq, spinlock_t *lock)
nr_added_bufs = 0; nr_added_bufs = 0;
do { do {
buf = alloc_buf(vq, PAGE_SIZE, 0); buf = alloc_buf(vq->vdev, PAGE_SIZE, 0);
if (!buf) if (!buf)
break; break;
......
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