diff options
| author | Jason Gunthorpe <jgg@nvidia.com> | 2026-06-01 13:52:33 -0300 |
|---|---|---|
| committer | Jason Gunthorpe <jgg@nvidia.com> | 2026-06-05 12:36:33 -0300 |
| commit | 55d984dae65262fbb0a673cff7cc9824a5e19bdb (patch) | |
| tree | a855508fd303c95f95f35a1242aea5c93ae7d7be /include/rdma | |
| parent | 09ea6837a0434fb4db99528a5055b6d822135dcf (diff) | |
RDMA/umem: Make ib_umem_is_contiguous() safe on 32 bit
Sashiko points out the roundup_pow_of_two() only uses unsigned long but
dma_addr_t can be u64.
Change this algorithm to be simpler, compute the page size, if any page
size is found and it results in a single block then it is contiguous.
Link: https://patch.msgid.link/r/3-v1-88303e9e509f+f7-ib_umem_types_jgg@nvidia.com
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Diffstat (limited to 'include/rdma')
| -rw-r--r-- | include/rdma/ib_umem.h | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/include/rdma/ib_umem.h b/include/rdma/ib_umem.h index 4c8f433ba246..bb4005a9c690 100644 --- a/include/rdma/ib_umem.h +++ b/include/rdma/ib_umem.h @@ -145,16 +145,11 @@ static inline unsigned long ib_umem_find_best_pgoff(struct ib_umem *umem, static inline bool ib_umem_is_contiguous(struct ib_umem *umem) { - dma_addr_t dma_addr; unsigned long pgsz; - /* - * Select the smallest aligned page that can contain the whole umem if - * it was contiguous. - */ - dma_addr = ib_umem_start_dma_addr(umem); - pgsz = roundup_pow_of_two((dma_addr ^ (umem->length - 1 + dma_addr)) + 1); - return !!ib_umem_find_best_pgoff(umem, pgsz, U64_MAX); + pgsz = ib_umem_find_best_pgsz(umem, ULONG_MAX, + ib_umem_start_dma_addr(umem)); + return pgsz && ib_umem_num_dma_blocks(umem, pgsz) == 1; } struct ib_umem_dmabuf *ib_umem_dmabuf_get(struct ib_device *device, |
