Skip to content

Commit 343a775

Browse files
lkpdngregkh
authored andcommitted
virtio_ring: add a func argument 'recycle_done' to virtqueue_reset()
[ Upstream commit 8d2da07 ] When virtqueue_reset() 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 it really occurs. Signed-off-by: Koichiro Den <[email protected]> Acked-by: Jason Wang <[email protected]> Reviewed-by: Xuan Zhuo <[email protected]> Signed-off-by: Paolo Abeni <[email protected]> Stable-dep-of: 76a771e ("virtio_net: ensure netdev_tx_reset_queue is called on bind xsk for tx") Signed-off-by: Sasha Levin <[email protected]>
1 parent 1cf8bdd commit 343a775

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
@@ -5547,7 +5547,7 @@ static int virtnet_rq_bind_xsk_pool(struct virtnet_info *vi, struct receive_queu
55475547

55485548
virtnet_rx_pause(vi, rq);
55495549

5550-
err = virtqueue_reset(rq->vq, virtnet_rq_unmap_free_buf);
5550+
err = virtqueue_reset(rq->vq, virtnet_rq_unmap_free_buf, NULL);
55515551
if (err) {
55525552
netdev_err(vi->dev, "reset rx fail: rx queue index: %d err: %d\n", qindex, err);
55535553

@@ -5576,7 +5576,7 @@ static int virtnet_sq_bind_xsk_pool(struct virtnet_info *vi,
55765576

55775577
virtnet_tx_pause(vi, sq);
55785578

5579-
err = virtqueue_reset(sq->vq, virtnet_sq_free_unused_buf);
5579+
err = virtqueue_reset(sq->vq, virtnet_sq_free_unused_buf, NULL);
55805580
if (err) {
55815581
netdev_err(vi->dev, "reset tx fail: tx queue index: %d err: %d\n", qindex, err);
55825582
pool = NULL;

drivers/virtio/virtio_ring.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2815,6 +2815,7 @@ EXPORT_SYMBOL_GPL(virtqueue_set_dma_premapped);
28152815
* virtqueue_reset - detach and recycle all unused buffers
28162816
* @_vq: the struct virtqueue we're talking about.
28172817
* @recycle: callback to recycle unused buffers
2818+
* @recycle_done: callback to be invoked when recycle for all unused buffers done
28182819
*
28192820
* Caller must ensure we don't call this with other virtqueue operations
28202821
* at the same time (except where noted).
@@ -2826,14 +2827,17 @@ EXPORT_SYMBOL_GPL(virtqueue_set_dma_premapped);
28262827
* -EPERM: Operation not permitted
28272828
*/
28282829
int virtqueue_reset(struct virtqueue *_vq,
2829-
void (*recycle)(struct virtqueue *vq, void *buf))
2830+
void (*recycle)(struct virtqueue *vq, void *buf),
2831+
void (*recycle_done)(struct virtqueue *vq))
28302832
{
28312833
struct vring_virtqueue *vq = to_vvq(_vq);
28322834
int err;
28332835

28342836
err = virtqueue_disable_and_recycle(_vq, recycle);
28352837
if (err)
28362838
return err;
2839+
if (recycle_done)
2840+
recycle_done(_vq);
28372841

28382842
if (vq->packed_ring)
28392843
virtqueue_reinit_packed(vq);

include/linux/virtio.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ int virtqueue_resize(struct virtqueue *vq, u32 num,
103103
void (*recycle)(struct virtqueue *vq, void *buf),
104104
void (*recycle_done)(struct virtqueue *vq));
105105
int virtqueue_reset(struct virtqueue *vq,
106-
void (*recycle)(struct virtqueue *vq, void *buf));
106+
void (*recycle)(struct virtqueue *vq, void *buf),
107+
void (*recycle_done)(struct virtqueue *vq));
107108

108109
struct virtio_admin_cmd {
109110
__le16 opcode;

0 commit comments

Comments
 (0)