Subject: Re: [net 5/9] net/mlx5: Register a unique thermal zone per device

From: Simon Horman <[email-masked]>
Date: Fri, 30 Jun 2023 22:10:16 +0200

On Fri, Jun 30, 2023 at 11:15:40AM -0700, Saeed Mahameed wrote:
> From: Saeed Mahameed <[email-masked]>
> 
> Prior to this patch only one "mlx5" thermal zone could have been
> registered regardless of the number of individual mlx5 devices in the
> system.
> 
> To fix this setup a unique name per device to register its own thermal
> zone.
> 
> In order to not register a thermal zone for a virtual device (VF/SF) add
> a check for PF device type.
> 
> The new name is a concatenation between "mlx5_" and "<PCI_DEV_BDF>", which
> will also help associating a thermal zone with its PCI device.
> 
> $ lspci | grep ConnectX
> 00:04.0 Ethernet controller: Mellanox Technologies MT2892 Family [ConnectX-6 Dx]
> 00:05.0 Ethernet controller: Mellanox Technologies MT2892 Family [ConnectX-6 Dx]
> 
> $ cat /sys/devices/virtual/thermal/thermal_zone0/type
> mlx5_0000:00:04.0
> $ cat /sys/devices/virtual/thermal/thermal_zone1/type
> mlx5_0000:00:05.0
> 
> Fixes: c1fef618d611 ("net/mlx5: Implement thermal zone")
> CC: Sandipan Patra <[email-masked]>
> Signed-off-by: Saeed Mahameed <[email-masked]>

...

> @@ -89,10 +94,10 @@ int mlx5_thermal_init(struct mlx5_core_dev *mdev)
>  								 &mlx5_thermal_ops,
>  								 NULL, 0, MLX5_THERMAL_POLL_INT_MSEC);
>  	if (IS_ERR(thermal->tzdev)) {
> -		dev_err(mdev->device, "Failed to register thermal zone device (%s) %ld\n",
> -			data, PTR_ERR(thermal->tzdev));
> +		err = PTR_ERR(thermal->tzdev);
> +		mlx5_core_err(mdev, "Failed to register thermal zone device (%s) %ld\n", data, err);

Hi Saeed,

unfortunately it seems that this breaks allmodconfig.

 drivers/net/ethernet/mellanox/mlx5/core/thermal.c:98:82: warning: format specifies type 'long' but the argument has type 'int' [-Wformat]
                 mlx5_core_err(mdev, "Failed to register thermal zone device (%s) %ld\n", data, err);
                                                                                  ~~~           ^~~
                                                                                  %d
 drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h:67:11: note: expanded from macro 'mlx5_core_err'
                ##__VA_ARGS__)
                  ^~~~~~~~~~~
 ./include/linux/dev_printk.h:144:65: note: expanded from macro 'dev_err'
         dev_printk_index_wrap(_dev_err, KERN_ERR, dev, dev_fmt(fmt), ##__VA_ARGS__)
                                                                ~~~     ^~~~~~~~~~~
 ./include/linux/dev_printk.h:110:23: note: expanded from macro 'dev_printk_index_wrap'
                 _p_func(dev, fmt, ##__VA_ARGS__);                       \
                              ~~~    ^~~~~~~~~~~
 1 warning generated.

>  		kfree(thermal);
> -		return -EINVAL;
> +		return err;
>  	}
>  	mdev->thermal = thermal;
> -- 
> 2.41.0