Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/intelhfi/intelhfi.c
| Show First 20 Lines • Show All 171 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| static int | static int | ||||
| intelhfi_hmp_capacity_provider_init(void) | intelhfi_hmp_capacity_provider_init(void) | ||||
| { | { | ||||
| struct hmp_pcpu *hp; | struct hmp_pcpu *hp; | ||||
| uint64_t msrval; | uint64_t msrval; | ||||
| uint8_t *highperf; | uint8_t *highperf; | ||||
| uint8_t maxperf; | uint8_t minperf = 255; | ||||
| int cpu; | int cpu; | ||||
| int ret = 0; | int ret = 0; | ||||
| /* Check & Temporary enable Intel Speed Shift msr */ | /* Check & Temporary enable Intel Speed Shift msr */ | ||||
| rdmsr_safe(MSR_IA32_PM_ENABLE, &msrval); | rdmsr_safe(MSR_IA32_PM_ENABLE, &msrval); | ||||
| if (!(msrval & IA32_PM_ENABLE_HWP_ENABLE)) { | if (!(msrval & IA32_PM_ENABLE_HWP_ENABLE)) { | ||||
| if (wrmsr_safe(MSR_IA32_PM_ENABLE, (msrval | IA32_PM_ENABLE_HWP_ENABLE))) | if (wrmsr_safe(MSR_IA32_PM_ENABLE, (msrval | IA32_PM_ENABLE_HWP_ENABLE))) | ||||
| return (-1); | return (-1); | ||||
| } | } | ||||
| /* Alloc temporary area for CPU core high perf. value */ | /* Alloc temporary area for CPU core high perf. value */ | ||||
| highperf = malloc((sizeof(uint8_t) * mp_ncpus), M_INTELHFI, M_NOWAIT | M_ZERO); | highperf = malloc((sizeof(uint8_t) * mp_ncpus), M_INTELHFI, M_NOWAIT | M_ZERO); | ||||
| if (highperf == NULL) { | if (highperf == NULL) { | ||||
| ret = -2; | ret = -2; | ||||
| goto capinit_err; | goto capinit_err; | ||||
| } | } | ||||
| /* Read CPU each core high perf. value from IA32_HWP_CAPABILITIES msr */ | /* Read CPU each core high perf. value from IA32_HWP_CAPABILITIES msr */ | ||||
| smp_rendezvous(NULL, intelhfi_hmp_capacity_read_highperf, NULL, highperf); | smp_rendezvous(NULL, intelhfi_hmp_capacity_read_highperf, NULL, highperf); | ||||
| /* Search MAX capacity core */ | /* Search MIN capacity core */ | ||||
| for (int c=0; c<mp_ncpus; c++) { | for (int c=0; c<mp_ncpus; c++) { | ||||
| if (*(highperf+c)>maxperf) | if (*(highperf+c)<minperf) | ||||
| maxperf = *(highperf+c); | minperf = *(highperf+c); | ||||
| } | } | ||||
| /* Set CPU core capacity for HMP */ | /* Set CPU core capacity for HMP */ | ||||
| CPU_FOREACH(cpu) { | CPU_FOREACH(cpu) { | ||||
| hp = DPCPU_ID_PTR(cpu, hmp_pcpu); | hp = DPCPU_ID_PTR(cpu, hmp_pcpu); | ||||
| hp->capacity = HMP_CAPACITY_NORMAL_FROM(*(highperf+cpu), maxperf); | hp->capacity = HMP_CAPACITY_NORMAL_FROM(*(highperf+cpu), minperf); | ||||
| } | } | ||||
| free(highperf, M_INTELHFI); | free(highperf, M_INTELHFI); | ||||
| /* Set intelhfi use HMP flag */ | /* Set intelhfi use HMP flag */ | ||||
| ihfi_inst.status |= INTELHFI_STATUS_USEHMP; | ihfi_inst.status |= INTELHFI_STATUS_USEHMP; | ||||
| capinit_err: | capinit_err: | ||||
| Show All 39 Lines | intelhfi_hmp_score_set(struct intelhfi_instance *inst) | ||||
| for (int grp=0; grp<(inst->cpu_top)->cg_children; grp++, entry+=inst->entrysize, cg++) { | for (int grp=0; grp<(inst->cpu_top)->cg_children; grp++, entry+=inst->entrysize, cg++) { | ||||
| for (uint32_t cid=cg->cg_first; cid<=cg->cg_last; cid++) { | for (uint32_t cid=cg->cg_first; cid<=cg->cg_last; cid++) { | ||||
| hp = DPCPU_ID_PTR(cid, hmp_pcpu); | hp = DPCPU_ID_PTR(cid, hmp_pcpu); | ||||
| KASSERT(hp != NULL, ("DPCPU area is NULL.")); | KASSERT(hp != NULL, ("DPCPU area is NULL.")); | ||||
| if (*(capflags+0) & INTELHFI_GH_FLAG_REPORT) | if (*(capflags+0) & INTELHFI_GH_FLAG_REPORT) | ||||
| hmp_set_score(hp, HMP_SCORE_PERF, (hmp_score_t)(*(entry+0))); | hmp_set_score(hp, HMP_SCORE_PERF, (((hmp_score_t)(*(entry+0)))<<2)); | ||||
| if (*(capflags+1) & INTELHFI_GH_FLAG_REPORT) | if (*(capflags+1) & INTELHFI_GH_FLAG_REPORT) | ||||
| hmp_set_score(hp, HMP_SCORE_EFF, (hmp_score_t)(*(entry+1))); | hmp_set_score(hp, HMP_SCORE_EFF, (((hmp_score_t)(*(entry+1)))<<2)); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| #endif /* HMP */ | #endif /* HMP */ | ||||
| /* | /* | ||||
| * LVT thermal interrupts handler | * LVT thermal interrupts handler | ||||
| */ | */ | ||||
| ▲ Show 20 Lines • Show All 482 Lines • Show Last 20 Lines | |||||