search for: vring_map_one_sg

Displaying 20 results from an estimated 127 matches for "vring_map_one_sg".

2023 May 17
2
[PATCH vhost v9 01/12] virtio_ring: put mapping error check in vring_map_one_sg
This patch put the dma addr error check in vring_map_one_sg(). The benefits of doing this: 1. make vring_map_one_sg more simple, without calling vring_mapping_error to check the return value. 2. reduce one judgment of vq->use_dma_api. Signed-off-by: Xuan Zhuo <xuanzhuo at linux.alibaba.com> --- drivers/virtio/virtio_ring.c | 37 +++++++++++++...
2023 Mar 21
1
[PATCH vhost v3 01/11] virtio_ring: split: separate dma codes
...+++++++++++++++++-------- 1 file changed, 93 insertions(+), 28 deletions(-) diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index 41144b5246a8..fe704ca6c813 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -379,6 +379,14 @@ static dma_addr_t vring_map_one_sg(const struct vring_virtqueue *vq, direction); } +static dma_addr_t vring_sg_address(struct scatterlist *sg) +{ + if (sg->dma_address) + return sg->dma_address; + + return (dma_addr_t)sg_phys(sg); +} + static dma_addr_t vring_map_single(const struct vring_virtqueue *vq, vo...
2023 May 17
12
[PATCH vhost v9 00/12] virtio core prepares for AF_XDP
...o core support reset per-queue 3. introduce DMA APIs to virtio core Please review. Thanks. v9: 1. use flag to distinguish the premapped operations. no do judgment by sg. v8: 1. vring_sg_address: check by sg_page(sg) not dma_address. Because 0 is a valid dma address 2. remove unused code from vring_map_one_sg() v7: 1. virtqueue_dma_dev() return NULL when virtio is without DMA API. v6: 1. change the size of the flags to u32. v5: 1. fix for error handler 2. add flags to record internal dma mapping v4: 1. rename map_inter to dma_map_internal 2. fix: Excess function parameter 'vq' descript...
2023 Mar 02
1
[PATCH vhost v1 02/12] virtio_ring: split: separate DMA codes
...ng_virtqueue *vq, + struct scatterlist *sgs[], + unsigned int total_sg, + unsigned int out_sgs, + unsigned int in_sgs) +{ + struct scatterlist *sg; + unsigned int n; + + for (n = 0; n < out_sgs; n++) { + for (sg = sgs[n]; sg; sg = sg_next(sg)) { + dma_addr_t addr = vring_map_one_sg(vq, sg, DMA_TO_DEVICE); + + if (vring_mapping_error(vq, addr)) + return -ENOMEM; + + sg->dma_address = addr; + } + } + + for (; n < (out_sgs + in_sgs); n++) { + for (sg = sgs[n]; sg; sg = sg_next(sg)) { + dma_addr_t addr = vring_map_one_sg(vq, sg, DMA_FROM_DEVICE); + + if (vring_...
2023 Jun 02
12
[PATCH vhost v10 00/10] virtio core prepares for AF_XDP
...e vq just handles the premapped request. 2. virtio-net support to do dma mapping in advance v9: 1. use flag to distinguish the premapped operations. no do judgment by sg. v8: 1. vring_sg_address: check by sg_page(sg) not dma_address. Because 0 is a valid dma address 2. remove unused code from vring_map_one_sg() v7: 1. virtqueue_dma_dev() return NULL when virtio is without DMA API. v6: 1. change the size of the flags to u32. v5: 1. fix for error handler 2. add flags to record internal dma mapping v4: 1. rename map_inter to dma_map_internal 2. fix: Excess function parameter 'vq' descript...
2023 Jun 02
12
[PATCH vhost v10 00/10] virtio core prepares for AF_XDP
...e vq just handles the premapped request. 2. virtio-net support to do dma mapping in advance v9: 1. use flag to distinguish the premapped operations. no do judgment by sg. v8: 1. vring_sg_address: check by sg_page(sg) not dma_address. Because 0 is a valid dma address 2. remove unused code from vring_map_one_sg() v7: 1. virtqueue_dma_dev() return NULL when virtio is without DMA API. v6: 1. change the size of the flags to u32. v5: 1. fix for error handler 2. add flags to record internal dma mapping v4: 1. rename map_inter to dma_map_internal 2. fix: Excess function parameter 'vq' descript...
2023 Mar 22
1
[PATCH vhost v4 01/11] virtio_ring: split: separate dma codes
...+++++++++++++++++-------- 1 file changed, 93 insertions(+), 28 deletions(-) diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index 41144b5246a8..fe704ca6c813 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -379,6 +379,14 @@ static dma_addr_t vring_map_one_sg(const struct vring_virtqueue *vq, direction); } +static dma_addr_t vring_sg_address(struct scatterlist *sg) +{ + if (sg->dma_address) + return sg->dma_address; + + return (dma_addr_t)sg_phys(sg); +} + static dma_addr_t vring_map_single(const struct vring_virtqueue *vq, vo...
2023 Apr 25
1
[PATCH vhost v7 01/11] virtio_ring: split: separate dma codes
...+++++++++++++++++-------- 1 file changed, 94 insertions(+), 28 deletions(-) diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index c5310eaf8b46..b073a70c1291 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -379,6 +379,14 @@ static dma_addr_t vring_map_one_sg(const struct vring_virtqueue *vq, direction); } +static dma_addr_t vring_sg_address(struct scatterlist *sg) +{ + if (sg->dma_address) + return sg->dma_address; + + return (dma_addr_t)sg_phys(sg); +} + static dma_addr_t vring_map_single(const struct vring_virtqueue *vq, vo...
2023 Jul 10
10
[PATCH vhost v11 00/10] virtio core prepares for AF_XDP
...e vq just handles the premapped request. 2. virtio-net support to do dma mapping in advance v9: 1. use flag to distinguish the premapped operations. no do judgment by sg. v8: 1. vring_sg_address: check by sg_page(sg) not dma_address. Because 0 is a valid dma address 2. remove unused code from vring_map_one_sg() v7: 1. virtqueue_dma_dev() return NULL when virtio is without DMA API. v6: 1. change the size of the flags to u32. v5: 1. fix for error handler 2. add flags to record internal dma mapping v4: 1. rename map_inter to dma_map_internal 2. fix: Excess function parameter 'vq' descript...
2023 Feb 20
2
[PATCH vhost 01/10] virtio_ring: split: refactor virtqueue_add_split() for premapped
..., descs_used, prev, err_idx; > - int head; > - bool indirect; > + unsigned int n; > > - START_USE(vq); > + for (n = 0; n < out_sgs; n++) { > + for (sg = sgs[n]; sg; sg = sg_next(sg)) { > + dma_addr_t addr = vring_map_one_sg(vq, sg, DMA_TO_DEVICE); > + > + if (vring_mapping_error(vq, addr)) > + return -ENOMEM; > + > + sg->dma_address = addr; > + } > + } > + for (; n < (out_sgs + in_sgs); n++...
2016 Dec 08
1
[PATCH 1/2] virtio_ring: Do not call dma_map_page if sg is already mapped.
On Wed, Dec 07, 2016 at 10:59:12PM -0800, Wendy Liang wrote: > If sg is already dma mapped, do not call dma_map_page() in > vring_map_one_sg(). > > In case of rpmsg, rpmsg uses dma_alloc_coherent() to allocate > memory to share with the remote. There is no pages setup > in dma_alloc_coherent(). > > In this case, we cannot convert the virtual address back to the > physical address. In this case, we can setup the sg...
2016 Dec 08
1
[PATCH 1/2] virtio_ring: Do not call dma_map_page if sg is already mapped.
On Wed, Dec 07, 2016 at 10:59:12PM -0800, Wendy Liang wrote: > If sg is already dma mapped, do not call dma_map_page() in > vring_map_one_sg(). > > In case of rpmsg, rpmsg uses dma_alloc_coherent() to allocate > memory to share with the remote. There is no pages setup > in dma_alloc_coherent(). > > In this case, we cannot convert the virtual address back to the > physical address. In this case, we can setup the sg...
2023 Aug 10
12
[PATCH vhost v13 00/12] virtio core prepares for AF_XDP
...e vq just handles the premapped request. 2. virtio-net support to do dma mapping in advance v9: 1. use flag to distinguish the premapped operations. no do judgment by sg. v8: 1. vring_sg_address: check by sg_page(sg) not dma_address. Because 0 is a valid dma address 2. remove unused code from vring_map_one_sg() v7: 1. virtqueue_dma_dev() return NULL when virtio is without DMA API. v6: 1. change the size of the flags to u32. v5: 1. fix for error handler 2. add flags to record internal dma mapping v4: 1. rename map_inter to dma_map_internal 2. fix: Excess function parameter 'vq' descript...
2023 Aug 10
12
[PATCH vhost v13 00/12] virtio core prepares for AF_XDP
...e vq just handles the premapped request. 2. virtio-net support to do dma mapping in advance v9: 1. use flag to distinguish the premapped operations. no do judgment by sg. v8: 1. vring_sg_address: check by sg_page(sg) not dma_address. Because 0 is a valid dma address 2. remove unused code from vring_map_one_sg() v7: 1. virtqueue_dma_dev() return NULL when virtio is without DMA API. v6: 1. change the size of the flags to u32. v5: 1. fix for error handler 2. add flags to record internal dma mapping v4: 1. rename map_inter to dma_map_internal 2. fix: Excess function parameter 'vq' descript...
2016 Dec 08
3
[PATCH 0/2] Virtio ring works with DMA coherent memory
RPMsg uses dma_alloc_coherent() to allocate memory to shared with the remote. In this case, as there is no pages setup in the dma_alloc_coherent(), we cannot get the physical address back from the virtual address, and thus, we can set the sg_dma_addr to store the DMA address and mark it already DMA mapped. When virtio vring sees the sg_dma_addr is ready set, do not call dma_map_page(). The issue
2016 Dec 08
3
[PATCH 0/2] Virtio ring works with DMA coherent memory
RPMsg uses dma_alloc_coherent() to allocate memory to shared with the remote. In this case, as there is no pages setup in the dma_alloc_coherent(), we cannot get the physical address back from the virtual address, and thus, we can set the sg_dma_addr to store the DMA address and mark it already DMA mapped. When virtio vring sees the sg_dma_addr is ready set, do not call dma_map_page(). The issue
2023 May 09
12
[PATCH vhost v8 00/12] virtio core prepares for AF_XDP
...et virtio core support these features: 1. virtio core support premapped 2. virtio core support reset per-queue 3. introduce DMA APIs to virtio core Please review. Thanks. v8: 1. vring_sg_address: check by sg_page(sg) not dma_address. Because 0 is a valid dma address 2. remove unused code from vring_map_one_sg() v7: 1. virtqueue_dma_dev() return NULL when virtio is without DMA API. v6: 1. change the size of the flags to u32. v5: 1. fix for error handler 2. add flags to record internal dma mapping v4: 1. rename map_inter to dma_map_internal 2. fix: Excess function parameter 'vq' descript...
2023 Mar 02
1
[PATCH vhost v1 06/12] virtio_ring: packed: separate DMA codes
...catterlist *sg; - unsigned int i, n, err_idx; + unsigned int i, n; u16 head, id; dma_addr_t addr; @@ -1362,14 +1362,9 @@ static int virtqueue_add_indirect_packed(struct vring_virtqueue *vq, for (n = 0; n < out_sgs + in_sgs; n++) { for (sg = sgs[n]; sg; sg = sg_next(sg)) { - addr = vring_map_one_sg(vq, sg, n < out_sgs ? - DMA_TO_DEVICE : DMA_FROM_DEVICE); - if (vring_mapping_error(vq, addr)) - goto unmap_release; - desc[i].flags = cpu_to_le16(n < out_sgs ? 0 : VRING_DESC_F_WRITE); - desc[i].addr = cpu_to_le64(addr); + desc[i].addr = cpu_to_le64(sg->dma_address...
2014 Aug 28
6
[PATCH v3 0/5] virtio: Clean up scatterlists and use the DMA API
This fixes virtio on Xen guests as well as on any other platform that uses virtio_pci on which physical addresses don't match bus addresses. This can be tested with: virtme-run --xen xen --kimg arch/x86/boot/bzImage --console using virtme from here: https://git.kernel.org/cgit/utils/kernel/virtme/virtme.git Without these patches, the guest hangs forever. With these patches,
2014 Aug 28
6
[PATCH v3 0/5] virtio: Clean up scatterlists and use the DMA API
This fixes virtio on Xen guests as well as on any other platform that uses virtio_pci on which physical addresses don't match bus addresses. This can be tested with: virtme-run --xen xen --kimg arch/x86/boot/bzImage --console using virtme from here: https://git.kernel.org/cgit/utils/kernel/virtme/virtme.git Without these patches, the guest hangs forever. With these patches,