* [PATCH 1/1] RDMA/mlx5: Fix page size bitmap calculation for KSM mode
@ 2025-08-24 14:48 Edward Srouji
2025-09-09 9:49 ` Leon Romanovsky
0 siblings, 1 reply; 2+ messages in thread
From: Edward Srouji @ 2025-08-24 14:48 UTC (permalink / raw)
To: edwards, jgg, leon; +Cc: michaelgur, linux-rdma, linux-kernel
When using KSM (Key Scatter-gather Memory) access mode, the HW requires
the IOVA to be aligned to the selected page size.
Without this alignment, the HW may not function correctly.
Currently, mlx5_umem_mkc_find_best_pgsz() does not filter out page sizes
that would result in misaligned IOVAs for KSM mode. This can lead to
selecting page sizes that are incompatible with the given IOVA.
Fix this by filtering the page size bitmap when in KSM mode, keeping
only page sizes to which the IOVA is aligned to.
Fixes: fcfb03597b7d ("RDMA/mlx5: Align mkc page size capability check to PRM")
Signed-off-by: Edward Srouji <edwards@nvidia.com>
Reviewed-by: Michael Guralnik <michaelgur@nvidia.com>
---
drivers/infiniband/hw/mlx5/mlx5_ib.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/infiniband/hw/mlx5/mlx5_ib.h b/drivers/infiniband/hw/mlx5/mlx5_ib.h
index 4fc2c0ca2af3..fbb9803785ba 100644
--- a/drivers/infiniband/hw/mlx5/mlx5_ib.h
+++ b/drivers/infiniband/hw/mlx5/mlx5_ib.h
@@ -1805,6 +1805,10 @@ mlx5_umem_mkc_find_best_pgsz(struct mlx5_ib_dev *dev, struct ib_umem *umem,
bitmap = GENMASK_ULL(max_log_entity_size_cap, min_log_entity_size_cap);
+ /* In KSM mode HW requires IOVA and mkey's page size to be aligned */
+ if (access_mode == MLX5_MKC_ACCESS_MODE_KSM && iova)
+ bitmap &= GENMASK_ULL(__ffs64(iova), 0);
+
return ib_umem_find_best_pgsz(umem, bitmap, iova);
}
--
2.21.3
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH 1/1] RDMA/mlx5: Fix page size bitmap calculation for KSM mode
2025-08-24 14:48 [PATCH 1/1] RDMA/mlx5: Fix page size bitmap calculation for KSM mode Edward Srouji
@ 2025-09-09 9:49 ` Leon Romanovsky
0 siblings, 0 replies; 2+ messages in thread
From: Leon Romanovsky @ 2025-09-09 9:49 UTC (permalink / raw)
To: jgg, Edward Srouji; +Cc: michaelgur, linux-rdma, linux-kernel
On Sun, 24 Aug 2025 17:48:39 +0300, Edward Srouji wrote:
> When using KSM (Key Scatter-gather Memory) access mode, the HW requires
> the IOVA to be aligned to the selected page size.
> Without this alignment, the HW may not function correctly.
>
> Currently, mlx5_umem_mkc_find_best_pgsz() does not filter out page sizes
> that would result in misaligned IOVAs for KSM mode. This can lead to
> selecting page sizes that are incompatible with the given IOVA.
>
> [...]
Applied, thanks!
[1/1] RDMA/mlx5: Fix page size bitmap calculation for KSM mode
https://git.kernel.org/rdma/rdma/c/f4d365433815fd
Best regards,
--
Leon Romanovsky <leon@kernel.org>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-09-09 9:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-08-24 14:48 [PATCH 1/1] RDMA/mlx5: Fix page size bitmap calculation for KSM mode Edward Srouji
2025-09-09 9:49 ` Leon Romanovsky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®