virtio_ring: add a func argument 'recycle_done' to virtqueue_resize()
commit 8d6712c892019b9b9dc5c7039edd3c9d770b510b upstream. 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
b4294d4ac6
commit
098b9821fe
@@ -3165,7 +3165,7 @@ static int virtnet_rx_resize(struct virtnet_info *vi,
|
||||
|
||||
virtnet_rx_pause(vi, rq);
|
||||
|
||||
err = virtqueue_resize(rq->vq, ring_num, virtnet_rq_unmap_free_buf);
|
||||
err = virtqueue_resize(rq->vq, ring_num, virtnet_rq_unmap_free_buf, NULL);
|
||||
if (err)
|
||||
netdev_err(vi->dev, "resize rx fail: rx queue index: %d err: %d\n", qindex, err);
|
||||
|
||||
@@ -3228,7 +3228,7 @@ static int virtnet_tx_resize(struct virtnet_info *vi, struct send_queue *sq,
|
||||
|
||||
virtnet_tx_pause(vi, sq);
|
||||
|
||||
err = virtqueue_resize(sq->vq, ring_num, virtnet_sq_free_unused_buf);
|
||||
err = virtqueue_resize(sq->vq, ring_num, virtnet_sq_free_unused_buf, NULL);
|
||||
if (err)
|
||||
netdev_err(vi->dev, "resize tx fail: tx queue index: %d err: %d\n", qindex, err);
|
||||
|
||||
|
||||
@@ -2716,6 +2716,7 @@ EXPORT_SYMBOL_GPL(vring_create_virtqueue_dma);
|
||||
* @_vq: the struct virtqueue we're talking about.
|
||||
* @num: new ring num
|
||||
* @recycle: callback to recycle unused buffers
|
||||
* @recycle_done: callback to be invoked when recycle for all unused buffers done
|
||||
*
|
||||
* When it is really necessary to create a new vring, it will set the current vq
|
||||
* into the reset state. Then call the passed callback to recycle the buffer
|
||||
@@ -2736,7 +2737,8 @@ EXPORT_SYMBOL_GPL(vring_create_virtqueue_dma);
|
||||
*
|
||||
*/
|
||||
int virtqueue_resize(struct virtqueue *_vq, u32 num,
|
||||
void (*recycle)(struct virtqueue *vq, void *buf))
|
||||
void (*recycle)(struct virtqueue *vq, void *buf),
|
||||
void (*recycle_done)(struct virtqueue *vq))
|
||||
{
|
||||
struct vring_virtqueue *vq = to_vvq(_vq);
|
||||
int err;
|
||||
@@ -2753,6 +2755,8 @@ int virtqueue_resize(struct virtqueue *_vq, u32 num,
|
||||
err = virtqueue_disable_and_recycle(_vq, recycle);
|
||||
if (err)
|
||||
return err;
|
||||
if (recycle_done)
|
||||
recycle_done(_vq);
|
||||
|
||||
if (vq->packed_ring)
|
||||
err = virtqueue_resize_packed(_vq, num);
|
||||
|
||||
@@ -100,7 +100,8 @@ dma_addr_t virtqueue_get_avail_addr(const struct virtqueue *vq);
|
||||
dma_addr_t virtqueue_get_used_addr(const struct virtqueue *vq);
|
||||
|
||||
int virtqueue_resize(struct virtqueue *vq, u32 num,
|
||||
void (*recycle)(struct virtqueue *vq, void *buf));
|
||||
void (*recycle)(struct virtqueue *vq, void *buf),
|
||||
void (*recycle_done)(struct virtqueue *vq));
|
||||
int virtqueue_reset(struct virtqueue *vq,
|
||||
void (*recycle)(struct virtqueue *vq, void *buf));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user