[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211013165942.89806-1-logang@deltatee.com>
Date: Wed, 13 Oct 2021 10:59:42 -0600
From: Logan Gunthorpe <logang@...tatee.com>
To: linux-rdma@...r.kernel.org, Jason Gunthorpe <jgg@...pe.ca>
Cc: linux-kernel@...r.kernel.org, Doug Ledford <dledford@...hat.com>,
Logan Gunthorpe <logang@...tatee.com>,
Bart Van Assche <bvanassche@....org>
Subject: [PATCH] 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.
Link: https://lore.kernel.org/all/996fa723-18ef-d35b-c565-c9cb9dc2d5e1@acm.org/T/#u
Reported-by: Bart Van Assche <bvanassche@....org>
Signed-off-by: Logan Gunthorpe <logang@...tatee.com>
Tested-by: Bart Van Assche <bvanassche@....org>
---
include/rdma/ib_verbs.h | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 4b50d9a3018a..4ba642fc8a19 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);
base-commit: 2a152512a155aaf27c3e67834ffafaed9525a7b5
--
2.30.2
Powered by blists - more mailing lists