Skip to content

Commit ce39cb0

Browse files
virtio_ring: add a func argument 'recycle_done' to virtqueue_resize()
JIRA: https://issues.redhat.com/browse/RHEL-56981 When virtqueue_resize() has actually recycled all unused buffers, additional work may be required in some cases. Relying solely on its return status is fragile, so introduce a new function argument 'recycle_done', which is invoked when the recycle really occurs. Cc: <stable@vger.kernel.org> # v6.11+ Signed-off-by: Koichiro Den <koichiro.den@canonical.com> Acked-by: Jason Wang <jasowang@redhat.com> Reviewed-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com> (cherry picked from commit 8d6712c) Signed-off-by: Cindy Lu <lulu@redhat.com>
1 parent e974458 commit ce39cb0

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

drivers/net/virtio_net.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3159,7 +3159,7 @@ static int virtnet_rx_resize(struct virtnet_info *vi,
31593159

31603160
virtnet_rx_pause(vi, rq);
31613161

3162-
err = virtqueue_resize(rq->vq, ring_num, virtnet_rq_unmap_free_buf);
3162+
err = virtqueue_resize(rq->vq, ring_num, virtnet_rq_unmap_free_buf, NULL);
31633163
if (err)
31643164
netdev_err(vi->dev, "resize rx fail: rx queue index: %d err: %d\n", qindex, err);
31653165

@@ -3222,7 +3222,7 @@ static int virtnet_tx_resize(struct virtnet_info *vi, struct send_queue *sq,
32223222

32233223
virtnet_tx_pause(vi, sq);
32243224

3225-
err = virtqueue_resize(sq->vq, ring_num, virtnet_sq_free_unused_buf);
3225+
err = virtqueue_resize(sq->vq, ring_num, virtnet_sq_free_unused_buf, NULL);
32263226
if (err)
32273227
netdev_err(vi->dev, "resize tx fail: tx queue index: %d err: %d\n", qindex, err);
32283228

drivers/virtio/virtio_ring.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2716,6 +2716,7 @@ EXPORT_SYMBOL_GPL(vring_create_virtqueue_dma);
27162716
* @_vq: the struct virtqueue we're talking about.
27172717
* @num: new ring num
27182718
* @recycle: callback to recycle unused buffers
2719+
* @recycle_done: callback to be invoked when recycle for all unused buffers done
27192720
*
27202721
* When it is really necessary to create a new vring, it will set the current vq
27212722
* into the reset state. Then call the passed callback to recycle the buffer
@@ -2736,7 +2737,8 @@ EXPORT_SYMBOL_GPL(vring_create_virtqueue_dma);
27362737
*
27372738
*/
27382739
int virtqueue_resize(struct virtqueue *_vq, u32 num,
2739-
void (*recycle)(struct virtqueue *vq, void *buf))
2740+
void (*recycle)(struct virtqueue *vq, void *buf),
2741+
void (*recycle_done)(struct virtqueue *vq))
27402742
{
27412743
struct vring_virtqueue *vq = to_vvq(_vq);
27422744
int err;
@@ -2753,6 +2755,8 @@ int virtqueue_resize(struct virtqueue *_vq, u32 num,
27532755
err = virtqueue_disable_and_recycle(_vq, recycle);
27542756
if (err)
27552757
return err;
2758+
if (recycle_done)
2759+
recycle_done(_vq);
27562760

27572761
if (vq->packed_ring)
27582762
err = virtqueue_resize_packed(_vq, num);

include/linux/virtio.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ dma_addr_t virtqueue_get_avail_addr(const struct virtqueue *vq);
100100
dma_addr_t virtqueue_get_used_addr(const struct virtqueue *vq);
101101

102102
int virtqueue_resize(struct virtqueue *vq, u32 num,
103-
void (*recycle)(struct virtqueue *vq, void *buf));
103+
void (*recycle)(struct virtqueue *vq, void *buf),
104+
void (*recycle_done)(struct virtqueue *vq));
104105
int virtqueue_reset(struct virtqueue *vq,
105106
void (*recycle)(struct virtqueue *vq, void *buf));
106107

0 commit comments

Comments
 (0)