Re: [PATCH v10 rdma-next] RDMA: Change capability fields in ib_device_attr from int to u32

Andy Shevchenko <[email protected]>
Newsgroups gmane.linux.scsi.target.devel,gmane.linux.drivers.rdma,gmane.linux.kernel,gmane.linux.kernel.cifs,gmane.network.samba.internals,gmane.linux.nfs,gmane.linux.network
Organization Intel Finland Oy - BIC 0357606-4 - c/o Alberga Business Park, 6 krs, Bertel Jungin Aukio 5, 02600 Espoo
Message-ID <[email protected]>
On Wed, Jul 08, 2026 at 10:51:29PM -0700, Erni Sri Satya Vennela 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.
> 
> The nvmet-rdma consumer of max_srq clamps it against
> ib_device.num_comp_vectors, which stays a signed int, so that site
> uses min_t() instead of min() to handle the signed/unsigned mismatch.

Assuming the functionality is left untouched, from code perspective LGTM,
Reviewed-by: Andy Shevchenko <[email protected]>

...

>  int ipoib_cm_dev_init(struct net_device *dev)
>  {
>  	struct ipoib_dev_priv *priv = ipoib_priv(dev);
> -	int max_srq_sge, i;
> +	u32 max_srq_sge;
> +	int i;
>  	u8 addr;

This can keep the reversed xmas tree ordering.

...

>  static int srq_size_set(const char *val, const struct kernel_param *kp)
>  {
> -	int n = 0, ret;
> +	unsigned int n;
> +	int ret;
>  
> -	ret = kstrtoint(val, 10, &n);
> +	ret = kstrtouint(val, 10, &n);
>  	if (ret != 0 || n < 256)
>  		return -EINVAL;

Side note (perhaps another patch?)

	ret = kstrtouint(val, 10, &n);
	if (ret)
		return ret;
	if (n < 256)
		return -ERANGE,

> -	return param_set_int(val, kp);
> +	return param_set_uint(val, kp);
>  }

...

Have you considered also replacing min_not_zero() or do some refactoring
around there?

-- 
With Best Regards,
Andy Shevchenko
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.