Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

dmaengine: qcom: bam_dma: Manage clocks when controlled_remotely is set

When bam dma is "controlled remotely", thus far clocks were not controlled
from the Linux. In this scenario, Linux was disabling runtime pm in bam dma
driver and not doing any clock management in suspend/resume hooks.

With introduction of crypto engine bam dma, the clock is a rpmh resource
that can be controlled from both Linux and TZ/remote side. Now bam dma
clock is getting enabled during probe even though the bam dma can be
"controlled remotely". But due to clocks not being handled properly,
bam_suspend generates a unbalanced clk_unprepare warning during system
suspend.

To fix the above issue and to enable proper clock-management, this patch
enables runtim-pm and handles bam dma clocks in suspend/resume hooks if
the clock node is present irrespective of controlled_remotely property.

Signed-off-by: Thara Gopinath <thara.gopinath@linaro.org>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Tested-by: John Stultz <john.stultz@linaro.org>
Reviewed-by: Shawn Guo <shawn.guo@linaro.org>
Link: https://lore.kernel.org/r/20210126211859.790892-1-thara.gopinath@linaro.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Thara Gopinath and committed by
Vinod Koul
123935a4 03d939c7

+15 -14
+15 -14
drivers/dma/qcom/bam_dma.c
··· 1274 1274 dev_err(bdev->dev, "num-ees unspecified in dt\n"); 1275 1275 } 1276 1276 1277 - bdev->bamclk = devm_clk_get(bdev->dev, "bam_clk"); 1278 - if (IS_ERR(bdev->bamclk)) { 1279 - if (!bdev->controlled_remotely) 1280 - return PTR_ERR(bdev->bamclk); 1277 + if (bdev->controlled_remotely) 1278 + bdev->bamclk = devm_clk_get_optional(bdev->dev, "bam_clk"); 1279 + else 1280 + bdev->bamclk = devm_clk_get(bdev->dev, "bam_clk"); 1281 1281 1282 - bdev->bamclk = NULL; 1283 - } 1282 + if (IS_ERR(bdev->bamclk)) 1283 + return PTR_ERR(bdev->bamclk); 1284 1284 1285 1285 ret = clk_prepare_enable(bdev->bamclk); 1286 1286 if (ret) { ··· 1354 1354 if (ret) 1355 1355 goto err_unregister_dma; 1356 1356 1357 - if (bdev->controlled_remotely) { 1357 + if (!bdev->bamclk) { 1358 1358 pm_runtime_disable(&pdev->dev); 1359 1359 return 0; 1360 1360 } ··· 1442 1442 { 1443 1443 struct bam_device *bdev = dev_get_drvdata(dev); 1444 1444 1445 - if (!bdev->controlled_remotely) 1445 + if (bdev->bamclk) { 1446 1446 pm_runtime_force_suspend(dev); 1447 - 1448 - clk_unprepare(bdev->bamclk); 1447 + clk_unprepare(bdev->bamclk); 1448 + } 1449 1449 1450 1450 return 0; 1451 1451 } ··· 1455 1455 struct bam_device *bdev = dev_get_drvdata(dev); 1456 1456 int ret; 1457 1457 1458 - ret = clk_prepare(bdev->bamclk); 1459 - if (ret) 1460 - return ret; 1458 + if (bdev->bamclk) { 1459 + ret = clk_prepare(bdev->bamclk); 1460 + if (ret) 1461 + return ret; 1461 1462 1462 - if (!bdev->controlled_remotely) 1463 1463 pm_runtime_force_resume(dev); 1464 + } 1464 1465 1465 1466 return 0; 1466 1467 }