Skip to contentSkip to conversation

soc: qcom: smp2p: Add wakeup capability to SMP2P IRQ

PATCH Superseded Deepak Kumar Singh 4 participants 9 messages Aug 5, 2021 – Aug 16, 2021

Subsystems (2)

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 soc: qcom: smp2p: Add wakeup capability to SMP2P IRQ

Some use cases require SMP2P interrupts to wake up the host from suspend. Mark smp2p interrupt as wakeup capable to abort the suspend.

---
 drivers/soc/qcom/smp2p.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/soc/qcom/smp2p.c +11 -0
index 2df4883..f8659b0 100644
@@ -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,19 @@ static int qcom_smp2p_probe(struct platform_device *pdev)
 		goto unwind_interfaces;
 	}
 
+	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
#1 lore raw

Quoting Deepak Kumar Singh (2021-08-05 09:17:33)

Quoted 2 lines

Some use cases require SMP2P interrupts to wake up the host from suspend.

Please elaborate on this point so we understand what sort of scenarios want to wakeup from suspend.

Quoted 21 lines

Mark smp2p interrupt as wakeup capable to abort
the suspend.

---
 drivers/soc/qcom/smp2p.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/soc/qcom/smp2p.c +1 -0
index 2df4883..f8659b0 100644
@@ -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

drivers/soc/qcom/smp2p.c static int qcom_smp2p_probe(struct platform_device *pdev) · line 542

Quoted 4 lines
drivers/soc/qcom/smp2p.c +1 -0
@@ -538,9 +539,19 @@ static int qcom_smp2p_probe(struct platform_device *pdev)
                goto unwind_interfaces;
        }
 
+       ret = device_init_wakeup(&pdev->dev, true);

Is smp2p supposed to wake up the device by default? If not, then this should be device_set_wakeup_capable() instead so that userspace can decide if it wants to get the wakeup.

drivers/soc/qcom/smp2p.c static int qcom_smp2p_probe(struct platform_device *pdev) · line 548

Quoted 6 lines
drivers/soc/qcom/smp2p.c +6 -0
+       if (ret)
+               goto unwind_interfaces;
+
+       ret = dev_pm_set_wake_irq(&pdev->dev, irq);
+       if (ret)
+               goto set_wakeup_failed;

Otherwise this looks good to me.

Quoted 9 lines
drivers/soc/qcom/smp2p.c +3 -0
        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);
#2 lore raw
Quoted 5 lines · Stephen Boyd

Quoting Deepak Kumar Singh (2021-08-05 09:17:33)

Quoted 2 lines

Some use cases require SMP2P interrupts to wake up the host from suspend.

Please elaborate on this point so we understand what sort of scenarios want to wakeup from suspend.

Once such scenario is where WiFi/modem crashes and notifies crash to local host through smp2p

if local host is in suspend it should wake up to handle the crash and reboot the WiFi/modem.

Quoted 24 lines
Quoted 24 lines

Mark smp2p interrupt as wakeup capable to abort
the suspend.

---
  drivers/soc/qcom/smp2p.c | 11 +++++++++++
  1 file changed, 11 insertions(+)
drivers/soc/qcom/smp2p.c +1 -0
index 2df4883..f8659b0 100644
@@ -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,19 @@ static int qcom_smp2p_probe(struct platform_device *pdev)
                 goto unwind_interfaces;
         }
 
Quoted 4 lines

drivers/soc/qcom/smp2p.c static int qcom_smp2p_probe(struct platform_device *pdev) · line 542

Quoted 1 line
drivers/soc/qcom/smp2p.c +1 -0
+       ret = device_init_wakeup(&pdev->dev, true);

Is smp2p supposed to wake up the device by default? If not, then this should be device_set_wakeup_capable() instead so that userspace can decide if it wants to get the wakeup.

yes, we want smp2p to be wake up capable by default.

Quoted 16 lines

drivers/soc/qcom/smp2p.c static int qcom_smp2p_probe(struct platform_device *pdev) · line 548

Quoted 6 lines
drivers/soc/qcom/smp2p.c +6 -0
+       if (ret)
+               goto unwind_interfaces;
+
+       ret = dev_pm_set_wake_irq(&pdev->dev, irq);
+       if (ret)
+               goto set_wakeup_failed;

Otherwise this looks good to me.

Quoted 8 lines
drivers/soc/qcom/smp2p.c +3 -0
         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);
#3 lore raw

Quoting Deepak Kumar Singh (2021-08-09 04:05:08)

Quoted 13 lines · Stephen Boyd
Quoted 5 lines

Quoting Deepak Kumar Singh (2021-08-05 09:17:33)

Quoted 2 lines

Some use cases require SMP2P interrupts to wake up the host from suspend.

Please elaborate on this point so we understand what sort of scenarios want to wakeup from suspend.

Once such scenario is where WiFi/modem crashes and notifies crash to local host through smp2p

if local host is in suspend it should wake up to handle the crash and reboot the WiFi/modem.

Does anything go wrong if the firmware crashes during suspend and the local host doesn't handle it until it wakes for some other reason? I'd like to understand if the crash handling can be delayed/combined with another wakeup.

Quoted 25 lines
Quoted 25 lines
Quoted 25 lines

Mark smp2p interrupt as wakeup capable to abort
the suspend.

---
  drivers/soc/qcom/smp2p.c | 11 +++++++++++
  1 file changed, 11 insertions(+)
drivers/soc/qcom/smp2p.c +1 -0
index 2df4883..f8659b0 100644
@@ -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,19 @@ static int qcom_smp2p_probe(struct platform_device *pdev)
                 goto unwind_interfaces;
         }
 
Quoted 5 lines
Quoted 4 lines

drivers/soc/qcom/smp2p.c static int qcom_smp2p_probe(struct platform_device *pdev) · line 542

Quoted 1 line
drivers/soc/qcom/smp2p.c +1 -0
+       ret = device_init_wakeup(&pdev->dev, true);

Is smp2p supposed to wake up the device by default? If not, then this should be device_set_wakeup_capable() instead so that userspace can decide if it wants to get the wakeup.

yes, we want smp2p to be wake up capable by default.

Why?

#4 lore raw
Quoted 12 lines · Stephen Boyd

Quoting Deepak Kumar Singh (2021-08-09 04:05:08)

Quoted 11 lines · Stephen Boyd
Quoted 5 lines

Quoting Deepak Kumar Singh (2021-08-05 09:17:33)

Quoted 2 lines

Some use cases require SMP2P interrupts to wake up the host from suspend.

Please elaborate on this point so we understand what sort of scenarios want to wakeup from suspend.

Once such scenario is where WiFi/modem crashes and notifies crash to local host through smp2p

Quoted 7 lines
Quoted 2 lines

if local host is in suspend it should wake up to handle the crash and reboot the WiFi/modem.

Does anything go wrong if the firmware crashes during suspend and the local host doesn't handle it until it wakes for some other reason? I'd like to understand if the crash handling can be delayed/combined with another wakeup.

If the modem firmware crashes
during suspend, the system comes
out of xo-shutdown and AFAIK stays
there until we handle the interrupt.

Quoted 33 lines
Quoted 26 lines
Quoted 26 lines
Quoted 26 lines

Mark smp2p interrupt as wakeup capable to abort
the suspend.

---
  drivers/soc/qcom/smp2p.c | 11 +++++++++++
  1 file changed, 11 insertions(+)
drivers/soc/qcom/smp2p.c +1 -0
index 2df4883..f8659b0 100644
@@ -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,19 @@ static int qcom_smp2p_probe(struct platform_device *pdev)
                 goto unwind_interfaces;
         }
 
Quoted 5 lines
Quoted 4 lines

drivers/soc/qcom/smp2p.c static int qcom_smp2p_probe(struct platform_device *pdev) · line 542

Quoted 1 line
drivers/soc/qcom/smp2p.c +1 -0
+       ret = device_init_wakeup(&pdev->dev, true);

Is smp2p supposed to wake up the device by default? If not, then this should be device_set_wakeup_capable() instead so that userspace can decide if it wants to get the wakeup.

yes, we want smp2p to be wake up capable by default.

Why?

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project.
#5 lore raw

Quoting Sibi Sankar (2021-08-10 10:24:32)

Quoted 21 lines · Stephen Boyd
Quoted 12 lines

Quoting Deepak Kumar Singh (2021-08-09 04:05:08)

Quoted 11 lines · Stephen Boyd
Quoted 5 lines

Quoting Deepak Kumar Singh (2021-08-05 09:17:33)

Quoted 2 lines

Some use cases require SMP2P interrupts to wake up the host from suspend.

Please elaborate on this point so we understand what sort of scenarios want to wakeup from suspend.

Once such scenario is where WiFi/modem crashes and notifies crash to local host through smp2p

Quoted 7 lines
Quoted 2 lines

if local host is in suspend it should wake up to handle the crash and reboot the WiFi/modem.

Does anything go wrong if the firmware crashes during suspend and the local host doesn't handle it until it wakes for some other reason? I'd like to understand if the crash handling can be delayed/combined with another wakeup.

Quoted 5 lines

If the modem firmware crashes during suspend, the system comes out of xo-shutdown and AFAIK stays there until we handle the interrupt.

So you're saying we waste power if we don't wakeup the AP and leave the SoC in a shallow low power state? That would be good to have indicated in the code via a comment and in the commit text so we know that we want to handle the wakeup by default.

#6 lore raw
Quoted 28 lines · Stephen Boyd

Quoting Sibi Sankar (2021-08-10 10:24:32)

Quoted 21 lines · Stephen Boyd
Quoted 12 lines

Quoting Deepak Kumar Singh (2021-08-09 04:05:08)

Quoted 11 lines · Stephen Boyd
Quoted 5 lines

Quoting Deepak Kumar Singh (2021-08-05 09:17:33)

Quoted 2 lines

Some use cases require SMP2P interrupts to wake up the host from suspend.

Please elaborate on this point so we understand what sort of scenarios want to wakeup from suspend.

Once such scenario is where WiFi/modem crashes and notifies crash to local host through smp2p

Quoted 7 lines
Quoted 2 lines

if local host is in suspend it should wake up to handle the crash and reboot the WiFi/modem.

Does anything go wrong if the firmware crashes during suspend and the local host doesn't handle it until it wakes for some other reason? I'd like to understand if the crash handling can be delayed/combined with another wakeup.

Quoted 5 lines

If the modem firmware crashes during suspend, the system comes out of xo-shutdown and AFAIK stays there until we handle the interrupt.

Quoted 4 lines

So you're saying we waste power if we don't wakeup the AP and leave the SoC in a shallow low power state? That would be good to have indicated in the code via a comment and in the commit text so we know that we want to handle the wakeup by default.

Sounds like in a system without autosleep (or userspace equivalent) it would be desirable to leave the SoC in this lower state than to wake up the system handle the crash and then just idle?

But leaving the system in this state will result in you missing your important phone calls...

Regards,
Bjorn

#7 lore raw

Quoting Bjorn Andersson (2021-08-10 16:11:10)

Quoted 35 lines · Stephen Boyd
Quoted 29 lines

Quoting Sibi Sankar (2021-08-10 10:24:32)

Quoted 21 lines · Stephen Boyd
Quoted 12 lines

Quoting Deepak Kumar Singh (2021-08-09 04:05:08)

Quoted 11 lines · Stephen Boyd
Quoted 5 lines

Quoting Deepak Kumar Singh (2021-08-05 09:17:33)

Quoted 2 lines

Some use cases require SMP2P interrupts to wake up the host from suspend.

Please elaborate on this point so we understand what sort of scenarios want to wakeup from suspend.

Once such scenario is where WiFi/modem crashes and notifies crash to local host through smp2p

Quoted 7 lines
Quoted 2 lines

if local host is in suspend it should wake up to handle the crash and reboot the WiFi/modem.

Does anything go wrong if the firmware crashes during suspend and the local host doesn't handle it until it wakes for some other reason? I'd like to understand if the crash handling can be delayed/combined with another wakeup.

Quoted 5 lines

If the modem firmware crashes during suspend, the system comes out of xo-shutdown and AFAIK stays there until we handle the interrupt.

Quoted 4 lines

So you're saying we waste power if we don't wakeup the AP and leave the SoC in a shallow low power state? That would be good to have indicated in the code via a comment and in the commit text so we know that we want to handle the wakeup by default.

Quoted 7 lines

Sounds like in a system without autosleep (or userspace equivalent) it would be desirable to leave the SoC in this lower state than to wake up the system handle the crash and then just idle?

But leaving the system in this state will result in you missing your important phone calls...

Yes I think we should just add a comment to the code and commit text and move on.

#8 lore raw
Quoted 34 lines · Stephen Boyd

Quoting Bjorn Andersson (2021-08-10 16:11:10)

Quoted 33 lines · Stephen Boyd
Quoted 24 lines

Quoting Sibi Sankar (2021-08-10 10:24:32)

Quoted 13 lines · Stephen Boyd
Quoted 12 lines

Quoting Deepak Kumar Singh (2021-08-09 04:05:08)

Quoted 11 lines · Stephen Boyd
Quoted 5 lines

Quoting Deepak Kumar Singh (2021-08-05 09:17:33)

Quoted 2 lines

Some use cases require SMP2P interrupts to wake up the host from suspend.

Please elaborate on this point so we understand what sort of scenarios want to wakeup from suspend.

Once such scenario is where WiFi/modem crashes and notifies crash to local host through smp2p

if local host is in suspend it should wake up to handle the crash and reboot the WiFi/modem.

Quoted 9 lines
Quoted 4 lines

Does anything go wrong if the firmware crashes during suspend and the local host doesn't handle it until it wakes for some other reason? I'd like to understand if the crash handling can be delayed/combined with another wakeup.

If the modem firmware crashes during suspend, the system comes out of xo-shutdown and AFAIK stays there until we handle the interrupt.

Quoted 4 lines

So you're saying we waste power if we don't wakeup the AP and leave the SoC in a shallow low power state? That would be good to have indicated in the code via a comment and in the commit text so we know that we want to handle the wakeup by default.

Sounds like in a system without autosleep (or userspace equivalent) it would be desirable to leave the SoC in this lower state than to wake up the system handle the crash and then just idle?

Quoted 5 lines
Quoted 3 lines

But leaving the system in this state will result in you missing your important phone calls...

Yes I think we should just add a comment to the code and commit text and move on.

Thanks, updated in patch set V2