lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Zh1BVDUkSSeHOvmP@amd.com>
Date: Mon, 15 Apr 2024 23:01:40 +0800
From: Huang Rui <ray.huang@....com>
To: "Yuan, Perry" <Perry.Yuan@....com>
Cc: "rafael.j.wysocki@...el.com" <rafael.j.wysocki@...el.com>,
	"Limonciello, Mario" <Mario.Limonciello@....com>,
	"viresh.kumar@...aro.org" <viresh.kumar@...aro.org>,
	"Shenoy, Gautham Ranjal" <gautham.shenoy@....com>,
	"Petkov, Borislav" <Borislav.Petkov@....com>,
	"Deucher, Alexander" <Alexander.Deucher@....com>,
	"Huang, Shimmer" <Shimmer.Huang@....com>,
	"oleksandr@...alenko.name" <oleksandr@...alenko.name>,
	"Du, Xiaojian" <Xiaojian.Du@....com>,
	"Meng, Li (Jassmine)" <Li.Meng@....com>,
	"linux-pm@...r.kernel.org" <linux-pm@...r.kernel.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v10 6/8] cpufreq: amd-pstate: get transition delay and
 latency value from ACPI tables

On Mon, Mar 25, 2024 at 11:03:26AM +0800, Yuan, Perry wrote:
> Make pstate driver initially retrieve the P-state transition delay and
> latency values from the BIOS ACPI tables which has more reasonable
> delay and latency values according to the platform design and
> requirements.
> 
> Previously there values were hardcoded at specific value which may
> have conflicted with platform and it might not reflect the most
> accurate or optimized setting for the processor.
> 
> [054h 0084   8]                Preserve Mask : FFFFFFFF00000000
> [05Ch 0092   8]                   Write Mask : 0000000000000001
> [064h 0100   4]              Command Latency : 00000FA0
> [068h 0104   4]          Maximum Access Rate : 0000EA60
> [06Ch 0108   2]      Minimum Turnaround Time : 0000
> 
> Reviewed-by: Gautham R. Shenoy <gautham.shenoy@....com>
> Reviewed-by: Mario Limonciello <mario.limonciello@....com>
> Tested-by: Dhananjay Ugwekar <Dhananjay.Ugwekar@....com>
> Signed-off-by: Perry Yuan <perry.yuan@....com>

Acked-by: Huang Rui <ray.huang@....com>

> ---
>  drivers/cpufreq/amd-pstate.c | 34 ++++++++++++++++++++++++++++++++--
>  1 file changed, 32 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index 6708c436e1a2..ec049b62b366 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -756,6 +756,36 @@ static void amd_pstate_update_limits(unsigned int cpu)
>  	mutex_unlock(&amd_pstate_driver_lock);
>  }
>  
> +/**
> + * Get pstate transition delay time from ACPI tables that firmware set
> + * instead of using hardcode value directly.
> + */
> +static u32 amd_pstate_get_transition_delay_us(unsigned int cpu)
> +{
> +	u32 transition_delay_ns;
> +
> +	transition_delay_ns = cppc_get_transition_latency(cpu);
> +	if (transition_delay_ns == CPUFREQ_ETERNAL)
> +		return AMD_PSTATE_TRANSITION_DELAY;
> +
> +	return transition_delay_ns / NSEC_PER_USEC;
> +}
> +
> +/**
> + * Get pstate transition latency value from ACPI tables that firmware
> + * set instead of using hardcode value directly.
> + */
> +static u32 amd_pstate_get_transition_latency(unsigned int cpu)
> +{
> +	u32 transition_latency;
> +
> +	transition_latency = cppc_get_transition_latency(cpu);
> +	if (transition_latency  == CPUFREQ_ETERNAL)
> +		return AMD_PSTATE_TRANSITION_LATENCY;
> +
> +	return transition_latency;
> +}
> +
>  /**
>   * amd_pstate_init_freq: Initialize the max_freq, min_freq,
>   *                       nominal_freq and lowest_nonlinear_freq for
> @@ -848,8 +878,8 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *policy)
>  		goto free_cpudata1;
>  	}
>  
> -	policy->cpuinfo.transition_latency = AMD_PSTATE_TRANSITION_LATENCY;
> -	policy->transition_delay_us = AMD_PSTATE_TRANSITION_DELAY;
> +	policy->cpuinfo.transition_latency = amd_pstate_get_transition_latency(policy->cpu);
> +	policy->transition_delay_us = amd_pstate_get_transition_delay_us(policy->cpu);
>  
>  	policy->min = min_freq;
>  	policy->max = max_freq;
> -- 
> 2.34.1
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ