* [PATCH v2 0/2] Fixes for hang on MT8195-Tomato during mediatek-cpufreq-hw init
@ 2024-01-10 14:23 Nícolas F. R. A. Prado
2024-01-10 14:23 ` [PATCH v2 2/2] cpufreq: mediatek-hw: Wait for CPU supplies before probing Nícolas F. R. A. Prado
0 siblings, 1 reply; 5+ messages in thread
From: Nícolas F. R. A. Prado @ 2024-01-10 14:23 UTC (permalink / raw)
To: Viresh Kumar, Rafael J . Wysocki, AngeloGioacchino Del Regno,
Matthias Brugger
Cc: kernel, Nícolas F. R. A. Prado, Conor Dooley, Hector.Yuan,
Krzysztof Kozlowski, Liam Girdwood, Mark Brown, Rob Herring,
devicetree, linux-arm-kernel, linux-kernel, linux-mediatek,
linux-pm
These two patches fix 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.
Changes in v2:
- Moved supply phandles to CPU nodes in DT
- Added fixes tags
- Added patch to verify CPU supplies are available before proceeding in
the mediatek-cpufreq-hw driver
Nícolas F. R. A. Prado (2):
arm64: dts: mediatek: cherry: Describe CPU supplies
cpufreq: mediatek-hw: Wait for CPU supplies before probing
.../boot/dts/mediatek/mt8195-cherry.dtsi | 32 +++++++++++++++++++
drivers/cpufreq/mediatek-cpufreq-hw.c | 19 ++++++++++-
2 files changed, 50 insertions(+), 1 deletion(-)
--
2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 2/2] cpufreq: mediatek-hw: Wait for CPU supplies before probing
2024-01-10 14:23 [PATCH v2 0/2] Fixes for hang on MT8195-Tomato during mediatek-cpufreq-hw init Nícolas F. R. A. Prado
@ 2024-01-10 14:23 ` Nícolas F. R. A. Prado
2024-01-10 14:31 ` AngeloGioacchino Del Regno
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Nícolas F. R. A. Prado @ 2024-01-10 14:23 UTC (permalink / raw)
To: Viresh Kumar, Rafael J . Wysocki, AngeloGioacchino Del Regno,
Matthias Brugger
Cc: kernel, Nícolas F. R. A. Prado, Hector.Yuan, Liam Girdwood,
Mark Brown, linux-arm-kernel, linux-kernel, linux-mediatek,
linux-pm
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: 4855e26bcf4d ("cpufreq: mediatek-hw: Add support for CPUFREQ HW")
Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
Changes in v2:
- Added this commit
drivers/cpufreq/mediatek-cpufreq-hw.c | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/drivers/cpufreq/mediatek-cpufreq-hw.c b/drivers/cpufreq/mediatek-cpufreq-hw.c
index d46afb3c0092..a1aa9385980a 100644
--- a/drivers/cpufreq/mediatek-cpufreq-hw.c
+++ b/drivers/cpufreq/mediatek-cpufreq-hw.c
@@ -13,6 +13,7 @@
#include <linux/of.h>
#include <linux/of_platform.h>
#include <linux/platform_device.h>
+#include <linux/regulator/consumer.h>
#include <linux/slab.h>
#define LUT_MAX_ENTRIES 32U
@@ -300,7 +301,23 @@ static struct cpufreq_driver cpufreq_mtk_hw_driver = {
static int mtk_cpufreq_hw_driver_probe(struct platform_device *pdev)
{
const void *data;
- int ret;
+ int ret, cpu;
+ struct device *cpu_dev;
+ struct regulator *cpu_reg;
+
+ /* Make sure that all CPU supplies are available before proceeding. */
+ for_each_possible_cpu(cpu) {
+ cpu_dev = get_cpu_device(cpu);
+ if (!cpu_dev)
+ return dev_err_probe(&pdev->dev, -EPROBE_DEFER,
+ "Failed to get cpu%d device\n", cpu);
+
+ cpu_reg = devm_regulator_get_optional(cpu_dev, "cpu");
+ if (IS_ERR(cpu_reg))
+ return dev_err_probe(&pdev->dev, PTR_ERR(cpu_reg),
+ "CPU%d regulator get failed\n", cpu);
+ }
+
data = of_device_get_match_data(&pdev->dev);
if (!data)
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 2/2] cpufreq: mediatek-hw: Wait for CPU supplies before probing
2024-01-10 14:23 ` [PATCH v2 2/2] cpufreq: mediatek-hw: Wait for CPU supplies before probing Nícolas F. R. A. Prado
@ 2024-01-10 14:31 ` AngeloGioacchino Del Regno
2024-01-22 8:38 ` Matthias Brugger
2024-01-23 6:09 ` Viresh Kumar
2 siblings, 0 replies; 5+ messages in thread
From: AngeloGioacchino Del Regno @ 2024-01-10 14:31 UTC (permalink / raw)
To: Nícolas F. R. A. Prado, Viresh Kumar, Rafael J . Wysocki,
Matthias Brugger
Cc: kernel, Hector.Yuan, Liam Girdwood, Mark Brown, linux-arm-kernel,
linux-kernel, linux-mediatek, linux-pm
Il 10/01/24 15:23, Nícolas F. R. A. Prado ha scritto:
> 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: 4855e26bcf4d ("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>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 2/2] cpufreq: mediatek-hw: Wait for CPU supplies before probing
2024-01-10 14:23 ` [PATCH v2 2/2] cpufreq: mediatek-hw: Wait for CPU supplies before probing Nícolas F. R. A. Prado
2024-01-10 14:31 ` AngeloGioacchino Del Regno
@ 2024-01-22 8:38 ` Matthias Brugger
2024-01-23 6:09 ` Viresh Kumar
2 siblings, 0 replies; 5+ messages in thread
From: Matthias Brugger @ 2024-01-22 8:38 UTC (permalink / raw)
To: Nícolas F. R. A. Prado, Viresh Kumar, Rafael J . Wysocki,
AngeloGioacchino Del Regno
Cc: kernel, Hector.Yuan, Liam Girdwood, Mark Brown, linux-arm-kernel,
linux-kernel, linux-mediatek, linux-pm
On 10/01/2024 15:23, Nícolas F. R. A. Prado wrote:
> 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: 4855e26bcf4d ("cpufreq: mediatek-hw: Add support for CPUFREQ HW")
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>
>
> ---
>
> Changes in v2:
> - Added this commit
>
> drivers/cpufreq/mediatek-cpufreq-hw.c | 19 ++++++++++++++++++-
> 1 file changed, 18 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/cpufreq/mediatek-cpufreq-hw.c b/drivers/cpufreq/mediatek-cpufreq-hw.c
> index d46afb3c0092..a1aa9385980a 100644
> --- a/drivers/cpufreq/mediatek-cpufreq-hw.c
> +++ b/drivers/cpufreq/mediatek-cpufreq-hw.c
> @@ -13,6 +13,7 @@
> #include <linux/of.h>
> #include <linux/of_platform.h>
> #include <linux/platform_device.h>
> +#include <linux/regulator/consumer.h>
> #include <linux/slab.h>
>
> #define LUT_MAX_ENTRIES 32U
> @@ -300,7 +301,23 @@ static struct cpufreq_driver cpufreq_mtk_hw_driver = {
> static int mtk_cpufreq_hw_driver_probe(struct platform_device *pdev)
> {
> const void *data;
> - int ret;
> + int ret, cpu;
> + struct device *cpu_dev;
> + struct regulator *cpu_reg;
> +
> + /* Make sure that all CPU supplies are available before proceeding. */
> + for_each_possible_cpu(cpu) {
> + cpu_dev = get_cpu_device(cpu);
> + if (!cpu_dev)
> + return dev_err_probe(&pdev->dev, -EPROBE_DEFER,
> + "Failed to get cpu%d device\n", cpu);
> +
> + cpu_reg = devm_regulator_get_optional(cpu_dev, "cpu");
> + if (IS_ERR(cpu_reg))
> + return dev_err_probe(&pdev->dev, PTR_ERR(cpu_reg),
> + "CPU%d regulator get failed\n", cpu);
> + }
> +
>
> data = of_device_get_match_data(&pdev->dev);
> if (!data)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 2/2] cpufreq: mediatek-hw: Wait for CPU supplies before probing
2024-01-10 14:23 ` [PATCH v2 2/2] cpufreq: mediatek-hw: Wait for CPU supplies before probing Nícolas F. R. A. Prado
2024-01-10 14:31 ` AngeloGioacchino Del Regno
2024-01-22 8:38 ` Matthias Brugger
@ 2024-01-23 6:09 ` Viresh Kumar
2 siblings, 0 replies; 5+ messages in thread
From: Viresh Kumar @ 2024-01-23 6:09 UTC (permalink / raw)
To: Nícolas F. R. A. Prado
Cc: Rafael J . Wysocki, AngeloGioacchino Del Regno, Matthias Brugger,
kernel, Hector.Yuan, Liam Girdwood, Mark Brown, linux-arm-kernel,
linux-kernel, linux-mediatek, linux-pm
On 10-01-24, 11:23, Nícolas F. R. A. Prado wrote:
> 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: 4855e26bcf4d ("cpufreq: mediatek-hw: Add support for CPUFREQ HW")
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
Applied 2/2. Thanks.
--
viresh
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-01-23 6:09 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-10 14:23 [PATCH v2 0/2] Fixes for hang on MT8195-Tomato during mediatek-cpufreq-hw init Nícolas F. R. A. Prado
2024-01-10 14:23 ` [PATCH v2 2/2] cpufreq: mediatek-hw: Wait for CPU supplies before probing Nícolas F. R. A. Prado
2024-01-10 14:31 ` AngeloGioacchino Del Regno
2024-01-22 8:38 ` Matthias Brugger
2024-01-23 6:09 ` Viresh Kumar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).