public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: bp@alien8.de, rafael.j.wysocki@intel.com, linux-pm@vger.kernel.org
Subject: Re: [TEST PATCH] cpufreq: intel_pstate: Workaround to for wrong ACPI perf table entry
Date: Wed, 18 Nov 2015 02:33:36 +0100	[thread overview]
Message-ID: <8524647.rknTxxgTfO@vostro.rjw.lan> (raw)
In-Reply-To: <1447801252-3626-1-git-send-email-srinivas.pandruvada@linux.intel.com>

On Tuesday, November 17, 2015 03:00:52 PM Srinivas Pandruvada wrote:
> With the implementation of ACPI _PSS and _PPC processing in the Intel P
> state driver, a bad ACPI configuration can impact max/min states. For
> example as reported by Borislav Petkov <bp@alien8.de>, the log shows:
> 
> [    0.826119] intel_pstate: default limits 0xc 0x1d 0x24
> [    0.827000] intel_pstate: CPU0 - ACPI _PSS perf data
> [    0.827020]      *P0: 2901 MHz, 35000 mW, 0xff00
> The above control value of 0xff00, is invalid. The first entry sets the
> max control value for turbo with a max non turbo frequency + 1 MHz. Here
> the control values should be 0x1d00.

I guess "the control value should not be greater than the one reported by the
CPU itself".

> intel_pstate_set_policy() depends on this control value in setting correct
> max pstate.

This looks sort of fragile to me.

> Two fixes have been done here:
> - If the control value is invalid then use the physical max turbo as the
> max. Here 0xff00 will be changed to 0x1d00

It will be changed to whatever is reported by the CPU I suppose.

> - Always reset the limits->min_perf_ctl and limits->max_perf_ctl, so that
> we will not use last value. In this case even if entry is not found the
> _PSS it will fallback to limits->max_perf and limits-> limits->max_perf.
> 
> Reported-by: Borislav Petkov <bp@alien8.de>
> Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> ---
>  drivers/cpufreq/intel_pstate.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
> index d3159f0..fc99e97 100644
> --- a/drivers/cpufreq/intel_pstate.c
> +++ b/drivers/cpufreq/intel_pstate.c
> @@ -311,6 +311,13 @@ static int intel_pstate_init_perf_limits(struct cpufreq_policy *policy)
>  		 * correct max turbo frequency based on the turbo ratio.
>  		 * Also need to convert to MHz as _PSS freq is in MHz.
>  		 */
> +		if (turbo_pss_ctl > cpu->pstate.turbo_pstate) {
> +			/* We hava an invalid control value here */
> +			turbo_pss_ctl = cpu->pstate.turbo_pstate;
> +			cpu->acpi_perf_data.states[0].control =
> +							turbo_pss_ctl << 8;
> +		}

Should we update pstate.turbo_pstate otherwise?

> +
>  		cpu->acpi_perf_data.states[0].core_frequency =
>  				turbo_pss_ctl * cpu->pstate.scaling / 1000;
>  	}

We seem to have one more bug in this function, but it doesn't affect the case
at hand.  Namely, if the turbo range is not present in the _PSS, we should
set pstate.turbo_pstate to pstate.max_pstate after we've updated the latter
and not before updating it.

I'm also wondering if turbo should be enabled when turbo_pass_ctl is less than
pstate.min_state.  Perhaps not?

> @@ -1272,6 +1279,8 @@ static int intel_pstate_set_policy(struct cpufreq_policy *policy)
>  
>  #if IS_ENABLED(CONFIG_ACPI)
>  	cpu = all_cpu_data[policy->cpu];
> +	limits->min_perf_ctl = 0;
> +	limits->max_perf_ctl = 0;

Wouldn't this re-introduce the problem fixed by commit 4ef451487019
(cpufreq: intel_pstate: Avoid calculation for max/min) in corner cases?

>  	for (i = 0; i < cpu->acpi_perf_data.state_count; i++) {
>  		int control;

That whole loop is fragile.

To me, it should just pick the first state that is not greater than policy->max
and the last one that is not less than policy->min.

Thanks,
Rafael


  parent reply	other threads:[~2015-11-18  1:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-17 23:00 [TEST PATCH] cpufreq: intel_pstate: Workaround to for wrong ACPI perf table entry Srinivas Pandruvada
2015-11-17 23:06 ` Srinivas Pandruvada
2015-11-18  1:33 ` Rafael J. Wysocki [this message]
2015-11-18  2:10   ` Srinivas Pandruvada
2015-11-18  3:19     ` Rafael J. Wysocki
2015-11-18  9:16       ` Borislav Petkov
2015-11-18 16:32       ` Srinivas Pandruvada
2015-11-18 17:20         ` Borislav Petkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8524647.rknTxxgTfO@vostro.rjw.lan \
    --to=rjw@rjwysocki.net \
    --cc=bp@alien8.de \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=srinivas.pandruvada@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox