diff mbox series

[RFC,v3,4/4] platform/x86/amd: pmc: Populate cpuidle sysfs file with hw sleep data

Message ID 20221115200156.12218-5-mario.limonciello@amd.com (mailing list archive)
State Deferred, archived
Headers show
Series Make it easier to measure % in HW sleep state | expand

Commit Message

Mario Limonciello Nov. 15, 2022, 8:01 p.m. UTC
AMD platforms don't provide an ACPI LPIT table, but the data about
duration of time in a hardware sleep state is part of the SMU metrics
table.

To allow userspace to query this from a standard location, export this
information to the standard
`/sys/devices/system/cpu/cpuidle/low_power_idle_system_residency_us`.

Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
RFC v2->v3:
 * New patch
---
 drivers/platform/x86/amd/pmc.c | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox series

Patch

diff --git a/drivers/platform/x86/amd/pmc.c b/drivers/platform/x86/amd/pmc.c
index 2550ba6d28f5..ef5c23df1a5b 100644
--- a/drivers/platform/x86/amd/pmc.c
+++ b/drivers/platform/x86/amd/pmc.c
@@ -787,6 +787,11 @@  static void amd_pmc_s2idle_restore(void)
 
 	/* Notify on failed entry */
 	amd_pmc_validate_deepest(pdev);
+
+	/* Silently fail, if cpuidle attribute group is not present */
+	sysfs_add_file_to_group(&cpu_subsys.dev_root->kobj,
+				&dev_attr_low_power_idle_system_residency_us.attr,
+				"cpuidle");
 }
 
 static struct acpi_s2idle_dev_ops amd_pmc_s2idle_dev_ops = {