linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pmdomain: core: Introduce device_set/get_out_band_wakeup()
@ 2025-03-11  8:32 Peng Fan (OSS)
  2025-04-03  9:46 ` Peng Fan
  0 siblings, 1 reply; 3+ messages in thread
From: Peng Fan (OSS) @ 2025-03-11  8:32 UTC (permalink / raw)
  To: ulf.hansson, rafael, pavel, len.brown, vincent.guittot
  Cc: linux-pm, linux-kernel, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

For some cases, a device could still wakeup the system even if its power
domain is in off state, because the device's wakeup hardware logic is
in an always-on domain.

To support this case, introduce device_set/get_out_band_wakeup() to
allow device drivers to control the behaviour in genpd for a device
that is attached to it.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---

V1:
 More discussion:
 https://lore.kernel.org/arm-scmi/20250218162045.GA15753@nxa18884-linux/T/#me83f18f001e0db51860c53d0979f1ac8deb10a12
 With "device_set_out_band_wakeup(dev, true);" in probe of driver
 drivers/usb/dwc3/dwc3-imx8mp.c, when USB power domain is in off state,
 usb could still wakeup the system.

 drivers/pmdomain/core.c   |  6 ++++--
 include/linux/pm.h        |  1 +
 include/linux/pm_wakeup.h | 17 +++++++++++++++++
 3 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/drivers/pmdomain/core.c b/drivers/pmdomain/core.c
index 9b2f28b34bb5..fa0d93c9078e 100644
--- a/drivers/pmdomain/core.c
+++ b/drivers/pmdomain/core.c
@@ -1450,7 +1450,8 @@ static int genpd_finish_suspend(struct device *dev,
 	if (ret)
 		return ret;
 
-	if (device_wakeup_path(dev) && genpd_is_active_wakeup(genpd))
+	if (device_wakeup_path(dev) && genpd_is_active_wakeup(genpd) &&
+	    !device_get_out_band_wakeup(dev))
 		return 0;
 
 	if (genpd->dev_ops.stop && genpd->dev_ops.start &&
@@ -1505,7 +1506,8 @@ static int genpd_finish_resume(struct device *dev,
 	if (IS_ERR(genpd))
 		return -EINVAL;
 
-	if (device_wakeup_path(dev) && genpd_is_active_wakeup(genpd))
+	if (device_wakeup_path(dev) && genpd_is_active_wakeup(genpd) &&
+	    !device_get_out_band_wakeup(dev))
 		return resume_noirq(dev);
 
 	genpd_lock(genpd);
diff --git a/include/linux/pm.h b/include/linux/pm.h
index 63a8dffda787..2c1dd35c3e19 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -683,6 +683,7 @@ struct dev_pm_info {
 	bool			smart_suspend:1;	/* Owned by the PM core */
 	bool			must_resume:1;		/* Owned by the PM core */
 	bool			may_skip_resume:1;	/* Set by subsystems */
+	bool			out_band_wakeup:1;
 #else
 	bool			should_wakeup:1;
 #endif
diff --git a/include/linux/pm_wakeup.h b/include/linux/pm_wakeup.h
index 51e0e8dd5f9e..8dee27c34c3c 100644
--- a/include/linux/pm_wakeup.h
+++ b/include/linux/pm_wakeup.h
@@ -94,6 +94,16 @@ static inline void device_set_wakeup_path(struct device *dev)
 	dev->power.wakeup_path = true;
 }
 
+static inline void device_set_out_band_wakeup(struct device *dev, bool capable)
+{
+	dev->power.out_band_wakeup = capable;
+}
+
+static inline bool device_get_out_band_wakeup(struct device *dev)
+{
+	return dev->power.out_band_wakeup;
+}
+
 /* drivers/base/power/wakeup.c */
 extern struct wakeup_source *wakeup_source_create(const char *name);
 extern void wakeup_source_destroy(struct wakeup_source *ws);
@@ -177,6 +187,13 @@ static inline bool device_wakeup_path(struct device *dev)
 
 static inline void device_set_wakeup_path(struct device *dev) {}
 
+static inline void device_set_out_band_wakeup(struct device *dev, bool capable) {}
+
+static inline bool device_get_out_band_wakeup(struct device *dev)
+{
+	return false;
+}
+
 static inline void __pm_stay_awake(struct wakeup_source *ws) {}
 
 static inline void pm_stay_awake(struct device *dev) {}
-- 
2.37.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] pmdomain: core: Introduce device_set/get_out_band_wakeup()
  2025-03-11  8:32 [PATCH] pmdomain: core: Introduce device_set/get_out_band_wakeup() Peng Fan (OSS)
@ 2025-04-03  9:46 ` Peng Fan
  2025-04-18 13:47   ` Peng Fan
  0 siblings, 1 reply; 3+ messages in thread
From: Peng Fan @ 2025-04-03  9:46 UTC (permalink / raw)
  To: ulf.hansson, rafael, pavel, len.brown, vincent.guittot
  Cc: linux-pm, linux-kernel, Peng Fan

Hi Ulf,

On Tue, Mar 11, 2025 at 04:32:39PM +0800, Peng Fan (OSS) wrote:
>From: Peng Fan <peng.fan@nxp.com>
>
>For some cases, a device could still wakeup the system even if its power
>domain is in off state, because the device's wakeup hardware logic is
>in an always-on domain.
>
>To support this case, introduce device_set/get_out_band_wakeup() to
>allow device drivers to control the behaviour in genpd for a device
>that is attached to it.

Do you have any comments on this patch?

Thanks,
Peng

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] pmdomain: core: Introduce device_set/get_out_band_wakeup()
  2025-04-03  9:46 ` Peng Fan
@ 2025-04-18 13:47   ` Peng Fan
  0 siblings, 0 replies; 3+ messages in thread
From: Peng Fan @ 2025-04-18 13:47 UTC (permalink / raw)
  To: ulf.hansson, rafael, pavel, len.brown, vincent.guittot
  Cc: linux-pm, linux-kernel, Peng Fan

Ping..

On Thu, Apr 03, 2025 at 05:46:29PM +0800, Peng Fan wrote:
>Hi Ulf,
>
>On Tue, Mar 11, 2025 at 04:32:39PM +0800, Peng Fan (OSS) wrote:
>>From: Peng Fan <peng.fan@nxp.com>
>>
>>For some cases, a device could still wakeup the system even if its power
>>domain is in off state, because the device's wakeup hardware logic is
>>in an always-on domain.
>>
>>To support this case, introduce device_set/get_out_band_wakeup() to
>>allow device drivers to control the behaviour in genpd for a device
>>that is attached to it.
>
>Do you have any comments on this patch?
>
>Thanks,
>Peng
>

Thanks,
Peng

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-04-18 12:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-11  8:32 [PATCH] pmdomain: core: Introduce device_set/get_out_band_wakeup() Peng Fan (OSS)
2025-04-03  9:46 ` Peng Fan
2025-04-18 13:47   ` Peng Fan

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).