[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAPDyKFpp1iuBXZB-T2=hhTND4Z63s7kJfaXWuiKTu1rrqMGc_Q@mail.gmail.com>
Date: Tue, 18 Feb 2025 13:49:34 +0100
From: Ulf Hansson <ulf.hansson@...aro.org>
To: "Rafael J. Wysocki" <rjw@...ysocki.net>
Cc: Linux PM <linux-pm@...r.kernel.org>, LKML <linux-kernel@...r.kernel.org>,
Alan Stern <stern@...land.harvard.edu>, Bjorn Helgaas <helgaas@...nel.org>,
Linux PCI <linux-pci@...r.kernel.org>, Johan Hovold <johan@...nel.org>,
Manivannan Sadhasivam <manivannan.sadhasivam@...aro.org>, Jon Hunter <jonathanh@...dia.com>,
Linux ACPI <linux-acpi@...r.kernel.org>,
Mika Westerberg <mika.westerberg@...ux.intel.com>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Subject: Re: [PATCH v1 2/3] PM: runtime: Introduce pm_runtime_blocked()
On Mon, 17 Feb 2025 at 21:20, Rafael J. Wysocki <rjw@...ysocki.net> wrote:
>
> From: Rafael J. Wysocki <rafael.j.wysocki@...el.com>
>
> Introduce a new helper function called pm_runtime_blocked() for
> checking the power.last_status value indicating whether or not the
> enabling of runtime PM for the given device has been blocked (which
> happens in the "prepare" phase of system-wide suspend if runtime
> PM is disabled for the given device at that point and has never
> been enabled so far).
>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@...el.com>
Reviewed-by: Ulf Hansson <ulf.hansson@...aro.org>
Kind regards
Uffe
> ---
> drivers/base/power/runtime.c | 17 +++++++++++++++++
> include/linux/pm_runtime.h | 2 ++
> 2 files changed, 19 insertions(+)
>
> --- a/drivers/base/power/runtime.c
> +++ b/drivers/base/power/runtime.c
> @@ -1555,6 +1555,23 @@
> }
> EXPORT_SYMBOL_GPL(pm_runtime_enable);
>
> +bool pm_runtime_blocked(struct device *dev)
> +{
> + bool ret;
> +
> + /*
> + * dev->power.last_status is a bit field, so in case it is updated via
> + * RMW, read it under the spin lock.
> + */
> + spin_lock_irq(&dev->power.lock);
> +
> + ret = dev->power.last_status == RPM_BLOCKED;
> +
> + spin_unlock_irq(&dev->power.lock);
> +
> + return ret;
> +}
> +
> static void pm_runtime_disable_action(void *data)
> {
> pm_runtime_dont_use_autosuspend(data);
> --- a/include/linux/pm_runtime.h
> +++ b/include/linux/pm_runtime.h
> @@ -81,6 +81,7 @@
> extern void pm_runtime_unblock(struct device *dev);
> extern void pm_runtime_enable(struct device *dev);
> extern void __pm_runtime_disable(struct device *dev, bool regular);
> +extern bool pm_runtime_blocked(struct device *dev);
> extern void pm_runtime_allow(struct device *dev);
> extern void pm_runtime_forbid(struct device *dev);
> extern void pm_runtime_no_callbacks(struct device *dev);
> @@ -277,6 +278,7 @@
> static inline void pm_runtime_unblock(struct device *dev) {}
> static inline void pm_runtime_enable(struct device *dev) {}
> static inline void __pm_runtime_disable(struct device *dev, bool c) {}
> +static inline bool pm_runtime_blocked(struct device *dev) { return true; }
> static inline void pm_runtime_allow(struct device *dev) {}
> static inline void pm_runtime_forbid(struct device *dev) {}
>
>
>
>
Powered by blists - more mailing lists