[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220126073533.44994-9-xuanzhuo@linux.alibaba.com>
Date: Wed, 26 Jan 2022 15:35:24 +0800
From: Xuan Zhuo <xuanzhuo@...ux.alibaba.com>
To: virtualization@...ts.linux-foundation.org, netdev@...r.kernel.org
Cc: "Michael S. Tsirkin" <mst@...hat.com>,
Jason Wang <jasowang@...hat.com>,
"David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Jesper Dangaard Brouer <hawk@...nel.org>,
John Fastabend <john.fastabend@...il.com>, bpf@...r.kernel.org
Subject: [PATCH v3 08/17] virtio_ring: queue_reset: packed: support enable reset queue
The purpose of this patch is to make vring packed support re-enable reset
vq.
The core idea is that when calling vring_create_virtqueue_packed, use the
existing vq instead of re-allocating vq. vq is passed in through
function parameters.
Signed-off-by: Xuan Zhuo <xuanzhuo@...ux.alibaba.com>
---
drivers/virtio/virtio_ring.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index a93a677008ba..4beb7c7127c1 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -1680,7 +1680,8 @@ static struct virtqueue *vring_create_virtqueue_packed(
bool context,
bool (*notify)(struct virtqueue *),
void (*callback)(struct virtqueue *),
- const char *name)
+ const char *name,
+ struct virtqueue *_vq)
{
struct vring_virtqueue *vq;
struct vring_packed_desc *ring;
@@ -1710,15 +1711,20 @@ static struct virtqueue *vring_create_virtqueue_packed(
if (!device)
goto err_device;
- vq = kmalloc(sizeof(*vq), GFP_KERNEL);
- if (!vq)
- goto err_vq;
+ if (_vq) {
+ vq = to_vvq(_vq);
+ } else {
+ vq = kmalloc(sizeof(*vq), GFP_KERNEL);
+ if (!vq)
+ goto err_vq;
+ }
vq->vq.callback = callback;
vq->vq.vdev = vdev;
vq->vq.name = name;
vq->vq.num_free = num;
vq->vq.index = index;
+ vq->vq.reset = false;
vq->we_own_ring = true;
vq->notify = notify;
vq->weak_barriers = weak_barriers;
@@ -1789,7 +1795,8 @@ static struct virtqueue *vring_create_virtqueue_packed(
err_desc_extra:
kfree(vq->packed.desc_state);
err_desc_state:
- kfree(vq);
+ if (!_vq)
+ kfree(vq);
err_vq:
vring_free_queue(vdev, event_size_in_bytes, device, device_event_dma_addr);
err_device:
@@ -2311,7 +2318,7 @@ struct virtqueue *vring_setup_virtqueue(
if (virtio_has_feature(vdev, VIRTIO_F_RING_PACKED))
return vring_create_virtqueue_packed(index, num, vring_align,
vdev, weak_barriers, may_reduce_num,
- context, notify, callback, name);
+ context, notify, callback, name, vq);
return vring_create_virtqueue_split(index, num, vring_align,
vdev, weak_barriers, may_reduce_num,
--
2.31.0
Powered by blists - more mailing lists