Skip to content

Commit 2df6475

Browse files
fengidrimstsirkin
authored andcommitted
virtio_ring: introduce virtqueue_dma_dev()
Added virtqueue_dma_dev() to get DMA device for virtio. Then the caller can do dma operation in advance. The purpose is to keep memory mapped across multiple add/get buf operations. Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com> Acked-by: Jason Wang <jasowang@redhat.com> Message-Id: <20230810123057.43407-6-xuanzhuo@linux.alibaba.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
1 parent d7344a2 commit 2df6475

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

drivers/virtio/virtio_ring.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2265,6 +2265,23 @@ int virtqueue_add_inbuf_ctx(struct virtqueue *vq,
22652265
}
22662266
EXPORT_SYMBOL_GPL(virtqueue_add_inbuf_ctx);
22672267

2268+
/**
2269+
* virtqueue_dma_dev - get the dma dev
2270+
* @_vq: the struct virtqueue we're talking about.
2271+
*
2272+
* Returns the dma dev. That can been used for dma api.
2273+
*/
2274+
struct device *virtqueue_dma_dev(struct virtqueue *_vq)
2275+
{
2276+
struct vring_virtqueue *vq = to_vvq(_vq);
2277+
2278+
if (vq->use_dma_api)
2279+
return vring_dma_dev(vq);
2280+
else
2281+
return NULL;
2282+
}
2283+
EXPORT_SYMBOL_GPL(virtqueue_dma_dev);
2284+
22682285
/**
22692286
* virtqueue_kick_prepare - first half of split virtqueue_kick call.
22702287
* @_vq: the struct virtqueue

include/linux/virtio.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ int virtqueue_add_sgs(struct virtqueue *vq,
6161
void *data,
6262
gfp_t gfp);
6363

64+
struct device *virtqueue_dma_dev(struct virtqueue *vq);
65+
6466
bool virtqueue_kick(struct virtqueue *vq);
6567

6668
bool virtqueue_kick_prepare(struct virtqueue *vq);

0 commit comments

Comments
 (0)