linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] firmware: imx: scu: ensure wakeup procedure calls pm_system_wakeup()
@ 2023-12-30  5:38 Xiaolei Wang
  2023-12-30 18:55 ` kernel test robot
  2023-12-30 18:55 ` kernel test robot
  0 siblings, 2 replies; 4+ messages in thread
From: Xiaolei Wang @ 2023-12-30  5:38 UTC (permalink / raw)
  To: shawnguo, s.hauer, kernel, festevam, linux-imx, peng.fan, treding,
	yibin.gong, robh, ranjani.vaidyanathan
  Cc: linux-arm-kernel, linux-kernel

There will still be mu irq in the suspend stage, for
example, in imx8. When the system enters the suspend
state, the GPIO enters the pad wakeup state. Calling
pm_system_wakeup() at this time will cause the system
suspend to terminate, so when it is set to wakeup, call
pm_system_wakeup(), through rtcwake -s 10 -v -m freeze
verification.

mxc_gpio_noirq_suspend
     mxc_gpio_set_pad_wakeup
         mbox_send_message
              imx_mu_isr
                 imx_mu_generic_rxdb

Fixes: 0caf847975b2 ("firmware: imx: make sure MU irq can wake up system from suspend mode")
Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
---
 drivers/firmware/imx/imx-scu-irq.c |  4 +++-
 drivers/firmware/imx/imx-scu.c     | 20 ++++++++++++++++++++
 include/linux/firmware/imx/sci.h   |  1 +
 3 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/drivers/firmware/imx/imx-scu-irq.c b/drivers/firmware/imx/imx-scu-irq.c
index 6125cccc9ba7..099a1f50d995 100644
--- a/drivers/firmware/imx/imx-scu-irq.c
+++ b/drivers/firmware/imx/imx-scu-irq.c
@@ -20,6 +20,7 @@
 #define IMX_SC_IRQ_NUM_GROUP	9
 
 static u32 mu_resource_id;
+int scu_suspend;
 
 struct imx_sc_msg_irq_get_status {
 	struct imx_sc_rpc_msg hdr;
@@ -109,7 +110,8 @@ static void imx_scu_irq_work_handler(struct work_struct *work)
 			scu_irq_wakeup[i].wakeup_src = irq_status;
 		}
 
-		pm_system_wakeup();
+		if (scu_suspend)
+			pm_system_wakeup();
 		imx_scu_irq_notifier_call_chain(irq_status, &i);
 	}
 }
diff --git a/drivers/firmware/imx/imx-scu.c b/drivers/firmware/imx/imx-scu.c
index 1dd4362ef9a3..b9f5c5eb4581 100644
--- a/drivers/firmware/imx/imx-scu.c
+++ b/drivers/firmware/imx/imx-scu.c
@@ -342,10 +342,30 @@ static int imx_scu_probe(struct platform_device *pdev)
 	return devm_of_platform_populate(dev);
 }
 
+
+
 static const struct of_device_id imx_scu_match[] = {
 	{ .compatible = "fsl,imx-scu", },
 	{ /* Sentinel */ }
 };
+static int __maybe_unused imx_scu_suspend_noirq(struct device *dev)
+{
+	scu_suspend = true;
+
+	return 0;
+}
+
+static int __maybe_unused imx_scu_resume_noirq(struct device *dev)
+{
+	scu_suspend = false;
+
+	return 0;
+};
+
+static const struct dev_pm_ops imx_scu_pm_ops = {
+	SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(imx_scu_suspend_noirq,
+				      imx_scu_resume_noirq)
+};
 
 static struct platform_driver imx_scu_driver = {
 	.driver = {
diff --git a/include/linux/firmware/imx/sci.h b/include/linux/firmware/imx/sci.h
index df17196df5ff..244df9c7629d 100644
--- a/include/linux/firmware/imx/sci.h
+++ b/include/linux/firmware/imx/sci.h
@@ -17,6 +17,7 @@
 #include <linux/firmware/imx/svc/rm.h>
 
 #if IS_ENABLED(CONFIG_IMX_SCU)
+extern int scu_suspend;
 int imx_scu_enable_general_irq_channel(struct device *dev);
 int imx_scu_irq_register_notifier(struct notifier_block *nb);
 int imx_scu_irq_unregister_notifier(struct notifier_block *nb);
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2024-01-03  3:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-30  5:38 [PATCH] firmware: imx: scu: ensure wakeup procedure calls pm_system_wakeup() Xiaolei Wang
2023-12-30 18:55 ` kernel test robot
2023-12-30 18:55 ` kernel test robot
2024-01-03  3:43   ` wangxiaolei

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