stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] ACPI / CPPC: Fix processing for guaranteed performance
       [not found] <20190322224520.6740-1-srinivas.pandruvada@linux.intel.com>
@ 2019-03-22 22:45 ` Srinivas Pandruvada
  2019-03-25 11:49   ` Rafael J. Wysocki
  2019-03-22 22:45 ` [PATCH 2/2] cpufreq: intel_pstate: Also use cppc nominal_perf for base_frequency Srinivas Pandruvada
  1 sibling, 1 reply; 4+ messages in thread
From: Srinivas Pandruvada @ 2019-03-22 22:45 UTC (permalink / raw)
  To: rjw, lenb, viresh.kumar
  Cc: linux-acpi, linux-kernel, linux-pm, pprakash, wangxiongfeng2,
	Srinivas Pandruvada, 4 . 20+

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")
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: 4.20+ <stable@vger.kernel.org> # 4.20+
---
 drivers/acpi/cppc_acpi.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
index 1b207fca1420..3f6c290e06af 100644
--- a/drivers/acpi/cppc_acpi.c
+++ b/drivers/acpi/cppc_acpi.c
@@ -1150,8 +1150,14 @@ 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_INTEGER  ||
+	    (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 2/2] cpufreq: intel_pstate: Also use cppc nominal_perf for base_frequency
       [not found] <20190322224520.6740-1-srinivas.pandruvada@linux.intel.com>
  2019-03-22 22:45 ` [PATCH 1/2] ACPI / CPPC: Fix processing for guaranteed performance Srinivas Pandruvada
@ 2019-03-22 22:45 ` Srinivas Pandruvada
  2019-03-25 12:04   ` Rafael J. Wysocki
  1 sibling, 1 reply; 4+ messages in thread
From: Srinivas Pandruvada @ 2019-03-22 22:45 UTC (permalink / raw)
  To: rjw, lenb, viresh.kumar
  Cc: linux-acpi, linux-kernel, linux-pm, pprakash, wangxiongfeng2,
	Srinivas Pandruvada, 4 . 20+

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")
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: 4.20+ <stable@vger.kernel.org> # 4.20+
---
 drivers/cpufreq/intel_pstate.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index 7b4b0a7ac68b..e16dea241c55 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -385,6 +385,9 @@ static int intel_pstate_get_cppc_guranteed(int cpu)
 	if (ret)
 		return ret;
 
+	if (!cppc_perf.guaranteed_perf)
+		return cppc_perf.nominal_perf;
+
 	return cppc_perf.guaranteed_perf;
 }
 
-- 
2.17.2


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

* Re: [PATCH 1/2] ACPI / CPPC: Fix processing for guaranteed performance
  2019-03-22 22:45 ` [PATCH 1/2] ACPI / CPPC: Fix processing for guaranteed performance Srinivas Pandruvada
@ 2019-03-25 11:49   ` Rafael J. Wysocki
  0 siblings, 0 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2019-03-25 11:49 UTC (permalink / raw)
  To: Srinivas Pandruvada
  Cc: Rafael J. Wysocki, Len Brown, Viresh Kumar,
	ACPI Devel Maling List, Linux Kernel Mailing List, Linux PM,
	Prashanth Prakash, Xiongfeng Wang, 4 . 20+

On Fri, Mar 22, 2019 at 11:45 PM Srinivas Pandruvada
<srinivas.pandruvada@linux.intel.com> wrote:
>
> 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")
> Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> Cc: 4.20+ <stable@vger.kernel.org> # 4.20+
> ---
>  drivers/acpi/cppc_acpi.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
> index 1b207fca1420..3f6c290e06af 100644
> --- a/drivers/acpi/cppc_acpi.c
> +++ b/drivers/acpi/cppc_acpi.c
> @@ -1150,8 +1150,14 @@ 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_INTEGER  ||
> +           (guaranteed_reg->type == ACPI_TYPE_BUFFER &&
> +            IS_NULL_REG(&guaranteed_reg->cpc_entry.reg))) {

AFAICS anything different from a buffer should be rejected here, so
why don't you do

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	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] cpufreq: intel_pstate: Also use cppc nominal_perf for base_frequency
  2019-03-22 22:45 ` [PATCH 2/2] cpufreq: intel_pstate: Also use cppc nominal_perf for base_frequency Srinivas Pandruvada
@ 2019-03-25 12:04   ` Rafael J. Wysocki
  0 siblings, 0 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2019-03-25 12:04 UTC (permalink / raw)
  To: Srinivas Pandruvada
  Cc: Rafael J. Wysocki, Len Brown, Viresh Kumar,
	ACPI Devel Maling List, Linux Kernel Mailing List, Linux PM,
	Prashanth Prakash, Xiongfeng Wang, 4 . 20+

On Fri, Mar 22, 2019 at 11:45 PM Srinivas Pandruvada
<srinivas.pandruvada@linux.intel.com> wrote:
>
> 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")
> Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> Cc: 4.20+ <stable@vger.kernel.org> # 4.20+
> ---
>  drivers/cpufreq/intel_pstate.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
> index 7b4b0a7ac68b..e16dea241c55 100644
> --- a/drivers/cpufreq/intel_pstate.c
> +++ b/drivers/cpufreq/intel_pstate.c
> @@ -385,6 +385,9 @@ static int intel_pstate_get_cppc_guranteed(int cpu)
>         if (ret)
>                 return ret;
>
> +       if (!cppc_perf.guaranteed_perf)
> +               return cppc_perf.nominal_perf;
> +
>         return cppc_perf.guaranteed_perf;
>  }

I would do this the other way around, that is

if (cppc_perf.guaranteed_perf)
        return cppc_perf.guaranteed_perf;

return cppc_perf.nominal_perf;

That is slightly easier to follow IMO.

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

end of thread, other threads:[~2019-03-25 12:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20190322224520.6740-1-srinivas.pandruvada@linux.intel.com>
2019-03-22 22:45 ` [PATCH 1/2] ACPI / CPPC: Fix processing for guaranteed performance Srinivas Pandruvada
2019-03-25 11:49   ` Rafael J. Wysocki
2019-03-22 22:45 ` [PATCH 2/2] cpufreq: intel_pstate: Also use cppc nominal_perf for base_frequency Srinivas Pandruvada
2019-03-25 12:04   ` 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).