diff mbox series

[rdma-next] RDMA/umem: Use correct value for SG entries in sg_copy_to_buffer()

Message ID 20190404152247.14700-1-shiraz.saleem@intel.com (mailing list archive)
State Mainlined
Commit d0b5c01bb446f87e94265b172c00f4e89829116d
Delegated to: Jason Gunthorpe
Headers show
Series [rdma-next] RDMA/umem: Use correct value for SG entries in sg_copy_to_buffer() | expand

Commit Message

Saleem, Shiraz April 4, 2019, 3:22 p.m. UTC
From: "Shiraz Saleem" <shiraz.saleem@intel.com>

With page combining, the assumption that number of SG entries
in umem SGL equal to number of system pages in umem no longer
holds.

umem->sg_nents tracks the SG entries in umem SGL. Use it
in sg_pcopy_to_buffer() as opposed to ib_umem_num_pages(umem).

Fixes: a4ca56b2b416 ("RDMA/umem: Combine contiguous PAGE_SIZE regions in SGEs")
Reported-by: Jason Gunthorpe <jgg@mellanox.com>
Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com>
---
 drivers/infiniband/core/umem.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Jason Gunthorpe April 4, 2019, 4:30 p.m. UTC | #1
On Thu, Apr 04, 2019 at 10:22:47AM -0500, Shiraz Saleem wrote:
> From: "Shiraz Saleem" <shiraz.saleem@intel.com>
> 
> With page combining, the assumption that number of SG entries
> in umem SGL equal to number of system pages in umem no longer
> holds.
> 
> umem->sg_nents tracks the SG entries in umem SGL. Use it
> in sg_pcopy_to_buffer() as opposed to ib_umem_num_pages(umem).
> 
> Fixes: a4ca56b2b416 ("RDMA/umem: Combine contiguous PAGE_SIZE regions in SGEs")
> Reported-by: Jason Gunthorpe <jgg@mellanox.com>
> Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com>
> ---
>  drivers/infiniband/core/umem.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Applied to for-next

Thanks,
Jason
diff mbox series

Patch

diff --git a/drivers/infiniband/core/umem.c b/drivers/infiniband/core/umem.c
index d31f5e3..7e912a9 100644
--- a/drivers/infiniband/core/umem.c
+++ b/drivers/infiniband/core/umem.c
@@ -381,8 +381,8 @@  int ib_umem_copy_from(void *dst, struct ib_umem *umem, size_t offset,
 		return -EINVAL;
 	}
 
-	ret = sg_pcopy_to_buffer(umem->sg_head.sgl, ib_umem_num_pages(umem),
-				 dst, length, offset + ib_umem_offset(umem));
+	ret = sg_pcopy_to_buffer(umem->sg_head.sgl, umem->sg_nents, dst, length,
+				 offset + ib_umem_offset(umem));
 
 	if (ret < 0)
 		return ret;