* [PATCH v3] RDMA/rtrs: client: Fix clt_path::max_pages_per_mr calculation
@ 2025-12-29 2:56 Honggang LI
2025-12-30 10:48 ` Leon Romanovsky
0 siblings, 1 reply; 2+ messages in thread
From: Honggang LI @ 2025-12-29 2:56 UTC (permalink / raw)
To: haris.iqbal, jinpu.wang; +Cc: jgg, leon, linux-rdma, linux-kernel, Honggang LI
If device max_mr_size bits in the range [mr_page_shift+31:mr_page_shift]
are zero, the `min3` function will set clt_path::max_pages_per_mr to
zero.
`alloc_path_reqs` will pass zero, which is invalid, as the third parameter
to `ib_alloc_mr`.
Fixes: 6a98d71daea1 ("RDMA/rtrs: client: main functionality")
Signed-off-by: Honggang LI <honggangli@163.com>
---
v2 -> v3:
Use `min_not_zero`.
v1 -> v2:
Correct the commit message and set max_pages_per_mr to U32_MAX
as Michael Gur suggested.
drivers/infiniband/ulp/rtrs/rtrs-clt.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
index 71387811b281..2b397a544cb9 100644
--- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c
+++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
@@ -1464,6 +1464,7 @@ static void query_fast_reg_mode(struct rtrs_clt_path *clt_path)
mr_page_shift = max(12, ffs(ib_dev->attrs.page_size_cap) - 1);
max_pages_per_mr = ib_dev->attrs.max_mr_size;
do_div(max_pages_per_mr, (1ull << mr_page_shift));
+ max_pages_per_mr = min_not_zero((u32)max_pages_per_mr, U32_MAX);
clt_path->max_pages_per_mr =
min3(clt_path->max_pages_per_mr, (u32)max_pages_per_mr,
ib_dev->attrs.max_fast_reg_page_list_len);
--
2.52.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v3] RDMA/rtrs: client: Fix clt_path::max_pages_per_mr calculation
2025-12-29 2:56 [PATCH v3] RDMA/rtrs: client: Fix clt_path::max_pages_per_mr calculation Honggang LI
@ 2025-12-30 10:48 ` Leon Romanovsky
0 siblings, 0 replies; 2+ messages in thread
From: Leon Romanovsky @ 2025-12-30 10:48 UTC (permalink / raw)
To: haris.iqbal, jinpu.wang, Honggang LI; +Cc: jgg, linux-rdma, linux-kernel
On Mon, 29 Dec 2025 10:56:17 +0800, Honggang LI wrote:
> If device max_mr_size bits in the range [mr_page_shift+31:mr_page_shift]
> are zero, the `min3` function will set clt_path::max_pages_per_mr to
> zero.
>
> `alloc_path_reqs` will pass zero, which is invalid, as the third parameter
> to `ib_alloc_mr`.
>
> [...]
Applied, thanks!
[1/1] RDMA/rtrs: client: Fix clt_path::max_pages_per_mr calculation
https://git.kernel.org/rdma/rdma/c/43bd09d5b750f7
Best regards,
--
Leon Romanovsky <leon@kernel.org>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-12-30 10:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-29 2:56 [PATCH v3] RDMA/rtrs: client: Fix clt_path::max_pages_per_mr calculation Honggang LI
2025-12-30 10:48 ` 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®