pmdomain: core: Introduce device_set/get_out_band_wakeup and use it in usb
Subsystems (9)
v3 cover pmdomain: core: Introduce device_set/get_out_band_wakeup and use it in usb
This is pick up of [1] which does not have response in about 5 months.
This V2 patchset
- includes usb driver changes(patch 2,3) to give people a full picture on how it is used.
- Rebased next-20250729 to resolve conflicts
To i.MX95, USB2 and USB3 are in HSIOMIX, but there is always on logic to make USB2 and USB3 has wakeup capability when HSIOMIX power domain is in off state. Otherwise the HSIOMIX will be kept on when USB2 and USB3 are configured to be wakeup source and Linux suspended. With this patchset, HSIOMIX could be powered off and Linux could still be woke up by USB hotplug event.
Patch 1 introduces device_set/get_out_band_wakeup
Patch 2 and 3 are drivers changes to use device_set_out_band_wakeup
[1]https://lore.kernel.org/linux-pm/[email protected]/
More old discussions:
https://lore.kernel.org/linux-pm/[email protected]/
---
Changes in v3:
- Add a new patch from Xu Yang to detach power domain for ci hdrc
- Add A-b for patch 4
- Link to v2: https://lore.kernel.org/r/[email protected]
---
Peng Fan (3):
pmdomain: core: Introduce device_set/get_out_band_wakeup()
usb: chipidea: ci_hdrc_imx: Set out of band wakeup for i.MX95
usb: dwc3: imx8mp: Set out of band wakeup for i.MX95
Xu Yang (1):
usb: chipidea: core: detach power domain for ci_hdrc platform device
drivers/pmdomain/core.c | 6 ++++-- drivers/usb/chipidea/ci_hdrc_imx.c | 8 ++++++++ drivers/usb/chipidea/core.c | 3 +++ drivers/usb/dwc3/dwc3-imx8mp.c | 4 ++++ include/linux/pm.h | 1 + include/linux/pm_wakeup.h | 17 +++++++++++++++++ include/linux/usb/chipidea.h | 1 + 7 files changed, 38 insertions(+), 2 deletions(-)
---
base-commit: 1b09efec32046a9c78cfecc46a26b1b139a3e8a8
change-id: 20250729-pm-243ff7097e44
Best regards,
Signature · 1 line
Peng Fan <[email protected]>
PATCH v3 1/4 pmdomain: core: Introduce device_set/get_out_band_wakeup()
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.
--- drivers/pmdomain/core.c | 6 ++++-- include/linux/pm.h | 1 + include/linux/pm_wakeup.h | 17 +++++++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-)
drivers/pmdomain/core.c +4 -2
@@ -1549,7 +1549,8 @@ static int genpd_finish_suspend(struct device *dev,if (ret)return ret; -if (device_awake_path (dev) &&genpd_is_active_wakeup (genpd)) +if (device_awake_path (dev) &&genpd_is_active_wakeup (genpd) && + !device_get_out_band_wakeup (dev))return 0 ; if (genpd->dev_ops.stop && genpd->dev_ops.start &&
@@ -1604,7 +1605,8 @@ static int genpd_finish_resume(struct device *dev,if (IS_ERR (genpd))return -EINVAL ; -if (device_awake_path (dev) &&genpd_is_active_wakeup (genpd)) +if (device_awake_path (dev) &&genpd_is_active_wakeup (genpd) && + !device_get_out_band_wakeup (dev))return resume_noirq (dev);genpd_lock (genpd);
include/linux/pm.h +1 -0
@@ -684,6 +684,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; bool strict_midlayer:1;#else bool should_wakeup:1;
include/linux/pm_wakeup.h +17 -0
@@ -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_register (struct device *dev,const char *name);
@@ -162,6 +172,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) {}
Signature · 1 line
2.37.1
PATCH v3 2/4 usb: chipidea: core: detach power domain for ci_hdrc platform device
In reply to Peng FanFrom: Xu Yang <[email protected]>
When add a platform device by calling ci_hdrc_add_device(), this device will reuse OF node of its parent device. If power-domains property is provided in the OF node, both two platform devices will be attached to the same power domain. This should be unnecessary and may bring other inconsistent behavior. For example, to support wakeup capability, these two platform device need different power domain state. The parent device need NOT power domain on for out-band interrupt, but the ci_hdrc device need power domain on for in-band interrupt. The i.MX95 Soc support out-band wakeup interrupt, the user need to enable wakeup for the parent device, but if the user also enable wakeup for ci_hdrc device, the power domain will keep at on state finally. To exclude such inconsistent behavior and simplify the power management, detach power domain for ci_hdrc platform device.
--- drivers/usb/chipidea/core.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/chipidea/core.c +3 -0
@@ -27,6 +27,7 @@#include <linux/kernel.h> #include <linux/slab.h> #include <linux/pm_runtime.h> +#include <linux/pm_domain.h> #include <linux/pinctrl/consumer.h> #include <linux/usb/ch9.h> #include <linux/usb/gadget.h>
@@ -915,6 +916,8 @@ struct platform_device *ci_hdrc_add_device(struct device *dev,if (ret) goto err; +dev_pm_domain_detach (&pdev->dev, false); +return pdev; err:
Signature · 1 line
2.37.1
PATCH v3 3/4 usb: chipidea: ci_hdrc_imx: Set out of band wakeup for i.MX95
In reply to Peng Fani.MX95 USB2 inside HSIOMIX could still wakeup Linux, even if HSIOMIX power domain(Digital logic) is off. There is still always on logic have the wakeup capability which is out band wakeup capbility.
So use device_set_out_band_wakeup for i.MX95 to make sure usb2 could wakeup system even if HSIOMIX power domain is in off state.
--- drivers/usb/chipidea/ci_hdrc_imx.c | 8 ++++++++ include/linux/usb/chipidea.h | 1 + 2 files changed, 9 insertions(+)
drivers/usb/chipidea/ci_hdrc_imx.c +8 -0
@@ -79,6 +79,10 @@ static const struct ci_hdrc_imx_platform_flag imx8ulp_usb_data = { CI_HDRC_HAS_PORTSC_PEC_MISSED, }; +static const struct ci_hdrc_imx_platform_flag imx95_usb_data = { + .flags =CI_HDRC_SUPPORTS_RUNTIME_PM |CI_HDRC_OUT_BAND_WAKEUP , +}; +static const struct ci_hdrc_imx_platform_flag s32g_usb_data = { .flags =CI_HDRC_DISABLE_HOST_STREAMING , };
@@ -94,6 +98,7 @@ static const struct of_device_id ci_hdrc_imx_dt_ids[] = { { .compatible = "fsl,imx7d-usb", .data = &imx7d_usb_data}, { .compatible = "fsl,imx7ulp-usb", .data = &imx7ulp_usb_data}, { .compatible = "fsl,imx8ulp-usb", .data = &imx8ulp_usb_data}, + { .compatible = "fsl,imx95-usb", .data = &imx95_usb_data}, { .compatible = "nxp,s32g2-usb", .data = &s32g_usb_data}, {/* sentinel */ } };
@@ -570,6 +575,9 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)device_set_wakeup_capable (dev, true); +if (pdata.flags &CI_HDRC_OUT_BAND_WAKEUP ) +device_set_out_band_wakeup (dev, true); +return 0 ; disable_device:
include/linux/usb/chipidea.h +1 -0
@@ -66,6 +66,7 @@ struct ci_hdrc_platform_data {#define CI_HDRC_HAS_PORTSC_PEC_MISSED BIT(17)#define CI_HDRC_FORCE_VBUS_ACTIVE_ALWAYS BIT(18)#define CI_HDRC_HAS_SHORT_PKT_LIMIT BIT(19) +#define CI_HDRC_OUT_BAND_WAKEUP BIT(20)enum usb_dr_mode dr_mode;#define CI_HDRC_CONTROLLER_RESET_EVENT 0#define CI_HDRC_CONTROLLER_STOPPED_EVENT 1
Signature · 1 line
2.37.1
PATCH v3 4/4 usb: dwc3: imx8mp: Set out of band wakeup for i.MX95
In reply to Peng Fani.MX95 DWC3 inside HSIOMIX could still wakeup Linux, even if HSIOMIX power domain(Digital logic) is off. There is still always on logic have the wakeup capability which is out band wakeup capbility.
So use device_set_out_band_wakeup for i.MX95 to make sure DWC3 could wakeup system even if HSIOMIX power domain is in off state.
--- drivers/usb/dwc3/dwc3-imx8mp.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/usb/dwc3/dwc3-imx8mp.c +4 -0
@@ -248,6 +248,10 @@ static int dwc3_imx8mp_probe(struct platform_device *pdev) }device_set_wakeup_capable (dev, true); + +if (device_is_compatible (dev,"fsl,imx95-dwc3" )) +device_set_out_band_wakeup (dev, true); +pm_runtime_put (dev);return 0 ;
Signature · 1 line
2.37.1
Re: [PATCH v3 1/4] pmdomain: core: Introduce device_set/get_out_band_wakeup()
In reply to Peng FanQuoted 9 lines · Peng Fan
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 <[email protected]>
Quoted 81 lines
--- drivers/pmdomain/core.c | 6 ++++-- include/linux/pm.h | 1 + include/linux/pm_wakeup.h | 17 +++++++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-)drivers/pmdomain/core.c +4
-2@@ -1549,7 +1549,8 @@ static int genpd_finish_suspend(struct device *dev,if (ret)return ret; -if (device_awake_path (dev) &&genpd_is_active_wakeup (genpd)) +if (device_awake_path (dev) &&genpd_is_active_wakeup (genpd) && + !device_get_out_band_wakeup (dev))return 0 ; if (genpd->dev_ops.stop && genpd->dev_ops.start &&@@ -1604,7 +1605,8 @@ static int genpd_finish_resume(struct device *dev,if (IS_ERR (genpd))return -EINVAL ; -if (device_awake_path (dev) &&genpd_is_active_wakeup (genpd)) +if (device_awake_path (dev) &&genpd_is_active_wakeup (genpd) && + !device_get_out_band_wakeup (dev))return resume_noirq (dev);genpd_lock (genpd);include/linux/pm.h +1
-0@@ -684,6 +684,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; bool strict_midlayer:1;#else bool should_wakeup:1;include/linux/pm_wakeup.h +17
-0@@ -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_register (struct device *dev,const char *name);@@ -162,6 +172,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) {}Signature · 2 lines
-- 2.37.1
Re: [PATCH v3 2/4] usb: chipidea: core: detach power domain for ci_hdrc platform device
In reply to Peng FanQuoted 16 lines · Peng Fan
From: Xu Yang <[email protected]>
When add a platform device by calling
ci_hdrc_add_device(), this device will reuse OF node of its parent device. If power-domains property is provided in the OF node, both two platform devices will be attached to the same power domain. This should be unnecessary and may bring other inconsistent behavior. For example, to support wakeup capability, these two platform device need different power domain state. The parent device need NOT power domain on for out-band interrupt, but theci_hdrcdevice need power domain on for in-band interrupt. The i.MX95 Soc support out-band wakeup interrupt, the user need to enable wakeup for the parent device, but if the user also enable wakeup forci_hdrcdevice, the power domain will keep at on state finally. To exclude such inconsistent behavior and simplify the power management, detach power domain forci_hdrcplatform device.
Quoted 1 line
Signed-off-by Xu Yang <[email protected]>
Quoted 29 lines
--- drivers/usb/chipidea/core.c | 3 +++ 1 file changed, 3 insertions(+)drivers/usb/chipidea/core.c +3
-0@@ -27,6 +27,7 @@#include <linux/kernel.h> #include <linux/slab.h> #include <linux/pm_runtime.h> +#include <linux/pm_domain.h> #include <linux/pinctrl/consumer.h> #include <linux/usb/ch9.h> #include <linux/usb/gadget.h> @@ -915,6 +916,8 @@ struct platform_device *ci_hdrc_add_device(struct device *dev,if (ret) goto err; +dev_pm_domain_detach (&pdev->dev, false); +return pdev; err:Signature · 2 lines
-- 2.37.1
Re: [PATCH v3 3/4] usb: chipidea: ci_hdrc_imx: Set out of band wakeup for i.MX95
In reply to Peng FanQuoted 8 lines · Peng Fan
i.MX95 USB2 inside HSIOMIX could still wakeup Linux, even if HSIOMIX power domain(Digital logic) is off. There is still always on logic have the wakeup capability which is out band wakeup capbility.
So use
device_set_out_band_wakeupfor i.MX95 to make sure usb2 could wakeup system even if HSIOMIX power domain is in off state.Signed-off-by Peng Fan <[email protected]>
Quoted 54 lines
--- drivers/usb/chipidea/ci_hdrc_imx.c | 8 ++++++++ include/linux/usb/chipidea.h | 1 + 2 files changed, 9 insertions(+)drivers/usb/chipidea/ci_hdrc_imx.c +8
-0@@ -79,6 +79,10 @@ static const struct ci_hdrc_imx_platform_flag imx8ulp_usb_data = { CI_HDRC_HAS_PORTSC_PEC_MISSED, }; +static const struct ci_hdrc_imx_platform_flag imx95_usb_data = { + .flags =CI_HDRC_SUPPORTS_RUNTIME_PM |CI_HDRC_OUT_BAND_WAKEUP , +}; +static const struct ci_hdrc_imx_platform_flag s32g_usb_data = { .flags =CI_HDRC_DISABLE_HOST_STREAMING , };@@ -94,6 +98,7 @@ static const struct of_device_id ci_hdrc_imx_dt_ids[] = { { .compatible = "fsl,imx7d-usb", .data = &imx7d_usb_data}, { .compatible = "fsl,imx7ulp-usb", .data = &imx7ulp_usb_data}, { .compatible = "fsl,imx8ulp-usb", .data = &imx8ulp_usb_data}, + { .compatible = "fsl,imx95-usb", .data = &imx95_usb_data}, { .compatible = "nxp,s32g2-usb", .data = &s32g_usb_data}, {/* sentinel */ } };@@ -570,6 +575,9 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)device_set_wakeup_capable (dev, true); +if (pdata.flags &CI_HDRC_OUT_BAND_WAKEUP ) +device_set_out_band_wakeup (dev, true); +return 0 ; disable_device:include/linux/usb/chipidea.h +1
-0@@ -66,6 +66,7 @@ struct ci_hdrc_platform_data {#define CI_HDRC_HAS_PORTSC_PEC_MISSED BIT(17)#define CI_HDRC_FORCE_VBUS_ACTIVE_ALWAYS BIT(18)#define CI_HDRC_HAS_SHORT_PKT_LIMIT BIT(19) +#define CI_HDRC_OUT_BAND_WAKEUP BIT(20)enum usb_dr_mode dr_mode;#define CI_HDRC_CONTROLLER_RESET_EVENT 0#define CI_HDRC_CONTROLLER_STOPPED_EVENT 1Signature · 2 lines
-- 2.37.1
Re: [PATCH v3 4/4] usb: dwc3: imx8mp: Set out of band wakeup for i.MX95
In reply to Peng FanQuoted 9 lines · Peng Fan
i.MX95 DWC3 inside HSIOMIX could still wakeup Linux, even if HSIOMIX power domain(Digital logic) is off. There is still always on logic have the wakeup capability which is out band wakeup capbility.
So use
device_set_out_band_wakeupfor i.MX95 to make sure DWC3 could wakeup system even if HSIOMIX power domain is in off state.Acked-by Thinh Nguyen <[email protected]>Signed-off-by Peng Fan <[email protected]>
Quoted 23 lines
--- drivers/usb/dwc3/dwc3-imx8mp.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/usb/dwc3/dwc3-imx8mp.c +4
-0@@ -248,6 +248,10 @@ static int dwc3_imx8mp_probe(struct platform_device *pdev) }device_set_wakeup_capable (dev, true); + +if (device_is_compatible (dev,"fsl,imx95-dwc3" )) +device_set_out_band_wakeup (dev, true); +pm_runtime_put (dev);return 0 ;Signature · 2 lines
-- 2.37.1
Quoted 2 lines · Peng Fan
This is pick up of [1] which does not have response in about 5 months.
Sorry, I have planned to have a look at this, but just never got to it.
Quoted 14 lines
This V2 patchset
- includes usb driverchanges(patch 2,3)to give people a full picture on how it is used.
- Rebased next-20250729 to resolve conflictsTo i.MX95, USB2 and USB3 are in HSIOMIX, but there is always on logic to make USB2 and USB3 has wakeup capability when HSIOMIX power domain is in off state. Otherwise the HSIOMIX will be kept on when USB2 and USB3 are configured to be wakeup source and Linux suspended. With this patchset, HSIOMIX could be powered off and Linux could still be woke up by USB hotplug event.
Patch 1 introduces device_set/get_out_band_wakeup
Patch 2 and 3 are drivers changes to usedevice_set_out_band_wakeup
Quoted 6 lines
[1]https://lore.kernel.org/linux-pm/[email protected]/
More old discussions:
https://lore.kernel.org/linux-pm/[email protected]/Signed-off-by Peng Fan <[email protected]>
Overall I think the series looks nice, but I will make some more thinking of this in the next few days and come back with some proper comments, at latest in the middle of next week.
Kind regards
Uffe
Quoted 31 lines
---
Changes in v3:
- Add a new patch from Xu Yang to detach power domain for ci hdrc
- Add A-b for patch 4
- Link to v2: https://lore.kernel.org/r/[email protected]---
Peng Fan (3):
pmdomain: core: Introduce device_set/get_out_band_wakeup()
usb: chipidea:ci_hdrc_imx: Set out of band wakeup for i.MX95
usb: dwc3: imx8mp: Set out of band wakeup for i.MX95Xu Yang (1):
usb: chipidea: core: detach power domain forci_hdrcplatform devicedrivers/pmdomain/core.c | 6 ++++-- drivers/usb/chipidea/ci_hdrc_imx.c | 8 ++++++++ drivers/usb/chipidea/core.c | 3 +++ drivers/usb/dwc3/dwc3-imx8mp.c | 4 ++++ include/linux/pm.h | 1 + include/linux/pm_wakeup.h | 17 +++++++++++++++++ include/linux/usb/chipidea.h | 1 + 7 files changed, 38 insertions(+), 2 deletions(-)---
base-commit:1b09efec32046a9c78cfecc46a26b1b139a3e8a8
change-id: 20250729-pm-243ff7097e44Best regards,
--
Peng Fan <[email protected]>
Hi Ulf
On Thu, Sep 11, 2025 at 04:45:31PM +0200, Ulf Hansson wrote:
[...]
Quoted 4 lines
Overall I think the series looks nice, but I will make some more thinking of this in the next few days and come back with some proper comments, at latest in the middle of next week.
Thanks a lot for the review! I'll stay tuned for your comments next week.
Thanks,
Peng
Re: [PATCH v3 1/4] pmdomain: core: Introduce device_set/get_out_band_wakeup()
In reply to Peng FanQuoted 3 lines · Peng Fan
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.
Don't we already have something like wake IRQs [1] for such purposes?
8<---------------------------------------------------------------------- That may involve turning on a special signal handling logic within the platform (such as an SoC) so that signals from a given line are routed in a different way during system sleep so as to trigger a system wakeup when needed ----------------------------------------------------------------------->8
Quoted 4 lines
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 explanation as to why wake IRQ is not solving this problem and you need to introduce these new APIs?
Quoted 77 lines
Signed-off-by Peng Fan <[email protected]>--- drivers/pmdomain/core.c | 6 ++++-- include/linux/pm.h | 1 + include/linux/pm_wakeup.h | 17 +++++++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-)drivers/pmdomain/core.c +4
-2@@ -1549,7 +1549,8 @@ static int genpd_finish_suspend(struct device *dev,if (ret)return ret; -if (device_awake_path (dev) &&genpd_is_active_wakeup (genpd)) +if (device_awake_path (dev) &&genpd_is_active_wakeup (genpd) && + !device_get_out_band_wakeup (dev))return 0 ; if (genpd->dev_ops.stop && genpd->dev_ops.start &&@@ -1604,7 +1605,8 @@ static int genpd_finish_resume(struct device *dev,if (IS_ERR (genpd))return -EINVAL ; -if (device_awake_path (dev) &&genpd_is_active_wakeup (genpd)) +if (device_awake_path (dev) &&genpd_is_active_wakeup (genpd) && + !device_get_out_band_wakeup (dev))return resume_noirq (dev);genpd_lock (genpd);include/linux/pm.h +1
-0@@ -684,6 +684,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; bool strict_midlayer:1;#else bool should_wakeup:1;include/linux/pm_wakeup.h +17
-0@@ -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_register (struct device *dev,const char *name);@@ -162,6 +172,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) {}
Signature · 3 lines
Best regards, Dhruva Gole Texas Instruments Incorporated
Re: [PATCH v3 1/4] pmdomain: core: Introduce device_set/get_out_band_wakeup()
In reply to Peng FanQuoted 8 lines · Peng Fan
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.
Thinking more into it, to me it seems like if the intent here is to only allow the device drivers to figure out whether they should be or not be executing the suspend/resume_noirqs then that can still be checked by wisely using the device set_wakeup APIs in the driver itself.
Not sure why this patch should be necessary for a
driver to execute the suspend_noirq or not. That decision can very well be taken inside the driver's suspend resume_noirq hooks based on wakeup capability and wake_enabled statuses.
Just a pseudo code:
```
driver_suspend_noirq () {
if (device_may_wakeup()) {
// do the sequence where the power domain might get turned off
// but like you say device can do some out band wakeup
return XXX;
}
// regular suspend sequence here... maybe inband wakeup config / clk
// disable etc...
}
```And something similar in resume_noirq?
Just need to make sure that the probe func does the device_set_wakeup_enable or capable stuff correctly as per your H/w and wakeup requirements...
Signature · 3 lines
Best regards, Dhruva Gole Texas Instruments Incorporated
Re: [PATCH v3 1/4] pmdomain: core: Introduce device_set/get_out_band_wakeup()
Hi Dhruva,
Quoted 15 lines · Dhruva Gole
Quoted 8 lines · Peng Fan
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.
Thinking more into it, to me it seems like if the intent here is to only allow the device drivers to figure out whether they should be or not be executing the suspend/resume_noirqs then that can still be checked by wisely using the device
set_wakeupAPIs in the driver itself.
Quoted 4 lines
Not sure why this patch should be necessary for a
driver to execute thesuspend_noirqor not. That decision can very well be taken inside the driver's suspendresume_noirqhooks based on wakeup capability andwake_enabledstatuses.
I should join today's SCMI meeting, but something else caught me (:
Thanks for looking into this.
In genpd_suspend_finish, genpd_sync_power_off will be called if "(device_awake_path(dev) && genpd_is_active_wakeup(genpd))" is false. So if the device is enabled wakeup, the genpd will not be turned off because the check return true.
But to i.MX, if the device is configured as wakeup source, we still need to power off the power domain, because the device has out-of-band wakeup logic.
This patch is to make sure the power domain could be powered off in suspend flow and powered up in resume flow.
Thanks,
Peng
Quoted 25 lines
Just a pseudo code:
``` driver_suspend_noirq () { if (device_may_wakeup()) { // do the sequence where the power domain might get turned off // but like you say device can do some out band wakeup return XXX; } // regular suspend sequence here... maybe inband wakeup config / clk // disable etc... } ```And something similar in
resume_noirq?Just need to make sure that the probe func does the
device_set_wakeup_enableor capable stuff correctly as per your H/w and wakeup requirements...Signature · 3 lines
Best regards, Dhruva Gole Texas Instruments Incorporated
Re: [PATCH v3 1/4] pmdomain: core: Introduce device_set/get_out_band_wakeup()
Hi Peng,
Quoted 18 lines · Peng Fan
Hi Dhruva,
Quoted 15 lines · Dhruva Gole
Quoted 8 lines · Peng Fan
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.
Thinking more into it, to me it seems like if the intent here is to only allow the device drivers to figure out whether they should be or not be executing the suspend/resume_noirqs then that can still be checked by wisely using the device
set_wakeupAPIs in the driver itself.
Quoted 6 lines
Quoted 4 lines
Not sure why this patch should be necessary for a
driver to execute thesuspend_noirqor not. That decision can very well be taken inside the driver's suspendresume_noirqhooks based on wakeup capability andwake_enabledstatuses.I should join today's SCMI meeting, but something else caught me (:
It's alright, maybe see you in the next one ;)
Quoted 7 lines
Thanks for looking into this.
In
genpd_suspend_finish,genpd_sync_power_offwill be called if "(device_awake_path(dev)&&genpd_is_active_wakeup(genpd))" is false. So if the device is enabled wakeup, the genpd will not be turned off because the check return true.
Umm I think this device_awake_path stuff is only going to be true when someone calls device_set_wakeup_path, I don't think it is going to return true for a wakeup_capable device. I know all these "wakeup" terminology and APIs have become all too confusing :( , so maybe Ulf can correct me.
I maybe misremembering, but I have seen in some cases where a driver may have marked itself wakeup_capable but the suspend hooks still do get called... So your concern about genpd_sync_power_off not being called due to wakeup capable device driver may not be valid... Again please feel to correct me if I am wrong.
Did you also look at the wake IRQ stuff I mentioned?
In the path you're talking about it just checks device_awake_path(dev) && genpd_is_active_wakeup(genpd) However if the device irq is just marked as a wake IRQ, I don't think that is checked anywhere in this path. So definitely if the IRQ of your device is set as a wake IRQ, it will still get suspended and resumed as usual and that's what you want right?
Quoted 35 lines
But to i.MX, if the device is configured as wakeup source, we still need to power off the power domain, because the device has out-of-band wakeup logic.
This patch is to make sure the power domain could be powered off in suspend flow and powered up in resume flow.
Thanks,
PengQuoted 25 lines
Just a pseudo code:
``` driver_suspend_noirq () { if (device_may_wakeup()) { // do the sequence where the power domain might get turned off // but like you say device can do some out band wakeup return XXX; } // regular suspend sequence here... maybe inband wakeup config / clk // disable etc... } ```And something similar in
resume_noirq?Just need to make sure that the probe func does the
device_set_wakeup_enableor capable stuff correctly as per your H/w and wakeup requirements...Signature · 3 lines
Best regards, Dhruva Gole Texas Instruments Incorporated
Signature · 3 lines
Best regards, Dhruva Gole Texas Instruments Incorporated
Re: [PATCH v3 1/4] pmdomain: core: Introduce device_set/get_out_band_wakeup()
Quoted 39 lines · Dhruva Gole
Hi Peng,
Quoted 18 lines · Peng Fan
Hi Dhruva,
Quoted 15 lines · Dhruva Gole
Quoted 8 lines · Peng Fan
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.
Thinking more into it, to me it seems like if the intent here is to only allow the device drivers to figure out whether they should be or not be executing the suspend/resume_noirqs then that can still be checked by wisely using the device
set_wakeupAPIs in the driver itself.Quoted 6 lines
Quoted 4 lines
Not sure why this patch should be necessary for a
driver to execute thesuspend_noirqor not. That decision can very well be taken inside the driver's suspendresume_noirqhooks based on wakeup capability andwake_enabledstatuses.I should join today's SCMI meeting, but something else caught me (:
It's alright, maybe see you in the next one ;)
Quoted 7 lines
Thanks for looking into this.
In
genpd_suspend_finish,genpd_sync_power_offwill be called if "(device_awake_path(dev)&&genpd_is_active_wakeup(genpd))" is false. So if the device is enabled wakeup, the genpd will not be turned off because the check return true.
Quoted 5 lines
Umm I think this
device_awake_pathstuff is only going to be true when someone callsdevice_set_wakeup_path, I don't think it is going to return true for awakeup_capabledevice. I know all these "wakeup" terminology and APIs have become all too confusing :( , so maybe Ulf can correct me.
The PM core checks device_may_wakeup() in device_suspend() and then sets dev->power.wakeup_path = true;
The device_set_awake_path() and device_awake_path(), is to allow drivers/subsystems to enforce its device to stay powered-on during system-wide suspend. This may be needed even if the device isn't configured to deliver system-wakeups.
Quoted 5 lines
I maybe misremembering, but I have seen in some cases where a driver may have marked itself
wakeup_capablebut the suspend hooks still do get called... So your concern aboutgenpd_sync_power_offnot being called due to wakeup capable device driver may not be valid... Again please feel to correct me if I am wrong.
The system PM callbacks should get called no matter what.
The problem Peng pointing out, is when genpd_suspend_noirq() (which calls genpd_finish_suspend()) is called for a device that is attached to a genpd, we may end up bailing out, preventing the power-off for its PM domain, while it may be perfectly fine to allow the PM domain to be powered-off.
The particular code we are looking at, is in genpd_finish_suspend():
if (device_awake_path(dev) && genpd_is_active_wakeup(genpd))
return 0;Quoted 8 lines
Did you also look at the wake IRQ stuff I mentioned?
In the path you're talking about it just checksdevice_awake_path(dev)&&genpd_is_active_wakeup(genpd)However if the device irq is just marked as a wake IRQ, I don't think that is checked anywhere in this path. So definitely if the IRQ of your device is set as a wake IRQ, it will still get suspended and resumed as usual and that's what you want right?
The missing piece for the wake_irq, is to know whether the interrupt can be delivered via an out-band-powered-on-logic, thus without requiring the device to stay powered-on during system suspend.
[...]
Kind regards
Uffe
Re: [PATCH v3 1/4] pmdomain: core: Introduce device_set/get_out_band_wakeup()
In reply to Peng FanQuoted 8 lines · Peng Fan
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.
Would you mind trying to extend/clarify this commit-msg a bit more, to make the benefit more clear.
For example, today we may be wasting energy, by unnecessarily keeping PM domains powered-on during system-wide suspend, when a device has been enabled for system-wakeup...
In regards to terminology, I would appreciate if we could use "system-wakeup" and "out-band system-wakeup logic" and "system-wide suspend".
Quoted 6 lines
Signed-off-by Peng Fan <[email protected]>--- drivers/pmdomain/core.c | 6 ++++-- include/linux/pm.h | 1 + include/linux/pm_wakeup.h | 17 +++++++++++++++++
Please split this into two separate patches.
Quoted 43 lines
3 files changed, 22 insertions(+), 2 deletions(-)drivers/pmdomain/core.c +4
-2@@ -1549,7 +1549,8 @@ static int genpd_finish_suspend(struct device *dev,if (ret)return ret; -if (device_awake_path (dev) &&genpd_is_active_wakeup (genpd)) +if (device_awake_path (dev) &&genpd_is_active_wakeup (genpd) && + !device_get_out_band_wakeup (dev))return 0 ; if (genpd->dev_ops.stop && genpd->dev_ops.start &&@@ -1604,7 +1605,8 @@ static int genpd_finish_resume(struct device *dev,if (IS_ERR (genpd))return -EINVAL ; -if (device_awake_path (dev) &&genpd_is_active_wakeup (genpd)) +if (device_awake_path (dev) &&genpd_is_active_wakeup (genpd) && + !device_get_out_band_wakeup (dev))return resume_noirq (dev);genpd_lock (genpd);include/linux/pm.h +1
-0@@ -684,6 +684,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; bool strict_midlayer:1;#else bool should_wakeup:1;include/linux/pm_wakeup.h +0
-0
include/linux/pm_wakeup.h static inline void device_set_wakeup_path(struct device *dev) · line 99
Quoted 6 lines
include/linux/pm_wakeup.h +3
-0@@ -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;
I suggest we drop the bool as in-parameter and just do:dev->power.out_band_wakeup = true;
Moreover, I think we should clear the flag in device_prepare(), next to where dev->power.wakeup_path is cleared.
This makes the behavior better aligned for users of these flags.
include/linux/pm_wakeup.h static inline void device_set_wakeup_path(struct device *dev) · line 102
Quoted 3 lines
include/linux/pm_wakeup.h +3
-0+} + +static inline bool device_get_out_band_wakeup (struct device *dev)
Nitpick: I would rename this into device_out_band_wakeup(). At least the "get" part is a confusing in my opinion, as indicates there is reference taken too.
Quoted 23 lines
include/linux/pm_wakeup.h +11
-1+{ +return dev->power.out_band_wakeup; +} +/* drivers/base/power/wakeup.c */ extern struct wakeup_source *wakeup_source_register (struct device *dev,const char *name);@@ -162,6 +172,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) {} --
Quoted 2 lines
2.37.1
Otherwise, from an overall functionality point of view, this makes sense to me!
Kind regards
Uffe
Re: [PATCH v3 2/4] usb: chipidea: core: detach power domain for ci_hdrc platform device
In reply to Peng FanQuoted 17 lines · Peng Fan
From: Xu Yang <[email protected]>
When add a platform device by calling
ci_hdrc_add_device(), this device will reuse OF node of its parent device. If power-domains property is provided in the OF node, both two platform devices will be attached to the same power domain. This should be unnecessary and may bring other inconsistent behavior. For example, to support wakeup capability, these two platform device need different power domain state. The parent device need NOT power domain on for out-band interrupt, but theci_hdrcdevice need power domain on for in-band interrupt. The i.MX95 Soc support out-band wakeup interrupt, the user need to enable wakeup for the parent device, but if the user also enable wakeup forci_hdrcdevice, the power domain will keep at on state finally. To exclude such inconsistent behavior and simplify the power management, detach power domain forci_hdrcplatform device.
Quoted 1 line
Signed-off-by Xu Yang <[email protected]>
Seems reasonable to me!
Kind regards
Uffe
Quoted 29 lines
--- drivers/usb/chipidea/core.c | 3 +++ 1 file changed, 3 insertions(+)drivers/usb/chipidea/core.c +3
-1@@ -27,6 +27,7 @@#include <linux/kernel.h> #include <linux/slab.h> #include <linux/pm_runtime.h> +#include <linux/pm_domain.h> #include <linux/pinctrl/consumer.h> #include <linux/usb/ch9.h> #include <linux/usb/gadget.h> @@ -915,6 +916,8 @@ struct platform_device *ci_hdrc_add_device(struct device *dev,if (ret) goto err; +dev_pm_domain_detach (&pdev->dev, false); +return pdev; err: --2.37.1
Re: [PATCH v3 3/4] usb: chipidea: ci_hdrc_imx: Set out of band wakeup for i.MX95
In reply to Peng FanQuoted 38 lines · Peng Fan
i.MX95 USB2 inside HSIOMIX could still wakeup Linux, even if HSIOMIX power domain(Digital logic) is off. There is still always on logic have the wakeup capability which is out band wakeup capbility.
So use
device_set_out_band_wakeupfor i.MX95 to make sure usb2 could wakeup system even if HSIOMIX power domain is in off state.Signed-off-by Peng Fan <[email protected]>--- drivers/usb/chipidea/ci_hdrc_imx.c | 8 ++++++++ include/linux/usb/chipidea.h | 1 + 2 files changed, 9 insertions(+)drivers/usb/chipidea/ci_hdrc_imx.c +5
-0@@ -79,6 +79,10 @@ static const struct ci_hdrc_imx_platform_flag imx8ulp_usb_data = { CI_HDRC_HAS_PORTSC_PEC_MISSED, }; +static const struct ci_hdrc_imx_platform_flag imx95_usb_data = { + .flags =CI_HDRC_SUPPORTS_RUNTIME_PM |CI_HDRC_OUT_BAND_WAKEUP , +}; +static const struct ci_hdrc_imx_platform_flag s32g_usb_data = { .flags =CI_HDRC_DISABLE_HOST_STREAMING , };@@ -94,6 +98,7 @@ static const struct of_device_id ci_hdrc_imx_dt_ids[] = { { .compatible = "fsl,imx7d-usb", .data = &imx7d_usb_data}, { .compatible = "fsl,imx7ulp-usb", .data = &imx7ulp_usb_data}, { .compatible = "fsl,imx8ulp-usb", .data = &imx8ulp_usb_data}, + { .compatible = "fsl,imx95-usb", .data = &imx95_usb_data}, { .compatible = "nxp,s32g2-usb", .data = &s32g_usb_data}, {/* sentinel */ } };
drivers/usb/chipidea/ci_hdrc_imx.c static int ci_hdrc_imx_probe(struct platform_device *pdev) · line 580
Quoted 6 lines
drivers/usb/chipidea/ci_hdrc_imx.c +3
-0@@ -570,6 +575,9 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)device_set_wakeup_capable (dev, true); +if (pdata.flags &CI_HDRC_OUT_BAND_WAKEUP ) +device_set_out_band_wakeup (dev, true); +
Based on my comment in patch1, I think we should set this flag from within a system suspend callback for the device in question.
[...]
Kind regards
Uffe
Re: [PATCH v3 4/4] usb: dwc3: imx8mp: Set out of band wakeup for i.MX95
In reply to Peng FanQuoted 19 lines · Peng Fan
i.MX95 DWC3 inside HSIOMIX could still wakeup Linux, even if HSIOMIX power domain(Digital logic) is off. There is still always on logic have the wakeup capability which is out band wakeup capbility.
So use
device_set_out_band_wakeupfor i.MX95 to make sure DWC3 could wakeup system even if HSIOMIX power domain is in off state.Acked-by Thinh Nguyen <[email protected]>Signed-off-by Peng Fan <[email protected]>--- drivers/usb/dwc3/dwc3-imx8mp.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/usb/dwc3/dwc3-imx8mp.c +0
-0
drivers/usb/dwc3/dwc3-imx8mp.c static int dwc3_imx8mp_probe(struct platform_device *pdev) · line 254
Quoted 7 lines
drivers/usb/dwc3/dwc3-imx8mp.c +4
-0@@ -248,6 +248,10 @@ static int dwc3_imx8mp_probe(struct platform_device *pdev) }device_set_wakeup_capable (dev, true); + +if (device_is_compatible (dev,"fsl,imx95-dwc3" )) +device_set_out_band_wakeup (dev, true); +
Similar comment as for patch3, please set this from system suspend callback instead.
Quoted 7 lines
drivers/usb/dwc3/dwc3-imx8mp.c +0
-1pm_runtime_put (dev);return 0 ; --2.37.1
Kind regards
Uffe