From: Logan Gunthorpe Date: Wed, 13 Oct 2021 16:59:42 +0000 (-0600) Subject: RDMA/core: Set sgtable nents when using ib_dma_virt_map_sg() X-Git-Tag: accepted/tizen/unified/20230118.172025~5435 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=88d564772486c9eae236667485e7db8190e8759a;p=platform%2Fkernel%2Flinux-rpi.git RDMA/core: Set sgtable nents when using ib_dma_virt_map_sg() [ Upstream commit ac0fffa0859b8e1e991939663b3ebdd80bf979e6 ] 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. Fixes: 79fbd3e1241c ("RDMA: Use the sg_table directly and remove the opencoded version from umem") Link: https://lore.kernel.org/r/20211013165942.89806-1-logang@deltatee.com Reported-by: Bart Van Assche Signed-off-by: Logan Gunthorpe Tested-by: Bart Van Assche Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index 4b50d9a..4ba642f 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -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);