Skip to contentSkip to conversation

cpufreq/amd-pstate: Prefix setup messages with FW_BUG

PATCH In review Mario Limonciello 2 participants 3 messages Mar 20, 2025 – Apr 2, 2025

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

PATCH 1/1 cpufreq/amd-pstate: Prefix setup messages with FW_BUG

From: Mario Limonciello <[email protected]>

To make it clearer that amd-pstate failing to setup is a problem with the firmware, prefix several messages with FW_BUG.

---
 drivers/cpufreq/amd-pstate.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/cpufreq/amd-pstate.c +3 -3
index 024d33d5e3670..0a9d6fe426d1c 100644
@@ -931,13 +931,13 @@ static int amd_pstate_init_freq(struct amd_cpudata *cpudata)
 	 * Check _CPC in ACPI table objects if any values are incorrect
 	 */
 	if (min_freq <= 0 || max_freq <= 0 || nominal_freq <= 0 || min_freq > max_freq) {
-		pr_err("min_freq(%d) or max_freq(%d) or nominal_freq(%d) value is incorrect\n",
+		pr_err(FW_BUG "min_freq(%d) or max_freq(%d) or nominal_freq(%d) value is incorrect\n",
 			min_freq, max_freq, nominal_freq);
 		return -EINVAL;
 	}
 
 	if (lowest_nonlinear_freq <= min_freq || lowest_nonlinear_freq > nominal_freq) {
-		pr_err("lowest_nonlinear_freq(%d) value is out of range [min_freq(%d), nominal_freq(%d)]\n",
+		pr_err(FW_BUG "lowest_nonlinear_freq(%d) value is out of range [min_freq(%d), nominal_freq(%d)]\n",
 			lowest_nonlinear_freq, min_freq, nominal_freq);
 		return -EINVAL;
 	}
@@ -1505,7 +1505,7 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy)
 	return 0;
 
 free_cpudata1:
-	pr_warn("Failed to initialize CPU %d: %d\n", policy->cpu, ret);
+	pr_warn(FW_BUG "Failed to initialize CPU %d: %d\n", policy->cpu, ret);
 	kfree(cpudata);
 	return ret;
 }
Signature · 1 line
2.43.0
#1 lore raw
Quoted 32 lines · Mario Limonciello

From: Mario Limonciello <[email protected]>

To make it clearer that amd-pstate failing to setup is a problem with the firmware, prefix several messages with FW_BUG.

---
 drivers/cpufreq/amd-pstate.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/cpufreq/amd-pstate.c +2 -2
index 024d33d5e3670..0a9d6fe426d1c 100644
@@ -931,13 +931,13 @@ static int amd_pstate_init_freq(struct amd_cpudata *cpudata)
 	 * Check _CPC in ACPI table objects if any values are incorrect
 	 */
 	if (min_freq <= 0 || max_freq <= 0 || nominal_freq <= 0 || min_freq > max_freq) {
-		pr_err("min_freq(%d) or max_freq(%d) or nominal_freq(%d) value is incorrect\n",
+		pr_err(FW_BUG "min_freq(%d) or max_freq(%d) or nominal_freq(%d) value is incorrect\n",
 			min_freq, max_freq, nominal_freq);
 		return -EINVAL;
 	}
 
 	if (lowest_nonlinear_freq <= min_freq || lowest_nonlinear_freq > nominal_freq) {
-		pr_err("lowest_nonlinear_freq(%d) value is out of range [min_freq(%d), nominal_freq(%d)]\n",
+		pr_err(FW_BUG "lowest_nonlinear_freq(%d) value is out of range [min_freq(%d), nominal_freq(%d)]\n",
 			lowest_nonlinear_freq, min_freq, nominal_freq);
 		return -EINVAL;
 	}

drivers/cpufreq/amd-pstate.c static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy) · line 1508

Quoted 5 lines
drivers/cpufreq/amd-pstate.c +1 -1
@@ -1505,7 +1505,7 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy)
 	return 0;
 
 free_cpudata1:
-	pr_warn("Failed to initialize CPU %d: %d\n", policy->cpu, ret);
+	pr_warn(FW_BUG "Failed to initialize CPU %d: %d\n", policy->cpu, ret);

Just thinking are we sure that we land here only through a firmware bug?

If not, we should probably use FW_WARN ?,
or
Should we add to the error message the specific firmware issue that might cause each of the functions to fail (e.g. amd_pstate_init_perf(), amd_pstate_init_freq(), etc).

Comments for the macros, for reference,

* FW_BUG
* Add this to a message where you are sure the firmware is buggy or behaves
* really stupid or out of spec. Be aware that the responsible BIOS developer
* should be able to fix this issue or at least get a concrete idea of the
* problem by reading your message without the need of looking at the kernel
* code.
*
* Use it for definite and high priority BIOS bugs.
*
* FW_WARN
* Use it for not that clear (e.g. could the kernel messed up things already?)
* and medium priority BIOS bugs.

Quoted 3 lines
drivers/cpufreq/amd-pstate.c +0 -0
 	kfree(cpudata);
 	return ret;
 }
#2 lore raw
Quoted 41 lines · Dhananjay Ugwekar
Quoted 32 lines · Mario Limonciello

From: Mario Limonciello <[email protected]>

To make it clearer that amd-pstate failing to setup is a problem with the firmware, prefix several messages with FW_BUG.

---
  drivers/cpufreq/amd-pstate.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
drivers/cpufreq/amd-pstate.c +2 -2
index 024d33d5e3670..0a9d6fe426d1c 100644
@@ -931,13 +931,13 @@ static int amd_pstate_init_freq(struct amd_cpudata *cpudata)
  	 * Check _CPC in ACPI table objects if any values are incorrect
  	 */
  	if (min_freq <= 0 || max_freq <= 0 || nominal_freq <= 0 || min_freq > max_freq) {
-		pr_err("min_freq(%d) or max_freq(%d) or nominal_freq(%d) value is incorrect\n",
+		pr_err(FW_BUG "min_freq(%d) or max_freq(%d) or nominal_freq(%d) value is incorrect\n",
  			min_freq, max_freq, nominal_freq);
  		return -EINVAL;
  	}
 
  	if (lowest_nonlinear_freq <= min_freq || lowest_nonlinear_freq > nominal_freq) {
-		pr_err("lowest_nonlinear_freq(%d) value is out of range [min_freq(%d), nominal_freq(%d)]\n",
+		pr_err(FW_BUG "lowest_nonlinear_freq(%d) value is out of range [min_freq(%d), nominal_freq(%d)]\n",
  			lowest_nonlinear_freq, min_freq, nominal_freq);
  		return -EINVAL;
  	}

drivers/cpufreq/amd-pstate.c static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy) · line 1508

Quoted 5 lines
drivers/cpufreq/amd-pstate.c +1 -1
@@ -1505,7 +1505,7 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy)
  	return 0;
 
  free_cpudata1:
-	pr_warn("Failed to initialize CPU %d: %d\n", policy->cpu, ret);
+	pr_warn(FW_BUG "Failed to initialize CPU %d: %d\n", policy->cpu, ret);

Just thinking are we sure that we land here only through a firmware bug?

Quoted 5 lines

If not, we should probably use FW_WARN ?,
or
Should we add to the error message the specific firmware issue that might cause each of the functions to fail (e.g. amd_pstate_init_perf(), amd_pstate_init_freq(), etc).

I looked at the call paths and I'm not convinced that they will all be firmware bugs. In any case I want to know whenever there is a failure here so we can evaluate if it's a firmware bug or a software bug.

If it's a software bug we'll obviously work on it, and if it's a firmware bug do our best to notify the firmware developer.

So I will abandon this patch, thanks for the great feedback.

Quoted 20 lines

Comments for the macros, for reference,

* FW_BUG
* Add this to a message where you are sure the firmware is buggy or behaves
* really stupid or out of spec. Be aware that the responsible BIOS developer
* should be able to fix this issue or at least get a concrete idea of the
* problem by reading your message without the need of looking at the kernel
* code.
*
* Use it for definite and high priority BIOS bugs.
*
* FW_WARN
* Use it for not that clear (e.g. could the kernel messed up things already?)
* and medium priority BIOS bugs.

Quoted 3 lines
drivers/cpufreq/amd-pstate.c +0 -0
  	kfree(cpudata);
  	return ret;
  }