Properly skip the first CPU. It only accidentally worked because the

CPU_FOREACH() loop always starts from BSP (cpu0) and the if condition
is always false for APs.

Reported by:	cem
This commit is contained in:
Jung-uk Kim 2017-11-30 20:21:42 +00:00
parent aea6d042a9
commit 82f0844956

View File

@ -167,10 +167,8 @@ static int
hwpstate_goto_pstate(device_t dev, int id) hwpstate_goto_pstate(device_t dev, int id)
{ {
sbintime_t sbt; sbintime_t sbt;
int i;
uint64_t msr; uint64_t msr;
int j; int cpu, i, j, limit;
int limit;
/* get the current pstate limit */ /* get the current pstate limit */
msr = rdmsr(MSR_AMD_10H_11H_LIMIT); msr = rdmsr(MSR_AMD_10H_11H_LIMIT);
@ -178,8 +176,8 @@ hwpstate_goto_pstate(device_t dev, int id)
if (limit > id) if (limit > id)
id = limit; id = limit;
HWPSTATE_DEBUG(dev, "setting P%d-state on cpu%d\n", id, cpu = curcpu;
PCPU_GET(cpuid)); HWPSTATE_DEBUG(dev, "setting P%d-state on cpu%d\n", id, cpu);
/* Go To Px-state */ /* Go To Px-state */
wrmsr(MSR_AMD_10H_11H_CONTROL, id); wrmsr(MSR_AMD_10H_11H_CONTROL, id);
@ -188,7 +186,7 @@ hwpstate_goto_pstate(device_t dev, int id)
* Probably should take _PSD into account. * Probably should take _PSD into account.
*/ */
CPU_FOREACH(i) { CPU_FOREACH(i) {
if (i == PCPU_GET(cpuid)) if (i == cpu)
continue; continue;
/* Bind to each cpu. */ /* Bind to each cpu. */