Skip to content

Commit 2f7b1d8

Browse files
Pin-yen Linbebarino
authored andcommitted
clk: mediatek: Do a runtime PM get on controllers during probe
mt8183-mfgcfg has a mutual dependency with genpd during the probing stage, which leads to a deadlock in the following call stack: CPU0: genpd_lock --> clk_prepare_lock genpd_power_off_work_fn() genpd_lock() generic_pm_domain::power_off() clk_unprepare() clk_prepare_lock() CPU1: clk_prepare_lock --> genpd_lock clk_register() __clk_core_init() clk_prepare_lock() clk_pm_runtime_get() genpd_lock() Do a runtime PM get at the probe function to make sure clk_register() won't acquire the genpd lock. Instead of only modifying mt8183-mfgcfg, do this on all mediatek clock controller probings because we don't believe this would cause any regression. Verified on MT8183 and MT8192 Chromebooks. Fixes: acddfc2 ("clk: mediatek: Add MT8183 clock support") Signed-off-by: Pin-yen Lin <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: AngeloGioacchino Del Regno <[email protected]> Tested-by: AngeloGioacchino Del Regno <[email protected]> Signed-off-by: Stephen Boyd <[email protected]>
1 parent 754e528 commit 2f7b1d8

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

drivers/clk/mediatek/clk-mtk.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <linux/of.h>
1414
#include <linux/of_address.h>
1515
#include <linux/platform_device.h>
16+
#include <linux/pm_runtime.h>
1617
#include <linux/slab.h>
1718

1819
#include "clk-mtk.h"
@@ -494,6 +495,16 @@ static int __mtk_clk_simple_probe(struct platform_device *pdev,
494495
return IS_ERR(base) ? PTR_ERR(base) : -ENOMEM;
495496
}
496497

498+
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;
507+
497508
/* Calculate how many clk_hw_onecell_data entries to allocate */
498509
num_clks = mcd->num_clks + mcd->num_composite_clks;
499510
num_clks += mcd->num_fixed_clks + mcd->num_factor_clks;
@@ -574,6 +585,8 @@ static int __mtk_clk_simple_probe(struct platform_device *pdev,
574585
goto unregister_clks;
575586
}
576587

588+
pm_runtime_put(&pdev->dev);
589+
577590
return r;
578591

579592
unregister_clks:
@@ -604,6 +617,8 @@ static int __mtk_clk_simple_probe(struct platform_device *pdev,
604617
free_base:
605618
if (mcd->shared_io && base)
606619
iounmap(base);
620+
621+
pm_runtime_put(&pdev->dev);
607622
return r;
608623
}
609624

0 commit comments

Comments
 (0)