[PATCH] soc: ti: pm33xx: fix resume from non-rtc suspend modes
From: Arsalan H. Awan
Date: Thu Aug 31 2023 - 11:13:39 EST
The am33xx_pm_rtc_setup() checks if the rtc device is available or not.
It configures the rtc if device is available, otherwise keeps the rtc
mode suspend functionality disabled.
In case a platform does not use the internal rtc and it is needed to
disable the rtc-only suspend mode, the resume from deepsleep or standby
modes fails right now becasue the am33xx_pm_end() tries to access the
rtc device and that results in a NULL pointer dereference.
This patch moves the rtc-only code within the correct bounds.
Otherwise, we get a kernel OOPS with a NULL pointer dereference on
resume when we try to access omap_rtc_scratch0.
Signed-off-by: Arsalan H. Awan <arsalan.awan@xxxxxxxxxxx>
---
drivers/soc/ti/pm33xx.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/soc/ti/pm33xx.c b/drivers/soc/ti/pm33xx.c
index f04c21157904..e3ccb0bb198a 100644
--- a/drivers/soc/ti/pm33xx.c
+++ b/drivers/soc/ti/pm33xx.c
@@ -305,10 +305,6 @@ static void am33xx_pm_end(void)
u32 val = 0;
struct nvmem_device *nvmem;
- nvmem = devm_nvmem_device_get(&omap_rtc->dev, "omap_rtc_scratch0");
- if (IS_ERR(nvmem))
- return;
-
m3_ipc->ops->finish_low_power(m3_ipc);
if (rtc_only_idle) {
if (retrigger_irq) {
@@ -324,6 +320,10 @@ static void am33xx_pm_end(void)
+ retrigger_irq / 32 * 4);
}
+ nvmem = devm_nvmem_device_get(&omap_rtc->dev, "omap_rtc_scratch0");
+ if (IS_ERR(nvmem))
+ return;
+
nvmem_device_write(nvmem, RTC_SCRATCH_MAGIC_REG * 4, 4,
(void *)&val);
}
--
2.25.1