soc/intel/block/power_limit: Avoid MSR read if it is not needed
In function 'set_power_limits' there is a path to bail out early if the Kconfig switch SOC_INTEL_DISABLE_POWER_LIMITS is selected. In this case reading the MSR PLATFORM_INFO is useless and can be avoided. So read it right before the value is needed. This was found by the scanbuild. In addition, fix an unnecessary line break to increase code readability. Change-Id: Ibdededdfd56287fb9b9223e78033a3cd6425e1a2 Signed-off-by: Werner Zeh <werner.zeh@siemens.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/69185 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Marc Jones <marc@marcjonesconsulting.com> Reviewed-by: Angel Pons <th3fanbus@gmail.com> Reviewed-by: Eric Lai <eric_lai@quanta.corp-partner.google.com>
This commit is contained in:
parent
ae129fc6d6
commit
44bf309309
|
@ -72,7 +72,7 @@ static const u8 power_limit_time_msr_to_sec[] = {
|
||||||
void set_power_limits(u8 power_limit_1_time,
|
void set_power_limits(u8 power_limit_1_time,
|
||||||
struct soc_power_limits_config *conf)
|
struct soc_power_limits_config *conf)
|
||||||
{
|
{
|
||||||
msr_t msr = rdmsr(MSR_PLATFORM_INFO);
|
msr_t msr;
|
||||||
msr_t limit;
|
msr_t limit;
|
||||||
unsigned int power_unit;
|
unsigned int power_unit;
|
||||||
unsigned int tdp, min_power, max_power, max_time, tdp_pl2, tdp_pl1;
|
unsigned int tdp, min_power, max_power, max_time, tdp_pl2, tdp_pl1;
|
||||||
|
@ -96,9 +96,9 @@ void set_power_limits(u8 power_limit_1_time,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (power_limit_1_time >= ARRAY_SIZE(power_limit_time_sec_to_msr))
|
if (power_limit_1_time >= ARRAY_SIZE(power_limit_time_sec_to_msr))
|
||||||
power_limit_1_time =
|
power_limit_1_time = ARRAY_SIZE(power_limit_time_sec_to_msr) - 1;
|
||||||
ARRAY_SIZE(power_limit_time_sec_to_msr) - 1;
|
|
||||||
|
|
||||||
|
msr = rdmsr(MSR_PLATFORM_INFO);
|
||||||
if (!(msr.lo & PLATFORM_INFO_SET_TDP))
|
if (!(msr.lo & PLATFORM_INFO_SET_TDP))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue