From cbbfb5c197356a71b3e22f6cc5483daa73cd72eb Mon Sep 17 00:00:00 2001 From: Robin Gong Date: Sat, 22 May 2021 01:17:49 +0800 Subject: [PATCH] MLK-25508: dmaengine: imx-sdma: fix kernel dump in audio record Check whether audiomix really off or not in runtime resume, if not, do nothing at HW level including script load to avoid the below crash: [ 40.348730] kernel BUG at mm/vmalloc.c:2064! [ 40.353001] Internal error: Oops - BUG: 0 [#1] PREEMPT SMP [ 40.358486] Modules linked in: [ 40.361547] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.10.35-05035-g08680b128d38-dirty #490 [ 40.369984] Hardware name: NXP i.MX8MPlus EVK board (DT) [ 40.375297] pstate: 00000005 (nzcv daif -PAN -UAO -TCO BTYPE=--) [ 40.381310] pc : __get_vm_area_node+0x164/0x188 [ 40.385842] lr : vmap+0x84/0x100 [ 40.389069] sp : ffff800011bdba80 [ 40.392384] x29: ffff800011bdba80 x28: 0000000000000000 [ 40.397700] x27: ffff0000c0447548 x26: ffff0000c69b80d4 [ 40.403015] x25: 0000000000001000 x24: 006800000000070b [ 40.408333] x23: ffff0000c7399300 x22: 0000000000001000 [ 40.413651] x21: 0000000000000010 x20: 0000000000000001 [ 40.418972] x19: fffffdfffff01540 x18: 00000000000000c0 [ 40.424290] x17: 0000000000000000 x16: 0000000000000000 [ 40.429605] x15: fffffdfffff024c0 x14: fffffdfffff024c8 [ 40.434921] x13: dead000000000122 x12: 0000000000001000 [ 40.440236] x11: ffff00017f3fba08 x10: ffff80016dc2b000 [ 40.445552] x9 : ffffffffffffffff x8 : 0000000000010001 [ 40.450870] x7 : ffff8000100f51a0 x6 : 0000000000000cc0 [ 40.456187] x5 : 00000000ffffffff x4 : fffffdffbfff0000 [ 40.461505] x3 : ffff800010000000 x2 : 0000000000000010 [ 40.466821] x1 : 0000000000000001 x0 : 0000000000001000 [ 40.472137] Call trace: [ 40.474588] __get_vm_area_node+0x164/0x188 [ 40.478775] dma_common_contiguous_remap+0xa8/0xe8 [ 40.483568] dma_direct_alloc+0x194/0x320 [ 40.487581] dma_alloc_attrs+0x7c/0xe0 [ 40.491333] sdma_load_script+0x64/0x170 [ 40.495260] sdma_runtime_resume+0x1cc/0x1e8 [ 40.499533] pm_generic_runtime_resume+0x28/0x40 [ 40.504153] __genpd_runtime_resume+0x2c/0xa0 [ 40.508512] genpd_runtime_resume+0x88/0x208 [ 40.512784] __rpm_callback+0xd4/0x148 [ 40.516535] rpm_callback+0x20/0x80 [ 40.520025] rpm_resume+0x39c/0x580 [ 40.523515] __pm_runtime_resume+0x38/0x80 [ 40.527614] sdma_int_handler+0x40/0x380 [ 40.531539] __handle_irq_event_percpu+0x4c/0x160 [ 40.536243] handle_irq_event_percpu+0x30/0x88 [ 40.540686] handle_irq_event+0x44/0xd8 [ 40.544525] handle_fasteoi_irq+0xb4/0x160 [ 40.548621] generic_handle_irq+0x2c/0x40 [ 40.552632] __handle_domain_irq+0x60/0xb8 [ 40.556730] gic_handle_irq+0x54/0x118 [ 40.560482] el1_irq+0xc0/0x180 [ 40.563626] cpuidle_enter_state+0x134/0x2e8 [ 40.567898] cpuidle_enter+0x34/0x48 [ 40.571476] call_cpuidle+0x18/0x38 [ 40.574963] do_idle+0x1f4/0x258 [ 40.578190] cpu_startup_entry+0x20/0x68 [ 40.582116] rest_init+0xd4/0xe0 [ 40.585347] arch_call_rest_init+0xc/0x14 [ 40.589359] start_kernel+0x470/0x4a4 [ 40.593027] Code: aa1403e0 a94153f3 a8c67bfd d65f03c0 (d4210000) [ 40.599126] ---[ end trace 1207e0499c4741de ]--- Signed-off-by: Robin Gong Reviewed-by: Shengjiu Wang Acked-by: Jason Liu --- drivers/dma/imx-sdma.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c index 66c2f8192e7f..8c8deddd7325 100644 --- a/drivers/dma/imx-sdma.c +++ b/drivers/dma/imx-sdma.c @@ -1588,7 +1588,7 @@ static int sdma_runtime_resume(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct sdma_engine *sdma = platform_get_drvdata(pdev); - int i, ret; + int i, ret = 0; ret = clk_enable(sdma->clk_ipg); if (ret) @@ -1597,6 +1597,27 @@ static int sdma_runtime_resume(struct device *dev) if (ret) goto disable_clk_ipg; + /* Do nothing at HW level if audiomix which shared with audio driver + * not off indeed. + */ + if (readl_relaxed(sdma->regs + SDMA_H_C0PTR)) { + if (sdma->iram_pool) + sdma->bd0 = gen_pool_dma_alloc(sdma->iram_pool, + sizeof(struct sdma_buffer_descriptor), + &sdma->bd0_phys); + else + sdma->bd0 = dma_alloc_coherent(sdma->dev, + sizeof(struct sdma_buffer_descriptor), + &sdma->bd0_phys, GFP_NOWAIT); + if (!sdma->bd0) + ret = -ENOMEM; + + sdma->is_on = true; + sdma->fw_loaded = true; + + return ret; + } + /* Be sure SDMA has not started yet */ writel_relaxed(0, sdma->regs + SDMA_H_C0PTR); -- 2.17.1