Changeset View
Changeset View
Standalone View
Standalone View
sys/x86/cpufreq/hwpstate_amd.c
- This file was moved from sys/x86/cpufreq/hwpstate.c.
Show First 20 Lines • Show All 118 Lines • ▼ Show 20 Lines | |||||
static int hwpstate_type(device_t dev, int *type); | static int hwpstate_type(device_t dev, int *type); | ||||
static int hwpstate_shutdown(device_t dev); | static int hwpstate_shutdown(device_t dev); | ||||
static int hwpstate_features(driver_t *driver, u_int *features); | static int hwpstate_features(driver_t *driver, u_int *features); | ||||
static int hwpstate_get_info_from_acpi_perf(device_t dev, device_t perf_dev); | static int hwpstate_get_info_from_acpi_perf(device_t dev, device_t perf_dev); | ||||
static int hwpstate_get_info_from_msr(device_t dev); | static int hwpstate_get_info_from_msr(device_t dev); | ||||
static int hwpstate_goto_pstate(device_t dev, int pstate_id); | static int hwpstate_goto_pstate(device_t dev, int pstate_id); | ||||
static int hwpstate_verbose; | static int hwpstate_verbose; | ||||
SYSCTL_INT(_debug, OID_AUTO, hwpstate_verbose, CTLFLAG_RWTUN, | SYSCTL_INT(_debug, OID_AUTO, hwpstate_amd_verbose, CTLFLAG_RWTUN, | ||||
&hwpstate_verbose, 0, "Debug hwpstate"); | &hwpstate_verbose, 0, "Debug hwpstate"); | ||||
static int hwpstate_verify; | static int hwpstate_verify; | ||||
SYSCTL_INT(_debug, OID_AUTO, hwpstate_verify, CTLFLAG_RWTUN, | SYSCTL_INT(_debug, OID_AUTO, hwpstate_amd_verify, CTLFLAG_RWTUN, | ||||
&hwpstate_verify, 0, "Verify P-state after setting"); | &hwpstate_verify, 0, "Verify P-state after setting"); | ||||
static device_method_t hwpstate_methods[] = { | static device_method_t hwpstate_methods[] = { | ||||
/* Device interface */ | /* Device interface */ | ||||
DEVMETHOD(device_identify, hwpstate_identify), | DEVMETHOD(device_identify, hwpstate_identify), | ||||
DEVMETHOD(device_probe, hwpstate_probe), | DEVMETHOD(device_probe, hwpstate_probe), | ||||
DEVMETHOD(device_attach, hwpstate_attach), | DEVMETHOD(device_attach, hwpstate_attach), | ||||
DEVMETHOD(device_detach, hwpstate_detach), | DEVMETHOD(device_detach, hwpstate_detach), | ||||
DEVMETHOD(device_shutdown, hwpstate_shutdown), | DEVMETHOD(device_shutdown, hwpstate_shutdown), | ||||
/* cpufreq interface */ | /* cpufreq interface */ | ||||
DEVMETHOD(cpufreq_drv_set, hwpstate_set), | DEVMETHOD(cpufreq_drv_set, hwpstate_set), | ||||
DEVMETHOD(cpufreq_drv_get, hwpstate_get), | DEVMETHOD(cpufreq_drv_get, hwpstate_get), | ||||
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} | ||||
}; | }; | ||||
static devclass_t hwpstate_devclass; | static devclass_t hwpstate_amd_devclass; | ||||
static driver_t hwpstate_driver = { | static driver_t hwpstate_amd_driver = { | ||||
"hwpstate", | "hwpstate_amd", | ||||
jhb: You don't actually have to rename this driver FWIW. It's fine to have multiple drivers with… | |||||
Not Done Inline ActionsI don't object to naming different things differently. It can reduce confusion in reports / debugging. cem: I don't object to naming different things differently. It can reduce confusion in reports /… | |||||
hwpstate_methods, | hwpstate_methods, | ||||
sizeof(struct hwpstate_softc), | sizeof(struct hwpstate_softc), | ||||
}; | }; | ||||
DRIVER_MODULE(hwpstate, cpu, hwpstate_driver, hwpstate_devclass, 0, 0); | DRIVER_MODULE(hwpstate_amd, cpu, hwpstate_amd_driver, hwpstate_amd_devclass, 0, 0); | ||||
/* | /* | ||||
* Go to Px-state on all cpus considering the limit. | * Go to Px-state on all cpus considering the limit. | ||||
*/ | */ | ||||
static int | static int | ||||
hwpstate_goto_pstate(device_t dev, int id) | hwpstate_goto_pstate(device_t dev, int id) | ||||
{ | { | ||||
sbintime_t sbt; | sbintime_t sbt; | ||||
▲ Show 20 Lines • Show All 137 Lines • ▼ Show 20 Lines | hwpstate_type(device_t dev, int *type) | ||||
*type = CPUFREQ_TYPE_ABSOLUTE; | *type = CPUFREQ_TYPE_ABSOLUTE; | ||||
return (0); | return (0); | ||||
} | } | ||||
static void | static void | ||||
hwpstate_identify(driver_t *driver, device_t parent) | hwpstate_identify(driver_t *driver, device_t parent) | ||||
{ | { | ||||
if (device_find_child(parent, "hwpstate", -1) != NULL) | if (device_find_child(parent, "hwpstate_amd", -1) != NULL) | ||||
return; | return; | ||||
if (cpu_vendor_id != CPU_VENDOR_AMD || CPUID_TO_FAMILY(cpu_id) < 0x10) | if (cpu_vendor_id != CPU_VENDOR_AMD || CPUID_TO_FAMILY(cpu_id) < 0x10) | ||||
return; | return; | ||||
/* | /* | ||||
* Check if hardware pstate enable bit is set. | * Check if hardware pstate enable bit is set. | ||||
*/ | */ | ||||
if ((amd_pminfo & AMDPM_HW_PSTATE) == 0) { | if ((amd_pminfo & AMDPM_HW_PSTATE) == 0) { | ||||
HWPSTATE_DEBUG(parent, "hwpstate enable bit is not set.\n"); | HWPSTATE_DEBUG(parent, "hwpstate enable bit is not set.\n"); | ||||
return; | return; | ||||
} | } | ||||
if (resource_disabled("hwpstate", 0)) | if (resource_disabled("hwpstate_amd", 0)) | ||||
return; | return; | ||||
Done Inline ActionsThis deserves a note in UPDATING. It might be worth just honoring the old name on both Intel and AMD hardware; I don't really see a downside. cem: This deserves a note in UPDATING. It might be worth just honoring the old name on both Intel… | |||||
Not Done Inline ActionsI would probably just leave the name as-is as well FWIW. jhb: I would probably just leave the name as-is as well FWIW. | |||||
if (BUS_ADD_CHILD(parent, 10, "hwpstate", -1) == NULL) | if (BUS_ADD_CHILD(parent, 10, "hwpstate_amd", -1) == NULL) | ||||
device_printf(parent, "hwpstate: add child failed\n"); | device_printf(parent, "hwpstate: add child failed\n"); | ||||
} | } | ||||
static int | static int | ||||
hwpstate_probe(device_t dev) | hwpstate_probe(device_t dev) | ||||
{ | { | ||||
struct hwpstate_softc *sc; | struct hwpstate_softc *sc; | ||||
device_t perf_dev; | device_t perf_dev; | ||||
▲ Show 20 Lines • Show All 199 Lines • Show Last 20 Lines |
You don't actually have to rename this driver FWIW. It's fine to have multiple drivers with the same name.