linux-remoteproc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V4 1/1] soc: qcom: smp2p: Add wakeup capability to SMP2P IRQ
@ 2021-09-18 19:02 Deepak Kumar Singh
  2021-09-20 18:37 ` Stephen Boyd
  0 siblings, 1 reply; 3+ messages in thread
From: Deepak Kumar Singh @ 2021-09-18 19:02 UTC (permalink / raw)
  To: bjorn.andersson, swboyd, clew, sibis
  Cc: linux-kernel, linux-arm-msm, linux-remoteproc,
	Deepak Kumar Singh, Andy Gross

Remote susbsystems notify fatal crash throught smp2p interrupt.
When remoteproc 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 remoteproc crash can be handled in system  resume path.
This patch marks interrupt wakeup capable but keeps wakeup disabled
by default. User space can enable it based on its requirement for
wakeup from suspend.

Signed-off-by: Deepak Kumar Singh <deesin@codeaurora.org>
---
 drivers/soc/qcom/smp2p.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/drivers/soc/qcom/smp2p.c b/drivers/soc/qcom/smp2p.c
index 2df4883..60ad632 100644
--- a/drivers/soc/qcom/smp2p.c
+++ b/drivers/soc/qcom/smp2p.c
@@ -14,6 +14,7 @@
 #include <linux/mfd/syscon.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/pm_wakeirq.h>
 #include <linux/regmap.h>
 #include <linux/soc/qcom/smem.h>
 #include <linux/soc/qcom/smem_state.h>
@@ -538,9 +539,26 @@ static int qcom_smp2p_probe(struct platform_device *pdev)
 		goto unwind_interfaces;
 	}
 
+	/*
+	 * Treat smp2p interrupt as wakeup source, but keep it disabled
+	 * by default. User space can decide enabling it depending on its
+	 * use cases. For example if remoteproc crashes and device wants
+	 * to handle it immediatedly (e.g. to not miss phone calls) it can
+	 * enable wakeup source from user space, while other devices which
+	 * do not have proper autosleep feature may want to handle it with
+	 * other wakeup events (e.g. Power button) instead waking up immediately.
+	 */
+	device_set_wakeup_capable(&pdev->dev, true);
+
+	ret = dev_pm_set_wake_irq(&pdev->dev, irq);
+	if (ret)
+		goto set_wake_irq_fail;
 
 	return 0;
 
+set_wake_irq_fail:
+	dev_pm_clear_wake_irq(&pdev->dev);
+
 unwind_interfaces:
 	list_for_each_entry(entry, &smp2p->inbound, node)
 		irq_domain_remove(entry->domain);
@@ -565,6 +583,9 @@ static int qcom_smp2p_remove(struct platform_device *pdev)
 	struct qcom_smp2p *smp2p = platform_get_drvdata(pdev);
 	struct smp2p_entry *entry;
 
+	dev_pm_clear_wake_irq(&pdev->dev);
+	device_init_wakeup(&pdev->dev, false);
+
 	list_for_each_entry(entry, &smp2p->inbound, node)
 		irq_domain_remove(entry->domain);
 
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


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

* Re: [PATCH V4 1/1] soc: qcom: smp2p: Add wakeup capability to SMP2P IRQ
  2021-09-18 19:02 [PATCH V4 1/1] soc: qcom: smp2p: Add wakeup capability to SMP2P IRQ Deepak Kumar Singh
@ 2021-09-20 18:37 ` Stephen Boyd
  2021-09-21 10:28   ` Deepak Kumar Singh
  0 siblings, 1 reply; 3+ messages in thread
From: Stephen Boyd @ 2021-09-20 18:37 UTC (permalink / raw)
  To: Deepak Kumar Singh, bjorn.andersson, clew, sibis
  Cc: linux-kernel, linux-arm-msm, linux-remoteproc, Andy Gross

Quoting Deepak Kumar Singh (2021-09-18 12:02:15)
> diff --git a/drivers/soc/qcom/smp2p.c b/drivers/soc/qcom/smp2p.c
> index 2df4883..60ad632 100644
> --- a/drivers/soc/qcom/smp2p.c
> +++ b/drivers/soc/qcom/smp2p.c
> @@ -14,6 +14,7 @@
>  #include <linux/mfd/syscon.h>
>  #include <linux/module.h>
>  #include <linux/platform_device.h>
> +#include <linux/pm_wakeirq.h>
>  #include <linux/regmap.h>
>  #include <linux/soc/qcom/smem.h>
>  #include <linux/soc/qcom/smem_state.h>
> @@ -538,9 +539,26 @@ static int qcom_smp2p_probe(struct platform_device *pdev)
>                 goto unwind_interfaces;
>         }
>
> +       /*
> +        * Treat smp2p interrupt as wakeup source, but keep it disabled
> +        * by default. User space can decide enabling it depending on its
> +        * use cases. For example if remoteproc crashes and device wants
> +        * to handle it immediatedly (e.g. to not miss phone calls) it can
> +        * enable wakeup source from user space, while other devices which
> +        * do not have proper autosleep feature may want to handle it with
> +        * other wakeup events (e.g. Power button) instead waking up immediately.
> +        */
> +       device_set_wakeup_capable(&pdev->dev, true);
> +
> +       ret = dev_pm_set_wake_irq(&pdev->dev, irq);
> +       if (ret)
> +               goto set_wake_irq_fail;
>
>         return 0;
>
> +set_wake_irq_fail:
> +       dev_pm_clear_wake_irq(&pdev->dev);
> +
>  unwind_interfaces:
>         list_for_each_entry(entry, &smp2p->inbound, node)
>                 irq_domain_remove(entry->domain);
> @@ -565,6 +583,9 @@ static int qcom_smp2p_remove(struct platform_device *pdev)
>         struct qcom_smp2p *smp2p = platform_get_drvdata(pdev);
>         struct smp2p_entry *entry;
>
> +       dev_pm_clear_wake_irq(&pdev->dev);
> +       device_init_wakeup(&pdev->dev, false);

Is this device_init_wakeup() call necessary? It looks like we can get
away without it and then once this driver probes the device will have
the wakeup capability set on it. Future binding/unbinding of the driver
will keep working.

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

* Re: [PATCH V4 1/1] soc: qcom: smp2p: Add wakeup capability to SMP2P IRQ
  2021-09-20 18:37 ` Stephen Boyd
@ 2021-09-21 10:28   ` Deepak Kumar Singh
  0 siblings, 0 replies; 3+ messages in thread
From: Deepak Kumar Singh @ 2021-09-21 10:28 UTC (permalink / raw)
  To: Stephen Boyd, bjorn.andersson, clew, sibis
  Cc: linux-kernel, linux-arm-msm, linux-remoteproc, Andy Gross


On 9/21/2021 12:07 AM, Stephen Boyd wrote:
> Quoting Deepak Kumar Singh (2021-09-18 12:02:15)
>> diff --git a/drivers/soc/qcom/smp2p.c b/drivers/soc/qcom/smp2p.c
>> index 2df4883..60ad632 100644
>> --- a/drivers/soc/qcom/smp2p.c
>> +++ b/drivers/soc/qcom/smp2p.c
>> @@ -14,6 +14,7 @@
>>   #include <linux/mfd/syscon.h>
>>   #include <linux/module.h>
>>   #include <linux/platform_device.h>
>> +#include <linux/pm_wakeirq.h>
>>   #include <linux/regmap.h>
>>   #include <linux/soc/qcom/smem.h>
>>   #include <linux/soc/qcom/smem_state.h>
>> @@ -538,9 +539,26 @@ static int qcom_smp2p_probe(struct platform_device *pdev)
>>                  goto unwind_interfaces;
>>          }
>>
>> +       /*
>> +        * Treat smp2p interrupt as wakeup source, but keep it disabled
>> +        * by default. User space can decide enabling it depending on its
>> +        * use cases. For example if remoteproc crashes and device wants
>> +        * to handle it immediatedly (e.g. to not miss phone calls) it can
>> +        * enable wakeup source from user space, while other devices which
>> +        * do not have proper autosleep feature may want to handle it with
>> +        * other wakeup events (e.g. Power button) instead waking up immediately.
>> +        */
>> +       device_set_wakeup_capable(&pdev->dev, true);
>> +
>> +       ret = dev_pm_set_wake_irq(&pdev->dev, irq);
>> +       if (ret)
>> +               goto set_wake_irq_fail;
>>
>>          return 0;
>>
>> +set_wake_irq_fail:
>> +       dev_pm_clear_wake_irq(&pdev->dev);
>> +
>>   unwind_interfaces:
>>          list_for_each_entry(entry, &smp2p->inbound, node)
>>                  irq_domain_remove(entry->domain);
>> @@ -565,6 +583,9 @@ static int qcom_smp2p_remove(struct platform_device *pdev)
>>          struct qcom_smp2p *smp2p = platform_get_drvdata(pdev);
>>          struct smp2p_entry *entry;
>>
>> +       dev_pm_clear_wake_irq(&pdev->dev);
>> +       device_init_wakeup(&pdev->dev, false);
> Is this device_init_wakeup() call necessary? It looks like we can get
> away without it and then once this driver probes the device will have
> the wakeup capability set on it. Future binding/unbinding of the driver
> will keep working.

ok, cleanup is handled in device_unregister() path. So it is redundant here.

I will remove this in next patch.


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

end of thread, other threads:[~2021-09-21 10:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-18 19:02 [PATCH V4 1/1] soc: qcom: smp2p: Add wakeup capability to SMP2P IRQ Deepak Kumar Singh
2021-09-20 18:37 ` Stephen Boyd
2021-09-21 10:28   ` Deepak Kumar Singh

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