* [PATCH] RDMA/cxgb4: program the upper 32 bits of the fast-reg MR length
@ 2026-12-03 18:56 Showrya M N
2026-12-03 9:46 ` sashiko-bot
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Showrya M N @ 2026-12-03 18:56 UTC (permalink / raw)
To: jgg, leon; +Cc: bharat, linux-rdma, Showrya M N
From: Potnuri Bharat Teja <bharat@chelsio.com>
ib_mr.length is a u64 and cxgb4 advertises max_mr_size as ~0ULL, but
build_memreg() and build_tpte_memreg() always program len_hi as 0 and
truncate the length into len_lo. A kernel fast-reg MR of 4GB or more,
e.g. one mapped with a large page size, is therefore registered in HW
with a truncated length.
Program len_hi/len_lo from the upper and lower 32 bits of the MR length,
as write_tpt_entry() already does for regular MRs.
Fixes: 8376b86de7d3 ("iw_cxgb4: Support the new memory registration API")
Signed-off-by: Potnuri Bharat Teja <bharat@chelsio.com>
Signed-off-by: Showrya M N <showrya@chelsio.com>
---
drivers/infiniband/hw/cxgb4/qp.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/infiniband/hw/cxgb4/qp.c b/drivers/infiniband/hw/cxgb4/qp.c
index e295f79e0cd3..cff7f4b4519e 100644
--- a/drivers/infiniband/hw/cxgb4/qp.c
+++ b/drivers/infiniband/hw/cxgb4/qp.c
@@ -803,8 +803,8 @@ static void build_tpte_memreg(struct fw_ri_fr_nsmr_tpte_wr *fr,
fr->tpte.nosnoop_pbladdr = cpu_to_be32(FW_RI_TPTE_PBLADDR_V(
PBL_OFF(&mhp->rhp->rdev, mhp->attr.pbl_addr)>>3));
fr->tpte.dca_mwbcnt_pstag = cpu_to_be32(0);
- fr->tpte.len_hi = cpu_to_be32(0);
- fr->tpte.len_lo = cpu_to_be32(mhp->ibmr.length);
+ fr->tpte.len_hi = cpu_to_be32(upper_32_bits(mhp->ibmr.length));
+ fr->tpte.len_lo = cpu_to_be32(lower_32_bits(mhp->ibmr.length));
fr->tpte.va_hi = cpu_to_be32(mhp->ibmr.iova >> 32);
fr->tpte.va_lo_fbo = cpu_to_be32(mhp->ibmr.iova & 0xffffffff);
@@ -831,8 +831,8 @@ static int build_memreg(struct t4_sq *sq, union t4_wr *wqe,
wqe->fr.pgsz_shift = ilog2(wr->mr->page_size) - 12;
wqe->fr.addr_type = FW_RI_VA_BASED_TO;
wqe->fr.mem_perms = c4iw_ib_to_tpt_access(wr->access);
- wqe->fr.len_hi = 0;
- wqe->fr.len_lo = cpu_to_be32(mhp->ibmr.length);
+ wqe->fr.len_hi = cpu_to_be32(upper_32_bits(mhp->ibmr.length));
+ wqe->fr.len_lo = cpu_to_be32(lower_32_bits(mhp->ibmr.length));
wqe->fr.stag = cpu_to_be32(wr->key);
wqe->fr.va_hi = cpu_to_be32(mhp->ibmr.iova >> 32);
wqe->fr.va_lo_fbo = cpu_to_be32(mhp->ibmr.iova &
--
2.52.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH] RDMA/cxgb4: program the upper 32 bits of the fast-reg MR length 2026-12-03 18:56 [PATCH] RDMA/cxgb4: program the upper 32 bits of the fast-reg MR length Showrya M N @ 2026-12-03 9:46 ` sashiko-bot 2026-12-03 21:40 ` [PATCH v2] " Showrya M N 2026-12-03 22:26 ` [PATCH v3] RDMA/cxgb4: fix the length of large fast-reg MRs Showrya M N 2 siblings, 0 replies; 6+ messages in thread From: sashiko-bot @ 2026-12-03 9:46 UTC (permalink / raw) To: Showrya M N; +Cc: linux-rdma Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] RDMA/cxgb4: Fixes trailer cites wrong commit for 64-bit MR length -- commit d38571d9c9d44d2d2a2f8dbb7f241c256d88b11c Author: Potnuri Bharat Teja <bharat@chelsio.com> > RDMA/cxgb4: program the upper 32 bits of the fast-reg MR length > > ib_mr.length is a u64 and cxgb4 advertises max_mr_size as ~0ULL, but > build_memreg() and build_tpte_memreg() always program len_hi as 0 and > truncate the length into len_lo. A kernel fast-reg MR of 4GB or more, > e.g. one mapped with a large page size, is therefore registered in HW > with a truncated length. > > Program len_hi/len_lo from the upper and lower 32 bits of the MR length, > as write_tpt_entry() already does for regular MRs. > > Fixes: 8376b86de7d3 ("iw_cxgb4: Support the new memory registration API") > Signed-off-by: Potnuri Bharat Teja <bharat@chelsio.com> > Signed-off-by: Showrya M N <showrya@chelsio.com> [Severity: Low] Should the Fixes: tag cite edd31551148c ("IB: Correct MR length field to be 64-bit") instead? At 8376b86de7d3 ("iw_cxgb4: Support the new memory registration API"), ib_mr.length was still a u32 and build_tpte_memreg() did not exist yet (it was added in 49b53a93a64a ("iw_cxgb4: add fast-path for small REG_MR operations")). Truncation in both functions started when edd31551148c ("IB: Correct MR length field to be 64-bit") widened ib_mr.length to u64. -- Sashiko AI review · https://sashiko.dev/#/patchset/20261203185637.27223-1-showrya@chelsio.com?part=1 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2] RDMA/cxgb4: program the upper 32 bits of the fast-reg MR length 2026-12-03 18:56 [PATCH] RDMA/cxgb4: program the upper 32 bits of the fast-reg MR length Showrya M N 2026-12-03 9:46 ` sashiko-bot @ 2026-12-03 21:40 ` Showrya M N 2026-12-03 12:26 ` sashiko-bot 2026-12-03 22:26 ` [PATCH v3] RDMA/cxgb4: fix the length of large fast-reg MRs Showrya M N 2 siblings, 1 reply; 6+ messages in thread From: Showrya M N @ 2026-12-03 21:40 UTC (permalink / raw) To: linux-rdma; +Cc: jgg, leon, Potnuri Bharat Teja, Showrya M N From: Potnuri Bharat Teja <bharat@chelsio.com> ib_mr.length is a u64 and cxgb4 advertises max_mr_size as ~0ULL, but build_memreg() and build_tpte_memreg() always program len_hi as 0 and truncate the length into len_lo. A kernel fast-reg MR of 4GB or more, e.g. one mapped with a large page size, is therefore registered in HW with a truncated length. Program len_hi/len_lo from the upper and lower 32 bits of the MR length, as write_tpt_entry() already does for regular MRs. Fixes: edd31551148c ("IB: Correct MR length field to be 64-bit") Signed-off-by: Potnuri Bharat Teja <bharat@chelsio.com> Signed-off-by: Showrya M N <showrya@chelsio.com> --- v2: - Fixes: point to edd31551148c, which widened ib_mr.length to u64; at 8376b86de7d3 the length was still 32 bits. --- --- drivers/infiniband/hw/cxgb4/qp.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/infiniband/hw/cxgb4/qp.c b/drivers/infiniband/hw/cxgb4/qp.c index e295f79e0cd3..cff7f4b4519e 100644 --- a/drivers/infiniband/hw/cxgb4/qp.c +++ b/drivers/infiniband/hw/cxgb4/qp.c @@ -803,8 +803,8 @@ static void build_tpte_memreg(struct fw_ri_fr_nsmr_tpte_wr *fr, fr->tpte.nosnoop_pbladdr = cpu_to_be32(FW_RI_TPTE_PBLADDR_V( PBL_OFF(&mhp->rhp->rdev, mhp->attr.pbl_addr)>>3)); fr->tpte.dca_mwbcnt_pstag = cpu_to_be32(0); - fr->tpte.len_hi = cpu_to_be32(0); - fr->tpte.len_lo = cpu_to_be32(mhp->ibmr.length); + fr->tpte.len_hi = cpu_to_be32(upper_32_bits(mhp->ibmr.length)); + fr->tpte.len_lo = cpu_to_be32(lower_32_bits(mhp->ibmr.length)); fr->tpte.va_hi = cpu_to_be32(mhp->ibmr.iova >> 32); fr->tpte.va_lo_fbo = cpu_to_be32(mhp->ibmr.iova & 0xffffffff); @@ -831,8 +831,8 @@ static int build_memreg(struct t4_sq *sq, union t4_wr *wqe, wqe->fr.pgsz_shift = ilog2(wr->mr->page_size) - 12; wqe->fr.addr_type = FW_RI_VA_BASED_TO; wqe->fr.mem_perms = c4iw_ib_to_tpt_access(wr->access); - wqe->fr.len_hi = 0; - wqe->fr.len_lo = cpu_to_be32(mhp->ibmr.length); + wqe->fr.len_hi = cpu_to_be32(upper_32_bits(mhp->ibmr.length)); + wqe->fr.len_lo = cpu_to_be32(lower_32_bits(mhp->ibmr.length)); wqe->fr.stag = cpu_to_be32(wr->key); wqe->fr.va_hi = cpu_to_be32(mhp->ibmr.iova >> 32); wqe->fr.va_lo_fbo = cpu_to_be32(mhp->ibmr.iova & -- 2.52.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2] RDMA/cxgb4: program the upper 32 bits of the fast-reg MR length 2026-12-03 21:40 ` [PATCH v2] " Showrya M N @ 2026-12-03 12:26 ` sashiko-bot 0 siblings, 0 replies; 6+ messages in thread From: sashiko-bot @ 2026-12-03 12:26 UTC (permalink / raw) To: Showrya M N, linux-rdma Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] RDMA/cxgb4: build_memreg() omits T5 8 GiB MR limit when setting len_hi -- commit 601ccce55408925f0a6e4b1599dc46426fab8ed8 Author: Potnuri Bharat Teja <bharat@chelsio.com> RDMA/cxgb4: program the upper 32 bits of the fast-reg MR length This commit updates build_tpte_memreg() and build_memreg() to program both the upper and lower 32 bits of mhp->ibmr.length into len_hi and len_lo instead of hardcoding len_hi to 0. > diff --git a/drivers/infiniband/hw/cxgb4/qp.c b/drivers/infiniband/hw/cxgb4/qp.c > index e295f79e0cd3e..cff7f4b4519e4 100644 > --- a/drivers/infiniband/hw/cxgb4/qp.c > +++ b/drivers/infiniband/hw/cxgb4/qp.c [ ... ] > @@ -831,8 +831,8 @@ static int build_memreg(struct t4_sq *sq, union t4_wr *wqe, > wqe->fr.pgsz_shift = ilog2(wr->mr->page_size) - 12; > wqe->fr.addr_type = FW_RI_VA_BASED_TO; > wqe->fr.mem_perms = c4iw_ib_to_tpt_access(wr->access); > - wqe->fr.len_hi = 0; > - wqe->fr.len_lo = cpu_to_be32(mhp->ibmr.length); > + wqe->fr.len_hi = cpu_to_be32(upper_32_bits(mhp->ibmr.length)); > + wqe->fr.len_lo = cpu_to_be32(lower_32_bits(mhp->ibmr.length)); [Severity: Medium] Should build_memreg() also enforce the T4/T5 < 8 GiB MR limit before programming len_hi? Commit 2550a88d956f ("RDMA/cxgb4: Limit MRs to < 8GB for T4/T5 devices") added mr_exceeds_hw_limits() in mem.c because T4/T5 hardware cannot handle MRs of 8 GiB or more, and c4iw_reg_user_mr() checks it before calling write_tpt_entry(). On T5 with DSGL enabled, c4iw_query_device() advertises up to 128 fast-reg pages and 128 MiB pages, allowing 8 GiB to 16 GiB fast-reg MRs. Neither c4iw_map_mr_sg() nor c4iw_post_send() checks mr_exceeds_hw_limits(), so build_memreg() now programs >= 8 GiB MRs into T5 hardware. Exposing mr_exceeds_hw_limits() and returning -EINVAL when it triggers in build_memreg() (or c4iw_map_mr_sg()) would keep fast-reg MRs within the hardware limit. -- Sashiko AI review · https://sashiko.dev/#/patchset/20261203214018.40717-1-showrya@chelsio.com?part=1 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v3] RDMA/cxgb4: fix the length of large fast-reg MRs 2026-12-03 18:56 [PATCH] RDMA/cxgb4: program the upper 32 bits of the fast-reg MR length Showrya M N 2026-12-03 9:46 ` sashiko-bot 2026-12-03 21:40 ` [PATCH v2] " Showrya M N @ 2026-12-03 22:26 ` Showrya M N 2026-12-03 13:14 ` sashiko-bot 2 siblings, 1 reply; 6+ messages in thread From: Showrya M N @ 2026-12-03 22:26 UTC (permalink / raw) To: linux-rdma; +Cc: jgg, leon, Potnuri Bharat Teja, Showrya M N From: Potnuri Bharat Teja <bharat@chelsio.com> ib_mr.length is a u64 and cxgb4 advertises max_mr_size as ~0ULL, but build_memreg() and build_tpte_memreg() always program len_hi as 0 and truncate the length into len_lo. A kernel fast-reg MR of 4GB or more, e.g. one mapped with a large page size, is therefore registered in HW with a truncated length. Program len_hi/len_lo from the upper and lower 32 bits of the MR length, as write_tpt_entry() already does for regular MRs. Also, T4 and T5 can't handle MRs of 8GB or more. c4iw_reg_user_mr() already rejects such MRs via mr_exceeds_hw_limits(), but fast-reg MRs get their length only in c4iw_map_mr_sg() and are never checked. With DSGL, a fast-reg MR holds up to 128 pages of up to 128MB, so it can reach 16GB. Apply the same limit in c4iw_map_mr_sg() and fail the mapping with -EINVAL. Fixes: edd31551148c ("IB: Correct MR length field to be 64-bit") Fixes: 2550a88d956f ("RDMA/cxgb4: Limit MRs to < 8GB for T4/T5 devices") Signed-off-by: Potnuri Bharat Teja <bharat@chelsio.com> Signed-off-by: Showrya M N <showrya@chelsio.com> --- Changes v2 -> v3: - Also apply the T4/T5 8GB MR limit (mr_exceeds_hw_limits()) to fast-reg MRs in c4iw_map_mr_sg(); until now only user MRs were checked (sashiko review). - Add Fixes: 2550a88d956f and update the subject accordingly. Changes v1 -> v2: - Fixes: point to edd31551148c, which widened ib_mr.length to u64; at 8376b86de7d3 the length was still 32 bits (sashiko review). drivers/infiniband/hw/cxgb4/mem.c | 7 ++++++- drivers/infiniband/hw/cxgb4/qp.c | 8 ++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c index c28f76a32d90..4bbc213dcfdb 100644 --- a/drivers/infiniband/hw/cxgb4/mem.c +++ b/drivers/infiniband/hw/cxgb4/mem.c @@ -679,10 +679,15 @@ int c4iw_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg, int sg_nents, unsigned int *sg_offset) { struct c4iw_mr *mhp = to_c4iw_mr(ibmr); + int n; mhp->mpl_len = 0; - return ib_sg_to_pages(ibmr, sg, sg_nents, sg_offset, c4iw_set_page); + n = ib_sg_to_pages(ibmr, sg, sg_nents, sg_offset, c4iw_set_page); + if (n > 0 && mr_exceeds_hw_limits(mhp->rhp, ibmr->length)) + return -EINVAL; + + return n; } int c4iw_dereg_mr(struct ib_mr *ib_mr, struct ib_udata *udata) diff --git a/drivers/infiniband/hw/cxgb4/qp.c b/drivers/infiniband/hw/cxgb4/qp.c index e295f79e0cd3..cff7f4b4519e 100644 --- a/drivers/infiniband/hw/cxgb4/qp.c +++ b/drivers/infiniband/hw/cxgb4/qp.c @@ -803,8 +803,8 @@ static void build_tpte_memreg(struct fw_ri_fr_nsmr_tpte_wr *fr, fr->tpte.nosnoop_pbladdr = cpu_to_be32(FW_RI_TPTE_PBLADDR_V( PBL_OFF(&mhp->rhp->rdev, mhp->attr.pbl_addr)>>3)); fr->tpte.dca_mwbcnt_pstag = cpu_to_be32(0); - fr->tpte.len_hi = cpu_to_be32(0); - fr->tpte.len_lo = cpu_to_be32(mhp->ibmr.length); + fr->tpte.len_hi = cpu_to_be32(upper_32_bits(mhp->ibmr.length)); + fr->tpte.len_lo = cpu_to_be32(lower_32_bits(mhp->ibmr.length)); fr->tpte.va_hi = cpu_to_be32(mhp->ibmr.iova >> 32); fr->tpte.va_lo_fbo = cpu_to_be32(mhp->ibmr.iova & 0xffffffff); @@ -831,8 +831,8 @@ static int build_memreg(struct t4_sq *sq, union t4_wr *wqe, wqe->fr.pgsz_shift = ilog2(wr->mr->page_size) - 12; wqe->fr.addr_type = FW_RI_VA_BASED_TO; wqe->fr.mem_perms = c4iw_ib_to_tpt_access(wr->access); - wqe->fr.len_hi = 0; - wqe->fr.len_lo = cpu_to_be32(mhp->ibmr.length); + wqe->fr.len_hi = cpu_to_be32(upper_32_bits(mhp->ibmr.length)); + wqe->fr.len_lo = cpu_to_be32(lower_32_bits(mhp->ibmr.length)); wqe->fr.stag = cpu_to_be32(wr->key); wqe->fr.va_hi = cpu_to_be32(mhp->ibmr.iova >> 32); wqe->fr.va_lo_fbo = cpu_to_be32(mhp->ibmr.iova & -- 2.52.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v3] RDMA/cxgb4: fix the length of large fast-reg MRs 2026-12-03 22:26 ` [PATCH v3] RDMA/cxgb4: fix the length of large fast-reg MRs Showrya M N @ 2026-12-03 13:14 ` sashiko-bot 0 siblings, 0 replies; 6+ messages in thread From: sashiko-bot @ 2026-12-03 13:14 UTC (permalink / raw) To: Showrya M N, linux-rdma Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] RDMA/cxgb4: inaccurate Fixes tag 2550a88d956f for fast-reg 8GB limit -- commit aee0ad15cad4c821862d1e5049a62a4e608edfbc Author: Potnuri Bharat Teja <bharat@chelsio.com> > RDMA/cxgb4: fix the length of large fast-reg MRs > > ib_mr.length is a u64 and cxgb4 advertises max_mr_size as ~0ULL, but > build_memreg() and build_tpte_memreg() always program len_hi as 0 and > truncate the length into len_lo. A kernel fast-reg MR of 4GB or more, > e.g. one mapped with a large page size, is therefore registered in HW > with a truncated length. > > Program len_hi/len_lo from the upper and lower 32 bits of the MR length, > as write_tpt_entry() already does for regular MRs. > > Also, T4 and T5 can't handle MRs of 8GB or more. c4iw_reg_user_mr() > already rejects such MRs via mr_exceeds_hw_limits(), but fast-reg MRs > get their length only in c4iw_map_mr_sg() and are never checked. With > DSGL, a fast-reg MR holds up to 128 pages of up to 128MB, so it can > reach 16GB. Apply the same limit in c4iw_map_mr_sg() and fail the > mapping with -EINVAL. > > Fixes: edd31551148c ("IB: Correct MR length field to be 64-bit") > Fixes: 2550a88d956f ("RDMA/cxgb4: Limit MRs to < 8GB for T4/T5 devices") > Signed-off-by: Potnuri Bharat Teja <bharat@chelsio.com> > Signed-off-by: Showrya M N <showrya@chelsio.com> [Severity: Low] Does the second Fixes tag accurately identify the introducing commit? At 2550a88d956f ("RDMA/cxgb4: Limit MRs to < 8GB for T4/T5 devices"), c4iw_map_mr_sg() did not exist yet (added in 8376b86de7d3 ("iw_cxgb4: Support the new memory registration API")), and wr.fast_reg.length was a u32, so fast-reg MRs could never reach 8GB. Fast-reg MRs could only reach 4GB or 8GB once ib_mr.length became u64 in edd31551148c ("IB: Correct MR length field to be 64-bit"), which is already cited by the first Fixes tag. Dropping the second Fixes tag avoids misleading automated stable backporting. -- Sashiko AI review · https://sashiko.dev/#/patchset/20261203222608.12907-1-showrya@chelsio.com?part=1 ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-12-03 13:14 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-12-03 18:56 [PATCH] RDMA/cxgb4: program the upper 32 bits of the fast-reg MR length Showrya M N 2026-12-03 9:46 ` sashiko-bot 2026-12-03 21:40 ` [PATCH v2] " Showrya M N 2026-12-03 12:26 ` sashiko-bot 2026-12-03 22:26 ` [PATCH v3] RDMA/cxgb4: fix the length of large fast-reg MRs Showrya M N 2026-12-03 13:14 ` sashiko-bot
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox