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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20221031204320.22464-2-mario.limonciello@amd.com>
Date:   Mon, 31 Oct 2022 15:43:17 -0500
From:   Mario Limonciello <mario.limonciello@....com>
To:     Sven van Ashbrook <svenva@...omium.org>,
        Rafael J Wysocki <rafael@...nel.org>,
        Pavel Machek <pavel@....cz>, Len Brown <len.brown@...el.com>
CC:     Rajneesh Bhardwaj <irenic.rajneesh@...il.com>,
        S-k Shyam-sundar <Shyam-sundar.S-k@....com>,
        <rrangel@...omium.org>, <platform-driver-x86@...r.kernel.org>,
        Rajat Jain <rajatja@...gle.com>,
        "David E Box" <david.e.box@...el.com>,
        Hans de Goede <hdegoede@...hat.com>,
        "Mario Limonciello" <mario.limonciello@....com>,
        <linux-kernel@...r.kernel.org>, <linux-pm@...r.kernel.org>
Subject: [RFC 1/3] PM: Add a sysfs file to represent whether hardware reached the deepest state

Both AMD and Intel SoCs have a concept of reporting whether the hardware
reached the deepest possible hardware state over s2idle as well as how much
time was spent in that state.

This information is valuable to both chip designers and system designers as
it helps to identify when there are problems with power consumption over
an s2idle cycle.

To make the information discoverable, create a new sysfs file and a symbol
that drivers from supported manufacturers can use to advertise this
information.

Suggested-by: David E Box <david.e.box@...el.com>
Signed-off-by: Mario Limonciello <mario.limonciello@....com>
---
 Documentation/ABI/testing/sysfs-power |  8 ++++++++
 include/linux/suspend.h               |  2 ++
 kernel/power/main.c                   | 14 ++++++++++++++
 3 files changed, 24 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-power b/Documentation/ABI/testing/sysfs-power
index f99d433ff3117..25c52d7469b9c 100644
--- a/Documentation/ABI/testing/sysfs-power
+++ b/Documentation/ABI/testing/sysfs-power
@@ -413,6 +413,14 @@ Description:
 		The /sys/power/suspend_stats/last_failed_step file contains
 		the last failed step in the suspend/resume path.
 
+What:		/sys/power/suspend_stats/last_hw_deepest_state
+Date:		December 2022
+Contact:	Mario Limonciello <mario.limonciello@....com>
+Description:
+		The /sys/power/suspend_stats/last_hw_deepest_state file contains
+		the amount of time spent in the deepest hardware sleep state.
+		This is measured in microseconds.
+
 What:		/sys/power/sync_on_suspend
 Date:		October 2019
 Contact:	Jonas Meurer <jonas@...esources.org>
diff --git a/include/linux/suspend.h b/include/linux/suspend.h
index cfe19a0289185..30b8a8018299b 100644
--- a/include/linux/suspend.h
+++ b/include/linux/suspend.h
@@ -68,6 +68,7 @@ struct suspend_stats {
 	int	last_failed_errno;
 	int	errno[REC_FAILED_NUM];
 	int	last_failed_step;
+	u64	last_hw_deepest_state;
 	enum suspend_stat_step	failed_steps[REC_FAILED_NUM];
 };
 
@@ -489,6 +490,7 @@ void restore_processor_state(void);
 extern int register_pm_notifier(struct notifier_block *nb);
 extern int unregister_pm_notifier(struct notifier_block *nb);
 extern void ksys_sync_helper(void);
+extern void pm_set_hw_deepest_state(u64 duration);
 
 #define pm_notifier(fn, pri) {				\
 	static struct notifier_block fn##_nb =			\
diff --git a/kernel/power/main.c b/kernel/power/main.c
index 31ec4a9b9d704..1bda5d2d26c53 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -54,6 +54,12 @@ void unlock_system_sleep(unsigned int flags)
 }
 EXPORT_SYMBOL_GPL(unlock_system_sleep);
 
+void pm_set_hw_deepest_state(u64 duration)
+{
+	suspend_stats.last_hw_deepest_state = duration;
+}
+EXPORT_SYMBOL_GPL(pm_set_hw_deepest_state);
+
 void ksys_sync_helper(void)
 {
 	ktime_t start;
@@ -377,6 +383,13 @@ static ssize_t last_failed_step_show(struct kobject *kobj,
 }
 static struct kobj_attribute last_failed_step = __ATTR_RO(last_failed_step);
 
+static ssize_t last_hw_deepest_state_show(struct kobject *kobj,
+		struct kobj_attribute *attr, char *buf)
+{
+	return sprintf(buf, "%llu\n", suspend_stats.last_hw_deepest_state);
+}
+static struct kobj_attribute last_hw_deepest_state = __ATTR_RO(last_hw_deepest_state);
+
 static struct attribute *suspend_attrs[] = {
 	&success.attr,
 	&fail.attr,
@@ -391,6 +404,7 @@ static struct attribute *suspend_attrs[] = {
 	&last_failed_dev.attr,
 	&last_failed_errno.attr,
 	&last_failed_step.attr,
+	&last_hw_deepest_state.attr,
 	NULL,
 };
 
-- 
2.34.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ