cpufreq(4) hwpstate: Yield CPU awaiting frequency change

It doesn't seem necessary to busy the CPU while waiting to transition
into a different p-state.

PR:		221621 (related, but does not completely address)
Reviewed by:	truckman
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D12260
This commit is contained in:
Conrad Meyer 2017-09-07 20:20:12 +00:00
parent f9fc9faa3a
commit 2e81566368

View File

@ -160,6 +160,7 @@ DRIVER_MODULE(hwpstate, cpu, hwpstate_driver, hwpstate_devclass, 0, 0);
static int static int
hwpstate_goto_pstate(device_t dev, int pstate) hwpstate_goto_pstate(device_t dev, int pstate)
{ {
sbintime_t sbt;
int i; int i;
uint64_t msr; uint64_t msr;
int j; int j;
@ -170,7 +171,7 @@ hwpstate_goto_pstate(device_t dev, int pstate)
/* get the current pstate limit */ /* get the current pstate limit */
msr = rdmsr(MSR_AMD_10H_11H_LIMIT); msr = rdmsr(MSR_AMD_10H_11H_LIMIT);
limit = AMD_10H_11H_GET_PSTATE_LIMIT(msr); limit = AMD_10H_11H_GET_PSTATE_LIMIT(msr);
if(limit > id) if (limit > id)
id = limit; id = limit;
/* /*
@ -184,7 +185,7 @@ hwpstate_goto_pstate(device_t dev, int pstate)
sched_bind(curthread, i); sched_bind(curthread, i);
thread_unlock(curthread); thread_unlock(curthread);
HWPSTATE_DEBUG(dev, "setting P%d-state on cpu%d\n", HWPSTATE_DEBUG(dev, "setting P%d-state on cpu%d\n",
id, PCPU_GET(cpuid)); id, PCPU_GET(cpuid));
/* Go To Px-state */ /* Go To Px-state */
wrmsr(MSR_AMD_10H_11H_CONTROL, id); wrmsr(MSR_AMD_10H_11H_CONTROL, id);
} }
@ -194,13 +195,14 @@ hwpstate_goto_pstate(device_t dev, int pstate)
sched_bind(curthread, i); sched_bind(curthread, i);
thread_unlock(curthread); thread_unlock(curthread);
/* wait loop (100*100 usec is enough ?) */ /* wait loop (100*100 usec is enough ?) */
for(j = 0; j < 100; j++){ for (j = 0; j < 100; j++){
/* get the result. not assure msr=id */ /* get the result. not assure msr=id */
msr = rdmsr(MSR_AMD_10H_11H_STATUS); msr = rdmsr(MSR_AMD_10H_11H_STATUS);
if(msr == id){ if (msr == id)
break; break;
} sbt = SBT_1MS / 10;
DELAY(100); tsleep_sbt(dev, PZERO, "pstate_goto", sbt,
sbt >> tc_precexp, 0);
} }
HWPSTATE_DEBUG(dev, "result: P%d-state on cpu%d\n", HWPSTATE_DEBUG(dev, "result: P%d-state on cpu%d\n",
(int)msr, PCPU_GET(cpuid)); (int)msr, PCPU_GET(cpuid));