RDMA/core: Set sgtable nents when using ib_dma_virt_map_sg()
PATCH 1/1 RDMA/core: Set sgtable nents when using ib_dma_virt_map_sg()
ib_dma_map_sgtable_attrs() should be mapping the sgls and setting nents but the ib_uses_virt_dma() path falls back to ib_dma_virt_map_sg() which will not set the nents in the sgtable.
Check the return value (per the map_sg calling convention) and set sgt->nents appropriately on success.
--- include/rdma/ib_verbs.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
include/rdma/ib_verbs.h +6 -1
@@ -4097,8 +4097,13 @@ static inline int ib_dma_map_sgtable_attrs(struct ib_device *dev,enum dma_data_direction direction, unsigned long dma_attrs) { + int nents; +if (ib_uses_virt_dma (dev)) { - ib_dma_virt_map_sg(dev, sgt->sgl, sgt->orig_nents); + nents =ib_dma_virt_map_sg (dev, sgt->sgl, sgt->orig_nents); +if (!nents) +return -EIO ; + sgt->nents = nents;return 0 ; }return dma_map_sgtable (dev->dma_device, sgt, direction, dma_attrs);
base-commit: 2a152512a155aaf27c3e67834ffafaed9525a7b5
Signature · 1 line
2.30.2
Quoted 11 lines · Logan Gunthorpe
ib_dma_map_sgtable_attrs()should be mapping the sgls and setting nents but theib_uses_virt_dma()path falls back toib_dma_virt_map_sg()which will not set the nents in the sgtable.Check the return value (per the
map_sgcalling convention) and setsgt->nentsappropriately on success.Reported-by Bart Van Assche <[email protected]>Signed-off-by Logan Gunthorpe <[email protected]>Tested-by Bart Van Assche <[email protected]>
Does this patch need a "Fixes:" tag?
Thanks,
Bart.
Quoted 8 lines · Bart Van Assche
Quoted 7 lines · Logan Gunthorpe
ib_dma_map_sgtable_attrs()should be mapping the sgls and setting nents but theib_uses_virt_dma()path falls back toib_dma_virt_map_sg()which will not set the nents in the sgtable.Check the return value (per the
map_sgcalling convention) and setsgt->nentsappropriately on success.
Quoted 8 lines
Quoted 6 lines
Link:
https://lore.kernel.org/all/[email protected]/T/#uReported-by Bart Van Assche <[email protected]>Signed-off-by Logan Gunthorpe <[email protected]>Tested-by Bart Van Assche <[email protected]>Does this patch need a "Fixes:" tag?
Right, yeah:
opencoded version from umem")
Logan
Quoted 7 lines · Logan Gunthorpe
ib_dma_map_sgtable_attrs()should be mapping the sgls and setting nents but theib_uses_virt_dma()path falls back toib_dma_virt_map_sg()which will not set the nents in the sgtable.Check the return value (per the
map_sgcalling convention) and setsgt->nentsappropriately on success.
Quoted 7 lines
Reported-by Bart Van Assche <[email protected]>Signed-off-by Logan Gunthorpe <[email protected]>Tested-by Bart Van Assche <[email protected]>--- include/rdma/ib_verbs.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
Applied to for-next, thanks
Jason