From: Logan Gunthorpe <logang@deltatee.com>
To: linux-rdma@vger.kernel.org, Jason Gunthorpe <jgg@ziepe.ca>
Cc: linux-kernel@vger.kernel.org, Doug Ledford <dledford@redhat.com>,
Logan Gunthorpe <logang@deltatee.com>,
Bart Van Assche <bvanassche@acm.org>
Subject: [PATCH] RDMA/core: Set sgtable nents when using ib_dma_virt_map_sg()
Date: Wed, 13 Oct 2021 10:59:42 -0600 [thread overview]
Message-ID: <20211013165942.89806-1-logang@deltatee.com> (raw)
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@acm.org>
Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Tested-by: Bart Van Assche <bvanassche@acm.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
next reply other threads:[~2021-10-13 16:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-13 16:59 Logan Gunthorpe [this message]
2021-10-13 18:33 ` [PATCH] RDMA/core: Set sgtable nents when using ib_dma_virt_map_sg() Bart Van Assche
2021-10-13 18:35 ` Logan Gunthorpe
2021-10-13 19:45 ` Jason Gunthorpe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211013165942.89806-1-logang@deltatee.com \
--to=logang@deltatee.com \
--cc=bvanassche@acm.org \
--cc=dledford@redhat.com \
--cc=jgg@ziepe.ca \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.