From: Heiner Kallweit <hkallweit1@gmail.com>
To: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
Pavel Machek <pavel@ucw.cz>, Len Brown <len.brown@intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Linux PM <linux-pm@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: [PATCH] PM: runtime: add RPM_IDLE_SUSPEND / RPM_IDLE_NO_SUSPEND constants
Date: Sat, 30 May 2020 18:33:33 +0200 [thread overview]
Message-ID: <94fe944c-c528-9459-fc75-7c94273dd2b1@gmail.com> (raw)
runtime_idle() callback implementations have to return a non-zero value
if they don't intend to suspend now. Several drivers use an errno like
-EBUSY for this purpose. This can be problematic because the return
value is propagated up the call chain, from rpm_idle() to
__pm_runtime_idle(), and from there to callers like
pm_runtime_put_sync(). A driver author checking the return value of
e.g. pm_runtime_put_sync() may as usual check for retval < 0 and
bail out.
Therefore a positive value should be returned. To facilitate this
add constants RPM_IDLE_SUSPEND and RPM_IDLE_NO_SUSPEND.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/base/power/runtime.c | 6 +++++-
include/linux/pm.h | 10 ++++++++--
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
index 9f62790f6..4f529075e 100644
--- a/drivers/base/power/runtime.c
+++ b/drivers/base/power/runtime.c
@@ -453,7 +453,11 @@ static int rpm_idle(struct device *dev, int rpmflags)
out:
trace_rpm_return_int_rcuidle(dev, _THIS_IP_, retval);
- return retval ? retval : rpm_suspend(dev, rpmflags | RPM_AUTO);
+
+ if (retval == RPM_IDLE_SUSPEND)
+ return rpm_suspend(dev, rpmflags | RPM_AUTO);
+
+ return retval;
}
/**
diff --git a/include/linux/pm.h b/include/linux/pm.h
index 121c104a4..971ed3d77 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -227,8 +227,9 @@ typedef struct pm_message {
*
* @runtime_idle: Device appears to be inactive and it might be put into a
* low-power state if all of the necessary conditions are satisfied.
- * Check these conditions, and return 0 if it's appropriate to let the PM
- * core queue a suspend request for the device.
+ * Check these conditions, and return RPM_IDLE_SUSPEND if it's
+ * appropriate to let the PM core queue a suspend request for the device.
+ * Return RPM_IDLE_NO_SUSPEND if you don't want to suspend now.
*
* Several device power state transitions are externally visible, affecting
* the state of pending I/O queues and (for drivers that touch hardware)
@@ -523,6 +524,11 @@ enum rpm_request {
RPM_REQ_RESUME,
};
+enum rpm_idle {
+ RPM_IDLE_SUSPEND = 0,
+ RPM_IDLE_NO_SUSPEND,
+};
+
struct wakeup_source;
struct wake_irq;
struct pm_domain_data;
--
2.26.2
next reply other threads:[~2020-05-30 16:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-30 16:33 Heiner Kallweit [this message]
2020-06-05 12:10 ` [PATCH] PM: runtime: add RPM_IDLE_SUSPEND / RPM_IDLE_NO_SUSPEND constants 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=94fe944c-c528-9459-fc75-7c94273dd2b1@gmail.com \
--to=hkallweit1@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=len.brown@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=pavel@ucw.cz \
--cc=rjw@rjwysocki.net \
/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;
as well as URLs for NNTP newsgroup(s).