Skip to content

Commit 878e845

Browse files
Pin-yen Linbebarino
authored andcommitted
clk: mediatek: mt8183: Only enable runtime PM on mt8183-mfgcfg
Commit 2f7b1d8 ("clk: mediatek: Do a runtime PM get on controllers during probe") enabled runtime PM for all mediatek clock controllers, but this introduced an issue on the resume path. If a device resumes earlier than the clock controller and calls clk_prepare() when runtime PM is enabled on the controller, it will end up calling clk_pm_runtime_get(). But the subsequent pm_runtime_resume_and_get() call will fail because the runtime PM is temporarily disabled during suspend. To workaround this, introduce a need_runtime_pm flag and only enable it on mt8183-mfgcfg, which is the driver that observed deadlock previously. Hopefully mt8183-cfgcfg won't run into the issue at the resume stage because the GPU should have stopped rendering before the system calls suspend. Fixes: 2f7b1d8 ("clk: mediatek: Do a runtime PM get on controllers during probe") Signed-off-by: Pin-yen Lin <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Stephen Boyd <[email protected]>
1 parent f7275fd commit 878e845

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

drivers/clk/mediatek/clk-mt8183-mfgcfg.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ static const struct mtk_gate mfg_clks[] = {
2929
static const struct mtk_clk_desc mfg_desc = {
3030
.clks = mfg_clks,
3131
.num_clks = ARRAY_SIZE(mfg_clks),
32+
.need_runtime_pm = true,
3233
};
3334

3435
static const struct of_device_id of_match_clk_mt8183_mfg[] = {

drivers/clk/mediatek/clk-mtk.c

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -496,14 +496,16 @@ static int __mtk_clk_simple_probe(struct platform_device *pdev,
496496
}
497497

498498

499-
devm_pm_runtime_enable(&pdev->dev);
500-
/*
501-
* Do a pm_runtime_resume_and_get() to workaround a possible
502-
* deadlock between clk_register() and the genpd framework.
503-
*/
504-
r = pm_runtime_resume_and_get(&pdev->dev);
505-
if (r)
506-
return r;
499+
if (mcd->need_runtime_pm) {
500+
devm_pm_runtime_enable(&pdev->dev);
501+
/*
502+
* Do a pm_runtime_resume_and_get() to workaround a possible
503+
* deadlock between clk_register() and the genpd framework.
504+
*/
505+
r = pm_runtime_resume_and_get(&pdev->dev);
506+
if (r)
507+
return r;
508+
}
507509

508510
/* Calculate how many clk_hw_onecell_data entries to allocate */
509511
num_clks = mcd->num_clks + mcd->num_composite_clks;
@@ -585,7 +587,8 @@ static int __mtk_clk_simple_probe(struct platform_device *pdev,
585587
goto unregister_clks;
586588
}
587589

588-
pm_runtime_put(&pdev->dev);
590+
if (mcd->need_runtime_pm)
591+
pm_runtime_put(&pdev->dev);
589592

590593
return r;
591594

@@ -618,7 +621,8 @@ static int __mtk_clk_simple_probe(struct platform_device *pdev,
618621
if (mcd->shared_io && base)
619622
iounmap(base);
620623

621-
pm_runtime_put(&pdev->dev);
624+
if (mcd->need_runtime_pm)
625+
pm_runtime_put(&pdev->dev);
622626
return r;
623627
}
624628

drivers/clk/mediatek/clk-mtk.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,8 @@ struct mtk_clk_desc {
237237

238238
int (*clk_notifier_func)(struct device *dev, struct clk *clk);
239239
unsigned int mfg_clk_idx;
240+
241+
bool need_runtime_pm;
240242
};
241243

242244
int mtk_clk_pdev_probe(struct platform_device *pdev);

0 commit comments

Comments
 (0)