Re: [PATCH] platform/x86/amd: pmc: Add sysfs files for SMU

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi

2022. szeptember 13., kedd 16:25 keltezéssel, Mario Limonciello írta:

> The CPU/APU SMU FW version and program is currently discoverable by
> turning on dynamic debugging or examining debugfs for the amdgpu
> driver. To make this more discoverable, create a dedicated sysfs
> file for it that userspace can parse without debugging enabled.
> 
> Signed-off-by: Mario Limonciello <mario.limonciello@xxxxxxx>
> ---
>  Documentation/ABI/testing/sysfs-amd-pmc | 13 ++++++++
>  drivers/platform/x86/amd/pmc.c          | 44 +++++++++++++++++++++++++
>  2 files changed, 57 insertions(+)
>  create mode 100644 Documentation/ABI/testing/sysfs-amd-pmc
> 
> diff --git a/Documentation/ABI/testing/sysfs-amd-pmc b/Documentation/ABI/testing/sysfs-amd-pmc
> new file mode 100644
> index 000000000000..ff627b48c875
> --- /dev/null
> +++ b/Documentation/ABI/testing/sysfs-amd-pmc
> @@ -0,0 +1,13 @@
> +What:		/sys/bus/platform/drivers/amd_pmc/*/smu_fw_version
> +Date:		October 2022
> +Contact:	Mario Limonciello <mario.limonciello@xxxxxxx>
> +Description:	Reading this file reports the version of the firmware loaded to
> +		System Management Unit (SMU) contained in AMD CPUs and
> +		APUs.
> +
> +What:		/sys/bus/platform/drivers/amd_pmc/*/smu_program
> +Date:		October 2022
> +Contact:	Mario Limonciello <mario.limonciello@xxxxxxx>
> +Description:	Reading this file reports the program corresponding to the SMU
> +		firmware version.  The program field is used to disambiguate two
> +		APU/CPU models that can share the same firmware binary.
> \ No newline at end of file
    ^^^^^^^^^^^^^^^^^^^^^^^^^


> diff --git a/drivers/platform/x86/amd/pmc.c b/drivers/platform/x86/amd/pmc.c
> index 700eb19e8450..4302e7662087 100644
> --- a/drivers/platform/x86/amd/pmc.c
> +++ b/drivers/platform/x86/amd/pmc.c
> @@ -455,6 +455,49 @@ static int amd_pmc_get_smu_version(struct amd_pmc_dev *dev)
>  	return 0;
>  }
> 
> +static ssize_t smu_fw_version_show(struct device *d, struct device_attribute *attr,
> +				   char *buf)
> +{
> +	struct amd_pmc_dev *dev = dev_get_drvdata(d);
> +
> +	if (!dev->major) {
> +		int rc = amd_pmc_get_smu_version(dev);
> +
> +		if (rc)
> +			return rc;
> +	}
> +	return sysfs_emit(buf, "%u.%u.%u\n", dev->major, dev->minor, dev->rev);
> +}
> +static DEVICE_ATTR_RO(smu_fw_version);
> +
> +static ssize_t smu_program_show(struct device *d, struct device_attribute *attr,
> +				   char *buf)
> +{
> +	struct amd_pmc_dev *dev = dev_get_drvdata(d);
> +
> +	if (!dev->major) {
> +		int rc = amd_pmc_get_smu_version(dev);
> +
> +		if (rc)
> +			return rc;
> +	}
> +	return sysfs_emit(buf, "%u\n", dev->smu_program);
> +}
> +static DEVICE_ATTR_RO(smu_program);
> +
> +static struct attribute *pmc_attrs[] = {
> +	&dev_attr_smu_fw_version.attr,
> +	&dev_attr_smu_program.attr,
> +};

I believe this should be NULL-terminated.


> +static struct attribute_group pmc_attr_group = {
> +	.attrs = pmc_attrs,
> +};
> +
> +static const struct attribute_group *pmc_groups[] = {
> +	&pmc_attr_group,
> +	NULL,
> +};

I think you could use the ATTRIBUTE_GROUPS() macro to generate these two objects.


> +
>  static int amd_pmc_idlemask_show(struct seq_file *s, void *unused)
>  {
>  	struct amd_pmc_dev *dev = s->private;
> @@ -935,6 +978,7 @@ static struct platform_driver amd_pmc_driver = {
>  	.driver = {
>  		.name = "amd_pmc",
>  		.acpi_match_table = amd_pmc_acpi_ids,
> +		.dev_groups = pmc_groups,
>  	},
>  	.probe = amd_pmc_probe,
>  	.remove = amd_pmc_remove,
> --
> 2.34.1
> 


Regards,
Barnabás Pőcze




[Index of Archives]     [Linux Kernel Development]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux