ACK/Cmnt: [SRU][N:linux-bluefield][PATCH v1 1/1] platform/mellanox: mlxbf-pmc: Ignore unsupported performance blocks

John Cabaj john.cabaj at canonical.com
Thu Jul 10 18:17:04 UTC 2025


On 7/8/25 5:31 AM, Shravan Kumar Ramani wrote:
> From: Luiz Capitulino <luizcap at redhat.com>
> 
> BugLink: https://bugs.launchpad.net/bugs/2116164

Please add Noble as targeted series on the LP bug.

> 
> Currently, the driver has two behaviors to deal with new & unsupported
> performance blocks reported by the firmware:
> 
>   1. For register and unknown block types, the driver will fail to load
>      with the following error message:
> 
>      [ 4510.956369] mlxbf-pmc: probe of MLNXBFD2:00 failed with error -22
> 
>   2. For counter and crspace blocks, the driver will load and sysfs files
>      will be created but getting the contents of event_list or trying to
>      setup the counter will fail
> 
> Instead, let's ignore and log unsupported blocks. This means the driver
> will always load and unsupported blocks will never show up in sysfs.
> 
> Signed-off-by: Luiz Capitulino <luizcap at redhat.com>
> Reviewed-by: Hans de Goede <hdegoede at redhat.com>
> Link: https://lore.kernel.org/r/f8e2e6210b43e825b69824b420c801cd513d401d.1708635408.git.luizcap@redhat.com
> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen at linux.intel.com>
> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen at linux.intel.com>
> (cherry picked from commit c0459eeb64e955b8fb9dd9f73b937f750387ef9a)
> Signed-off-by: Shravan Kumar Ramani <shravankr at nvidia.com>
> ---
>   drivers/platform/mellanox/mlxbf-pmc.c | 16 ++++++++++++++--
>   1 file changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/platform/mellanox/mlxbf-pmc.c b/drivers/platform/mellanox/mlxbf-pmc.c
> index 725ce0e4e321..900069eb186e 100644
> --- a/drivers/platform/mellanox/mlxbf-pmc.c
> +++ b/drivers/platform/mellanox/mlxbf-pmc.c
> @@ -1198,6 +1198,11 @@ static const struct mlxbf_pmc_events *mlxbf_pmc_event_list(const char *blk, size
>   	return events;
>   }
>   
> +static bool mlxbf_pmc_event_supported(const char *blk)
> +{
> +	return !!mlxbf_pmc_event_list(blk, NULL);
> +}
> +
>   /* Get the event number given the name */
>   static int mlxbf_pmc_get_event_num(const char *blk, const char *evt)
>   {
> @@ -1966,6 +1971,9 @@ static int mlxbf_pmc_init_perftype_counter(struct device *dev, unsigned int blk_
>   	struct mlxbf_pmc_attribute *attr;
>   	unsigned int i = 0, j = 0;
>   
> +	if (!mlxbf_pmc_event_supported(pmc->block_name[blk_num]))
> +		return -ENOENT;
> +
>   	/* "event_list" sysfs to list events supported by the block */
>   	attr = &pmc->block[blk_num].attr_event_list;
>   	sysfs_attr_init(&attr->dev_attr.attr);
> @@ -2064,7 +2072,7 @@ static int mlxbf_pmc_init_perftype_reg(struct device *dev, unsigned int blk_num)
>   
>   	events = mlxbf_pmc_event_list(pmc->block_name[blk_num], &count);
>   	if (!events)
> -		return -EINVAL;
> +		return -ENOENT;
>   
>   	pmc->block[blk_num].attr_event = devm_kcalloc(
>   		dev, count, sizeof(struct mlxbf_pmc_attribute), GFP_KERNEL);
> @@ -2103,7 +2111,7 @@ static int mlxbf_pmc_create_groups(struct device *dev, unsigned int blk_num)
>   	else if (pmc->block[blk_num].type == MLXBF_PMC_TYPE_REGISTER)
>   		err = mlxbf_pmc_init_perftype_reg(dev, blk_num);
>   	else
> -		err = -EINVAL;
> +		err = -ENOENT;
>   
>   	if (err)
>   		return err;
> @@ -2231,6 +2239,10 @@ static int mlxbf_pmc_map_counters(struct device *dev)
>   			return -ENOMEM;
>   
>   		ret = mlxbf_pmc_create_groups(dev, i);
> +		if (ret == -ENOENT) {
> +			dev_warn(dev, "ignoring unsupported block: '%s'\n", pmc->block_name[i]);
> +			continue;
> +		}
>   		if (ret)
>   			return ret;
>   	}

Acked-by: John Cabaj <john.cabaj at canonical.com>





More information about the kernel-team mailing list