mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] mmc: mtk-sd: Fix error handle of probe function
@ 2024-11-07  1:47 Andy-ld Lu
  2024-11-07 11:02 ` AngeloGioacchino Del Regno
  0 siblings, 1 reply; 3+ messages in thread
From: Andy-ld Lu @ 2024-11-07  1:47 UTC (permalink / raw)
  To: angelogioacchino.delregno, ulf.hansson, matthias.bgg, wenbin.mei
  Cc: linux-mmc, linux-kernel, linux-arm-kernel, linux-mediatek, Andy-ld Lu

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.

Signed-off-by: Andy-ld Lu <andy-ld.lu@mediatek.com>
---
 drivers/mmc/host/mtk-sd.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c
index a2750a45c1b7..022526a1f754 100644
--- a/drivers/mmc/host/mtk-sd.c
+++ b/drivers/mmc/host/mtk-sd.c
@@ -3007,7 +3007,7 @@ static int msdc_drv_probe(struct platform_device *pdev)
 	ret = msdc_ungate_clock(host);
 	if (ret) {
 		dev_err(&pdev->dev, "Cannot ungate clocks!\n");
-		goto release_mem;
+		goto release_clk;
 	}
 	msdc_init_hw(host);
 
@@ -3017,14 +3017,14 @@ static int msdc_drv_probe(struct platform_device *pdev)
 					     GFP_KERNEL);
 		if (!host->cq_host) {
 			ret = -ENOMEM;
-			goto release_mem;
+			goto release;
 		}
 		host->cq_host->caps |= CQHCI_TASK_DESC_SZ_128;
 		host->cq_host->mmio = host->base + 0x800;
 		host->cq_host->ops = &msdc_cmdq_ops;
 		ret = cqhci_init(host->cq_host, mmc, true);
 		if (ret)
-			goto release_mem;
+			goto release;
 		mmc->max_segs = 128;
 		/* cqhci 16bit length */
 		/* 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)
 end:
 	pm_runtime_disable(host->dev);
 release:
-	platform_set_drvdata(pdev, NULL);
 	msdc_deinit_hw(host);
+release_clk:
 	msdc_gate_clock(host);
+	platform_set_drvdata(pdev, NULL);
 release_mem:
 	if (host->dma.gpd)
 		dma_free_coherent(&pdev->dev,
-- 
2.46.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mmc: mtk-sd: Fix error handle of probe function
  2024-11-07  1:47 [PATCH] mmc: mtk-sd: Fix error handle of probe function Andy-ld Lu
@ 2024-11-07 11:02 ` AngeloGioacchino Del Regno
  2024-11-07 11:35   ` Andy-ld Lu (卢东)
  0 siblings, 1 reply; 3+ messages in thread
From: AngeloGioacchino Del Regno @ 2024-11-07 11:02 UTC (permalink / raw)
  To: Andy-ld Lu, ulf.hansson, matthias.bgg, wenbin.mei
  Cc: linux-mmc, linux-kernel, linux-arm-kernel, linux-mediatek

Il 07/11/24 02:47, Andy-ld Lu ha scritto:
> 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.
> 
> Signed-off-by: Andy-ld Lu <andy-ld.lu@mediatek.com>

Please add the relevant Fixes tag, as this is a fix and should be backported.

After which, I'll give you my R-b.

Cheers,
Angelo


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mmc: mtk-sd: Fix error handle of probe function
  2024-11-07 11:02 ` AngeloGioacchino Del Regno
@ 2024-11-07 11:35   ` Andy-ld Lu (卢东)
  0 siblings, 0 replies; 3+ messages in thread
From: Andy-ld Lu (卢东) @ 2024-11-07 11:35 UTC (permalink / raw)
  To: ulf.hansson, matthias.bgg, AngeloGioacchino Del Regno,
	Wenbin Mei (梅文彬)
  Cc: linux-arm-kernel, linux-mmc, linux-kernel, linux-mediatek

On Thu, 2024-11-07 at 12:02 +0100, AngeloGioacchino Del Regno wrote:
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
> 
> 
> Il 07/11/24 02:47, Andy-ld Lu ha scritto:
> > 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.
> > 
> > Signed-off-by: Andy-ld Lu <andy-ld.lu@mediatek.com>
> 
> Please add the relevant Fixes tag, as this is a fix and should be
> backported.
> 
> After which, I'll give you my R-b.
> 
> Cheers,
> Angelo

Thanks for your review, I will add it in next change.

Best regards
Andy-ld Lu
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-11-07 11:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-07  1:47 [PATCH] mmc: mtk-sd: Fix error handle of probe function Andy-ld Lu
2024-11-07 11:02 ` AngeloGioacchino Del Regno
2024-11-07 11:35   ` Andy-ld Lu (卢东)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®