pmdomain: core: Introduce device_set/get_out_band_wakeup
Subsystems (9)
v2 cover pmdomain: core: Introduce device_set/get_out_band_wakeup
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]/
---
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
drivers/pmdomain/core.c | 6 ++++-- drivers/usb/chipidea/ci_hdrc_imx.c | 8 ++++++++ drivers/usb/dwc3/dwc3-imx8mp.c | 4 ++++ include/linux/pm.h | 1 + include/linux/pm_wakeup.h | 17 +++++++++++++++++ include/linux/usb/chipidea.h | 1 + 6 files changed, 35 insertions(+), 2 deletions(-)
---
base-commit: 54efec8782214652b331c50646013f8526570e8d
change-id: 20250729-pm-243ff7097e44
Best regards,
Signature · 1 line
Peng Fan <[email protected]>
PATCH v2 1/3 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
Re: [PATCH v2 1/3] pmdomain: core: Introduce device_set/get_out_band_wakeup()
Hi Ulf,
Quoted 7 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 please give a look on this patch? Is it the right way to resolve the issue or any suggestions?
Thanks,
Peng
PATCH v2 2/3 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 */ } };
@@ -569,6 +574,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
Re: [PATCH v2 2/3] usb: chipidea: ci_hdrc_imx: Set out of band wakeup for i.MX95
Hi Peng,
Quoted 37 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 579
Quoted 6 lines
drivers/usb/chipidea/ci_hdrc_imx.c +3
-0@@ -569,6 +574,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); +
In current design, ci_hdrc_imx_probe() will create another platform device B which will be a child of current device A. Furthermore, device A and device B will attached to a same power domain. In this case, some conflict setting may happen. For example, if the user wants to enable wakeup for this USB port, they may echo "enabled" to wakeup file for both device A and device B as before. As a result, device A is out band wakeup so it doesn't depend on power domain on, but device B has also enabled wakeup so the power domain will keep on finally. Actually, the power domain needs to be off for imx95.
So I think only letting the parent device A itself attach to power domain should be enough. If it's the right way, then below change needs to be included to avoid potential misbehavior.
drivers/usb/chipidea/core.c +2 -0
@@ -915,6 +915,8 @@ struct platform_device *ci_hdrc_add_device(struct device *dev,if (ret) goto err; +dev_pm_domain_detach (&pdev->dev, false); +return pdev;
Thanks,
Xu Yang
Quoted 19 lines
drivers/usb/chipidea/ci_hdrc_imx.c +0
-0return 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 v2 2/3] usb: chipidea: ci_hdrc_imx: Set out of band wakeup for i.MX95
Quoted 57 lines · Xu Yang
Hi Peng,
Quoted 37 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 579
Quoted 6 lines
drivers/usb/chipidea/ci_hdrc_imx.c +3
-0@@ -569,6 +574,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); +In current design,
ci_hdrc_imx_probe()will create another platform device B which will be a child of current device A. Furthermore, device A and device B will attached to a same power domain. In this case, some conflict setting may happen. For example, if the user wants to enable wakeup for this USB port, they may echo "enabled" to wakeup file for both device A and device B as before. As a result, device A is out band wakeup so it doesn't depend on power domain on, but device B has also enabled wakeup so the power domain will keep on finally. Actually, the power domain needs to be off for imx95.
Quoted 3 lines
So I think only letting the parent device A itself attach to power domain should be enough. If it's the right way, then below change needs to be included to avoid potential misbehavior.
Thanks for looking into this.
Just detaching the power domain may break others. I think the better one should be:
if (device_get_out_band_wakeup(dev))
device_set_out_band_wakeup(&pdev->dev);
Regards,
Peng
drivers/usb/chipidea/core.c struct platform_device *ci_hdrc_add_device(struct device *dev, · line 918
Quoted 10 lines
drivers/usb/chipidea/core.c +1
-0@@ -915,6 +915,8 @@ struct platform_device *ci_hdrc_add_device(struct device *dev,if (ret) goto err; +dev_pm_domain_detach (&pdev->dev, false);
I think the
Quoted 25 lines
drivers/usb/chipidea/core.c +1
-0+return pdev; Thanks,Xu Yang
Quoted 19 lines
drivers/usb/chipidea/ci_hdrc_imx.c +0
-0return 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 v2 2/3] usb: chipidea: ci_hdrc_imx: Set out of band wakeup for i.MX95
Quoted 62 lines · Peng Fan
Quoted 57 lines · Xu Yang
Hi Peng,
Quoted 37 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 579
Quoted 6 lines
drivers/usb/chipidea/ci_hdrc_imx.c +3
-0@@ -569,6 +574,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); +In current design,
ci_hdrc_imx_probe()will create another platform device B which will be a child of current device A. Furthermore, device A and device B will attached to a same power domain. In this case, some conflict setting may happen. For example, if the user wants to enable wakeup for this USB port, they may echo "enabled" to wakeup file for both device A and device B as before. As a result, device A is out band wakeup so it doesn't depend on power domain on, but device B has also enabled wakeup so the power domain will keep on finally. Actually, the power domain needs to be off for imx95.Quoted 3 lines
So I think only letting the parent device A itself attach to power domain should be enough. If it's the right way, then below change needs to be included to avoid potential misbehavior.
Quoted 6 lines
Thanks for looking into this.
Just detaching the power domain may break others. I think the better one should be:if (
device_get_out_band_wakeup(dev))device_set_out_band_wakeup(&pdev->dev);
I don't prefer such way. Firstly, The irq of pdev->dev is totally a in-band interrupt. This will mislead the users. Secondly, it won't take effect if call device_set_out_band_wakeup() in ci_hdrc_add_device() because the dev hasn't set out-band wakeup yet.
Thanks,
Xu Yang
Quoted 41 lines
Regards,
Pengdrivers/usb/chipidea/core.c struct platform_device *ci_hdrc_add_device(struct device *dev, · line 918
Quoted 10 lines
drivers/usb/chipidea/core.c +1
-0@@ -915,6 +915,8 @@ struct platform_device *ci_hdrc_add_device(struct device *dev,if (ret) goto err; +dev_pm_domain_detach (&pdev->dev, false);I think the
Quoted 25 lines
drivers/usb/chipidea/core.c +1
-0+return pdev; Thanks,Xu Yang
Quoted 19 lines
drivers/usb/chipidea/ci_hdrc_imx.c +0
-0return 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
PATCH v2 3/3 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 v2 3/3] usb: dwc3: imx8mp: Set out of band wakeup for i.MX95
Quoted 31 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.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 +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
BR,
Thinh