Skip to content

Commit 788715b

Browse files
nfrapradovireshk
authored andcommitted
cpufreq: mediatek-hw: Wait for CPU supplies before probing
Before proceeding with the probe and enabling frequency scaling for the CPUs, make sure that all supplies feeding the CPUs have probed. This fixes an issue observed on MT8195-Tomato where if the mediatek-cpufreq-hw driver enabled the hardware (by writing to REG_FREQ_ENABLE) before the SPMI controller driver (spmi-mtk-pmif), behind which lies the big CPU supply, probed the platform would hang shortly after with "rcu: INFO: rcu_preempt detected stalls on CPUs/tasks" being printed in the log. Fixes: 4855e26 ("cpufreq: mediatek-hw: Add support for CPUFREQ HW") Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
1 parent f661017 commit 788715b

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

drivers/cpufreq/mediatek-cpufreq-hw.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <linux/of.h>
1414
#include <linux/of_platform.h>
1515
#include <linux/platform_device.h>
16+
#include <linux/regulator/consumer.h>
1617
#include <linux/slab.h>
1718

1819
#define LUT_MAX_ENTRIES 32U
@@ -300,7 +301,23 @@ static struct cpufreq_driver cpufreq_mtk_hw_driver = {
300301
static int mtk_cpufreq_hw_driver_probe(struct platform_device *pdev)
301302
{
302303
const void *data;
303-
int ret;
304+
int ret, cpu;
305+
struct device *cpu_dev;
306+
struct regulator *cpu_reg;
307+
308+
/* Make sure that all CPU supplies are available before proceeding. */
309+
for_each_possible_cpu(cpu) {
310+
cpu_dev = get_cpu_device(cpu);
311+
if (!cpu_dev)
312+
return dev_err_probe(&pdev->dev, -EPROBE_DEFER,
313+
"Failed to get cpu%d device\n", cpu);
314+
315+
cpu_reg = devm_regulator_get_optional(cpu_dev, "cpu");
316+
if (IS_ERR(cpu_reg))
317+
return dev_err_probe(&pdev->dev, PTR_ERR(cpu_reg),
318+
"CPU%d regulator get failed\n", cpu);
319+
}
320+
304321

305322
data = of_device_get_match_data(&pdev->dev);
306323
if (!data)

0 commit comments

Comments
 (0)