From: Dominik Brodowski <linux@dominikbrodowski.net>
To: linux-pm@lists.linux-foundation.org
Subject: [PATCH] runtime pm: add sysfs debug files
Date: Sun, 11 Apr 2010 17:01:36 +0200 [thread overview]
Message-ID: <20100411150136.GA6693@comet.dominikbrodowski.net> (raw)
Add a few sysfs files relating to runtime power management for
advanced debug purposes:
runtime_status: what state is the device in currently? E.g., it
reports "disabled" if runtime power management is
disabled for a device, "suspended" for runtime-suspended
devices, and "active" for active devices.
runtime_usage: the runtime PM usage count of a device
runtime_children: the runtime PM children usage count of a device, or
0 if the ignore_children flag is set.
Also, CONFIG_PM_SLEEP_ADVANCED_DEBUG is not defined in any Kconfig
file, so replace it with CONFIG_PM_ADVANCED_DEBUG.
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
index 86fd937..6ba0f06 100644
--- a/drivers/base/power/sysfs.c
+++ b/drivers/base/power/sysfs.c
@@ -5,6 +5,7 @@
#include <linux/device.h>
#include <linux/string.h>
#include <linux/pm_runtime.h>
+#include <asm/atomic.h>
#include "power.h"
/*
@@ -143,7 +144,49 @@ wake_store(struct device * dev, struct device_attribute *attr,
static DEVICE_ATTR(wakeup, 0644, wake_show, wake_store);
-#ifdef CONFIG_PM_SLEEP_ADVANCED_DEBUG
+#ifdef CONFIG_PM_ADVANCED_DEBUG
+#ifdef CONFIG_PM_RUNTIME
+
+static ssize_t usagecount_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ return sprintf(buf, "%d\n", atomic_read(&dev->power.usage_count));
+}
+
+static ssize_t children_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ return sprintf(buf, "%d\n", dev->power.ignore_children ?
+ 0 : atomic_read(&dev->power.child_count));
+}
+
+static ssize_t rtpm_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ int status = dev->power.runtime_status;
+ if (dev->power.disable_depth)
+ return sprintf(buf, "disabled\n");
+ if (dev->power.runtime_auto == false)
+ return sprintf(buf, "forbidden\n");
+ switch (status) {
+ case RPM_SUSPENDED:
+ return sprintf(buf, "suspended\n");
+ case RPM_SUSPENDING:
+ return sprintf(buf, "to be suspended\n");
+ case RPM_RESUMING:
+ return sprintf(buf, "to be resumed\n");
+ case RPM_ACTIVE:
+ return sprintf(buf, "active\n");
+ }
+ return -EIO;
+}
+
+static DEVICE_ATTR(runtime_usage, 0444, usagecount_show, NULL);
+static DEVICE_ATTR(runtime_children, 0444, children_show, NULL);
+static DEVICE_ATTR(runtime_status, 0444, rtpm_show, NULL);
+
+#endif
+
static ssize_t async_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
@@ -170,15 +213,20 @@ static ssize_t async_store(struct device *dev, struct device_attribute *attr,
}
static DEVICE_ATTR(async, 0644, async_show, async_store);
-#endif /* CONFIG_PM_SLEEP_ADVANCED_DEBUG */
+#endif /* CONFIG_PM_ADVANCED_DEBUG */
static struct attribute * power_attrs[] = {
#ifdef CONFIG_PM_RUNTIME
&dev_attr_control.attr,
#endif
&dev_attr_wakeup.attr,
-#ifdef CONFIG_PM_SLEEP_ADVANCED_DEBUG
+#ifdef CONFIG_PM_ADVANCED_DEBUG
&dev_attr_async.attr,
+#ifdef CONFIG_PM_RUNTIME
+ &dev_attr_runtime_usage.attr,
+ &dev_attr_runtime_children.attr,
+ &dev_attr_runtime_status.attr,
+#endif
#endif
NULL,
};
next reply other threads:[~2010-04-11 15:01 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-11 15:01 Dominik Brodowski [this message]
2010-04-11 18:54 ` [PATCH] runtime pm: add sysfs debug files Alan Stern
2010-04-15 17:47 ` [PATCH v2] " Dominik Brodowski
2010-04-15 18:33 ` Alan Stern
2010-04-16 12:55 ` Dominik Brodowski
2010-04-16 14:36 ` Alan Stern
2010-04-16 17:51 ` Rafael J. Wysocki
2010-04-23 18:27 ` Rafael J. Wysocki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100411150136.GA6693@comet.dominikbrodowski.net \
--to=linux@dominikbrodowski.net \
--cc=linux-pm@lists.linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox