Skip to content

Commit 2912204

Browse files
Andy-ld LuUlf Hansson
authored andcommitted
mmc: mtk-sd: Fix error handle of probe function
In the probe function, it goes to 'release_mem' label and returns after some procedure failure. But if the clocks (partial or all) have been enabled previously, they would not be disabled in msdc_runtime_suspend, since runtime PM is not yet enabled for this case. That cause mmc related clocks always on during system suspend and block suspend flow. Below log is from a SDCard issue of MT8196 chromebook, it returns -ETIMEOUT while polling clock stable in the msdc_ungate_clock() and probe failed, but the enabled clocks could not be disabled anyway. [ 129.059253] clk_chk_dev_pm_suspend() [ 129.350119] suspend warning: msdcpll is on [ 129.354494] [ck_msdc30_1_sel : enabled, 1, 1, 191999939, ck_msdcpll_d2] [ 129.362787] [ck_msdcpll_d2 : enabled, 1, 1, 191999939, msdcpll] [ 129.371041] [ck_msdc30_1_ck : enabled, 1, 1, 191999939, ck_msdc30_1_sel] [ 129.379295] [msdcpll : enabled, 1, 1, 383999878, clk26m] Add a new 'release_clk' label and reorder the error handle functions to make sure the clocks be disabled after probe failure. Fixes: ffaea6e ("mmc: mtk-sd: Use readl_poll_timeout instead of open-coded polling") Fixes: 7a2fa8e ("mmc: mtk-sd: use devm_mmc_alloc_host") Signed-off-by: Andy-ld Lu <andy-ld.lu@mediatek.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Cc: stable@vger.kernel.org Message-ID: <20241107121215.5201-1-andy-ld.lu@mediatek.com> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent 7f083e4 commit 2912204

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

drivers/mmc/host/mtk-sd.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3007,7 +3007,7 @@ static int msdc_drv_probe(struct platform_device *pdev)
30073007
ret = msdc_ungate_clock(host);
30083008
if (ret) {
30093009
dev_err(&pdev->dev, "Cannot ungate clocks!\n");
3010-
goto release_mem;
3010+
goto release_clk;
30113011
}
30123012
msdc_init_hw(host);
30133013

@@ -3017,14 +3017,14 @@ static int msdc_drv_probe(struct platform_device *pdev)
30173017
GFP_KERNEL);
30183018
if (!host->cq_host) {
30193019
ret = -ENOMEM;
3020-
goto release_mem;
3020+
goto release;
30213021
}
30223022
host->cq_host->caps |= CQHCI_TASK_DESC_SZ_128;
30233023
host->cq_host->mmio = host->base + 0x800;
30243024
host->cq_host->ops = &msdc_cmdq_ops;
30253025
ret = cqhci_init(host->cq_host, mmc, true);
30263026
if (ret)
3027-
goto release_mem;
3027+
goto release;
30283028
mmc->max_segs = 128;
30293029
/* cqhci 16bit length */
30303030
/* 0 size, means 65536 so we don't have to -1 here */
@@ -3064,9 +3064,10 @@ static int msdc_drv_probe(struct platform_device *pdev)
30643064
end:
30653065
pm_runtime_disable(host->dev);
30663066
release:
3067-
platform_set_drvdata(pdev, NULL);
30683067
msdc_deinit_hw(host);
3068+
release_clk:
30693069
msdc_gate_clock(host);
3070+
platform_set_drvdata(pdev, NULL);
30703071
release_mem:
30713072
if (host->dma.gpd)
30723073
dma_free_coherent(&pdev->dev,

0 commit comments

Comments
 (0)