lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 15 Nov 2022 14:01:55 -0600
From:   Mario Limonciello <mario.limonciello@....com>
To:     "Rafael J . Wysocki" <rafael@...nel.org>,
        Shyam Sundar S K <Shyam-sundar.S-k@....com>
CC:     Sven van Ashbrook <svenva@...omium.org>,
        Raul Rangel <rrangel@...omium.org>, <linux-pm@...r.kernel.org>,
        <platform-driver-x86@...r.kernel.org>, Pavel Machek <pavel@....cz>,
        Len Brown <len.brown@...el.com>,
        John Stultz <jstultz@...gle.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Stephen Boyd <sboyd@...nel.org>,
        Rajneesh Bhardwaj <irenic.rajneesh@...il.com>,
        Rajat Jain <rajatja@...gle.com>,
        David E Box <david.e.box@...el.com>,
        Hans de Goede <hdegoede@...hat.com>,
        <linux-kernel@...r.kernel.org>
Subject: [RFC v3 3/4] platform/x86/amd: pmc: Report duration of time in deepest hw state

amd_pmc displays a warning when a suspend didn't get to the deepest
state and a dynamic debugging message with the duration if it did.

Rather than logging to dynamic debugging the duration spent in the
deepest state, report this to a file in sysfs.

Signed-off-by: Mario Limonciello <mario.limonciello@....com>
---
RFC v2->v3:
 * Create new sysfs file instead of reporting using kernel symbol
---
 Documentation/ABI/testing/sysfs-amd-pmc |  6 ++++++
 drivers/platform/x86/amd/pmc.c          | 22 +++++++++++++++++++---
 2 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/Documentation/ABI/testing/sysfs-amd-pmc b/Documentation/ABI/testing/sysfs-amd-pmc
index c421b72844f1..89354da8e680 100644
--- a/Documentation/ABI/testing/sysfs-amd-pmc
+++ b/Documentation/ABI/testing/sysfs-amd-pmc
@@ -11,3 +11,9 @@ Contact:	Mario Limonciello <mario.limonciello@....com>
 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.
+
+What:		/sys/bus/platform/drivers/amd_pmc/*/low_power_idle_system_residency_us
+Date:		December 2022
+Contact:	Mario Limonciello <mario.limonciello@....com>
+Description:	Reading this file reports the duration of the last suspend that
+		was spent in the deepest hardware sleep state in microseconds.
diff --git a/drivers/platform/x86/amd/pmc.c b/drivers/platform/x86/amd/pmc.c
index 96e790e639a2..2550ba6d28f5 100644
--- a/drivers/platform/x86/amd/pmc.c
+++ b/drivers/platform/x86/amd/pmc.c
@@ -13,6 +13,7 @@
 #include <linux/acpi.h>
 #include <linux/bitfield.h>
 #include <linux/bits.h>
+#include <linux/cpu.h>
 #include <linux/debugfs.h>
 #include <linux/delay.h>
 #include <linux/io.h>
@@ -363,9 +364,6 @@ static void amd_pmc_validate_deepest(struct amd_pmc_dev *pdev)
 
 	if (!table.s0i3_last_entry_status)
 		dev_warn(pdev->dev, "Last suspend didn't reach deepest state\n");
-	else
-		dev_dbg(pdev->dev, "Last suspend in deepest state for %lluus\n",
-			 table.timein_s0i3_lastcapture);
 }
 #endif
 
@@ -417,12 +415,30 @@ static ssize_t smu_program_show(struct device *d, struct device_attribute *attr,
 	return sysfs_emit(buf, "%u\n", dev->smu_program);
 }
 
+static ssize_t low_power_idle_system_residency_us_show(struct device *d,
+						       struct device_attribute *attr,
+						       char *buf)
+{
+	struct amd_pmc_dev *dev = &pmc;
+	struct smu_metrics table;
+	int ret;
+
+	ret = get_metrics_table(dev, &table);
+	if (ret)
+		return ret;
+
+	return sysfs_emit(buf, "%llu\n", table.s0i3_last_entry_status ?
+					 table.timein_s0i3_lastcapture : 0);
+}
+
 static DEVICE_ATTR_RO(smu_fw_version);
 static DEVICE_ATTR_RO(smu_program);
+static DEVICE_ATTR_RO(low_power_idle_system_residency_us);
 
 static struct attribute *pmc_attrs[] = {
 	&dev_attr_smu_fw_version.attr,
 	&dev_attr_smu_program.attr,
+	&dev_attr_low_power_idle_system_residency_us.attr,
 	NULL,
 };
 ATTRIBUTE_GROUPS(pmc);
-- 
2.34.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ