Skip to content

Commit

Permalink
clk: mediatek: mt8183: Only enable runtime PM on mt8183-mfgcfg
Browse files Browse the repository at this point in the history
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 <treapking@chromium.org>
Link: https://lore.kernel.org/r/20240613120357.1043342-1-treapking@chromium.org
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
  • Loading branch information
Pin-yen Lin authored and Stephen Boyd committed Jul 1, 2024
1 parent f7275fd commit 878e845
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
1 change: 1 addition & 0 deletions drivers/clk/mediatek/clk-mt8183-mfgcfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ static const struct mtk_gate mfg_clks[] = {
static const struct mtk_clk_desc mfg_desc = {
.clks = mfg_clks,
.num_clks = ARRAY_SIZE(mfg_clks),
.need_runtime_pm = true,
};

static const struct of_device_id of_match_clk_mt8183_mfg[] = {
Expand Down
24 changes: 14 additions & 10 deletions drivers/clk/mediatek/clk-mtk.c
Original file line number Diff line number Diff line change
Expand Up @@ -496,14 +496,16 @@ static int __mtk_clk_simple_probe(struct platform_device *pdev,
}


devm_pm_runtime_enable(&pdev->dev);
/*
* Do a pm_runtime_resume_and_get() to workaround a possible
* deadlock between clk_register() and the genpd framework.
*/
r = pm_runtime_resume_and_get(&pdev->dev);
if (r)
return r;
if (mcd->need_runtime_pm) {
devm_pm_runtime_enable(&pdev->dev);
/*
* Do a pm_runtime_resume_and_get() to workaround a possible
* deadlock between clk_register() and the genpd framework.
*/
r = pm_runtime_resume_and_get(&pdev->dev);
if (r)
return r;
}

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

pm_runtime_put(&pdev->dev);
if (mcd->need_runtime_pm)
pm_runtime_put(&pdev->dev);

return r;

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

pm_runtime_put(&pdev->dev);
if (mcd->need_runtime_pm)
pm_runtime_put(&pdev->dev);
return r;
}

Expand Down
2 changes: 2 additions & 0 deletions drivers/clk/mediatek/clk-mtk.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@ struct mtk_clk_desc {

int (*clk_notifier_func)(struct device *dev, struct clk *clk);
unsigned int mfg_clk_idx;

bool need_runtime_pm;
};

int mtk_clk_pdev_probe(struct platform_device *pdev);
Expand Down

0 comments on commit 878e845

Please sign in to comment.