Changeset View
Changeset View
Standalone View
Standalone View
sys/x86/cpufreq/hwpstate_amd.c
| Show First 20 Lines • Show All 196 Lines • ▼ Show 20 Lines | static device_method_t hwpstate_methods[] = { | ||||
| DEVMETHOD(cpufreq_drv_settings, hwpstate_settings), | DEVMETHOD(cpufreq_drv_settings, hwpstate_settings), | ||||
| DEVMETHOD(cpufreq_drv_type, hwpstate_type), | DEVMETHOD(cpufreq_drv_type, hwpstate_type), | ||||
| /* ACPI interface */ | /* ACPI interface */ | ||||
| DEVMETHOD(acpi_get_features, hwpstate_features), | DEVMETHOD(acpi_get_features, hwpstate_features), | ||||
| {0, 0} | {0, 0} | ||||
| }; | }; | ||||
| struct amdhwp_dump_sysctl_handler_request { | struct get_cppc_regs_data { | ||||
| uint64_t enable; | uint64_t enable; | ||||
| uint64_t caps; | uint64_t caps; | ||||
| uint64_t req; | uint64_t req; | ||||
| int res; | int res; | ||||
| }; | }; | ||||
| static void | static void | ||||
| print_msr_bits(struct sbuf *const sb, const char *const legend, | print_msr_bits(struct sbuf *const sb, const char *const legend, | ||||
| Show All 28 Lines | print_msr_bits(sb, "Desired Performance", | ||||
| AMD_CPPC_REQUEST_DES_PERF_BITS, request); | AMD_CPPC_REQUEST_DES_PERF_BITS, request); | ||||
| print_msr_bits(sb, "Minimum Performance", | print_msr_bits(sb, "Minimum Performance", | ||||
| AMD_CPPC_REQUEST_MIN_PERF_BITS, request); | AMD_CPPC_REQUEST_MIN_PERF_BITS, request); | ||||
| print_msr_bits(sb, "Maximum Performance", | print_msr_bits(sb, "Maximum Performance", | ||||
| AMD_CPPC_REQUEST_MAX_PERF_BITS, request); | AMD_CPPC_REQUEST_MAX_PERF_BITS, request); | ||||
| } | } | ||||
| static void | static void | ||||
| amdhwp_dump_sysctl_handler_cb(void *args) | get_cppc_regs_cb(void *args) | ||||
| { | { | ||||
| struct amdhwp_dump_sysctl_handler_request *req = | struct get_cppc_regs_data *data = args; | ||||
| (struct amdhwp_dump_sysctl_handler_request *)args; | |||||
| req->res = rdmsr_safe(MSR_AMD_CPPC_ENABLE, &req->enable); | data->res = rdmsr_safe(MSR_AMD_CPPC_ENABLE, &data->enable); | ||||
| if (req->res == 0) | if (data->res == 0) | ||||
| req->res = rdmsr_safe(MSR_AMD_CPPC_CAPS_1, &req->caps); | data->res = rdmsr_safe(MSR_AMD_CPPC_CAPS_1, &data->caps); | ||||
| if (req->res == 0) | if (data->res == 0) | ||||
| req->res = rdmsr_safe(MSR_AMD_CPPC_REQUEST, &req->req); | data->res = rdmsr_safe(MSR_AMD_CPPC_REQUEST, &data->req); | ||||
| } | } | ||||
| static int | static int | ||||
| amdhwp_dump_sysctl_handler(SYSCTL_HANDLER_ARGS) | sysctl_cppc_dump_handler(SYSCTL_HANDLER_ARGS) | ||||
| { | { | ||||
| device_t dev; | device_t dev; | ||||
| struct pcpu *pc; | struct pcpu *pc; | ||||
| struct sbuf *sb; | struct sbuf *sb; | ||||
| struct hwpstate_softc *sc; | struct hwpstate_softc *sc; | ||||
| struct amdhwp_dump_sysctl_handler_request request; | struct get_cppc_regs_data request; | ||||
| uint64_t data; | uint64_t data; | ||||
| int ret; | int ret; | ||||
| sc = (struct hwpstate_softc *)arg1; | sc = (struct hwpstate_softc *)arg1; | ||||
| dev = sc->dev; | dev = sc->dev; | ||||
| pc = cpu_get_pcpu(dev); | pc = cpu_get_pcpu(dev); | ||||
| if (pc == NULL) | if (pc == NULL) | ||||
| return (ENXIO); | return (ENXIO); | ||||
| sb = sbuf_new(NULL, NULL, 1024, SBUF_FIXEDLEN | SBUF_INCLUDENUL); | sb = sbuf_new(NULL, NULL, 1024, SBUF_FIXEDLEN | SBUF_INCLUDENUL); | ||||
| sbuf_putc(sb, '\n'); | sbuf_putc(sb, '\n'); | ||||
| smp_rendezvous_cpu(pc->pc_cpuid, smp_no_rendezvous_barrier, | smp_rendezvous_cpu(pc->pc_cpuid, smp_no_rendezvous_barrier, | ||||
| amdhwp_dump_sysctl_handler_cb, smp_no_rendezvous_barrier, &request); | get_cppc_regs_cb, smp_no_rendezvous_barrier, &request); | ||||
| ret = request.res; | ret = request.res; | ||||
| if (ret) | if (ret) | ||||
| goto out; | goto out; | ||||
| data = request.enable; | data = request.enable; | ||||
| sbuf_printf(sb, "CPU%d: HWP %sabled\n", pc->pc_cpuid, | sbuf_printf(sb, "CPU%d: HWP %sabled\n", pc->pc_cpuid, | ||||
| ((data & 1) ? "En" : "Dis")); | ((data & 1) ? "En" : "Dis")); | ||||
| if (data == 0) | if (data == 0) | ||||
| ▲ Show 20 Lines • Show All 477 Lines • ▼ Show 20 Lines | hwpstate_attach(device_t dev) | ||||
| sc = device_get_softc(dev); | sc = device_get_softc(dev); | ||||
| if (sc->flags & PSTATE_CPPC) { | if (sc->flags & PSTATE_CPPC) { | ||||
| if ((res = amd_set_autonomous_hwp(sc))) | if ((res = amd_set_autonomous_hwp(sc))) | ||||
| return res; | return res; | ||||
| SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), | SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), | ||||
| SYSCTL_STATIC_CHILDREN(_debug), OID_AUTO, | SYSCTL_STATIC_CHILDREN(_debug), OID_AUTO, | ||||
| device_get_nameunit(dev), | device_get_nameunit(dev), | ||||
| CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_SKIP | CTLFLAG_MPSAFE, | CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_SKIP | CTLFLAG_MPSAFE, | ||||
| sc, 0, amdhwp_dump_sysctl_handler, "A", ""); | sc, 0, sysctl_cppc_dump_handler, "A", ""); | ||||
| SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), | SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), | ||||
| SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, | SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, | ||||
| "epp", CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, dev, 0, | "epp", CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, dev, 0, | ||||
| sysctl_epp_select, "I", | sysctl_epp_select, "I", | ||||
| "Efficiency/Performance Preference " | "Efficiency/Performance Preference " | ||||
| "(range from 0, most performant, through 100, most efficient)"); | "(range from 0, most performant, through 100, most efficient)"); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 167 Lines • Show Last 20 Lines | |||||