Skip to contentSkip to conversation

RDMA/core: Set sgtable nents when using ib_dma_virt_map_sg()

PATCH Applied Logan Gunthorpe 3 participants 4 messages Oct 13, 2021 InfiniBand

lore
Share & tools
lore
#0 lore raw

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
index 4b50d9a3018a..4ba642fc8a19 100644
@@ -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
#1 lore raw
Quoted 11 lines · Logan Gunthorpe

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.

Does this patch need a "Fixes:" tag?

Thanks,

Bart.

#2 lore raw
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 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.

Quoted 8 lines
Quoted 6 lines

Link:
https://lore.kernel.org/all/[email protected]/T/#u

Does this patch need a "Fixes:" tag?

Right, yeah:

Fixes 79fbd3e1241c ("RDMA: Use the sg_table directly and remove the

opencoded version from umem")

Logan

maintainer Applied
#3 lore raw
In reply to Logan Gunthorpe
Quoted 7 lines · Logan Gunthorpe

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.

Quoted 7 lines
---
 include/rdma/ib_verbs.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Applied to for-next, thanks

Jason