Re: [PATCH rdma-next v6] RDMA: Change capability fields in ib_device_attr from int to u32
David Laight <[email protected]> Tue, 2 Jun 2026 12:33:27 +0100
| Newsgroups | gmane.linux.nfs,gmane.linux.drivers.rdma,gmane.linux.kernel,gmane.linux.scsi.target.devel,gmane.linux.kernel.cifs,gmane.network.samba.internals,gmane.linux.network |
|---|---|
| Message-ID | <20260602123327.35aa286a@pumpkin> |
On Mon, 1 Jun 2026 02:25:15 -0700 Erni Sri Satya Vennela <[email protected]> wrote: > The capability counter fields in struct ib_device_attr are declared > as signed int, but these values are inherently non-negative. Drivers > maintain their cached caps as u32 and assign them directly into these > int fields; if a cap exceeds INT_MAX the implicit narrowing yields a > negative value visible to the IB core. > > Change the signed int capability fields to u32 to match the > underlying nature of the data. Also update consumers across the IB > core, ULPs, NVMe-oF target, RDS, and NFS/RDMA so the new u32 values > are not forced back through signed int or u8 via min()/min_t() or > narrowing local variables. > > Suggested-by: Jason Gunthorpe <[email protected]> > Signed-off-by: Erni Sri Satya Vennela <[email protected]> > --- ... > diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.c b/drivers/infiniband/ulp/rtrs/rtrs-srv.c > index 6482ad859bd1..852213365ecd 100644 > --- a/drivers/infiniband/ulp/rtrs/rtrs-srv.c > +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.c > @@ -1731,7 +1731,7 @@ static int create_con(struct rtrs_srv_path *srv_path, > * All receive and all send (each requiring invalidate) > * + 2 for drain and heartbeat > */ > - max_send_wr = min_t(int, wr_limit, > + max_send_wr = min_t(u32, wr_limit, > SERVICE_CON_QUEUE_DEPTH * 2 + 2); That should compile as min(). (The constant is known to be non-negative.) ... > diff --git a/drivers/nvme/target/rdma.c b/drivers/nvme/target/rdma.c > index e6e2c3f9afdf..fd6923198ec1 100644 > --- a/drivers/nvme/target/rdma.c > +++ b/drivers/nvme/target/rdma.c ... > @@ -1553,8 +1554,8 @@ static int nvmet_rdma_cm_accept(struct rdma_cm_id *cm_id, > > param.rnr_retry_count = 7; > param.flow_control = 1; > - param.initiator_depth = min_t(u8, p->initiator_depth, > - queue->dev->device->attrs.max_qp_init_rd_atom); > + param.initiator_depth = (u8)min_t(u32, p->initiator_depth, > + min_t(u32, U8_MAX, queue->dev->device->attrs.max_qp_init_rd_atom)); I think you've change one of those to min_3(). Nesting min() is a good way to bloat the pre-processor output. You don't need any of the casts. param.initiator_depth = min_3(p->initiator_depth, queue->dev->device->attrs.max_qp_init_rd_atom, U8_MAX); should be fine - if a bit long. There are also (u32)U8_MAX casts lurking - pointless. -- David