Skip to contentSkip to conversation

cpufreq: intel_pstate: Override parameters if HWP forced by BIOS

PATCH Superseded Doug Smythies 4 participants 13 messages Sep 9, 2021 – Sep 10, 2021

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cpufreq: intel_pstate: Override parameters if HWP forced by BIOS

If HWP has been already been enabled by BIOS, it may be necessary to override some kernel command line parameters. Once it has been enabled it requires a reset to be disabled.

---
 drivers/cpufreq/intel_pstate.c | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)
drivers/cpufreq/intel_pstate.c +16 -6
index bb4549959b11..073bae5d4498 100644
@@ -3267,7 +3267,7 @@ static int __init intel_pstate_init(void)
 		 */
 		if ((!no_hwp && boot_cpu_has(X86_FEATURE_HWP_EPP)) ||
 		    intel_pstate_hwp_is_enabled()) {
-			hwp_active++;
+			hwp_active = 1;
 			hwp_mode_bdw = id->driver_data;
 			intel_pstate.attr = hwp_cpufreq_attrs;
 			intel_cpufreq.attr = hwp_cpufreq_attrs;
@@ -3347,17 +3347,27 @@ device_initcall(intel_pstate_init);
 
 static int __init intel_pstate_setup(char *str)
 {
+	/*
+	 * If BIOS is forcing HWP, then parameter
+	 * overrides might be needed. Only print
+	 * the message once, and regardless of
+	 * any overrides.
+	 */
+	if(!hwp_active && boot_cpu_has(X86_FEATURE_HWP))
+		if(intel_pstate_hwp_is_enabled()){
+			pr_info("HWP enabled by BIOS\n");
+			hwp_active = 1;
+		}
 	if (!str)
 		return -EINVAL;
 
-	if (!strcmp(str, "disable"))
+	if (!strcmp(str, "disable") && !hwp_active)
 		no_load = 1;
-	else if (!strcmp(str, "active"))
+	if (!strcmp(str, "active"))
 		default_driver = &intel_pstate;
-	else if (!strcmp(str, "passive"))
+	if (!strcmp(str, "passive"))
 		default_driver = &intel_cpufreq;
-
-	if (!strcmp(str, "no_hwp")) {
+	if (!strcmp(str, "no_hwp") && !hwp_active) {
 		pr_info("HWP disabled\n");
 		no_hwp = 1;
 	}
Signature · 1 line
2.25.1
#1 lore raw
Quoted 16 lines · Doug Smythies

If HWP has been already been enabled by BIOS, it may be necessary to override some kernel command line parameters. Once it has been enabled it requires a reset to be disabled.

---
 drivers/cpufreq/intel_pstate.c | 22 ++++++++++++++++------

 1 file changed, 16 insertions(+), 6 deletions(-)
drivers/cpufreq/intel_pstate.c +0 -0
index bb4549959b11..073bae5d4498 100644
@@ -3267,7 +3267,7 @@ static int __init intel_pstate_init(void)
                  */
Quoted 4 lines

                if ((!no_hwp && boot_cpu_has(X86_FEATURE_HWP_EPP)) || intel_pstate_hwp_is_enabled()) {
-                       hwp_active++;
+                       hwp_active = 1;

Why this change?

Quoted 6 lines

                        hwp_mode_bdw = id->driver_data; intel_pstate.attr = hwp_cpufreq_attrs; intel_cpufreq.attr = hwp_cpufreq_attrs;

drivers/cpufreq/intel_pstate.c +0 -0
@@ -3347,17 +3347,27 @@ device_initcall(intel_pstate_init);


 static int __init intel_pstate_setup(char *str)

Quoted 8 lines

 {
+       /*
+        * If BIOS is forcing HWP, then parameter
+        * overrides might be needed. Only print
+        * the message once, and regardless of
+        * any overrides.
+        */
+       if(!hwp_active

This part of code is from early_param, Is it possible that hwp_active is not 0?

Quoted 9 lines

&& boot_cpu_has(X86_FEATURE_HWP))
+               if(intel_pstate_hwp_is_enabled()){ +                       pr_info("HWP enabled by BIOS\n"); +                       hwp_active = 1;
+               }
        if (!str)
                return -EINVAL;

-       if (!strcmp(str, "disable"))

Quoted 8 lines

+       if (!strcmp(str, "disable") && !hwp_active) no_load = 1;
-       else if (!strcmp(str, "active"))
+       if (!strcmp(str, "active")) default_driver = &intel_pstate; -       else if (!strcmp(str, "passive"))
+       if (!strcmp(str, "passive")) default_driver = &intel_cpufreq;

Why "else if" changed to "if" ?

Thanks,
Srinivas

Quoted 6 lines

-
-       if (!strcmp(str, "no_hwp")) {
+       if (!strcmp(str, "no_hwp") && !hwp_active) { pr_info("HWP disabled\n"); no_hwp = 1;
        }

#2 lore raw
Quoted 11 lines · Srinivas Pandruvada
Quoted 9 lines · Doug Smythies

If HWP has been already been enabled by BIOS, it may be necessary to override some kernel command line parameters. Once it has been enabled it requires a reset to be disabled.

---
 drivers/cpufreq/intel_pstate.c | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)
Quoted 12 lines

drivers/cpufreq/intel_pstate.c static int __init intel_pstate_init(void) · line 3270

Quoted 11 lines
drivers/cpufreq/intel_pstate.c +1 -1
index bb4549959b11..073bae5d4498 100644
@@ -3267,7 +3267,7 @@ static int __init intel_pstate_init(void)
                 */
                if ((!no_hwp && boot_cpu_has(X86_FEATURE_HWP_EPP)) ||
                    intel_pstate_hwp_is_enabled()) {
-                       hwp_active++;
+                       hwp_active = 1;

Why this change?

I think hwp_active can be changed to bool and then it would make sense to update this line.

Quoted 5 lines
Quoted 5 lines
drivers/cpufreq/intel_pstate.c +0 -0
                        hwp_mode_bdw = id->driver_data;
                        intel_pstate.attr = hwp_cpufreq_attrs;
                        intel_cpufreq.attr = hwp_cpufreq_attrs;
@@ -3347,17 +3347,27 @@ device_initcall(intel_pstate_init);
 
Quoted 11 lines

drivers/cpufreq/intel_pstate.c device_initcall(intel_pstate_init);

Quoted 9 lines
drivers/cpufreq/intel_pstate.c +7 -0
 static int __init intel_pstate_setup(char *str)
 {
+       /*
+        * If BIOS is forcing HWP, then parameter
+        * overrides might be needed. Only print
+        * the message once, and regardless of
+        * any overrides.
+        */
+       if(!hwp_active

This part of code is from early_param, Is it possible that hwp_active is not 0?

Well, it wouldn't matter even if it were nonzero. This check is just pointless anyway.

Quoted 2 lines

drivers/cpufreq/intel_pstate.c device_initcall(intel_pstate_init); · line 3358

Quoted 2 lines
drivers/cpufreq/intel_pstate.c +1 -0
 && boot_cpu_has(X86_FEATURE_HWP))
+               if(intel_pstate_hwp_is_enabled()){

This should be

if (boot_cpu_has(X86_FEATURE_HWP) && intel_pstate_hwp_is_enabled()) {

Quoted 25 lines
Quoted 5 lines
drivers/cpufreq/intel_pstate.c +3 -0
+                       pr_info("HWP enabled by BIOS\n");
+                       hwp_active = 1;
+               }
        if (!str)
                return -EINVAL;

drivers/cpufreq/intel_pstate.c device_initcall(intel_pstate_init); · line 3369

Quoted 10 lines
drivers/cpufreq/intel_pstate.c +3 -3
 
-       if (!strcmp(str, "disable"))
+       if (!strcmp(str, "disable") && !hwp_active)
                no_load = 1;
-       else if (!strcmp(str, "active"))
+       if (!strcmp(str, "active"))
                default_driver = &intel_pstate;
-       else if (!strcmp(str, "passive"))
+       if (!strcmp(str, "passive"))
                default_driver = &intel_cpufreq;

Why "else if" changed to "if" ?

Quoted 6 lines
drivers/cpufreq/intel_pstate.c +1 -2
-
-       if (!strcmp(str, "no_hwp")) {
+       if (!strcmp(str, "no_hwp") && !hwp_active) {
                pr_info("HWP disabled\n");
                no_hwp = 1;
        }
#3 lore raw
Quoted 50 lines · Rafael J. Wysocki
Quoted 11 lines · Srinivas Pandruvada
Quoted 9 lines · Doug Smythies

If HWP has been already been enabled by BIOS, it may be necessary to override some kernel command line parameters. Once it has been enabled it requires a reset to be disabled.

---
 drivers/cpufreq/intel_pstate.c | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)
Quoted 12 lines

drivers/cpufreq/intel_pstate.c static int __init intel_pstate_init(void) · line 3270

Quoted 11 lines
drivers/cpufreq/intel_pstate.c +1 -1
index bb4549959b11..073bae5d4498 100644
@@ -3267,7 +3267,7 @@ static int __init intel_pstate_init(void)
                 */
                if ((!no_hwp && boot_cpu_has(X86_FEATURE_HWP_EPP)) ||
                    intel_pstate_hwp_is_enabled()) {
-                       hwp_active++;
+                       hwp_active = 1;

Why this change?

I think hwp_active can be changed to bool and then it would make sense to update this line.

Quoted 5 lines
Quoted 5 lines
drivers/cpufreq/intel_pstate.c +0 -0
                        hwp_mode_bdw = id->driver_data;
                        intel_pstate.attr = hwp_cpufreq_attrs;
                        intel_cpufreq.attr = hwp_cpufreq_attrs;
@@ -3347,17 +3347,27 @@ device_initcall(intel_pstate_init);
 
Quoted 11 lines

drivers/cpufreq/intel_pstate.c device_initcall(intel_pstate_init);

Quoted 9 lines
drivers/cpufreq/intel_pstate.c +7 -0
 static int __init intel_pstate_setup(char *str)
 {
+       /*
+        * If BIOS is forcing HWP, then parameter
+        * overrides might be needed. Only print
+        * the message once, and regardless of
+        * any overrides.
+        */
+       if(!hwp_active

This part of code is from early_param, Is it possible that hwp_active is not 0?

Well, it wouldn't matter even if it were nonzero. This check is just pointless anyway.

Quoted 6 lines
Quoted 2 lines

drivers/cpufreq/intel_pstate.c device_initcall(intel_pstate_init); · line 3358

Quoted 2 lines
drivers/cpufreq/intel_pstate.c +1 -0
 && boot_cpu_has(X86_FEATURE_HWP))
+               if(intel_pstate_hwp_is_enabled()){

This should be

if (boot_cpu_has(X86_FEATURE_HWP) && intel_pstate_hwp_is_enabled()) {

Disagree.
This routine gets executed once per intel_pstate related grub command line entry. The purpose of the "if(!hwp_active" part is to prevent the printing of the message to the logs multiple times.

Quoted 26 lines
Quoted 26 lines
Quoted 6 lines
drivers/cpufreq/intel_pstate.c +3 -0
+                       pr_info("HWP enabled by BIOS\n");
+                       hwp_active = 1;
+               }
        if (!str)
                return -EINVAL;

drivers/cpufreq/intel_pstate.c device_initcall(intel_pstate_init); · line 3369

Quoted 10 lines
drivers/cpufreq/intel_pstate.c +3 -3
 
-       if (!strcmp(str, "disable"))
+       if (!strcmp(str, "disable") && !hwp_active)
                no_load = 1;
-       else if (!strcmp(str, "active"))
+       if (!strcmp(str, "active"))
                default_driver = &intel_pstate;
-       else if (!strcmp(str, "passive"))
+       if (!strcmp(str, "passive"))
                default_driver = &intel_cpufreq;

Why "else if" changed to "if" ?

Quoted 6 lines
drivers/cpufreq/intel_pstate.c +1 -2
-
-       if (!strcmp(str, "no_hwp")) {
+       if (!strcmp(str, "no_hwp") && !hwp_active) {
                pr_info("HWP disabled\n");
                no_hwp = 1;
        }
#4 lore raw
Quoted 55 lines · Doug Smythies
Quoted 53 lines · Rafael J. Wysocki
Quoted 11 lines · Srinivas Pandruvada
Quoted 9 lines · Doug Smythies

If HWP has been already been enabled by BIOS, it may be necessary to override some kernel command line parameters. Once it has been enabled it requires a reset to be disabled.

---
 drivers/cpufreq/intel_pstate.c | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)
Quoted 12 lines

drivers/cpufreq/intel_pstate.c static int __init intel_pstate_init(void) · line 3270

Quoted 11 lines
drivers/cpufreq/intel_pstate.c +1 -1
index bb4549959b11..073bae5d4498 100644
@@ -3267,7 +3267,7 @@ static int __init intel_pstate_init(void)
                 */
                if ((!no_hwp && boot_cpu_has(X86_FEATURE_HWP_EPP)) ||
                    intel_pstate_hwp_is_enabled()) {
-                       hwp_active++;
+                       hwp_active = 1;

Why this change?

I think hwp_active can be changed to bool and then it would make sense to update this line.

Quoted 5 lines
Quoted 5 lines
drivers/cpufreq/intel_pstate.c +0 -0
                        hwp_mode_bdw = id->driver_data;
                        intel_pstate.attr = hwp_cpufreq_attrs;
                        intel_cpufreq.attr = hwp_cpufreq_attrs;
@@ -3347,17 +3347,27 @@ device_initcall(intel_pstate_init);
 
Quoted 11 lines

drivers/cpufreq/intel_pstate.c device_initcall(intel_pstate_init);

Quoted 9 lines
drivers/cpufreq/intel_pstate.c +7 -0
 static int __init intel_pstate_setup(char *str)
 {
+       /*
+        * If BIOS is forcing HWP, then parameter
+        * overrides might be needed. Only print
+        * the message once, and regardless of
+        * any overrides.
+        */
+       if(!hwp_active

This part of code is from early_param, Is it possible that hwp_active is not 0?

Well, it wouldn't matter even if it were nonzero. This check is just pointless anyway.

Quoted 2 lines
Quoted 2 lines
drivers/cpufreq/intel_pstate.c +1 -0
 && boot_cpu_has(X86_FEATURE_HWP))
+               if(intel_pstate_hwp_is_enabled()){
Quoted 8 lines
Quoted 3 lines

This should be

if (boot_cpu_has(X86_FEATURE_HWP) && intel_pstate_hwp_is_enabled()) {

Disagree.
This routine gets executed once per intel_pstate related grub command line entry. The purpose of the "if(!hwp_active" part is to prevent the printing of the message to the logs multiple times.

Ah OK. Fair enough.

You can do all of the checks in one conditional, though. They will be processed left-to-right anyway.

But then it would be good to avoid calling intel_pstate_hwp_is_enabled() multiple times if it returns false.

And having said all that I'm not sure why you are trying to make no_hwp depend on !hwp_active? I will not be taken into account anyway if intel_pstate_hwp_is_enabled() returns 'true'?

So if no_hwp is covered regardless, you may move the intel_pstate_hwp_is_enabled() inside the no_load conditional.

Alternatively, and I would do that, intel_pstate_hwp_is_enabled() could be evaluated earlier in intel_pstate_init() and if it returned 'true', both no_load and no_hwp would be disregarded.

#5 lore raw
Quoted 78 lines · Rafael J. Wysocki
Quoted 55 lines · Doug Smythies
Quoted 53 lines · Rafael J. Wysocki
Quoted 11 lines · Srinivas Pandruvada
Quoted 9 lines · Doug Smythies

If HWP has been already been enabled by BIOS, it may be necessary to override some kernel command line parameters. Once it has been enabled it requires a reset to be disabled.

---
 drivers/cpufreq/intel_pstate.c | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)
Quoted 12 lines

drivers/cpufreq/intel_pstate.c static int __init intel_pstate_init(void) · line 3270

Quoted 11 lines
drivers/cpufreq/intel_pstate.c +1 -1
index bb4549959b11..073bae5d4498 100644
@@ -3267,7 +3267,7 @@ static int __init intel_pstate_init(void)
                 */
                if ((!no_hwp && boot_cpu_has(X86_FEATURE_HWP_EPP)) ||
                    intel_pstate_hwp_is_enabled()) {
-                       hwp_active++;
+                       hwp_active = 1;

Why this change?

I think hwp_active can be changed to bool and then it would make sense to update this line.

Quoted 5 lines
Quoted 5 lines
drivers/cpufreq/intel_pstate.c +0 -0
                        hwp_mode_bdw = id->driver_data;
                        intel_pstate.attr = hwp_cpufreq_attrs;
                        intel_cpufreq.attr = hwp_cpufreq_attrs;
@@ -3347,17 +3347,27 @@ device_initcall(intel_pstate_init);
 
Quoted 11 lines

drivers/cpufreq/intel_pstate.c device_initcall(intel_pstate_init); · line 3356

Quoted 9 lines
drivers/cpufreq/intel_pstate.c +7 -0
 static int __init intel_pstate_setup(char *str)
 {
+       /*
+        * If BIOS is forcing HWP, then parameter
+        * overrides might be needed. Only print
+        * the message once, and regardless of
+        * any overrides.
+        */
+       if(!hwp_active

This part of code is from early_param, Is it possible that hwp_active is not 0?

Well, it wouldn't matter even if it were nonzero. This check is just pointless anyway.

Quoted 2 lines
Quoted 2 lines
drivers/cpufreq/intel_pstate.c +1 -0
 && boot_cpu_has(X86_FEATURE_HWP))
+               if(intel_pstate_hwp_is_enabled()){
Quoted 8 lines
Quoted 3 lines

This should be

if (boot_cpu_has(X86_FEATURE_HWP) && intel_pstate_hwp_is_enabled()) {

Disagree.
This routine gets executed once per intel_pstate related grub command line entry. The purpose of the "if(!hwp_active" part is to prevent the printing of the message to the logs multiple times.

Ah OK. Fair enough.

You can do all of the checks in one conditional, though. They will be processed left-to-right anyway.

But then it would be good to avoid calling intel_pstate_hwp_is_enabled() multiple times if it returns false.

And having said all that I'm not sure why you are trying to make no_hwp depend on !hwp_active? I will not be taken into account anyway if intel_pstate_hwp_is_enabled() returns 'true'?

Quoted 6 lines

So if no_hwp is covered regardless, you may move the intel_pstate_hwp_is_enabled() inside the no_load conditional.

Alternatively, and I would do that, intel_pstate_hwp_is_enabled() could be evaluated earlier in intel_pstate_init() and if it returned 'true', both no_load and no_hwp would be disregarded.

Something like the attached, for the record.

---
 drivers/cpufreq/intel_pstate.c |   16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/cpufreq/intel_pstate.c +11 -5
Index: linux-pm/drivers/cpufreq/intel_pstate.c
===================================================================
@@ -3205,11 +3205,15 @@ static int __init intel_pstate_init(void
 	if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL)
 		return -ENODEV;
 
-	if (no_load)
-		return -ENODEV;
-
 	id = x86_match_cpu(hwp_support_ids);
 	if (id) {
+		bool hwp_forced = intel_pstate_hwp_is_enabled();
+
+		if (hwp_forced)
+			pr_info("HWP enabled by BIOS\n");
+		else if (no_load)
+			return -ENODEV;
+
 		copy_cpu_funcs(&core_funcs);
 		/*
 		 * Avoid enabling HWP for processors without EPP support,
@@ -3219,8 +3223,7 @@ static int __init intel_pstate_init(void
 		 * If HWP is enabled already, though, there is no choice but to
 		 * deal with it.
 		 */
-		if ((!no_hwp && boot_cpu_has(X86_FEATURE_HWP_EPP)) ||
-		    intel_pstate_hwp_is_enabled()) {
+		if ((!no_hwp && boot_cpu_has(X86_FEATURE_HWP_EPP)) || hwp_forced) {
 			hwp_active++;
 			hwp_mode_bdw = id->driver_data;
 			intel_pstate.attr = hwp_cpufreq_attrs;
@@ -3236,6 +3239,9 @@ static int __init intel_pstate_init(void
 			goto hwp_cpu_matched;
 		}
 	} else {
+		if (no_load)
+			return -ENODEV;
+
 		id = x86_match_cpu(intel_pstate_cpu_ids);
 		if (!id) {
 			pr_info("CPU model not supported\n");
#6 lore raw
Quoted 76 lines · Rafael J. Wysocki
Quoted 75 lines · Rafael J. Wysocki
Quoted 53 lines · Doug Smythies
Quoted 52 lines · Rafael J. Wysocki
Quoted 11 lines · Srinivas Pandruvada
Quoted 9 lines · Doug Smythies

If HWP has been already been enabled by BIOS, it may be necessary to override some kernel command line parameters. Once it has been enabled it requires a reset to be disabled.

---
 drivers/cpufreq/intel_pstate.c | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)
Quoted 12 lines

drivers/cpufreq/intel_pstate.c static int __init intel_pstate_init(void) · line 3270

Quoted 11 lines
drivers/cpufreq/intel_pstate.c +1 -1
index bb4549959b11..073bae5d4498 100644
@@ -3267,7 +3267,7 @@ static int __init intel_pstate_init(void)
                 */
                if ((!no_hwp && boot_cpu_has(X86_FEATURE_HWP_EPP)) ||
                    intel_pstate_hwp_is_enabled()) {
-                       hwp_active++;
+                       hwp_active = 1;

Why this change?

I think hwp_active can be changed to bool and then it would make sense to update this line.

Quoted 5 lines
Quoted 5 lines
drivers/cpufreq/intel_pstate.c +0 -0
                        hwp_mode_bdw = id->driver_data;
                        intel_pstate.attr = hwp_cpufreq_attrs;
                        intel_cpufreq.attr = hwp_cpufreq_attrs;
@@ -3347,17 +3347,27 @@ device_initcall(intel_pstate_init);
 
Quoted 11 lines

drivers/cpufreq/intel_pstate.c device_initcall(intel_pstate_init); · line 3356

Quoted 9 lines
drivers/cpufreq/intel_pstate.c +7 -0
 static int __init intel_pstate_setup(char *str)
 {
+       /*
+        * If BIOS is forcing HWP, then parameter
+        * overrides might be needed. Only print
+        * the message once, and regardless of
+        * any overrides.
+        */
+       if(!hwp_active

This part of code is from early_param, Is it possible that hwp_active is not 0?

Well, it wouldn't matter even if it were nonzero. This check is just pointless anyway.

Quoted 2 lines
Quoted 2 lines
drivers/cpufreq/intel_pstate.c +1 -0
 && boot_cpu_has(X86_FEATURE_HWP))
+               if(intel_pstate_hwp_is_enabled()){
Quoted 8 lines
Quoted 3 lines

This should be

if (boot_cpu_has(X86_FEATURE_HWP) && intel_pstate_hwp_is_enabled()) {

Disagree.
This routine gets executed once per intel_pstate related grub command line entry. The purpose of the "if(!hwp_active" part is to prevent the printing of the message to the logs multiple times.

Ah OK. Fair enough.

You can do all of the checks in one conditional, though. They will be processed left-to-right anyway.

But then it would be good to avoid calling intel_pstate_hwp_is_enabled() multiple times if it returns false.

And having said all that I'm not sure why you are trying to make no_hwp depend on !hwp_active? I will not be taken into account anyway if intel_pstate_hwp_is_enabled() returns 'true'?

Quoted 8 lines
Quoted 6 lines

So if no_hwp is covered regardless, you may move the intel_pstate_hwp_is_enabled() inside the no_load conditional.

Alternatively, and I would do that, intel_pstate_hwp_is_enabled() could be evaluated earlier in intel_pstate_init() and if it returned 'true', both no_load and no_hwp would be disregarded.

Something like the attached, for the record.

O.K. and Thanks.
I was trying to avoid this line getting into the log:

[    0.000000] intel_pstate: HWP disabled

only to overridden later by, now, these lines:

[    0.373742] intel_pstate: HWP enabled by BIOS
[    0.374177] intel_pstate: Intel P-state driver initializing
[    0.375097] intel_pstate: HWP enabled

Let me see if I can go with your suggestion and get to what I had hoped to get in the logs.

By the way, my current command line options are:

[    0.000000] Command line:

BOOT_IMAGE=/boot/vmlinuz-5.14.0-ipstate9 root=UUID=0ac356c1-caa9-4c2e-8229-4408bd998dbd ro ipv6.disable=1 consoleblank=314 intel_pstate=force intel_pstate=active intel_pstate=no_hwp msr.allow_writes=on cpuidle.governor=teo

... Doug

#7 lore raw
Quoted 92 lines · Doug Smythies
Quoted 76 lines · Rafael J. Wysocki
Quoted 75 lines · Rafael J. Wysocki
Quoted 53 lines · Doug Smythies
Quoted 52 lines · Rafael J. Wysocki
Quoted 11 lines · Srinivas Pandruvada
Quoted 9 lines · Doug Smythies

If HWP has been already been enabled by BIOS, it may be necessary to override some kernel command line parameters. Once it has been enabled it requires a reset to be disabled.

---
 drivers/cpufreq/intel_pstate.c | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)
Quoted 12 lines

drivers/cpufreq/intel_pstate.c static int __init intel_pstate_init(void) · line 3270

Quoted 11 lines
drivers/cpufreq/intel_pstate.c +1 -1
index bb4549959b11..073bae5d4498 100644
@@ -3267,7 +3267,7 @@ static int __init intel_pstate_init(void)
                 */
                if ((!no_hwp && boot_cpu_has(X86_FEATURE_HWP_EPP)) ||
                    intel_pstate_hwp_is_enabled()) {
-                       hwp_active++;
+                       hwp_active = 1;

Why this change?

I think hwp_active can be changed to bool and then it would make sense to update this line.

Quoted 5 lines
Quoted 5 lines
drivers/cpufreq/intel_pstate.c +0 -0
                        hwp_mode_bdw = id->driver_data;
                        intel_pstate.attr = hwp_cpufreq_attrs;
                        intel_cpufreq.attr = hwp_cpufreq_attrs;
@@ -3347,17 +3347,27 @@ device_initcall(intel_pstate_init);
 
Quoted 11 lines

drivers/cpufreq/intel_pstate.c device_initcall(intel_pstate_init); · line 3356

Quoted 9 lines
drivers/cpufreq/intel_pstate.c +7 -0
 static int __init intel_pstate_setup(char *str)
 {
+       /*
+        * If BIOS is forcing HWP, then parameter
+        * overrides might be needed. Only print
+        * the message once, and regardless of
+        * any overrides.
+        */
+       if(!hwp_active

This part of code is from early_param, Is it possible that hwp_active is not 0?

Well, it wouldn't matter even if it were nonzero. This check is just pointless anyway.

Quoted 2 lines
Quoted 2 lines
drivers/cpufreq/intel_pstate.c +1 -0
 && boot_cpu_has(X86_FEATURE_HWP))
+               if(intel_pstate_hwp_is_enabled()){
Quoted 8 lines
Quoted 3 lines

This should be

if (boot_cpu_has(X86_FEATURE_HWP) && intel_pstate_hwp_is_enabled()) {

Disagree.
This routine gets executed once per intel_pstate related grub command line entry. The purpose of the "if(!hwp_active" part is to prevent the printing of the message to the logs multiple times.

Ah OK. Fair enough.

You can do all of the checks in one conditional, though. They will be processed left-to-right anyway.

But then it would be good to avoid calling intel_pstate_hwp_is_enabled() multiple times if it returns false.

And having said all that I'm not sure why you are trying to make no_hwp depend on !hwp_active? I will not be taken into account anyway if intel_pstate_hwp_is_enabled() returns 'true'?

Quoted 8 lines
Quoted 6 lines

So if no_hwp is covered regardless, you may move the intel_pstate_hwp_is_enabled() inside the no_load conditional.

Alternatively, and I would do that, intel_pstate_hwp_is_enabled() could be evaluated earlier in intel_pstate_init() and if it returned 'true', both no_load and no_hwp would be disregarded.

Something like the attached, for the record.

O.K. and Thanks.
I was trying to avoid this line getting into the log:

[    0.000000] intel_pstate: HWP disabled
Quoted 8 lines

only to overridden later by, now, these lines:

[    0.373742] intel_pstate: HWP enabled by BIOS
[    0.374177] intel_pstate: Intel P-state driver initializing
[    0.375097] intel_pstate: HWP enabled

Let me see if I can go with your suggestion and get to what I had hoped to get in the logs.

It would be sufficient to put the "disabled" printk() after the "no_hwp" if () statement in intel_pstate_init(). See attached.

BTW, I've changed the message to "HWP not enabled", because that's what really happens to be precise.

---
 drivers/cpufreq/intel_pstate.c |   22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)
drivers/cpufreq/intel_pstate.c +14 -8
Index: linux-pm/drivers/cpufreq/intel_pstate.c
===================================================================
@@ -3205,11 +3205,15 @@ static int __init intel_pstate_init(void
 	if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL)
 		return -ENODEV;
 
-	if (no_load)
-		return -ENODEV;
-
 	id = x86_match_cpu(hwp_support_ids);
 	if (id) {
+		bool hwp_forced = intel_pstate_hwp_is_enabled();
+
+		if (hwp_forced)
+			pr_info("HWP enabled by BIOS\n");
+		else if (no_load)
+			return -ENODEV;
+
 		copy_cpu_funcs(&core_funcs);
 		/*
 		 * Avoid enabling HWP for processors without EPP support,
@@ -3219,8 +3223,7 @@ static int __init intel_pstate_init(void
 		 * If HWP is enabled already, though, there is no choice but to
 		 * deal with it.
 		 */
-		if ((!no_hwp && boot_cpu_has(X86_FEATURE_HWP_EPP)) ||
-		    intel_pstate_hwp_is_enabled()) {
+		if ((!no_hwp && boot_cpu_has(X86_FEATURE_HWP_EPP)) || hwp_forced) {
 			hwp_active++;
 			hwp_mode_bdw = id->driver_data;
 			intel_pstate.attr = hwp_cpufreq_attrs;
@@ -3235,7 +3238,11 @@ static int __init intel_pstate_init(void
 
 			goto hwp_cpu_matched;
 		}
+		pr_info("HWP not enabled\n");
 	} else {
+		if (no_load)
+			return -ENODEV;
+
 		id = x86_match_cpu(intel_pstate_cpu_ids);
 		if (!id) {
 			pr_info("CPU model not supported\n");
@@ -3314,10 +3321,9 @@ static int __init intel_pstate_setup(cha
 	else if (!strcmp(str, "passive"))
 		default_driver = &intel_cpufreq;
 
-	if (!strcmp(str, "no_hwp")) {
-		pr_info("HWP disabled\n");
+	if (!strcmp(str, "no_hwp"))
 		no_hwp = 1;
-	}
+
 	if (!strcmp(str, "force"))
 		force_load = 1;
 	if (!strcmp(str, "hwp_only"))
#8 lore raw
Quoted 98 lines · Rafael J. Wysocki
Quoted 97 lines · Doug Smythies
Quoted 76 lines · Rafael J. Wysocki
Quoted 75 lines · Rafael J. Wysocki
Quoted 53 lines · Doug Smythies
Quoted 52 lines · Rafael J. Wysocki
Quoted 11 lines · Srinivas Pandruvada
Quoted 9 lines · Doug Smythies

If HWP has been already been enabled by BIOS, it may be necessary to override some kernel command line parameters. Once it has been enabled it requires a reset to be disabled.

---
 drivers/cpufreq/intel_pstate.c | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)
Quoted 12 lines

drivers/cpufreq/intel_pstate.c static int __init intel_pstate_init(void) · line 3270

Quoted 11 lines
drivers/cpufreq/intel_pstate.c +1 -1
index bb4549959b11..073bae5d4498 100644
@@ -3267,7 +3267,7 @@ static int __init intel_pstate_init(void)
                 */
                if ((!no_hwp && boot_cpu_has(X86_FEATURE_HWP_EPP)) ||
                    intel_pstate_hwp_is_enabled()) {
-                       hwp_active++;
+                       hwp_active = 1;

Why this change?

I think hwp_active can be changed to bool and then it would make sense to update this line.

Quoted 5 lines
Quoted 5 lines
drivers/cpufreq/intel_pstate.c +0 -0
                        hwp_mode_bdw = id->driver_data;
                        intel_pstate.attr = hwp_cpufreq_attrs;
                        intel_cpufreq.attr = hwp_cpufreq_attrs;
@@ -3347,17 +3347,27 @@ device_initcall(intel_pstate_init);
 
Quoted 11 lines

drivers/cpufreq/intel_pstate.c device_initcall(intel_pstate_init); · line 3356

Quoted 9 lines
drivers/cpufreq/intel_pstate.c +7 -0
 static int __init intel_pstate_setup(char *str)
 {
+       /*
+        * If BIOS is forcing HWP, then parameter
+        * overrides might be needed. Only print
+        * the message once, and regardless of
+        * any overrides.
+        */
+       if(!hwp_active

This part of code is from early_param, Is it possible that hwp_active is not 0?

Well, it wouldn't matter even if it were nonzero. This check is just pointless anyway.

Quoted 2 lines
Quoted 2 lines
drivers/cpufreq/intel_pstate.c +1 -0
 && boot_cpu_has(X86_FEATURE_HWP))
+               if(intel_pstate_hwp_is_enabled()){
Quoted 8 lines
Quoted 3 lines

This should be

if (boot_cpu_has(X86_FEATURE_HWP) && intel_pstate_hwp_is_enabled()) {

Disagree.
This routine gets executed once per intel_pstate related grub command line entry. The purpose of the "if(!hwp_active" part is to prevent the printing of the message to the logs multiple times.

Ah OK. Fair enough.

You can do all of the checks in one conditional, though. They will be processed left-to-right anyway.

But then it would be good to avoid calling intel_pstate_hwp_is_enabled() multiple times if it returns false.

And having said all that I'm not sure why you are trying to make no_hwp depend on !hwp_active? I will not be taken into account anyway if intel_pstate_hwp_is_enabled() returns 'true'?

Quoted 8 lines
Quoted 6 lines

So if no_hwp is covered regardless, you may move the intel_pstate_hwp_is_enabled() inside the no_load conditional.

Alternatively, and I would do that, intel_pstate_hwp_is_enabled() could be evaluated earlier in intel_pstate_init() and if it returned 'true', both no_load and no_hwp would be disregarded.

Something like the attached, for the record.

O.K. and Thanks.
I was trying to avoid this line getting into the log:

[    0.000000] intel_pstate: HWP disabled

only to overridden later by, now, these lines:

[    0.373742] intel_pstate: HWP enabled by BIOS
[    0.374177] intel_pstate: Intel P-state driver initializing
[    0.375097] intel_pstate: HWP enabled
Quoted 5 lines
Quoted 2 lines

Let me see if I can go with your suggestion and get to what I had hoped to get in the logs.

It would be sufficient to put the "disabled" printk() after the "no_hwp" if () statement in intel_pstate_init(). See attached.

Agreed, thanks. Yes, I was thinking similar.

Quoted 2 lines

BTW, I've changed the message to "HWP not enabled", because that's what really happens to be precise.

Agreed. Good idea.

Give me a fews days to create and test a formal patch. I currently have limited access to a computer that doesn't force HWP via BIOS.

... Doug

#9 lore raw
Quoted 106 lines · Doug Smythies
Quoted 98 lines · Rafael J. Wysocki
Quoted 97 lines · Doug Smythies
Quoted 76 lines · Rafael J. Wysocki
Quoted 75 lines · Rafael J. Wysocki
Quoted 53 lines · Doug Smythies
Quoted 52 lines · Rafael J. Wysocki
Quoted 11 lines · Srinivas Pandruvada
Quoted 9 lines · Doug Smythies

If HWP has been already been enabled by BIOS, it may be necessary to override some kernel command line parameters. Once it has been enabled it requires a reset to be disabled.

---
 drivers/cpufreq/intel_pstate.c | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)
Quoted 12 lines

drivers/cpufreq/intel_pstate.c static int __init intel_pstate_init(void) · line 3270

Quoted 11 lines
drivers/cpufreq/intel_pstate.c +1 -1
index bb4549959b11..073bae5d4498 100644
@@ -3267,7 +3267,7 @@ static int __init intel_pstate_init(void)
                 */
                if ((!no_hwp && boot_cpu_has(X86_FEATURE_HWP_EPP)) ||
                    intel_pstate_hwp_is_enabled()) {
-                       hwp_active++;
+                       hwp_active = 1;

Why this change?

I think hwp_active can be changed to bool and then it would make sense to update this line.

Quoted 5 lines
Quoted 5 lines
drivers/cpufreq/intel_pstate.c +0 -0
                        hwp_mode_bdw = id->driver_data;
                        intel_pstate.attr = hwp_cpufreq_attrs;
                        intel_cpufreq.attr = hwp_cpufreq_attrs;
@@ -3347,17 +3347,27 @@ device_initcall(intel_pstate_init);
 
Quoted 11 lines

drivers/cpufreq/intel_pstate.c device_initcall(intel_pstate_init); · line 3356

Quoted 9 lines
drivers/cpufreq/intel_pstate.c +7 -0
 static int __init intel_pstate_setup(char *str)
 {
+       /*
+        * If BIOS is forcing HWP, then parameter
+        * overrides might be needed. Only print
+        * the message once, and regardless of
+        * any overrides.
+        */
+       if(!hwp_active

This part of code is from early_param, Is it possible that hwp_active is not 0?

Well, it wouldn't matter even if it were nonzero. This check is just pointless anyway.

Quoted 2 lines
Quoted 2 lines
drivers/cpufreq/intel_pstate.c +1 -0
 && boot_cpu_has(X86_FEATURE_HWP))
+               if(intel_pstate_hwp_is_enabled()){
Quoted 8 lines
Quoted 3 lines

This should be

if (boot_cpu_has(X86_FEATURE_HWP) && intel_pstate_hwp_is_enabled()) {

Disagree.
This routine gets executed once per intel_pstate related grub command line entry. The purpose of the "if(!hwp_active" part is to prevent the printing of the message to the logs multiple times.

Ah OK. Fair enough.

You can do all of the checks in one conditional, though. They will be processed left-to-right anyway.

But then it would be good to avoid calling intel_pstate_hwp_is_enabled() multiple times if it returns false.

And having said all that I'm not sure why you are trying to make no_hwp depend on !hwp_active? I will not be taken into account anyway if intel_pstate_hwp_is_enabled() returns 'true'?

Quoted 8 lines
Quoted 6 lines

So if no_hwp is covered regardless, you may move the intel_pstate_hwp_is_enabled() inside the no_load conditional.

Alternatively, and I would do that, intel_pstate_hwp_is_enabled() could be evaluated earlier in intel_pstate_init() and if it returned 'true', both no_load and no_hwp would be disregarded.

Something like the attached, for the record.

O.K. and Thanks.
I was trying to avoid this line getting into the log:

[    0.000000] intel_pstate: HWP disabled

only to overridden later by, now, these lines:

[    0.373742] intel_pstate: HWP enabled by BIOS
[    0.374177] intel_pstate: Intel P-state driver initializing
[    0.375097] intel_pstate: HWP enabled
Quoted 5 lines
Quoted 2 lines

Let me see if I can go with your suggestion and get to what I had hoped to get in the logs.

It would be sufficient to put the "disabled" printk() after the "no_hwp" if () statement in intel_pstate_init(). See attached.

Quoted 8 lines

Agreed, thanks. Yes, I was thinking similar.

Quoted 2 lines

BTW, I've changed the message to "HWP not enabled", because that's what really happens to be precise.

Agreed. Good idea.

Give me a fews days to create and test a formal patch.

OK

Quoted 2 lines

I currently have limited access to a computer that doesn't force HWP via BIOS.

#10 lore raw
In reply to Srinivas Pandruvada
Quoted 11 lines · Srinivas Pandruvada
Quoted 9 lines · Doug Smythies

If HWP has been already been enabled by BIOS, it may be necessary to override some kernel command line parameters. Once it has been enabled it requires a reset to be disabled.

---
 drivers/cpufreq/intel_pstate.c | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)
Quoted 12 lines

drivers/cpufreq/intel_pstate.c static int __init intel_pstate_init(void) · line 3270

Quoted 11 lines
drivers/cpufreq/intel_pstate.c +1 -1
index bb4549959b11..073bae5d4498 100644
@@ -3267,7 +3267,7 @@ static int __init intel_pstate_init(void)
                 */
                if ((!no_hwp && boot_cpu_has(X86_FEATURE_HWP_EPP)) ||
                    intel_pstate_hwp_is_enabled()) {
-                       hwp_active++;
+                       hwp_active = 1;

Why this change?

It was just to keep it at 1, but I agree not absolutely needed.

Quoted 6 lines
Quoted 6 lines
drivers/cpufreq/intel_pstate.c +0 -0
                        hwp_mode_bdw = id->driver_data;
                        intel_pstate.attr = hwp_cpufreq_attrs;
                        intel_cpufreq.attr = hwp_cpufreq_attrs;
@@ -3347,17 +3347,27 @@ device_initcall(intel_pstate_init);
 
Quoted 11 lines

drivers/cpufreq/intel_pstate.c device_initcall(intel_pstate_init);

Quoted 9 lines
drivers/cpufreq/intel_pstate.c +7 -0
 static int __init intel_pstate_setup(char *str)
 {
+       /*
+        * If BIOS is forcing HWP, then parameter
+        * overrides might be needed. Only print
+        * the message once, and regardless of
+        * any overrides.
+        */
+       if(!hwp_active

This part of code is from early_param, Is it possible that hwp_active is not 0?

Not at this point, in any testing I did. But I do not know the authoritative answer to your question.

Quoted 19 lines
Quoted 8 lines
drivers/cpufreq/intel_pstate.c +4 -0
 && boot_cpu_has(X86_FEATURE_HWP))
+               if(intel_pstate_hwp_is_enabled()){
+                       pr_info("HWP enabled by BIOS\n");
+                       hwp_active = 1;
+               }
        if (!str)
                return -EINVAL;

drivers/cpufreq/intel_pstate.c device_initcall(intel_pstate_init); · line 3369

Quoted 10 lines
drivers/cpufreq/intel_pstate.c +3 -3
 
-       if (!strcmp(str, "disable"))
+       if (!strcmp(str, "disable") && !hwp_active)
                no_load = 1;
-       else if (!strcmp(str, "active"))
+       if (!strcmp(str, "active"))
                default_driver = &intel_pstate;
-       else if (!strcmp(str, "passive"))
+       if (!strcmp(str, "passive"))
                default_driver = &intel_cpufreq;
Quoted 1 line

Why "else if" changed to "if" ?

Because it doesn't matter anyway and I would have had to figure out another qualifier. This way, and given that this executes once per intel_pstate command line parameter, the code executes the way it used to, overall.

Quoted 13 lines

Thanks,
Srinivas

Quoted 6 lines
drivers/cpufreq/intel_pstate.c +1 -2
-
-       if (!strcmp(str, "no_hwp")) {
+       if (!strcmp(str, "no_hwp") && !hwp_active) {
                pr_info("HWP disabled\n");
                no_hwp = 1;
        }
#11 lore raw
Quoted 47 lines · Doug Smythies
Quoted 11 lines · Srinivas Pandruvada
Quoted 9 lines · Doug Smythies

If HWP has been already been enabled by BIOS, it may be necessary to override some kernel command line parameters. Once it has been enabled it requires a reset to be disabled.

---
 drivers/cpufreq/intel_pstate.c | 22 ++++++++++++++++------

 1 file changed, 16 insertions(+), 6 deletions(-)
Quoted 13 lines
Quoted 7 lines
drivers/cpufreq/intel_pstate.c +0 -0
index bb4549959b11..073bae5d4498 100644
@@ -3267,7 +3267,7 @@ static int __init intel_pstate_init(void)
                  */
Quoted 5 lines

                if ((!no_hwp && boot_cpu_has(X86_FEATURE_HWP_EPP)) || intel_pstate_hwp_is_enabled()) { -                       hwp_active++;
+                       hwp_active = 1;

Why this change?

It was just to keep it at 1, but I agree not absolutely needed.

Quoted 6 lines
Quoted 6 lines

                        hwp_mode_bdw = id->driver_data; intel_pstate.attr = hwp_cpufreq_attrs; intel_cpufreq.attr = hwp_cpufreq_attrs;

drivers/cpufreq/intel_pstate.c +0 -0
@@ -3347,17 +3347,27 @@ device_initcall(intel_pstate_init);
 
Quoted 11 lines

drivers/cpufreq/intel_pstate.c device_initcall(intel_pstate_init);

Quoted 9 lines
drivers/cpufreq/intel_pstate.c +7 -0
  static int __init intel_pstate_setup(char *str)
  {
+       /*
+        * If BIOS is forcing HWP, then parameter
+        * overrides might be needed. Only print
+        * the message once, and regardless of
+        * any overrides.
+        */
+       if(!hwp_active

This part of code is from early_param, Is it possible that hwp_active is not 0?

Quoted 4 lines

Not at this point, in any testing I did. But I do not know the authoritative answer to your question.

But as you explained you want to prevent repeated print of "HWP enabled by BIOS". So you need this.

Quoted 19 lines
Quoted 19 lines
Quoted 18 lines
drivers/cpufreq/intel_pstate.c +7 -3
 && boot_cpu_has(X86_FEATURE_HWP))
+               if(intel_pstate_hwp_is_enabled()){
+                       pr_info("HWP enabled by BIOS\n");
+                       hwp_active = 1;
+               }
         if (!str)
                 return -EINVAL;
 
-       if (!strcmp(str, "disable"))
+       if (!strcmp(str, "disable") && !hwp_active)
                 no_load = 1;
-       else if (!strcmp(str, "active"))
+       if (!strcmp(str, "active"))
                 default_driver = &intel_pstate;
-       else if (!strcmp(str, "passive"))
+       if (!strcmp(str, "passive"))
                 default_driver = &intel_cpufreq;
Quoted 7 lines
Quoted 1 line

Why "else if" changed to "if" ?

Because it doesn't matter anyway and I would have had to figure out another qualifier. This way, and given that this executes once per intel_pstate command line parameter, the code executes the way it used to, overall.

If someone specified intel_pstate=active, it will also compare with "passive" with this change.

Thanks,
Srinivas

Quoted 14 lines
Quoted 14 lines

Thanks,
Srinivas

Quoted 6 lines
drivers/cpufreq/intel_pstate.c +1 -2
-
-       if (!strcmp(str, "no_hwp")) {
+       if (!strcmp(str, "no_hwp") && !hwp_active) {
                 pr_info("HWP disabled\n");
                 no_hwp = 1;

        }

#12 lore raw
Quoted 76 lines · Srinivas Pandruvada
Quoted 47 lines · Doug Smythies
Quoted 11 lines · Srinivas Pandruvada
Quoted 9 lines · Doug Smythies

If HWP has been already been enabled by BIOS, it may be necessary to override some kernel command line parameters. Once it has been enabled it requires a reset to be disabled.

---
 drivers/cpufreq/intel_pstate.c | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)
Quoted 13 lines

drivers/cpufreq/intel_pstate.c static int __init intel_pstate_init(void) · line 3270

Quoted 12 lines
drivers/cpufreq/intel_pstate.c +0 -0
index bb4549959b11..073bae5d4498 100644
@@ -3267,7 +3267,7 @@ static int __init intel_pstate_init(void)
                 */
                if ((!no_hwp &&

boot_cpu_has(X86_FEATURE_HWP_EPP)) ||

                    intel_pstate_hwp_is_enabled()) {
drivers/cpufreq/intel_pstate.c +1 -1
-                       hwp_active++;
+                       hwp_active = 1;

Why this change?

It was just to keep it at 1, but I agree not absolutely needed.

Quoted 6 lines
Quoted 6 lines
                        hwp_mode_bdw = id->driver_data;
                        intel_pstate.attr = hwp_cpufreq_attrs;
                        intel_cpufreq.attr = hwp_cpufreq_attrs;
drivers/cpufreq/intel_pstate.c +0 -0
@@ -3347,17 +3347,27 @@ device_initcall(intel_pstate_init);
 
Quoted 11 lines

drivers/cpufreq/intel_pstate.c device_initcall(intel_pstate_init);

Quoted 9 lines
drivers/cpufreq/intel_pstate.c +7 -0
 static int __init intel_pstate_setup(char *str)
 {
+       /*
+        * If BIOS is forcing HWP, then parameter
+        * overrides might be needed. Only print
+        * the message once, and regardless of
+        * any overrides.
+        */
+       if(!hwp_active

This part of code is from early_param, Is it possible that hwp_active is not 0?

Quoted 4 lines

Not at this point, in any testing I did. But I do not know the authoritative answer to your question.

But as you explained you want to prevent repeated print of "HWP enabled by BIOS". So you need this.

Quoted 21 lines
Quoted 20 lines
Quoted 8 lines
drivers/cpufreq/intel_pstate.c +4 -0
 && boot_cpu_has(X86_FEATURE_HWP))
+               if(intel_pstate_hwp_is_enabled()){
+                       pr_info("HWP enabled by BIOS\n");
+                       hwp_active = 1;
+               }
        if (!str)
                return -EINVAL;

drivers/cpufreq/intel_pstate.c device_initcall(intel_pstate_init); · line 3369

Quoted 10 lines
drivers/cpufreq/intel_pstate.c +3 -3
 
-       if (!strcmp(str, "disable"))
+       if (!strcmp(str, "disable") && !hwp_active)
                no_load = 1;
-       else if (!strcmp(str, "active"))
+       if (!strcmp(str, "active"))
                default_driver = &intel_pstate;
-       else if (!strcmp(str, "passive"))
+       if (!strcmp(str, "passive"))
                default_driver = &intel_cpufreq;

Why "else if" changed to "if" ?

Quoted 7 lines
Quoted 5 lines

Because it doesn't matter anyway and I would have had to figure out another qualifier. This way, and given that this executes once per intel_pstate command line parameter, the code executes the way it used to, overall.

If someone specified intel_pstate=active, it will also compare with "passive" with this change.

Disagree.
As far as I can tell, and I tested, it works as expected.

... Doug

Quoted 10 lines
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
drivers/cpufreq/intel_pstate.c +1 -2
-
-       if (!strcmp(str, "no_hwp")) {
+       if (!strcmp(str, "no_hwp") && !hwp_active) {
                pr_info("HWP disabled\n");
                no_hwp = 1;
        }