soc: qcom: smp2p: Add wakeup capability to SMP2P IRQ
Subsystems (2)
PATCH v2 1/1 soc: qcom: smp2p: Add wakeup capability to SMP2P IRQ
Remote susbsystems notify fatal crash throught smp2p interrupt. When modem/wifi crashes it can cause soc to come out of low power state and may not allow again to enter in low power state until crash is handled.
Mark smp2p interrupt wakeup capable so that interrupt handler is executed and remote susbsystem crash can be handled in system resume path.
--- drivers/soc/qcom/smp2p.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/soc/qcom/smp2p.c +12 -0
@@ -18,6 +18,7 @@#include <linux/soc/qcom/smem.h> #include <linux/soc/qcom/smem_state.h> #include <linux/spinlock.h> +#include <linux/pm_wakeirq.h> /* * The Shared Memory Point to Point (SMP2P) protocol facilitates communication
@@ -538,9 +539,20 @@ static int qcom_smp2p_probe(struct platform_device *pdev) goto unwind_interfaces; } +/* Setup smp2p interrupt as wakeup source */ + ret =device_init_wakeup (&pdev->dev, true); +if (ret) + goto unwind_interfaces; + + ret =dev_pm_set_wake_irq (&pdev->dev, irq); +if (ret) + goto set_wakeup_failed;return 0 ; +set_wakeup_failed: +device_init_wakeup (&pdev->dev, false); + unwind_interfaces:list_for_each_entry (entry, &smp2p->inbound, node)irq_domain_remove (entry->domain);
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Quoted 32 lines · Deepak Kumar Singh
Remote susbsystems notify fatal crash throught smp2p interrupt. When modem/wifi crashes it can cause soc to come out of low power state and may not allow again to enter in low power state until crash is handled.
Mark smp2p interrupt wakeup capable so that interrupt handler is executed and remote susbsystem crash can be handled in system resume path.
Signed-off-by Deepak Kumar Singh <[email protected]>--- drivers/soc/qcom/smp2p.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)drivers/soc/qcom/smp2p.c +5
-0@@ -18,6 +18,7 @@#include <linux/soc/qcom/smem.h> #include <linux/soc/qcom/smem_state.h> #include <linux/spinlock.h> +#include <linux/pm_wakeirq.h> /* * The Shared Memory Point to Point (SMP2P) protocol facilitates communication @@ -538,9 +539,20 @@ static int qcom_smp2p_probe(struct platform_device *pdev) goto unwind_interfaces; } +/* Setup smp2p interrupt as wakeup source */ + ret =device_init_wakeup (&pdev->dev, true); +if (ret) + goto unwind_interfaces;
drivers/soc/qcom/smp2p.c static int qcom_smp2p_probe(struct platform_device *pdev) · line 555
Quoted 10 lines
drivers/soc/qcom/smp2p.c +7
-0+ + ret =dev_pm_set_wake_irq (&pdev->dev, irq); +if (ret) + goto set_wakeup_failed;return 0 ; +set_wakeup_failed: +device_init_wakeup (&pdev->dev, false); +
I think you need to call dev_pm_clear_wake_irq() and device_init_wakeup(..., false) in qcom_smp2p_remove() to free all resources.
Quoting Deepak Kumar Singh (2021-08-16 03:05:35)
Quoted 17 lines
Remote susbsystems notify fatal crash throught smp2p interrupt. When modem/wifi crashes it can cause soc to come out of low power state and may not allow again to enter in low power state until crash is handled.
Mark smp2p interrupt wakeup capable so that interrupt handler is executed and remote susbsystem crash can be handled in system resume path.
Signed-off-by Deepak Kumar Singh <[email protected]>--- drivers/soc/qcom/smp2p.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)drivers/soc/qcom/smp2p.c +0
-0
drivers/soc/qcom/smp2p.c line 21
Quoted 4 lines
drivers/soc/qcom/smp2p.c +1
-0@@ -18,6 +18,7 @@#include <linux/soc/qcom/smem.h> #include <linux/soc/qcom/smem_state.h> #include <linux/spinlock.h> +#include <linux/pm_wakeirq.h>
Please sort alphabetically by include name, 'p' before 's'.
drivers/soc/qcom/smp2p.c static int qcom_smp2p_probe(struct platform_device *pdev) · line 542
Quoted 8 lines
drivers/soc/qcom/smp2p.c +1
-0/* * The Shared Memory Point to Point (SMP2P) protocol facilitates communication @@ -538,9 +539,20 @@ static int qcom_smp2p_probe(struct platform_device *pdev) goto unwind_interfaces; } +/* Setup smp2p interrupt as wakeup source */
This comment is bad. Please don't reiterate what the code is doing. Instead, write something like
/*
* Treat remoteproc crashes as wakeups by default so we handle
* them sooner rather than along with the next wakeup (e.g.
* power button). This avoids leaving the system in a shallower
* suspend power state if a remoteproc crashes during suspend,
* but requires userspace to actively suspend the device after
* handling the crash, or CONFIG_PM_AUTOSLEEP to be true. */
drivers/soc/qcom/smp2p.c static int qcom_smp2p_probe(struct platform_device *pdev) · line 543
Quoted 1 line
drivers/soc/qcom/smp2p.c +1
-0+ ret =device_init_wakeup (&pdev->dev, true);
I still wonder if it's better to leave this off by default and only enable it if the kernel is using autosuspend (PM_AUTOSLEEP). Then userspace is responsible to decide if it can handle the wakeup with the screen off, reload the remoteproc, and go back to suspend if it isn't using autosuspend.
Quoted 3 lines
drivers/soc/qcom/smp2p.c +3
-0+if (ret) + goto unwind_interfaces; +
Quoted 43 lines · Stephen Boyd
Quoting Deepak Kumar Singh (2021-08-16 03:05:35)
Quoted 17 lines
Remote susbsystems notify fatal crash throught smp2p interrupt. When modem/wifi crashes it can cause soc to come out of low power state and may not allow again to enter in low power state until crash is handled.
Mark smp2p interrupt wakeup capable so that interrupt handler is executed and remote susbsystem crash can be handled in system resume path.
Signed-off-by Deepak Kumar Singh <[email protected]>--- drivers/soc/qcom/smp2p.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)drivers/soc/qcom/smp2p.c +0
-0drivers/soc/qcom/smp2p.c line 21
Quoted 4 lines
drivers/soc/qcom/smp2p.c +1
-0@@ -18,6 +18,7 @@#include <linux/soc/qcom/smem.h> #include <linux/soc/qcom/smem_state.h> #include <linux/spinlock.h> +#include <linux/pm_wakeirq.h> Please sort alphabetically by include name, 'p' before 's'.
drivers/soc/qcom/smp2p.c static int qcom_smp2p_probe(struct platform_device *pdev) · line 542
Quoted 7 lines
drivers/soc/qcom/smp2p.c +1
-0/* * The Shared Memory Point to Point (SMP2P) protocol facilitates communication @@ -538,9 +539,20 @@ static int qcom_smp2p_probe(struct platform_device *pdev) goto unwind_interfaces; } +/* Setup smp2p interrupt as wakeup source */ This comment is bad. Please don't reiterate what the code is doing. Instead, write something like
/*
* Treat remoteproc crashes as wakeups by default so we handle
* them sooner rather than along with the next wakeup (e.g.
* power button). This avoids leaving the system in a shallower
* suspend power state if a remoteproc crashes during suspend,
* but requires userspace to actively suspend the device after
* handling the crash, orCONFIG_PM_AUTOSLEEPto be true. */
Quoted 6 lines
drivers/soc/qcom/smp2p.c static int qcom_smp2p_probe(struct platform_device *pdev) · line 543
Quoted 1 line
drivers/soc/qcom/smp2p.c +1
-0+ ret =device_init_wakeup (&pdev->dev, true);I still wonder if it's better to leave this off by default and only enable it if the kernel is using autosuspend (
PM_AUTOSLEEP). Then userspace is responsible to decide if it can handle the wakeup with the screen off, reload the remoteproc, and go back to suspend if it isn't using autosuspend.
Seems like not all targets use PM_AUTOSLEEP feature, even those targets may require wakeup to handle
modem crash so that important modem events are not missed. I think we can keep wake up as default behavior
and let the user space disable it through sysfs if it doesn't want it as wake up source.
Quoted 3 lines
Quoted 3 lines
drivers/soc/qcom/smp2p.c +3
-0+if (ret) + goto unwind_interfaces; +
Quoting Deepak Kumar Singh (2021-09-13 10:45:19)
Quoted 9 lines · Stephen Boyd
Quoted 6 lines
Quoted 1 line
+ ret =
device_init_wakeup(&pdev->dev, true);I still wonder if it's better to leave this off by default and only enable it if the kernel is using autosuspend (
PM_AUTOSLEEP). Then userspace is responsible to decide if it can handle the wakeup with the screen off, reload the remoteproc, and go back to suspend if it isn't using autosuspend.
Quoted 8 lines
Seems like not all targets use
PM_AUTOSLEEPfeature, even those targets may require wakeup to handlemodem crash so that important modem events are not missed. I think we can keep wake up as default behavior
and let the user space disable it through sysfs if it doesn't want it as wake up source.
I don't understand. What if userspace is simple and doesn't use autosleep and will turn the screen on when the kernel resumes? Why do we expect the modem crashing and causing the screen to turn on to be a good user experience?