2021-06-30 08:09:22

by Robin Gong

[permalink] [raw]
Subject: [PATCH v1] mailbox: imx: fix crash in resume on i.mx8ulp

check 'priv->clk' before 'imx_mu_read()' otherwise below crash may happen on
i.mx8ulp, since clock maybe already disabled by runtime suspend.

[ 79.155733] Internal error: synchronous external abort: 96000210 [#1] PREEMPT SMP
[ 79.162979] Modules linked in:
[ 79.165998] CPU: 0 PID: 460 Comm: sh Not tainted 5.10.35-00234-g0b4d749783dc-dirty #571
[ 79.173738] Hardware name: NXP i.MX8ULP EVK (DT)
[ 79.178240] pstate: 60000005 (nZCv daif -PAN -UAO -TCO BTYPE=--)
[ 79.184082] pc : imx_mu_resume_noirq+0x14/0x78
[ 79.188422] lr : dpm_run_callback.isra.0+0x38/0xd8
[ 79.193085] sp : ffff80001b63baa0
[ 79.196337] x29: ffff80001b63baa0 x28: 0000000000000000
[ 79.201512] x27: ffff800011bd9b30 x26: ffff80001157acd0
[ 79.206682] x25: ffff800011a210f4 x24: 00000012682e38d8
[ 79.211855] x23: 0000000000000000 x22: ffff800011b85000
[ 79.217023] x21: ffff00000425c810 x20: 0000000000000010
[ 79.222195] x19: ffff800010c79550 x18: 0000000000000010
[ 79.227368] x17: 0000000000000000 x16: 0000000000000000
[ 79.232539] x15: 0000006fb5d33a2c x14: 000000000000027a
[ 79.237709] x13: 0000000000000303 x12: 0000000000000001
[ 79.242879] x11: 0000000000000040 x10: ffff000004424f80
[ 79.248050] x9 : ffff000004424f78 x8 : 0000000000000028
[ 79.253222] x7 : 0000000000000006 x6 : 0000000000000657
[ 79.258395] x5 : 0000000000000657 x4 : 0000000000000000
[ 79.263567] x3 : 0000000000000001 x2 : 0000000000000110
[ 79.268742] x1 : ffff0000054b8080 x0 : ffff80001af40110
[ 79.273915] Call trace:
[ 79.276340] imx_mu_resume_noirq+0x14/0x78
[ 79.280345] device_resume_noirq+0x80/0x170
[ 79.284431] dpm_resume_noirq+0xb0/0x218
[ 79.288271] suspend_devices_and_enter+0x20c/0x5b8
[ 79.292938] pm_suspend+0x2ec/0x350
[ 79.296362] state_store+0x88/0x108
[ 79.299786] kobj_attr_store+0x14/0x28
[ 79.303460] sysfs_kf_write+0x40/0x50
[ 79.307046] kernfs_fop_write_iter+0x110/0x1a0
[ 79.311388] new_sync_write+0xe4/0x178
[ 79.315062] vfs_write+0x24c/0x380
[ 79.318404] ksys_write+0x68/0xf0
[ 79.321664] __arm64_sys_write+0x18/0x20
[ 79.325508] el0_svc_common.constprop.0+0x68/0x160
[ 79.330179] do_el0_svc+0x20/0x80
[ 79.333436] el0_svc+0x10/0x18
[ 79.336444] el0_sync_handler+0xa8/0xb0
[ 79.340200] el0_sync+0x140/0x180
[ 79.343463] Code: f94a9022 f9400420 b9403c42 8b020000 (b9400000)
[ 79.349383] ---[ end trace 4af1de2c96411434 ]---

Signed-off-by: Robin Gong <[email protected]>
---
drivers/mailbox/imx-mailbox.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mailbox/imx-mailbox.c b/drivers/mailbox/imx-mailbox.c
index 2543c7b6..848c0fe 100644
--- a/drivers/mailbox/imx-mailbox.c
+++ b/drivers/mailbox/imx-mailbox.c
@@ -620,7 +620,7 @@ static int __maybe_unused imx_mu_resume_noirq(struct device *dev)
* send failed, may lead to system freeze. This issue
* is observed by testing freeze mode suspend.
*/
- if (!imx_mu_read(priv, priv->dcfg->xCR) && !priv->clk)
+ if (!priv->clk && !imx_mu_read(priv, priv->dcfg->xCR))
imx_mu_write(priv, priv->xcr, priv->dcfg->xCR);

return 0;
--
2.7.4