linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] Correct the processing for base_frequency
@ 2019-03-25 16:04 Srinivas Pandruvada
  2019-03-25 16:04 ` [PATCH v2 1/2] ACPI / CPPC: Fix processing for guaranteed performance Srinivas Pandruvada
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Srinivas Pandruvada @ 2019-03-25 16:04 UTC (permalink / raw)
  To: rjw, lenb, viresh.kumar
  Cc: linux-acpi, linux-kernel, linux-pm, pprakash, wangxiongfeng2,
	srinivas.pandruvada

The base_frequency display in cpufreq sysfs for intel_pstate gets the
guaranteed ratio by reading CPPC guaranteed performance register as a
first preference before falling back to x86 MSR for Hardware P-state
Capabilities. The current code in cppc_acpi.c assumed that "guaranteed
performance register" can be an integer field, which is invalid as per
ACPI spec. So this change explicitly check for INTEGER values for
invalid BIOS/firmware and ignore. 
Also guaranteed performance register field is optional and when not
present, nominal performance can be used as the guaranteed performance.
But spec calls that this is true only in non-autonomous mode. So
no change is made in cppc_acpi.c to make nominal as guaranteed in this
case to avoid dependency on autonomous and non-autonomous mode. Instead
a change is added to intel_pstate driver, which is specific to x86 to
make nominal as guaranteed when guaranteed performance field is absent
or has invalid value.
Also we are working to clarify this non-autonomous mode requirement
through ACPI standard body.

v2:
Changes done as suggested by Rafael.


Srinivas Pandruvada (2):
  ACPI / CPPC: Fix processing for guaranteed performance
  cpufreq: intel_pstate: Also use cppc nominal_perf for base_frequency

 drivers/acpi/cppc_acpi.c       | 9 +++++++--
 drivers/cpufreq/intel_pstate.c | 5 ++++-
 2 files changed, 11 insertions(+), 3 deletions(-)

-- 
2.17.2


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 1/2] ACPI / CPPC: Fix processing for guaranteed performance
  2019-03-25 16:04 [PATCH v2 0/2] Correct the processing for base_frequency Srinivas Pandruvada
@ 2019-03-25 16:04 ` Srinivas Pandruvada
  2019-03-25 16:04 ` [PATCH v2 2/2] cpufreq: intel_pstate: Also use cppc nominal_perf for base_frequency Srinivas Pandruvada
  2019-03-26 11:38 ` [PATCH v2 0/2] Correct the processing " Rafael J. Wysocki
  2 siblings, 0 replies; 4+ messages in thread
From: Srinivas Pandruvada @ 2019-03-25 16:04 UTC (permalink / raw)
  To: rjw, lenb, viresh.kumar
  Cc: linux-acpi, linux-kernel, linux-pm, pprakash, wangxiongfeng2,
	srinivas.pandruvada

As per ACPI specification "Guaranteed Performance Register" is a "Buffer"
field. It can't be "Integer" field. So treat "Integer" type as invalid and
ignore "Guaranteed Performance Register".
Also save one cpc_read() call, when "Guaranteed Performance Register" is
not present, which means register defined as:
"Register(SystemMemory, 0, 0, 0, 0)".

Fixes: 29523f095397 ("ACPI / CPPC: Add support for guaranteed performance")
Suggested-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: 4.20+ <stable@vger.kernel.org> # 4.20+
---
 drivers/acpi/cppc_acpi.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
index 1b207fca1420..d4244e7d0e38 100644
--- a/drivers/acpi/cppc_acpi.c
+++ b/drivers/acpi/cppc_acpi.c
@@ -1150,8 +1150,13 @@ int cppc_get_perf_caps(int cpunum, struct cppc_perf_caps *perf_caps)
 	cpc_read(cpunum, nominal_reg, &nom);
 	perf_caps->nominal_perf = nom;
 
-	cpc_read(cpunum, guaranteed_reg, &guaranteed);
-	perf_caps->guaranteed_perf = guaranteed;
+	if (guaranteed_reg->type != ACPI_TYPE_BUFFER  ||
+	    IS_NULL_REG(&guaranteed_reg->cpc_entry.reg)) {
+		perf_caps->guaranteed_perf = 0;
+	} else {
+		cpc_read(cpunum, guaranteed_reg, &guaranteed);
+		perf_caps->guaranteed_perf = guaranteed;
+	}
 
 	cpc_read(cpunum, lowest_non_linear_reg, &min_nonlinear);
 	perf_caps->lowest_nonlinear_perf = min_nonlinear;
-- 
2.17.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 2/2] cpufreq: intel_pstate: Also use cppc nominal_perf for base_frequency
  2019-03-25 16:04 [PATCH v2 0/2] Correct the processing for base_frequency Srinivas Pandruvada
  2019-03-25 16:04 ` [PATCH v2 1/2] ACPI / CPPC: Fix processing for guaranteed performance Srinivas Pandruvada
@ 2019-03-25 16:04 ` Srinivas Pandruvada
  2019-03-26 11:38 ` [PATCH v2 0/2] Correct the processing " Rafael J. Wysocki
  2 siblings, 0 replies; 4+ messages in thread
From: Srinivas Pandruvada @ 2019-03-25 16:04 UTC (permalink / raw)
  To: rjw, lenb, viresh.kumar
  Cc: linux-acpi, linux-kernel, linux-pm, pprakash, wangxiongfeng2,
	srinivas.pandruvada

ACPI specifications stat that if the "Guaranteed Performance Register" is
not implemented, OSPM assumes guaranteed performance is always equal to
nominal performance. So for invalid and unimplemented guaranteed
performance register, use nominal performance as guaranteed performance.

This change will fallback to nominal_perf when guranteed_perf is invalid.
If nominal_perf is also invalid, then fallback to existing implementation,
which is to read from HWP Capabilities MSR.

Fixes: 86d333a8cc7f ("cpufreq: intel_pstate: Add base_frequency attribute")
Suggested-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: 4.20+ <stable@vger.kernel.org> # 4.20+
---
 drivers/cpufreq/intel_pstate.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index e22f0dbaebb1..b599c7318aab 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -385,7 +385,10 @@ static int intel_pstate_get_cppc_guranteed(int cpu)
 	if (ret)
 		return ret;
 
-	return cppc_perf.guaranteed_perf;
+	if (cppc_perf.guaranteed_perf)
+		return cppc_perf.guaranteed_perf;
+
+	return cppc_perf.nominal_perf;
 }
 
 #else /* CONFIG_ACPI_CPPC_LIB */
-- 
2.17.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 0/2] Correct the processing for base_frequency
  2019-03-25 16:04 [PATCH v2 0/2] Correct the processing for base_frequency Srinivas Pandruvada
  2019-03-25 16:04 ` [PATCH v2 1/2] ACPI / CPPC: Fix processing for guaranteed performance Srinivas Pandruvada
  2019-03-25 16:04 ` [PATCH v2 2/2] cpufreq: intel_pstate: Also use cppc nominal_perf for base_frequency Srinivas Pandruvada
@ 2019-03-26 11:38 ` Rafael J. Wysocki
  2 siblings, 0 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2019-03-26 11:38 UTC (permalink / raw)
  To: Srinivas Pandruvada
  Cc: lenb, viresh.kumar, linux-acpi, linux-kernel, linux-pm, pprakash,
	wangxiongfeng2

On Monday, March 25, 2019 5:04:38 PM CET Srinivas Pandruvada wrote:
> The base_frequency display in cpufreq sysfs for intel_pstate gets the
> guaranteed ratio by reading CPPC guaranteed performance register as a
> first preference before falling back to x86 MSR for Hardware P-state
> Capabilities. The current code in cppc_acpi.c assumed that "guaranteed
> performance register" can be an integer field, which is invalid as per
> ACPI spec. So this change explicitly check for INTEGER values for
> invalid BIOS/firmware and ignore. 
> Also guaranteed performance register field is optional and when not
> present, nominal performance can be used as the guaranteed performance.
> But spec calls that this is true only in non-autonomous mode. So
> no change is made in cppc_acpi.c to make nominal as guaranteed in this
> case to avoid dependency on autonomous and non-autonomous mode. Instead
> a change is added to intel_pstate driver, which is specific to x86 to
> make nominal as guaranteed when guaranteed performance field is absent
> or has invalid value.
> Also we are working to clarify this non-autonomous mode requirement
> through ACPI standard body.
> 
> v2:
> Changes done as suggested by Rafael.
> 
> 
> Srinivas Pandruvada (2):
>   ACPI / CPPC: Fix processing for guaranteed performance
>   cpufreq: intel_pstate: Also use cppc nominal_perf for base_frequency
> 
>  drivers/acpi/cppc_acpi.c       | 9 +++++++--
>  drivers/cpufreq/intel_pstate.c | 5 ++++-
>  2 files changed, 11 insertions(+), 3 deletions(-)
> 
> 

Both applied, thanks!



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-03-26 11:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-25 16:04 [PATCH v2 0/2] Correct the processing for base_frequency Srinivas Pandruvada
2019-03-25 16:04 ` [PATCH v2 1/2] ACPI / CPPC: Fix processing for guaranteed performance Srinivas Pandruvada
2019-03-25 16:04 ` [PATCH v2 2/2] cpufreq: intel_pstate: Also use cppc nominal_perf for base_frequency Srinivas Pandruvada
2019-03-26 11:38 ` [PATCH v2 0/2] Correct the processing " Rafael J. Wysocki

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