LF-5352: dmaengine: imx-sdma: fix the potential access registers without clock
authorJoy Zou <joy.zou@nxp.com>
Wed, 19 Jan 2022 02:16:43 +0000 (10:16 +0800)
committerJosep Orga <jorga@somdevices.com>
Tue, 27 Jun 2023 14:03:22 +0000 (16:03 +0200)
commit1a7c5905e6ef8ef8747bf479a1e827eb306098c0
tree2a890a2bec462bd46b715b3df25bcc4ab6180718
parenta981b0617df66ce70ff03faadb8d1aa4a0138d78
LF-5352: dmaengine: imx-sdma: fix the potential access registers without clock

The issue can be triggered with the sdma pm_runtime false.

If the dma client try to use sdma in boot phase, it may cause
system hang. The sdma driver really enable clk after sdma load
firmware, the clk_disable_unused will disable the SDMA1_ROOT_CLK
before the sdma driver enable clk. This issue will comes if access
the sdma register when the SDMA1_ROOT_CLK is disable.

This issue is very easy to reproduce with hdmi connected displayer
on imx7d-sbd board which the i2c will use sdma early before sdma
firmware loaded and clock enabled.

The client i2c calls dmaengine_prep_slave_single->device_prep_slave_sg
->sdma_prep_slave_sg->sdma_config_write->sdma_config_channel to get
descriptor in boot phase. Then, the function sdma_config_channel will
access sdma registers. If clk is disable will cause system hang.

This patch adds clk_enable and clk_disable to make sure the clk
enable before access sdma hardware.

Signed-off-by: Joy Zou <joy.zou@nxp.com>
Reviewed-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Reviewed-by: Dong Aisheng <aisheng.dong@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
drivers/dma/imx-sdma.c