Skip to contentSkip to conversation

Fixes for hang on MT8195-Tomato during mediatek-cpufreq-hw init

PATCH In review Nícolas F. R. A. Prado 4 participants 10 messages Jan 10, 2024 – Mar 1, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v2 cover Fixes for hang on MT8195-Tomato during mediatek-cpufreq-hw init

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(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH v2 1/2 arm64: dts: mediatek: cherry: Describe CPU supplies

Describe in each CPU node the regulator supplying it.

Fixes 260c04d425eb ("arm64: dts: mediatek: cherry: Enable MT6315 regulators on SPMI bus")

---

Changes in v2:
- Moved supplies to CPU nodes
- Added fixes tag

 .../boot/dts/mediatek/mt8195-cherry.dtsi      | 32 +++++++++++++++++++
 1 file changed, 32 insertions(+)
arch/arm64/boot/dts/mediatek/mt8195-cherry.dtsi +32 -0
index 3c6079edda19..1f3a6755f155 100644
@@ -264,6 +264,38 @@ &auxadc {
 	status = "okay";
 };
 
+&cpu0 {
+	cpu-supply = <&mt6359_vcore_buck_reg>;
+};
+
+&cpu1 {
+	cpu-supply = <&mt6359_vcore_buck_reg>;
+};
+
+&cpu2 {
+	cpu-supply = <&mt6359_vcore_buck_reg>;
+};
+
+&cpu3 {
+	cpu-supply = <&mt6359_vcore_buck_reg>;
+};
+
+&cpu4 {
+	cpu-supply = <&mt6315_6_vbuck1>;
+};
+
+&cpu5 {
+	cpu-supply = <&mt6315_6_vbuck1>;
+};
+
+&cpu6 {
+	cpu-supply = <&mt6315_6_vbuck1>;
+};
+
+&cpu7 {
+	cpu-supply = <&mt6315_6_vbuck1>;
+};
+
 &dp_intf0 {
 	status = "okay";
 
Signature · 1 line
2.43.0
#3 lore raw

Re: [PATCH v2 1/2] arm64: dts: mediatek: cherry: Describe CPU supplies

Quoted 8 lines · AngeloGioacchino Del Regno

Il 10/01/24 15:23, Nícolas F. R. A. Prado ha scritto:

Quoted 5 lines

Describe in each CPU node the regulator supplying it.

Fixes 260c04d425eb ("arm64: dts: mediatek: cherry: Enable MT6315 regulators on SPMI bus")

Hello,

looks like this patch was never picked up, while the cpufreq part has been merged for a while, so I'm still getting the mentioned hangs on linux-next. Could this be queued? :)

Thanks,
Nícolas

#4 lore raw

Re: [PATCH v2 1/2] arm64: dts: mediatek: cherry: Describe CPU supplies

Il 29/02/24 21:23, Nícolas F. R. A. Prado ha scritto:

Quoted 10 lines · AngeloGioacchino Del Regno
Quoted 8 lines

Il 10/01/24 15:23, Nícolas F. R. A. Prado ha scritto:

Quoted 5 lines

Describe in each CPU node the regulator supplying it.

Fixes 260c04d425eb ("arm64: dts: mediatek: cherry: Enable MT6315 regulators on SPMI bus")
Quoted 8 lines

Hello,

looks like this patch was never picked up, while the cpufreq part has been merged for a while, so I'm still getting the mentioned hangs on linux-next. Could this be queued? :)

Thanks,
Nícolas

Will send that on the next -fixes round.

Thanks for the reminder.

#5 lore raw

Re: [PATCH v2 1/2] arm64: dts: mediatek: cherry: Describe CPU supplies

In reply to Nícolas F. R. A. Prado

+CC Nicolas Dufresne <[email protected]>

As he told me he was experiencing the hangs fixed in this series too.

Quoted 60 lines · Nícolas F. R. A. Prado

Describe in each CPU node the regulator supplying it.

Fixes 260c04d425eb ("arm64: dts: mediatek: cherry: Enable MT6315 regulators on SPMI bus")

---

Changes in v2:
- Moved supplies to CPU nodes
- Added fixes tag

 .../boot/dts/mediatek/mt8195-cherry.dtsi      | 32 +++++++++++++++++++
 1 file changed, 32 insertions(+)
arch/arm64/boot/dts/mediatek/mt8195-cherry.dtsi +32 -0
index 3c6079edda19..1f3a6755f155 100644
@@ -264,6 +264,38 @@ &auxadc {
 	status = "okay";
 };
 
+&cpu0 {
+	cpu-supply = <&mt6359_vcore_buck_reg>;
+};
+
+&cpu1 {
+	cpu-supply = <&mt6359_vcore_buck_reg>;
+};
+
+&cpu2 {
+	cpu-supply = <&mt6359_vcore_buck_reg>;
+};
+
+&cpu3 {
+	cpu-supply = <&mt6359_vcore_buck_reg>;
+};
+
+&cpu4 {
+	cpu-supply = <&mt6315_6_vbuck1>;
+};
+
+&cpu5 {
+	cpu-supply = <&mt6315_6_vbuck1>;
+};
+
+&cpu6 {
+	cpu-supply = <&mt6315_6_vbuck1>;
+};
+
+&cpu7 {
+	cpu-supply = <&mt6315_6_vbuck1>;
+};
+
 &dp_intf0 {
 	status = "okay";
 
Signature · 1 line
2.43.0
#6 lore raw

PATCH v2 2/2 cpufreq: mediatek-hw: Wait for CPU supplies before probing

In reply to Nícolas F. R. A. Prado

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")

---

Changes in v2:
- Added this commit

 drivers/cpufreq/mediatek-cpufreq-hw.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
drivers/cpufreq/mediatek-cpufreq-hw.c +18 -1
index d46afb3c0092..a1aa9385980a 100644
@@ -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)
Signature · 1 line
2.43.0
maintainer Reviewed-by on v2 2/2
#7 lore raw

Re: [PATCH v2 2/2] cpufreq: mediatek-hw: Wait for CPU supplies before probing

Il 10/01/24 15:23, Nícolas F. R. A. Prado ha scritto:

Quoted 10 lines

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.

Quoted 3 lines
Fixes 4855e26bcf4d ("cpufreq: mediatek-hw: Add support for CPUFREQ HW")
maintainer Reviewed-by on v2 2/2
#8 lore raw

Re: [PATCH v2 2/2] cpufreq: mediatek-hw: Wait for CPU supplies before probing

In reply to Nícolas F. R. A. Prado
Quoted 10 lines · Nícolas F. R. A. Prado

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.

Quoted 2 lines
Fixes 4855e26bcf4d ("cpufreq: mediatek-hw: Add support for CPUFREQ HW")
Quoted 46 lines

---

Changes in v2:
- Added this commit

  drivers/cpufreq/mediatek-cpufreq-hw.c | 19 ++++++++++++++++++-
  1 file changed, 18 insertions(+), 1 deletion(-)
drivers/cpufreq/mediatek-cpufreq-hw.c +18 -1
index d46afb3c0092..a1aa9385980a 100644
@@ -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)
maintainer
#9 lore raw

Re: [PATCH v2 2/2] cpufreq: mediatek-hw: Wait for CPU supplies before probing

In reply to Nícolas F. R. A. Prado
Quoted 10 lines · Nícolas F. R. A. Prado

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.

Quoted 2 lines
Fixes 4855e26bcf4d ("cpufreq: mediatek-hw: Add support for CPUFREQ HW")

Applied 2/2. Thanks.

Signature · 1 line
viresh