Skip to content
Permalink
Browse files
virtio: support virtqueue_detach_unused_buf_ctx
Supports returning ctx while recycling unused buf, which helps to
release buf in different ways for different bufs.

Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
  • Loading branch information
fengidri authored and intel-lab-lkp committed Jun 16, 2021
1 parent 2f6e3dc commit 6155fdb771fa9f6c96472440c6b846dbfc4aebde
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
@@ -815,7 +815,8 @@ static bool virtqueue_enable_cb_delayed_split(struct virtqueue *_vq)
return true;
}

static void *virtqueue_detach_unused_buf_split(struct virtqueue *_vq)
static void *virtqueue_detach_unused_buf_ctx_split(struct virtqueue *_vq,
void **ctx)
{
struct vring_virtqueue *vq = to_vvq(_vq);
unsigned int i;
@@ -828,7 +829,7 @@ static void *virtqueue_detach_unused_buf_split(struct virtqueue *_vq)
continue;
/* detach_buf_split clears data, so grab it now. */
buf = vq->split.desc_state[i].data;
detach_buf_split(vq, i, NULL);
detach_buf_split(vq, i, ctx);
vq->split.avail_idx_shadow--;
vq->split.vring.avail->idx = cpu_to_virtio16(_vq->vdev,
vq->split.avail_idx_shadow);
@@ -1526,7 +1527,8 @@ static bool virtqueue_enable_cb_delayed_packed(struct virtqueue *_vq)
return true;
}

static void *virtqueue_detach_unused_buf_packed(struct virtqueue *_vq)
static void *virtqueue_detach_unused_buf_ctx_packed(struct virtqueue *_vq,
void **ctx)
{
struct vring_virtqueue *vq = to_vvq(_vq);
unsigned int i;
@@ -1539,7 +1541,7 @@ static void *virtqueue_detach_unused_buf_packed(struct virtqueue *_vq)
continue;
/* detach_buf clears data, so grab it now. */
buf = vq->packed.desc_state[i].data;
detach_buf_packed(vq, i, NULL);
detach_buf_packed(vq, i, ctx);
END_USE(vq);
return buf;
}
@@ -2018,12 +2020,18 @@ EXPORT_SYMBOL_GPL(virtqueue_enable_cb_delayed);
* This is not valid on an active queue; it is useful only for device
* shutdown.
*/
void *virtqueue_detach_unused_buf(struct virtqueue *_vq)
void *virtqueue_detach_unused_buf_ctx(struct virtqueue *_vq, void **ctx)
{
struct vring_virtqueue *vq = to_vvq(_vq);

return vq->packed_ring ? virtqueue_detach_unused_buf_packed(_vq) :
virtqueue_detach_unused_buf_split(_vq);
return vq->packed_ring ?
virtqueue_detach_unused_buf_ctx_packed(_vq, ctx) :
virtqueue_detach_unused_buf_ctx_split(_vq, ctx);
}

void *virtqueue_detach_unused_buf(struct virtqueue *_vq)
{
return virtqueue_detach_unused_buf_ctx(_vq, NULL);
}
EXPORT_SYMBOL_GPL(virtqueue_detach_unused_buf);

@@ -78,6 +78,8 @@ bool virtqueue_poll(struct virtqueue *vq, unsigned);

bool virtqueue_enable_cb_delayed(struct virtqueue *vq);

void *virtqueue_detach_unused_buf_ctx(struct virtqueue *vq, void **ctx);

void *virtqueue_detach_unused_buf(struct virtqueue *vq);

unsigned int virtqueue_get_vring_size(struct virtqueue *vq);

0 comments on commit 6155fdb

Please sign in to comment.