* [PATCH] RDMA/core: Set sgtable nents when using ib_dma_virt_map_sg()
@ 2021-10-13 16:59 Logan Gunthorpe
2021-10-13 18:33 ` Bart Van Assche
2021-10-13 19:45 ` Jason Gunthorpe
0 siblings, 2 replies; 4+ messages in thread
From: Logan Gunthorpe @ 2021-10-13 16:59 UTC (permalink / raw)
To: linux-rdma, Jason Gunthorpe
Cc: linux-kernel, Doug Ledford, Logan Gunthorpe, Bart Van Assche
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] RDMA/core: Set sgtable nents when using ib_dma_virt_map_sg()
2021-10-13 16:59 [PATCH] RDMA/core: Set sgtable nents when using ib_dma_virt_map_sg() Logan Gunthorpe
@ 2021-10-13 18:33 ` Bart Van Assche
2021-10-13 18:35 ` Logan Gunthorpe
2021-10-13 19:45 ` Jason Gunthorpe
1 sibling, 1 reply; 4+ messages in thread
From: Bart Van Assche @ 2021-10-13 18:33 UTC (permalink / raw)
To: Logan Gunthorpe, linux-rdma, Jason Gunthorpe; +Cc: linux-kernel, Doug Ledford
On 10/13/21 9:59 AM, Logan Gunthorpe wrote:
> 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>
Does this patch need a "Fixes:" tag?
Thanks,
Bart.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] RDMA/core: Set sgtable nents when using ib_dma_virt_map_sg()
2021-10-13 18:33 ` Bart Van Assche
@ 2021-10-13 18:35 ` Logan Gunthorpe
0 siblings, 0 replies; 4+ messages in thread
From: Logan Gunthorpe @ 2021-10-13 18:35 UTC (permalink / raw)
To: Bart Van Assche, linux-rdma, Jason Gunthorpe; +Cc: linux-kernel, Doug Ledford
On 2021-10-13 12:33 p.m., Bart Van Assche wrote:
> On 10/13/21 9:59 AM, Logan Gunthorpe wrote:
>> 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>
>
> 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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] RDMA/core: Set sgtable nents when using ib_dma_virt_map_sg()
2021-10-13 16:59 [PATCH] RDMA/core: Set sgtable nents when using ib_dma_virt_map_sg() Logan Gunthorpe
2021-10-13 18:33 ` Bart Van Assche
@ 2021-10-13 19:45 ` Jason Gunthorpe
1 sibling, 0 replies; 4+ messages in thread
From: Jason Gunthorpe @ 2021-10-13 19:45 UTC (permalink / raw)
To: Logan Gunthorpe; +Cc: linux-rdma, linux-kernel, Doug Ledford, Bart Van Assche
On Wed, Oct 13, 2021 at 10:59:42AM -0600, Logan Gunthorpe wrote:
> 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(-)
Applied to for-next, thanks
Jason
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-10-13 19:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-13 16:59 [PATCH] RDMA/core: Set sgtable nents when using ib_dma_virt_map_sg() Logan Gunthorpe
2021-10-13 18:33 ` Bart Van Assche
2021-10-13 18:35 ` Logan Gunthorpe
2021-10-13 19:45 ` Jason Gunthorpe
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.