diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2009-02-24 06:25:33 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2009-02-24 06:25:33 +0000 |
commit | db0fede20cc5ec4218ba8e31beb66d6950ff87bb (patch) | |
tree | d257e41ffc2debe84bd2557f0d2eb2f620a1d9a3 /sys/dev/acpi | |
parent | 423ceb33d05e87de11fe451872839f3189ccf4e4 (diff) |
Backout a backout because noone knows what the hell the backout is a
backout of. COME ON. Be exact in your commit messages.
Diffstat (limited to 'sys/dev/acpi')
-rw-r--r-- | sys/dev/acpi/acpicpu.c | 67 |
1 files changed, 61 insertions, 6 deletions
diff --git a/sys/dev/acpi/acpicpu.c b/sys/dev/acpi/acpicpu.c index 48ee91c56ea..36dc5ebe731 100644 --- a/sys/dev/acpi/acpicpu.c +++ b/sys/dev/acpi/acpicpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpicpu.c,v 1.51 2009/02/18 03:13:49 marco Exp $ */ +/* $OpenBSD: acpicpu.c,v 1.52 2009/02/24 06:25:32 deraadt Exp $ */ /* * Copyright (c) 2005 Marco Peereboom <marco@openbsd.org> * @@ -41,12 +41,29 @@ int acpicpu_match(struct device *, void *, void *); void acpicpu_attach(struct device *, struct device *, void *); int acpicpu_notify(struct aml_node *, int, void *); void acpicpu_setperf(int); +void acpicpu_setperf_ppc_change(struct acpicpu_pss *, int); #define ACPI_STATE_C0 0x00 #define ACPI_STATE_C1 0x01 #define ACPI_STATE_C2 0x02 #define ACPI_STATE_C3 0x03 +#define ACPI_PDC_REVID 0x1 +#define ACPI_PDC_SMP 0xa +#define ACPI_PDC_MSR 0x1 + +/* _PDC Intel capabilities flags from linux */ +#define ACPI_PDC_P_FFH 0x0001 +#define ACPI_PDC_C_C1_HALT 0x0002 +#define ACPI_PDC_T_FFH 0x0004 +#define ACPI_PDC_SMP_C1PT 0x0008 +#define ACPI_PDC_SMP_C2C3 0x0010 +#define ACPI_PDC_SMP_P_SWCOORD 0x0020 +#define ACPI_PDC_SMP_C_SWCOORD 0x0040 +#define ACPI_PDC_SMP_T_SWCOORD 0x0080 +#define ACPI_PDC_C_C1_FFH 0x0100 +#define ACPI_PDC_C_C2C3_FFH 0x0200 + #define FLAGS_NO_C2 0x01 #define FLAGS_NO_C3 0x02 #define FLAGS_BMCHECK 0x04 @@ -121,6 +138,8 @@ int acpicpu_getpct(struct acpicpu_softc *); int acpicpu_getpss(struct acpicpu_softc *); struct acpi_cstate *acpicpu_add_cstate(struct acpicpu_softc *, int, int, int, int); +void acpicpu_set_pdc(struct acpicpu_softc *); + #if 0 void acpicpu_set_throttle(struct acpicpu_softc *, int); struct acpi_cstate *acpicpu_find_cstate(struct acpicpu_softc *, int); @@ -170,6 +189,28 @@ acpicpu_find_cstate(struct acpicpu_softc *sc, int type) } #endif + +void +acpicpu_set_pdc(struct acpicpu_softc *sc) { + struct aml_value cmd; + struct aml_value res; + uint32_t buf[3]; + + memset(&cmd, 0, sizeof(cmd)); + cmd.type = AML_OBJTYPE_BUFFER; + cmd.v_buffer = (uint8_t *)&buf; + cmd.length = sizeof(buf); + + buf[0] = ACPI_PDC_REVID; + buf[1] = 1; + buf[2] = ACPI_PDC_C_C1_HALT | ACPI_PDC_P_FFH | ACPI_PDC_C_C1_FFH + | ACPI_PDC_C_C2C3_FFH | ACPI_PDC_SMP_P_SWCOORD | ACPI_PDC_SMP_C2C3 + | ACPI_PDC_SMP_C1PT; + + aml_evalname(sc->sc_acpi, sc->sc_devnode, "_PDC", 1, &cmd, &res); +} + + struct acpi_cstate * acpicpu_add_cstate(struct acpicpu_softc *sc, int type, int latency, int power, int address) @@ -268,6 +309,13 @@ acpicpu_attach(struct device *parent, struct device *self, void *aux) } sc->sc_duty_off = sc->sc_acpi->sc_fadt->duty_offset; sc->sc_duty_wid = sc->sc_acpi->sc_fadt->duty_width; + +#if defined(amd64) + if (strcmp(cpu_vendor, "GenuineIntel") == 0) + if (cpu_ecxfeature & CPUIDECX_EST) + acpicpu_set_pdc(sc); +#endif + if (!valid_throttle(sc->sc_duty_off, sc->sc_duty_wid, sc->sc_pblk_addr)) sc->sc_flags |= FLAGS_NOTHROTTLE; #ifdef ACPI_DEBUG @@ -298,6 +346,7 @@ acpicpu_attach(struct device *parent, struct device *self, void *aux) sc->sc_acpi->sc_fadt->p_lvl3_lat, -1, sc->sc_pblk_addr + 5); } + if (acpicpu_getpss(sc)) { sc->sc_flags |= FLAGS_NOPSS; } else { @@ -342,6 +391,7 @@ acpicpu_attach(struct device *parent, struct device *self, void *aux) DEVNAME(sc), status, sc->sc_level); if (setperf_prio < 30) { cpu_setperf = acpicpu_setperf; + acpicpu_set_notify(acpicpu_setperf_ppc_change); setperf_prio = 30; acpi_hasprocfvs = 1; } @@ -535,8 +585,6 @@ acpicpu_fetch_pss(struct acpicpu_pss **pss) * XXX: According to the ACPI spec in an SMP system all processors * are supposed to support the same states. For now we pray * the bios ensures this... - * XXX part deux: this needs to account for _PPC as well - * when AC is removed the nr of _PSS entries can go down */ sc = acpicpu_sc[0]; @@ -562,9 +610,6 @@ acpicpu_notify(struct aml_node *node, int notify_type, void *arg) if (sc->sc_notify) sc->sc_notify(sc->sc_pss, sc->sc_pss_len); - /* reset performance to current percentage */ - /* XXX will fail for amd64 for now */ - cpu_setperf(sc->sc_level); break; default: printf("%s: unhandled cpu event %x\n", DEVNAME(sc), @@ -585,6 +630,16 @@ acpicpu_set_notify(void (*func)(struct acpicpu_pss *, int)) { } void +acpicpu_setperf_ppc_change(struct acpicpu_pss *pss, int npss) { + struct acpicpu_softc *sc; + + sc = acpicpu_sc[0]; + + if (sc != NULL) + cpu_setperf(sc->sc_level); +} + +void acpicpu_setperf(int level) { struct acpicpu_softc *sc; |