platform/x86/amd: pmc: Add sysfs files for SMU
PATCH 1/1 platform/x86/amd: pmc: Add sysfs files for SMU
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.
--- 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
Documentation/ABI/testing/sysfs-amd-pmc new file +13 -0
@@ -0,0 +1,13 @@ +What: /sys/bus/platform/drivers/amd_pmc/*/smu_fw_version +Date: October 2022 +Contact: Mario Limonciello <[email protected]> +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 <[email protected]> +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.
drivers/platform/x86/amd/pmc.c +44 -0
56 lines not on this page · raw message
Signature · 1 line
2.34.1
Hi
2022. szeptember 13., kedd 16:25 keltezéssel, Mario Limonciello írta:
Quoted 22 lines
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 <[email protected]>--- 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-pmcDocumentation/ABI/testing/sysfs-amd-pmc new file +4
-0@@ -0,0 +1,13 @@ +What: /sys/bus/platform/drivers/amd_pmc/*/smu_fw_version +Date: October 2022 +Contact: Mario Limonciello <[email protected]> +Description: Reading this file reports the version of the firmware loaded to
Documentation/ABI/testing/sysfs-amd-pmc line 13
Quoted 10 lines
Documentation/ABI/testing/sysfs-amd-pmc new file +9
-0+ 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 <[email protected]> +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.
^^^^^^^^^^^^^^^^^^^^^^^^^
Quoted 32 lines
drivers/platform/x86/amd/pmc.c +24
-0@@ -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)
drivers/platform/x86/amd/pmc.c static int amd_pmc_get_smu_version(struct amd_pmc_dev *dev) · line 491
Quoted 10 lines
drivers/platform/x86/amd/pmc.c +10
-0+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.
drivers/platform/x86/amd/pmc.c static int amd_pmc_get_smu_version(struct amd_pmc_dev *dev) · line 499
Quoted 8 lines
drivers/platform/x86/amd/pmc.c +8
-0+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.
Quoted 13 lines
drivers/platform/x86/amd/pmc.c +2
-1+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, --
Quoted 2 lines
2.34.1
Regards,
Barnabás Pőcze