Skip to contentSkip to conversation

cpufreq: ti: Fix probe ordering with k3-socinfo

PATCH In review Akashdeep Kaur 2 participants 3 messages Jun 3 CPU frequency scaling framework

lore
Share & tools
lore
#0 lore raw

v5 cover cpufreq: ti: Fix probe ordering with k3-socinfo

For K3 SoCs, ti-cpufreq depends on k3-socinfo to provide SoC revision information via soc_device_match(). If ti-cpufreq probes before k3-socinfo, soc_device_match() returns NULL, causing incorrect revision detection and OPP table initialization failures.

Add a needs_k3_socinfo flag to ti_cpufreq_soc_data to properly handle probe deferral when k3-socinfo hasn't registered the SoC device yet.

Changes in v5
- Use dev_err_probe() instead of dev_dbg() with updated error message
- Link to v4: https://lore.kernel.org/all/[email protected]/

Changes in v4
- Use needs_k3_socinfo flag in soc_data
- Link to v3: https://lore.kernel.org/all/[email protected]/

Changes in v3
- Simplified to single patch (EPROBE_DEFER only)
- Changed the logic to detect whether the probe is for am62 family SoCs
- Dropped device link patch after analysis as revision information is cached after successful probe. Module reload also works as k3-socinfo stays bound during normal operation
- Link to v2: https://lore.kernel.org/all/[email protected]/

Changes in v2
- Added DT bindings documentation for ti,soc-info property
- Reordered patches: bindings first, then driver changes, then DTS
- Link to v1: https://lore.kernel.org/all/[email protected]/

Testing
- Verified correct probe ordering on AM625, AM62A7, AM62P5 platforms

---

Akashdeep Kaur (1):
cpufreq: ti: Add EPROBE_DEFER for K3 SoCs

 drivers/cpufreq/ti-cpufreq.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

--
2.34.1

#1 lore raw

PATCH v5 1/1 cpufreq: ti: Add EPROBE_DEFER for K3 SoCs

On K3 SoCs, ti-cpufreq relies on k3-socinfo to register the SoC device before soc_device_match() can return valid revision information. If ti-cpufreq probes before k3-socinfo, soc_device_match() returns NULL, leading to incorrect CPU frequency scaling behavior.

Add a needs_k3_socinfo flag to ti_cpufreq_soc_data (similar to the existing multi_regulator pattern) to defer probe when k3-socinfo hasn't registered the SoC device yet.

---
 drivers/cpufreq/ti-cpufreq.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/cpufreq/ti-cpufreq.c +10 -0
index a01abc1622eb..f2c8d9e3a1b5 100644
@@ -99,6 +99,7 @@ struct ti_cpufreq_soc_data {
 	unsigned long efuse_shift;
 	unsigned long rev_offset;
 	bool multi_regulator;
+	bool needs_k3_socinfo;
 /* Backward compatibility hack: Might have missing syscon */
 #define TI_QUIRK_SYSCON_MAY_BE_MISSING	0x1
 /* Backward compatibility hack: new syscon size is 1 register wide */
@@ -347,6 +348,7 @@ static struct ti_cpufreq_soc_data am625_soc_data = {
 	.efuse_mask = 0x07c0,
 	.efuse_shift = 0x6,
 	.multi_regulator = false,
+	.needs_k3_socinfo = true,
 	.quirks = TI_QUIRK_SYSCON_IS_SINGLE_REG,
 };
 
@@ -356,6 +358,7 @@ static struct ti_cpufreq_soc_data am62a7_soc_data = {
 	.efuse_mask = 0x07c0,
 	.efuse_shift = 0x6,
 	.multi_regulator = false,
+	.needs_k3_socinfo = true,
 };
 
 static struct ti_cpufreq_soc_data am62l3_soc_data = {
@@ -364,6 +367,7 @@ static struct ti_cpufreq_soc_data am62l3_soc_data = {
 	.efuse_mask = 0x07c0,
 	.efuse_shift = 0x6,
 	.multi_regulator = false,
+	.needs_k3_socinfo = true,
 };
 
 static struct ti_cpufreq_soc_data am62p5_soc_data = {
@@ -372,6 +376,7 @@ static struct ti_cpufreq_soc_data am62p5_soc_data = {
 	.efuse_mask = 0x07c0,
 	.efuse_shift = 0x6,
 	.multi_regulator = false,
+	.needs_k3_socinfo = true,
 };
 
 /**
@@ -443,6 +448,11 @@ static int ti_cpufreq_get_rev(struct ti_cpufreq_data *opp_data,
 		goto done;
 	}
 
+	/* Defer if k3-socinfo hasn't registered the SoC device yet */
+	if (opp_data->soc_data->needs_k3_socinfo)
+		return dev_err_probe(opp_data->cpu_dev, -EPROBE_DEFER,
+				     "SoC device not registered by k3-socinfo\n");
+
 	ret = regmap_read(opp_data->syscon, opp_data->soc_data->rev_offset,
 			  &revision);
 	if (opp_data->soc_data->quirks & TI_QUIRK_SYSCON_MAY_BE_MISSING && ret == -EIO) {

--
2.34.1

Reviewed-by on v5 1/1
#2 lore raw

Re: [PATCH v5 1/1] cpufreq: ti: Add EPROBE_DEFER for K3 SoCs

Quoted 11 lines · Akashdeep Kaur

On K3 SoCs, ti-cpufreq relies on k3-socinfo to register the SoC device before soc_device_match() can return valid revision information. If ti-cpufreq probes before k3-socinfo, soc_device_match() returns NULL, leading to incorrect CPU frequency scaling behavior.

Add a needs_k3_socinfo flag to ti_cpufreq_soc_data (similar to the existing multi_regulator pattern) to defer probe when k3-socinfo hasn't registered the SoC device yet.

Looks good to me with small one nit inline.

Quoted 49 lines
---
  drivers/cpufreq/ti-cpufreq.c | 10 ++++++++++
  1 file changed, 10 insertions(+)
drivers/cpufreq/ti-cpufreq.c +5 -0
index a01abc1622eb..f2c8d9e3a1b5 100644
@@ -99,6 +99,7 @@ struct ti_cpufreq_soc_data {
  	unsigned long efuse_shift;
  	unsigned long rev_offset;
  	bool multi_regulator;
+	bool needs_k3_socinfo;
  /* Backward compatibility hack: Might have missing syscon */
  #define TI_QUIRK_SYSCON_MAY_BE_MISSING	0x1
  /* Backward compatibility hack: new syscon size is 1 register wide */
@@ -347,6 +348,7 @@ static struct ti_cpufreq_soc_data am625_soc_data = {
  	.efuse_mask = 0x07c0,
  	.efuse_shift = 0x6,
  	.multi_regulator = false,
+	.needs_k3_socinfo = true,
  	.quirks = TI_QUIRK_SYSCON_IS_SINGLE_REG,
  };
 
@@ -356,6 +358,7 @@ static struct ti_cpufreq_soc_data am62a7_soc_data = {
  	.efuse_mask = 0x07c0,
  	.efuse_shift = 0x6,
  	.multi_regulator = false,
+	.needs_k3_socinfo = true,
  };
 
  static struct ti_cpufreq_soc_data am62l3_soc_data = {
@@ -364,6 +367,7 @@ static struct ti_cpufreq_soc_data am62l3_soc_data = {
  	.efuse_mask = 0x07c0,
  	.efuse_shift = 0x6,
  	.multi_regulator = false,
+	.needs_k3_socinfo = true,
  };
 
  static struct ti_cpufreq_soc_data am62p5_soc_data = {
@@ -372,6 +376,7 @@ static struct ti_cpufreq_soc_data am62p5_soc_data = {
  	.efuse_mask = 0x07c0,
  	.efuse_shift = 0x6,
  	.multi_regulator = false,
+	.needs_k3_socinfo = true,
  };
 
  /**

drivers/cpufreq/ti-cpufreq.c static int ti_cpufreq_get_rev(struct ti_cpufreq_data *opp_data, · line 454

Quoted 7 lines
drivers/cpufreq/ti-cpufreq.c +4 -0
@@ -443,6 +448,11 @@ static int ti_cpufreq_get_rev(struct ti_cpufreq_data *opp_data,
  		goto done;
  	}
 
+	/* Defer if k3-socinfo hasn't registered the SoC device yet */
+	if (opp_data->soc_data->needs_k3_socinfo)
+		return dev_err_probe(opp_data->cpu_dev, -EPROBE_DEFER,
+				     "SoC device not registered by k3-socinfo\n");

Nit: dev_err_probe() attaches the defer reason to cpu_dev instead of the ti-cpufreq platform device, so devices_deferred won't show it, right

That said, this matches the existing pattern in ti_cpufreq_probe() where all dev_err/dev_dbg calls use opp_data->cpu_dev.

If so, maybe it could be cleaned up in a separate patch.

Quoted 7 lines
drivers/cpufreq/ti-cpufreq.c +1 -1
+
  	ret = regmap_read(opp_data->syscon, opp_data->soc_data->rev_offset,
  			  &revision);
  	if (opp_data->soc_data->quirks & TI_QUIRK_SYSCON_MAY_BE_MISSING && ret == -EIO) {
--

2.34.1

Signature · 2 lines
Thx and BRs,
Zhongqiu Han