Skip to content

Commit 36798d5

Browse files
Artemy-Mellanoxjgunthorpe
authored andcommitted
RDMA/umem: Fix ib_umem_find_best_pgsz()
Except for the last entry, the ending iova alignment sets the maximum possible page size as the low bits of the iova must be zero when starting the next chunk. Fixes: 4a35339 ("RDMA/umem: Add API to find best driver supported page size in an MR") Link: https://lore.kernel.org/r/20200128135612.174820-1-leon@kernel.org Signed-off-by: Artemy Kovalyov <artemyko@mellanox.com> Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Tested-by: Gal Pressman <galpress@amazon.com> Reviewed-by: Jason Gunthorpe <jgg@mellanox.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
1 parent ea660ad commit 36798d5

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

‎drivers/infiniband/core/umem.c‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,13 @@ unsigned long ib_umem_find_best_pgsz(struct ib_umem *umem,
166166
* for any address.
167167
*/
168168
mask |= (sg_dma_address(sg) + pgoff) ^ va;
169-
if (i && i != (umem->nmap - 1))
170-
/* restrict by length as well for interior SGEs */
171-
mask |= sg_dma_len(sg);
172169
va += sg_dma_len(sg) - pgoff;
170+
/* Except for the last entry, the ending iova alignment sets
171+
* the maximum possible page size as the low bits of the iova
172+
* must be zero when starting the next chunk.
173+
*/
174+
if (i != (umem->nmap - 1))
175+
mask |= va;
173176
pgoff = 0;
174177
}
175178
best_pg_bit = rdma_find_pg_bit(mask, pgsz_bitmap);

0 commit comments

Comments
 (0)