CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: thorpej Date: Thu Feb 4 23:54:48 UTC 2021 Modified Files: src/sys/arch/x86/acpi: acpi_machdep.c Log Message: Call acpi_device_register() as appropriate. To generate a diff of this commit: cvs rdiff -u -r1.30 -r1.31 src/sys/arch/x86/acpi/acpi_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_machdep.c diff -u src/sys/arch/x86/acpi/acpi_machdep.c:1.30 src/sys/arch/x86/acpi/acpi_machdep.c:1.31 --- src/sys/arch/x86/acpi/acpi_machdep.c:1.30 Sat May 2 16:44:35 2020 +++ src/sys/arch/x86/acpi/acpi_machdep.c Thu Feb 4 23:54:48 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_machdep.c,v 1.30 2020/05/02 16:44:35 bouyer Exp $ */ +/* $NetBSD: acpi_machdep.c,v 1.31 2021/02/04 23:54:48 thorpej Exp $ */ /* * Copyright 2001 Wasabi Systems, Inc. @@ -40,7 +40,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.30 2020/05/02 16:44:35 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.31 2021/02/04 23:54:48 thorpej Exp $"); #include #include @@ -603,6 +603,8 @@ device_acpi_register(device_t dev, void if (parent == NULL) return; + acpi_device_register(dev, aux); + device_is_vga = device_is_a(dev, "vga") || device_is_a(dev, "genfb"); device_is_pci = device_is_a(parent, "pci"); device_is_isa = device_is_a(parent, "isa");
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: ad Date: Thu Mar 19 19:55:34 UTC 2020 Modified Files: src/sys/arch/x86/acpi: acpi_cpu_md.c Log Message: PR kern/55080: current does not boot Back out previous. To be addressed differently. To generate a diff of this commit: cvs rdiff -u -r1.82 -r1.83 src/sys/arch/x86/acpi/acpi_cpu_md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_cpu_md.c diff -u src/sys/arch/x86/acpi/acpi_cpu_md.c:1.82 src/sys/arch/x86/acpi/acpi_cpu_md.c:1.83 --- src/sys/arch/x86/acpi/acpi_cpu_md.c:1.82 Sat Mar 14 13:50:46 2020 +++ src/sys/arch/x86/acpi/acpi_cpu_md.c Thu Mar 19 19:55:34 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_cpu_md.c,v 1.82 2020/03/14 13:50:46 ad Exp $ */ +/* $NetBSD: acpi_cpu_md.c,v 1.83 2020/03/19 19:55:34 ad Exp $ */ /*- * Copyright (c) 2010, 2011 Jukka Ruohonen @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.82 2020/03/14 13:50:46 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.83 2020/03/19 19:55:34 ad Exp $"); #include #include @@ -103,10 +103,8 @@ __KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md. #define FID_TO_VCO_FID(fidd) (((fid) < 8) ? (8 + ((fid) << 1)) : (fid)) -#ifdef ACPICPU_ENABLE_C3 static char native_idle_text[16]; void (*native_idle)(void) = NULL; -#endif static int acpicpu_md_quirk_piix4(const struct pci_attach_args *); static void acpicpu_md_pstate_hwf_reset(void *, void *); @@ -350,12 +348,6 @@ acpicpu_md_quirk_c1e(void) int acpicpu_md_cstate_start(struct acpicpu_softc *sc) { -#ifdef ACPICPU_ENABLE_C3 - /* - * XXX There are performance problems with the ACPI idle loop, and - * it does not enter deep sleep. Once those are resolved it'll be - * re-enabled. - */ const size_t size = sizeof(native_idle_text); struct acpicpu_cstate *cs; bool ipi = false; @@ -377,7 +369,6 @@ acpicpu_md_cstate_start(struct acpicpu_s } x86_cpu_idle_set(acpicpu_cstate_idle, "acpi", ipi); -#endif /* ACPICPU_ENABLE_C3 */ return 0; } @@ -385,12 +376,6 @@ acpicpu_md_cstate_start(struct acpicpu_s int acpicpu_md_cstate_stop(void) { -#ifdef ACPICPU_ENABLE_C3 - /* - * XXX There are performance problems with the ACPI idle loop, and - * it does not enter deep sleep. Once those are resolved it'll be - * re-enabled. - */ static char text[16]; void (*func)(void); bool ipi; @@ -408,7 +393,6 @@ acpicpu_md_cstate_stop(void) * out from the ACPI idle-loop before detachment. */ xc_barrier(0); -#endif /* ACPICPU_ENABLE_C3 */ return 0; }
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: ad Date: Sat Mar 14 13:50:46 UTC 2020 Modified Files: src/sys/arch/x86/acpi: acpi_cpu_md.c Log Message: Put ACPI idle under ACPICPU_ENABLE_C3 until the wrinkles are ironed out. This seems well written and basically all good, but currently doesn't enter a low power state, and imposes a big performance penalty. Proposed on port-i386 & port-amd64. To generate a diff of this commit: cvs rdiff -u -r1.81 -r1.82 src/sys/arch/x86/acpi/acpi_cpu_md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_cpu_md.c diff -u src/sys/arch/x86/acpi/acpi_cpu_md.c:1.81 src/sys/arch/x86/acpi/acpi_cpu_md.c:1.82 --- src/sys/arch/x86/acpi/acpi_cpu_md.c:1.81 Tue Nov 5 20:21:34 2019 +++ src/sys/arch/x86/acpi/acpi_cpu_md.c Sat Mar 14 13:50:46 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_cpu_md.c,v 1.81 2019/11/05 20:21:34 maxv Exp $ */ +/* $NetBSD: acpi_cpu_md.c,v 1.82 2020/03/14 13:50:46 ad Exp $ */ /*- * Copyright (c) 2010, 2011 Jukka Ruohonen @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.81 2019/11/05 20:21:34 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.82 2020/03/14 13:50:46 ad Exp $"); #include #include @@ -103,8 +103,10 @@ __KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md. #define FID_TO_VCO_FID(fidd) (((fid) < 8) ? (8 + ((fid) << 1)) : (fid)) +#ifdef ACPICPU_ENABLE_C3 static char native_idle_text[16]; void (*native_idle)(void) = NULL; +#endif static int acpicpu_md_quirk_piix4(const struct pci_attach_args *); static void acpicpu_md_pstate_hwf_reset(void *, void *); @@ -348,6 +350,12 @@ acpicpu_md_quirk_c1e(void) int acpicpu_md_cstate_start(struct acpicpu_softc *sc) { +#ifdef ACPICPU_ENABLE_C3 + /* + * XXX There are performance problems with the ACPI idle loop, and + * it does not enter deep sleep. Once those are resolved it'll be + * re-enabled. + */ const size_t size = sizeof(native_idle_text); struct acpicpu_cstate *cs; bool ipi = false; @@ -369,6 +377,7 @@ acpicpu_md_cstate_start(struct acpicpu_s } x86_cpu_idle_set(acpicpu_cstate_idle, "acpi", ipi); +#endif /* ACPICPU_ENABLE_C3 */ return 0; } @@ -376,6 +385,12 @@ acpicpu_md_cstate_start(struct acpicpu_s int acpicpu_md_cstate_stop(void) { +#ifdef ACPICPU_ENABLE_C3 + /* + * XXX There are performance problems with the ACPI idle loop, and + * it does not enter deep sleep. Once those are resolved it'll be + * re-enabled. + */ static char text[16]; void (*func)(void); bool ipi; @@ -393,6 +408,7 @@ acpicpu_md_cstate_stop(void) * out from the ACPI idle-loop before detachment. */ xc_barrier(0); +#endif /* ACPICPU_ENABLE_C3 */ return 0; }
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: mlelstv Date: Wed May 1 07:26:28 UTC 2019 Modified Files: src/sys/arch/x86/acpi: acpi_machdep.c Log Message: Handle ISA/EISA interrupts like isa_machdep.c. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/sys/arch/x86/acpi/acpi_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_machdep.c diff -u src/sys/arch/x86/acpi/acpi_machdep.c:1.25 src/sys/arch/x86/acpi/acpi_machdep.c:1.26 --- src/sys/arch/x86/acpi/acpi_machdep.c:1.25 Sat Mar 9 10:04:41 2019 +++ src/sys/arch/x86/acpi/acpi_machdep.c Wed May 1 07:26:28 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_machdep.c,v 1.25 2019/03/09 10:04:41 kre Exp $ */ +/* $NetBSD: acpi_machdep.c,v 1.26 2019/05/01 07:26:28 mlelstv Exp $ */ /* * Copyright 2001 Wasabi Systems, Inc. @@ -40,7 +40,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.25 2019/03/09 10:04:41 kre Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.26 2019/05/01 07:26:28 mlelstv Exp $"); #include #include @@ -174,11 +174,12 @@ acpi_md_intr_establish(uint32_t Interrup { void *ih; struct pic *pic; - int irq, pin; + int irq = InterruptNumber, pin; #if NIOAPIC > 0 - struct ioapic_softc *sc; + struct ioapic_softc *ioapic; struct acpi_md_override ovr; struct mp_intr_map tmpmap, *mip, **mipp = NULL; + intr_handle_t mpih; int redir, mpflags; /* @@ -188,12 +189,11 @@ acpi_md_intr_establish(uint32_t Interrup mpflags = (MPS_INTTR_LEVEL << 2) | MPS_INTPO_ACTLO; redir = IOAPIC_REDLO_LEVEL | IOAPIC_REDLO_ACTLO; - /* * Apply any MADT override setting. */ - ovr.irq = InterruptNumber; + ovr.irq = irq; ovr.pin = -1; if (acpi_madt_map() == AE_OK) { acpi_madt_walk(acpi_md_findoverride, &ovr); @@ -203,11 +203,11 @@ acpi_md_intr_establish(uint32_t Interrup } if (ovr.pin != -1) { - bool sci = InterruptNumber == AcpiGbl_FADT.SciInterrupt; + bool sci = irq == AcpiGbl_FADT.SciInterrupt; int polarity = ovr.flags & ACPI_MADT_POLARITY_MASK; int trigger = ovr.flags & ACPI_MADT_TRIGGER_MASK; - InterruptNumber = ovr.pin; + irq = ovr.pin; if (polarity == ACPI_MADT_POLARITY_ACTIVE_HIGH || (!sci && polarity == ACPI_MADT_POLARITY_CONFORMS)) { mpflags &= ~MPS_INTPO_ACTLO; @@ -223,40 +223,63 @@ acpi_md_intr_establish(uint32_t Interrup } } + pic = NULL; + pin = irq; + /* * If the interrupt is handled via IOAPIC, update the map. * If the map isn't set up yet, install a temporary one. + * Identify ISA & EISA interrupts */ - - sc = ioapic_find_bybase(InterruptNumber); - if (sc != NULL) { - pic = &sc->sc_pic; - - if (pic->pic_type == PIC_IOAPIC) { - pin = (int)InterruptNumber - pic->pic_vecbase; - irq = -1; - } else { - irq = pin = (int)InterruptNumber; + if (mp_busses != NULL) { + if (intr_find_mpmapping(mp_isa_bus, irq, &mpih) == 0 || + intr_find_mpmapping(mp_eisa_bus, irq, &mpih) == 0) { + if (!APIC_IRQ_ISLEGACY(mpih)) { +pin = APIC_IRQ_PIN(mpih); +ioapic = ioapic_find(APIC_IRQ_APIC(mpih)); +if (ioapic != NULL) + pic = &ioapic->sc_pic; + } } + } - mip = sc->sc_pins[pin].ip_map; - if (mip) { - mip->flags &= ~0xf; - mip->flags |= mpflags; - mip->redir &= ~(IOAPIC_REDLO_LEVEL | - IOAPIC_REDLO_ACTLO); - mip->redir |= redir; - } else { - mipp = &sc->sc_pins[pin].ip_map; - *mipp = &tmpmap; - tmpmap.redir = redir; - tmpmap.flags = mpflags; + if (pic == NULL) { + /* + * If the interrupt is handled via IOAPIC, update the map. + * If the map isn't set up yet, install a temporary one. + */ + ioapic = ioapic_find_bybase(irq); + if (ioapic != NULL) { + pic = &ioapic->sc_pic; + + if (pic->pic_type == PIC_IOAPIC) { +pin = irq - pic->pic_vecbase; +irq = -1; + } else { +pin = irq; + } + + mip = ioapic->sc_pins[pin].ip_map; + if (mip) { +mip->flags &= ~0xf; +mip->flags |= mpflags; +mip->redir &= ~(IOAPIC_REDLO_LEVEL | + IOAPIC_REDLO_ACTLO); +mip->redir |= redir; + } else { +mipp = &ioapic->sc_pins[pin].ip_map; +*mipp = &tmpmap; +tmpmap.redir = redir; +tmpmap.flags = mpflags; + } } - } else + } + + if (pic == NULL) #endif { pic = &i8259_pic; - irq = pin = (int)InterruptNumber; + pin = irq; } ih = intr_establish_xname(irq, pic, pin, type, ipl,
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: kre Date: Sat Mar 9 10:04:42 UTC 2019 Modified Files: src/sys/arch/x86/acpi: acpi_machdep.c Log Message: In acpi_md_OsRemoveInterruptHandler() redir and mpflags are only relevant to the NIOAPIC > 0 case (not used without that). Rearrange #if's slightly to make that happen (avoid "set but not used" warnings (aka errors) when NIOAPIC == 0 (or undefined)). To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/sys/arch/x86/acpi/acpi_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_machdep.c diff -u src/sys/arch/x86/acpi/acpi_machdep.c:1.24 src/sys/arch/x86/acpi/acpi_machdep.c:1.25 --- src/sys/arch/x86/acpi/acpi_machdep.c:1.24 Sat Mar 9 08:42:25 2019 +++ src/sys/arch/x86/acpi/acpi_machdep.c Sat Mar 9 10:04:41 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_machdep.c,v 1.24 2019/03/09 08:42:25 maxv Exp $ */ +/* $NetBSD: acpi_machdep.c,v 1.25 2019/03/09 10:04:41 kre Exp $ */ /* * Copyright 2001 Wasabi Systems, Inc. @@ -40,7 +40,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.24 2019/03/09 08:42:25 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.25 2019/03/09 10:04:41 kre Exp $"); #include #include @@ -174,12 +174,12 @@ acpi_md_intr_establish(uint32_t Interrup { void *ih; struct pic *pic; + int irq, pin; #if NIOAPIC > 0 struct ioapic_softc *sc; struct acpi_md_override ovr; struct mp_intr_map tmpmap, *mip, **mipp = NULL; -#endif - int irq, pin, redir, mpflags; + int redir, mpflags; /* * ACPI interrupts default to level-triggered active-low. @@ -188,7 +188,6 @@ acpi_md_intr_establish(uint32_t Interrup mpflags = (MPS_INTTR_LEVEL << 2) | MPS_INTPO_ACTLO; redir = IOAPIC_REDLO_LEVEL | IOAPIC_REDLO_ACTLO; -#if NIOAPIC > 0 /* * Apply any MADT override setting.
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: maxv Date: Sun Mar 3 17:33:33 UTC 2019 Modified Files: src/sys/arch/x86/acpi: acpi_machdep.c Log Message: Fix bug, PG_W is 'wired', not 'writable'. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sys/arch/x86/acpi/acpi_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_machdep.c diff -u src/sys/arch/x86/acpi/acpi_machdep.c:1.22 src/sys/arch/x86/acpi/acpi_machdep.c:1.23 --- src/sys/arch/x86/acpi/acpi_machdep.c:1.22 Mon Feb 11 14:59:32 2019 +++ src/sys/arch/x86/acpi/acpi_machdep.c Sun Mar 3 17:33:33 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_machdep.c,v 1.22 2019/02/11 14:59:32 cherry Exp $ */ +/* $NetBSD: acpi_machdep.c,v 1.23 2019/03/03 17:33:33 maxv Exp $ */ /* * Copyright 2001 Wasabi Systems, Inc. @@ -40,7 +40,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.22 2019/02/11 14:59:32 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.23 2019/03/03 17:33:33 maxv Exp $"); #include #include @@ -350,7 +350,7 @@ acpi_md_OsWritable(void *Pointer, uint32 for (; sva < eva; sva += PAGE_SIZE) { pte = kvtopte(sva); - if ((*pte & (PG_V|PG_W)) != (PG_V|PG_W)) { + if ((*pte & (PG_V|PG_RW)) != (PG_V|PG_RW)) { rv = FALSE; break; }
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: jmcneill Date: Thu Nov 22 15:06:00 UTC 2018 Modified Files: src/sys/arch/x86/acpi: acpi_machdep.c Log Message: Apply MADT interrupt source overrides to interrupts established via acpi_md_intr_establish. To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/sys/arch/x86/acpi/acpi_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_machdep.c diff -u src/sys/arch/x86/acpi/acpi_machdep.c:1.20 src/sys/arch/x86/acpi/acpi_machdep.c:1.21 --- src/sys/arch/x86/acpi/acpi_machdep.c:1.20 Fri Nov 16 23:03:55 2018 +++ src/sys/arch/x86/acpi/acpi_machdep.c Thu Nov 22 15:06:00 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_machdep.c,v 1.20 2018/11/16 23:03:55 jmcneill Exp $ */ +/* $NetBSD: acpi_machdep.c,v 1.21 2018/11/22 15:06:00 jmcneill Exp $ */ /* * Copyright 2001 Wasabi Systems, Inc. @@ -40,7 +40,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.20 2018/11/16 23:03:55 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.21 2018/11/22 15:06:00 jmcneill Exp $"); #include #include @@ -151,19 +151,40 @@ acpi_md_OsInstallInterruptHandler(uint32 const char *xname) { void *ih; + + ih = acpi_md_intr_establish(InterruptNumber, IPL_TTY, IST_LEVEL, + (int (*)(void *))ServiceRoutine, Context, false, xname); + if (ih == NULL) + return AE_NO_MEMORY; + + *cookiep = ih; + + return AE_OK; +} + +void +acpi_md_OsRemoveInterruptHandler(void *cookie) +{ + intr_disestablish(cookie); +} + +void * +acpi_md_intr_establish(uint32_t InterruptNumber, int ipl, int type, +int (*handler)(void *), void *arg, bool mpsafe, const char *xname) +{ + void *ih; struct pic *pic; #if NIOAPIC > 0 struct ioapic_softc *sc; struct acpi_md_override ovr; struct mp_intr_map tmpmap, *mip, **mipp = NULL; #endif - int irq, pin, type, redir, mpflags; + int irq, pin, redir, mpflags; /* * ACPI interrupts default to level-triggered active-low. */ - type = IST_LEVEL; mpflags = (MPS_INTTR_LEVEL << 2) | MPS_INTPO_ACTLO; redir = IOAPIC_REDLO_LEVEL | IOAPIC_REDLO_ACTLO; @@ -239,11 +260,8 @@ acpi_md_OsInstallInterruptHandler(uint32 irq = pin = (int)InterruptNumber; } - /* - * XXX probably, IPL_BIO is enough. - */ - ih = intr_establish_xname(irq, pic, pin, type, IPL_TTY, - (int (*)(void *)) ServiceRoutine, Context, false, xname); + ih = intr_establish_xname(irq, pic, pin, type, ipl, + handler, arg, mpsafe, xname); #if NIOAPIC > 0 if (mipp) { @@ -251,33 +269,7 @@ acpi_md_OsInstallInterruptHandler(uint32 } #endif - if (ih == NULL) - return AE_NO_MEMORY; - - *cookiep = ih; - - return AE_OK; -} - -void -acpi_md_OsRemoveInterruptHandler(void *cookie) -{ - intr_disestablish(cookie); -} - -void * -acpi_md_intr_establish(uint32_t irq, int ipl, int type, int (*handler)(void *), -void *arg, bool mpsafe, const char *xname) -{ - struct pic *pic; - int pin; - - pic = intr_findpic(irq); - if (pic == NULL) - return NULL; - pin = irq - pic->pic_vecbase; - - return intr_establish_xname(irq, pic, pin, type, ipl, handler, arg, mpsafe, xname); + return ih; } void
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: maxv Date: Sat Sep 23 10:38:59 UTC 2017 Modified Files: src/sys/arch/x86/acpi: acpi_wakeup.c Log Message: Initialize the errata MSRs when waking up, otherwise they are clear and we're re-enabling certain CPU bugs. To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/sys/arch/x86/acpi/acpi_wakeup.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_wakeup.c diff -u src/sys/arch/x86/acpi/acpi_wakeup.c:1.48 src/sys/arch/x86/acpi/acpi_wakeup.c:1.49 --- src/sys/arch/x86/acpi/acpi_wakeup.c:1.48 Sat Sep 23 10:00:00 2017 +++ src/sys/arch/x86/acpi/acpi_wakeup.c Sat Sep 23 10:38:59 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_wakeup.c,v 1.48 2017/09/23 10:00:00 maxv Exp $ */ +/* $NetBSD: acpi_wakeup.c,v 1.49 2017/09/23 10:38:59 maxv Exp $ */ /*- * Copyright (c) 2002, 2011 The NetBSD Foundation, Inc. @@ -59,7 +59,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.48 2017/09/23 10:00:00 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.49 2017/09/23 10:38:59 maxv Exp $"); #include #include @@ -274,6 +274,7 @@ acpi_cpu_sleep(struct cpu_info *ci) if (rcr4() & CR4_OSXSAVE) wrxcr(0, xcr0); pat_init(ci); + x86_errata(); #if NLAPIC > 0 lapic_enable(); lapic_set_lvt(); @@ -346,6 +347,7 @@ acpi_md_sleep(int state) if (rcr4() & CR4_OSXSAVE) wrxcr(0, xcr0); pat_init(&cpu_info_primary); + x86_errata(); i8259_reinit(); #if NLAPIC > 0 lapic_enable();
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: maxv Date: Sat Sep 23 10:00:00 UTC 2017 Modified Files: src/sys/arch/x86/acpi: acpi_wakeup.c Log Message: Reinitialize the PAT MSR when waking up, otherwise the write-combined pages become write-through. To generate a diff of this commit: cvs rdiff -u -r1.47 -r1.48 src/sys/arch/x86/acpi/acpi_wakeup.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_wakeup.c diff -u src/sys/arch/x86/acpi/acpi_wakeup.c:1.47 src/sys/arch/x86/acpi/acpi_wakeup.c:1.48 --- src/sys/arch/x86/acpi/acpi_wakeup.c:1.47 Tue Sep 19 01:22:14 2017 +++ src/sys/arch/x86/acpi/acpi_wakeup.c Sat Sep 23 10:00:00 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_wakeup.c,v 1.47 2017/09/19 01:22:14 maya Exp $ */ +/* $NetBSD: acpi_wakeup.c,v 1.48 2017/09/23 10:00:00 maxv Exp $ */ /*- * Copyright (c) 2002, 2011 The NetBSD Foundation, Inc. @@ -59,7 +59,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.47 2017/09/19 01:22:14 maya Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.48 2017/09/23 10:00:00 maxv Exp $"); #include #include @@ -141,7 +141,6 @@ acpi_md_sleep_patch(struct cpu_info *ci) tmp_pdir = pmap_init_tmp_pgtbl(acpi_wakeup_paddr); - /* Execute Sleep */ memcpy((void *)acpi_wakeup_vaddr, wakecode, sizeof(wakecode)); if (CPU_IS_PRIMARY(ci)) { @@ -260,15 +259,21 @@ acpi_cpu_sleep(struct cpu_info *ci) if (rcr4() & CR4_OSXSAVE) xcr0 = rdxcr(0); + /* Go get some sleep */ if (acpi_md_sleep_prepare(-1)) goto out; - /* Execute Wakeup */ + /* + * Sleeping and having bad nightmares about what could go wrong + * when waking up. + */ + + /* We just woke up (cpuN), execution is resumed here */ cpu_init_msrs(ci, false); fpuinit(ci); if (rcr4() & CR4_OSXSAVE) wrxcr(0, xcr0); - + pat_init(ci); #if NLAPIC > 0 lapic_enable(); lapic_set_lvt(); @@ -326,14 +331,21 @@ acpi_md_sleep(int state) if (rcr4() & CR4_OSXSAVE) xcr0 = rdxcr(0); + /* Go get some sleep */ if (acpi_md_sleep_prepare(state)) goto out; - /* Execute Wakeup */ + /* + * Sleeping and having bad nightmares about what could go wrong + * when waking up. + */ + + /* We just woke up (cpu0), execution is resumed here */ cpu_init_msrs(&cpu_info_primary, false); fpuinit(&cpu_info_primary); if (rcr4() & CR4_OSXSAVE) wrxcr(0, xcr0); + pat_init(&cpu_info_primary); i8259_reinit(); #if NLAPIC > 0 lapic_enable(); @@ -373,6 +385,7 @@ acpi_md_sleep(int state) out: #ifdef MULTIPROCESSOR + /* Wake up the secondary CPUs */ for (CPU_INFO_FOREACH(cii, ci)) { if (CPU_IS_PRIMARY(ci)) continue;
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: maya Date: Tue Sep 19 01:22:14 UTC 2017 Modified Files: src/sys/arch/x86/acpi: acpi_wakeup.c Log Message: Remove unused macro To generate a diff of this commit: cvs rdiff -u -r1.46 -r1.47 src/sys/arch/x86/acpi/acpi_wakeup.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_wakeup.c diff -u src/sys/arch/x86/acpi/acpi_wakeup.c:1.46 src/sys/arch/x86/acpi/acpi_wakeup.c:1.47 --- src/sys/arch/x86/acpi/acpi_wakeup.c:1.46 Thu Aug 10 13:13:03 2017 +++ src/sys/arch/x86/acpi/acpi_wakeup.c Tue Sep 19 01:22:14 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_wakeup.c,v 1.46 2017/08/10 13:13:03 maxv Exp $ */ +/* $NetBSD: acpi_wakeup.c,v 1.47 2017/09/19 01:22:14 maya Exp $ */ /*- * Copyright (c) 2002, 2011 The NetBSD Foundation, Inc. @@ -59,7 +59,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.46 2017/08/10 13:13:03 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.47 2017/09/19 01:22:14 maya Exp $"); #include #include @@ -137,12 +137,6 @@ acpi_md_sleep_patch(struct cpu_info *ci) *addr = val; \ } while (0) -#define WAKECODE_BCOPY(offset, type, val) do { \ - void **addr; \ - addr = (void **)(acpi_wakeup_vaddr + offset); \ - memcpy(addr, &(val), sizeof(type)); \ -} while (0) - paddr_ttmp_pdir; tmp_pdir = pmap_init_tmp_pgtbl(acpi_wakeup_paddr); @@ -172,7 +166,6 @@ acpi_md_sleep_patch(struct cpu_info *ci) #endif WAKECODE_FIXUP(WAKEUP_restorecpu, void *, acpi_md_sleep_exit); #undef WAKECODE_FIXUP -#undef WAKECODE_BCOPY } static int
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: maxv Date: Thu Aug 10 13:13:03 UTC 2017 Modified Files: src/sys/arch/x86/acpi: acpi_wakeup.c Log Message: Save and restore xcr0 when doing ACPI sleeps. Should fix PR/49174. To generate a diff of this commit: cvs rdiff -u -r1.45 -r1.46 src/sys/arch/x86/acpi/acpi_wakeup.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_wakeup.c diff -u src/sys/arch/x86/acpi/acpi_wakeup.c:1.45 src/sys/arch/x86/acpi/acpi_wakeup.c:1.46 --- src/sys/arch/x86/acpi/acpi_wakeup.c:1.45 Thu Oct 20 16:05:04 2016 +++ src/sys/arch/x86/acpi/acpi_wakeup.c Thu Aug 10 13:13:03 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_wakeup.c,v 1.45 2016/10/20 16:05:04 maxv Exp $ */ +/* $NetBSD: acpi_wakeup.c,v 1.46 2017/08/10 13:13:03 maxv Exp $ */ /*- * Copyright (c) 2002, 2011 The NetBSD Foundation, Inc. @@ -59,7 +59,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.45 2016/10/20 16:05:04 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.46 2017/08/10 13:13:03 maxv Exp $"); #include #include @@ -250,6 +250,7 @@ acpi_md_sleep_enter(int state) void acpi_cpu_sleep(struct cpu_info *ci) { + uint64_t xcr0 = 0; int s; KASSERT(!CPU_IS_PRIMARY(ci)); @@ -259,12 +260,21 @@ acpi_cpu_sleep(struct cpu_info *ci) fpusave_cpu(true); x86_disable_intr(); + /* + * XXX also need to save the PMCs, the dbregs, and probably a few + * MSRs too. + */ + if (rcr4() & CR4_OSXSAVE) + xcr0 = rdxcr(0); + if (acpi_md_sleep_prepare(-1)) goto out; /* Execute Wakeup */ cpu_init_msrs(ci, false); fpuinit(ci); + if (rcr4() & CR4_OSXSAVE) + wrxcr(0, xcr0); #if NLAPIC > 0 lapic_enable(); @@ -285,6 +295,7 @@ out: int acpi_md_sleep(int state) { + uint64_t xcr0 = 0; int s, ret = 0; #ifdef MULTIPROCESSOR struct cpu_info *ci; @@ -315,12 +326,21 @@ acpi_md_sleep(int state) } #endif + /* + * XXX also need to save the PMCs, the dbregs, and probably a few + * MSRs too. + */ + if (rcr4() & CR4_OSXSAVE) + xcr0 = rdxcr(0); + if (acpi_md_sleep_prepare(state)) goto out; /* Execute Wakeup */ cpu_init_msrs(&cpu_info_primary, false); fpuinit(&cpu_info_primary); + if (rcr4() & CR4_OSXSAVE) + wrxcr(0, xcr0); i8259_reinit(); #if NLAPIC > 0 lapic_enable();
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: maxv Date: Thu Oct 20 16:05:04 UTC 2016 Modified Files: src/sys/arch/x86/acpi: acpi_wakeup.c Log Message: There is a huge fpu synchronization issue here. When the remote CPUs receive the ACPI sleep IPI, they do not save the fpu state of the lwp they are executing. The problem is, when waking up they reinitialize the registers of their local fpu and go back to their lwp directly. Therefore, if an lwp is interrupted while storing data in an fpu register, that data gets overwritten, which basically means the lwp is likely to go crazy when resuming execution. Fix this by simply saving the fpu state correctly. This way when going to sleep the state is stored in the lwp's pcb and CR0_TS is set, so the next time the lwp wants to use the fpu we'll get a dna, and the state will be restored as expected. While here, don't forget to reenable interrupts (and the spl) if an error occurs. To generate a diff of this commit: cvs rdiff -u -r1.44 -r1.45 src/sys/arch/x86/acpi/acpi_wakeup.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_wakeup.c diff -u src/sys/arch/x86/acpi/acpi_wakeup.c:1.44 src/sys/arch/x86/acpi/acpi_wakeup.c:1.45 --- src/sys/arch/x86/acpi/acpi_wakeup.c:1.44 Thu Oct 20 14:06:18 2016 +++ src/sys/arch/x86/acpi/acpi_wakeup.c Thu Oct 20 16:05:04 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_wakeup.c,v 1.44 2016/10/20 14:06:18 maxv Exp $ */ +/* $NetBSD: acpi_wakeup.c,v 1.45 2016/10/20 16:05:04 maxv Exp $ */ /*- * Copyright (c) 2002, 2011 The NetBSD Foundation, Inc. @@ -59,7 +59,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.44 2016/10/20 14:06:18 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.45 2016/10/20 16:05:04 maxv Exp $"); #include #include @@ -250,13 +250,17 @@ acpi_md_sleep_enter(int state) void acpi_cpu_sleep(struct cpu_info *ci) { + int s; + KASSERT(!CPU_IS_PRIMARY(ci)); KASSERT(ci == curcpu()); + s = splhigh(); + fpusave_cpu(true); x86_disable_intr(); if (acpi_md_sleep_prepare(-1)) - return; + goto out; /* Execute Wakeup */ cpu_init_msrs(ci, false); @@ -272,7 +276,9 @@ acpi_cpu_sleep(struct cpu_info *ci) kcpuset_atomic_set(kcpuset_running, cpu_index(ci)); tsc_sync_ap(ci); +out: x86_enable_intr(); + splx(s); } #endif
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: maxv Date: Thu Oct 20 14:06:18 UTC 2016 Modified Files: src/sys/arch/x86/acpi: acpi_wakeup.c Log Message: Reload the MSRs on the original cpu on i386 - looks like I forgot this part in my rev1.41. Technically it does not change anything, since the only MSR is NOX and it is already reloaded in the trampoline. To generate a diff of this commit: cvs rdiff -u -r1.43 -r1.44 src/sys/arch/x86/acpi/acpi_wakeup.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_wakeup.c diff -u src/sys/arch/x86/acpi/acpi_wakeup.c:1.43 src/sys/arch/x86/acpi/acpi_wakeup.c:1.44 --- src/sys/arch/x86/acpi/acpi_wakeup.c:1.43 Fri Oct 7 10:58:03 2016 +++ src/sys/arch/x86/acpi/acpi_wakeup.c Thu Oct 20 14:06:18 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_wakeup.c,v 1.43 2016/10/07 10:58:03 skrll Exp $ */ +/* $NetBSD: acpi_wakeup.c,v 1.44 2016/10/20 14:06:18 maxv Exp $ */ /*- * Copyright (c) 2002, 2011 The NetBSD Foundation, Inc. @@ -59,7 +59,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.43 2016/10/07 10:58:03 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.44 2016/10/20 14:06:18 maxv Exp $"); #include #include @@ -313,9 +313,7 @@ acpi_md_sleep(int state) goto out; /* Execute Wakeup */ -#ifndef __i386__ cpu_init_msrs(&cpu_info_primary, false); -#endif fpuinit(&cpu_info_primary); i8259_reinit(); #if NLAPIC > 0
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: skrll Date: Fri Oct 7 10:58:03 UTC 2016 Modified Files: src/sys/arch/x86/acpi: acpi_wakeup.c Log Message: Don't include sys/cdefs.h and __KERNEL_RSCID twice... once is enough. To generate a diff of this commit: cvs rdiff -u -r1.42 -r1.43 src/sys/arch/x86/acpi/acpi_wakeup.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_wakeup.c diff -u src/sys/arch/x86/acpi/acpi_wakeup.c:1.42 src/sys/arch/x86/acpi/acpi_wakeup.c:1.43 --- src/sys/arch/x86/acpi/acpi_wakeup.c:1.42 Tue Sep 20 08:38:55 2016 +++ src/sys/arch/x86/acpi/acpi_wakeup.c Fri Oct 7 10:58:03 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_wakeup.c,v 1.42 2016/09/20 08:38:55 maya Exp $ */ +/* $NetBSD: acpi_wakeup.c,v 1.43 2016/10/07 10:58:03 skrll Exp $ */ /*- * Copyright (c) 2002, 2011 The NetBSD Foundation, Inc. @@ -29,9 +29,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include -__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.42 2016/09/20 08:38:55 maya Exp $"); - /*- * Copyright (c) 2001 Takanori Watanabe * Copyright (c) 2001 Mitsuru IWASAKI @@ -62,7 +59,7 @@ __KERNEL_RCSID(0, "$NetBSD: acpi_wakeup. */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.42 2016/09/20 08:38:55 maya Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.43 2016/10/07 10:58:03 skrll Exp $"); #include #include
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: maya Date: Tue Sep 20 08:38:55 UTC 2016 Modified Files: src/sys/arch/x86/acpi: acpi_wakeup.c Log Message: use a value of hw.acpi.sleep.vbios that might actually work for any real hardware suspend. stop dragging feet through the ground in PR kern/50781 To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/sys/arch/x86/acpi/acpi_wakeup.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_wakeup.c diff -u src/sys/arch/x86/acpi/acpi_wakeup.c:1.41 src/sys/arch/x86/acpi/acpi_wakeup.c:1.42 --- src/sys/arch/x86/acpi/acpi_wakeup.c:1.41 Wed Jul 27 13:04:28 2016 +++ src/sys/arch/x86/acpi/acpi_wakeup.c Tue Sep 20 08:38:55 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_wakeup.c,v 1.41 2016/07/27 13:04:28 maxv Exp $ */ +/* $NetBSD: acpi_wakeup.c,v 1.42 2016/09/20 08:38:55 maya Exp $ */ /*- * Copyright (c) 2002, 2011 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.41 2016/07/27 13:04:28 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.42 2016/09/20 08:38:55 maya Exp $"); /*- * Copyright (c) 2001 Takanori Watanabe @@ -62,7 +62,7 @@ __KERNEL_RCSID(0, "$NetBSD: acpi_wakeup. */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.41 2016/07/27 13:04:28 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.42 2016/09/20 08:38:55 maya Exp $"); #include #include @@ -111,7 +111,7 @@ __KERNEL_RCSID(0, "$NetBSD: acpi_wakeup. static paddr_t acpi_wakeup_paddr = 3 * PAGE_SIZE; static vaddr_t acpi_wakeup_vaddr; -int acpi_md_vbios_reset = 1; /* Referenced by dev/pci/vga_pci.c */ +int acpi_md_vbios_reset = 0; /* Referenced by dev/pci/vga_pci.c */ int acpi_md_vesa_modenum = 0; /* Referenced by arch/x86/x86/genfb_machdep.c */ static int acpi_md_beep_on_reset = 0;
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: maxv Date: Wed Jul 27 13:04:29 UTC 2016 Modified Files: src/sys/arch/x86/acpi: acpi_wakeup.c Log Message: Call cpu_init_msrs on i386 when waking up. Currently it does not change anything, since MSR_EFER is already enabled earlier. But if we add new MSRs in the future, we will want them when waking up as well. To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.41 src/sys/arch/x86/acpi/acpi_wakeup.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_wakeup.c diff -u src/sys/arch/x86/acpi/acpi_wakeup.c:1.40 src/sys/arch/x86/acpi/acpi_wakeup.c:1.41 --- src/sys/arch/x86/acpi/acpi_wakeup.c:1.40 Sun Jul 24 14:09:22 2016 +++ src/sys/arch/x86/acpi/acpi_wakeup.c Wed Jul 27 13:04:28 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_wakeup.c,v 1.40 2016/07/24 14:09:22 maxv Exp $ */ +/* $NetBSD: acpi_wakeup.c,v 1.41 2016/07/27 13:04:28 maxv Exp $ */ /*- * Copyright (c) 2002, 2011 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.40 2016/07/24 14:09:22 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.41 2016/07/27 13:04:28 maxv Exp $"); /*- * Copyright (c) 2001 Takanori Watanabe @@ -62,7 +62,7 @@ __KERNEL_RCSID(0, "$NetBSD: acpi_wakeup. */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.40 2016/07/24 14:09:22 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.41 2016/07/27 13:04:28 maxv Exp $"); #include #include @@ -262,10 +262,9 @@ acpi_cpu_sleep(struct cpu_info *ci) return; /* Execute Wakeup */ -#ifndef __i386__ cpu_init_msrs(ci, false); -#endif fpuinit(ci); + #if NLAPIC > 0 lapic_enable(); lapic_set_lvt();
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: htodd Date: Thu Jan 28 23:50:04 UTC 2016 Modified Files: src/sys/arch/x86/acpi: acpi_machdep.c Log Message: Fix build break. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/arch/x86/acpi/acpi_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_machdep.c diff -u src/sys/arch/x86/acpi/acpi_machdep.c:1.11 src/sys/arch/x86/acpi/acpi_machdep.c:1.12 --- src/sys/arch/x86/acpi/acpi_machdep.c:1.11 Thu Jan 28 01:09:56 2016 +++ src/sys/arch/x86/acpi/acpi_machdep.c Thu Jan 28 23:50:04 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_machdep.c,v 1.11 2016/01/28 01:09:56 christos Exp $ */ +/* $NetBSD: acpi_machdep.c,v 1.12 2016/01/28 23:50:04 htodd Exp $ */ /* * Copyright 2001 Wasabi Systems, Inc. @@ -40,7 +40,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.11 2016/01/28 01:09:56 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.12 2016/01/28 23:50:04 htodd Exp $"); #include #include @@ -89,6 +89,7 @@ acpi_md_OsGetRootPointer(void) ACPI_PHYSICAL_ADDRESS PhysicalAddress; ACPI_STATUS Status; +#ifndef XEN /* If EFI is available, attempt to use it to locate the ACPI table. */ if (efi_probe()) { PhysicalAddress = efi_getcfgtblpa(&EFI_UUID_ACPI20); @@ -98,6 +99,7 @@ acpi_md_OsGetRootPointer(void) return PhysicalAddress; } +#endif Status = AcpiFindRootPointer(&PhysicalAddress); if (ACPI_FAILURE(Status)) PhysicalAddress = 0;
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: christos Date: Tue Oct 6 15:06:05 UTC 2015 Modified Files: src/sys/arch/x86/acpi: acpi_machdep.c Log Message: CID/1325751: Avoid possible 32 bit overflow. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/arch/x86/acpi/acpi_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_machdep.c diff -u src/sys/arch/x86/acpi/acpi_machdep.c:1.9 src/sys/arch/x86/acpi/acpi_machdep.c:1.10 --- src/sys/arch/x86/acpi/acpi_machdep.c:1.9 Fri Oct 2 01:22:52 2015 +++ src/sys/arch/x86/acpi/acpi_machdep.c Tue Oct 6 11:06:05 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_machdep.c,v 1.9 2015/10/02 05:22:52 msaitoh Exp $ */ +/* $NetBSD: acpi_machdep.c,v 1.10 2015/10/06 15:06:05 christos Exp $ */ /* * Copyright 2001 Wasabi Systems, Inc. @@ -40,7 +40,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.9 2015/10/02 05:22:52 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.10 2015/10/06 15:06:05 christos Exp $"); #include #include @@ -352,7 +352,8 @@ acpi_md_mcfg_validate(uint64_t addr, int if (bim == NULL) return false; - size = (*bus_end - bus_start + 1) * ACPIMCFG_SIZE_PER_BUS; + size = *bus_end - bus_start + 1; + size *= ACPIMCFG_SIZE_PER_BUS; for (i = 0; i < bim->num; i++) { mapaddr = bim->entry[i].addr; mapsize = bim->entry[i].size;
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: christos Date: Tue Aug 18 10:42:41 UTC 2015 Modified Files: src/sys/arch/x86/acpi: acpi_wakeup.c Log Message: dup the argument of the wakeup vector. XXX: is that correct? To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.39 src/sys/arch/x86/acpi/acpi_wakeup.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_wakeup.c diff -u src/sys/arch/x86/acpi/acpi_wakeup.c:1.38 src/sys/arch/x86/acpi/acpi_wakeup.c:1.39 --- src/sys/arch/x86/acpi/acpi_wakeup.c:1.38 Tue Feb 25 13:30:08 2014 +++ src/sys/arch/x86/acpi/acpi_wakeup.c Tue Aug 18 06:42:41 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_wakeup.c,v 1.38 2014/02/25 18:30:08 pooka Exp $ */ +/* $NetBSD: acpi_wakeup.c,v 1.39 2015/08/18 10:42:41 christos Exp $ */ /*- * Copyright (c) 2002, 2011 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.38 2014/02/25 18:30:08 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.39 2015/08/18 10:42:41 christos Exp $"); /*- * Copyright (c) 2001 Takanori Watanabe @@ -62,7 +62,7 @@ __KERNEL_RCSID(0, "$NetBSD: acpi_wakeup. */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.38 2014/02/25 18:30:08 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.39 2015/08/18 10:42:41 christos Exp $"); #include #include @@ -300,7 +300,7 @@ acpi_md_sleep(int state) return -1; } - AcpiSetFirmwareWakingVector(acpi_wakeup_paddr); + AcpiSetFirmwareWakingVector(acpi_wakeup_paddr, acpi_wakeup_paddr); s = splhigh(); fpusave_cpu(true);
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: joerg Date: Mon May 12 11:51:34 UTC 2014 Modified Files: src/sys/arch/x86/acpi: acpi_machdep.c Log Message: acpi_md_findoverride is only used when NIOAPIC > 0, so don't provide it otherwise. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/arch/x86/acpi/acpi_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_machdep.c diff -u src/sys/arch/x86/acpi/acpi_machdep.c:1.7 src/sys/arch/x86/acpi/acpi_machdep.c:1.8 --- src/sys/arch/x86/acpi/acpi_machdep.c:1.7 Sun Oct 6 16:34:48 2013 +++ src/sys/arch/x86/acpi/acpi_machdep.c Mon May 12 11:51:34 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_machdep.c,v 1.7 2013/10/06 16:34:48 jakllsch Exp $ */ +/* $NetBSD: acpi_machdep.c,v 1.8 2014/05/12 11:51:34 joerg Exp $ */ /* * Copyright 2001 Wasabi Systems, Inc. @@ -40,7 +40,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.7 2013/10/06 16:34:48 jakllsch Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.8 2014/05/12 11:51:34 joerg Exp $"); #include #include @@ -99,6 +99,7 @@ struct acpi_md_override { int flags; }; +#if NIOAPIC > 0 static ACPI_STATUS acpi_md_findoverride(ACPI_SUBTABLE_HEADER *hdrp, void *aux) { @@ -117,6 +118,7 @@ acpi_md_findoverride(ACPI_SUBTABLE_HEADE } return AE_OK; } +#endif ACPI_STATUS acpi_md_OsInstallInterruptHandler(uint32_t InterruptNumber,
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: christos Date: Thu Apr 17 16:01:24 UTC 2014 Modified Files: src/sys/arch/x86/acpi: acpi_cpu_md.c Log Message: CID/1203191: Out of bounds read To generate a diff of this commit: cvs rdiff -u -r1.76 -r1.77 src/sys/arch/x86/acpi/acpi_cpu_md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_cpu_md.c diff -u src/sys/arch/x86/acpi/acpi_cpu_md.c:1.76 src/sys/arch/x86/acpi/acpi_cpu_md.c:1.77 --- src/sys/arch/x86/acpi/acpi_cpu_md.c:1.76 Thu Mar 27 14:22:56 2014 +++ src/sys/arch/x86/acpi/acpi_cpu_md.c Thu Apr 17 12:01:24 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_cpu_md.c,v 1.76 2014/03/27 18:22:56 christos Exp $ */ +/* $NetBSD: acpi_cpu_md.c,v 1.77 2014/04/17 16:01:24 christos Exp $ */ /*- * Copyright (c) 2010, 2011 Jukka Ruohonen @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.76 2014/03/27 18:22:56 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.77 2014/04/17 16:01:24 christos Exp $"); #include #include @@ -1150,11 +1150,11 @@ acpicpu_md_pstate_sysctl_all(SYSCTLFN_AR if (sc->sc_pstate[i].ps_freq == 0) continue; + if (len >= sizeof(buf)) + break; len += snprintf(buf + len, sizeof(buf) - len, "%u%s", sc->sc_pstate[i].ps_freq, i < (sc->sc_pstate_count - 1) ? " " : ""); - if (len > sizeof(buf)) - break; } mutex_exit(&sc->sc_mtx);
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: jruoho Date: Wed Nov 20 13:52:30 UTC 2013 Modified Files: src/sys/arch/x86/acpi: acpi_cpu_md.c Log Message: Allow 4-bit range for MSR_THERM_CONTROL. To generate a diff of this commit: cvs rdiff -u -r1.73 -r1.74 src/sys/arch/x86/acpi/acpi_cpu_md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_cpu_md.c diff -u src/sys/arch/x86/acpi/acpi_cpu_md.c:1.73 src/sys/arch/x86/acpi/acpi_cpu_md.c:1.74 --- src/sys/arch/x86/acpi/acpi_cpu_md.c:1.73 Fri Nov 15 08:47:55 2013 +++ src/sys/arch/x86/acpi/acpi_cpu_md.c Wed Nov 20 13:52:30 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_cpu_md.c,v 1.73 2013/11/15 08:47:55 msaitoh Exp $ */ +/* $NetBSD: acpi_cpu_md.c,v 1.74 2013/11/20 13:52:30 jruoho Exp $ */ /*- * Copyright (c) 2010, 2011 Jukka Ruohonen @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.73 2013/11/15 08:47:55 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.74 2013/11/20 13:52:30 jruoho Exp $"); #include #include @@ -986,7 +986,7 @@ acpicpu_md_tstate_set(struct acpicpu_tst uint8_t i; val = ts->ts_control; - val = val & __BITS(1, 4); + val = val & __BITS(0, 4); wrmsr(MSR_THERM_CONTROL, val);
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: jakllsch Date: Sun Oct 6 16:34:49 UTC 2013 Modified Files: src/sys/arch/x86/acpi: acpi_machdep.c Log Message: Correct acpi_md_OsWritable() logic so that it can return TRUE. >From Masanori Kanaoka in PR 47571. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/arch/x86/acpi/acpi_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_machdep.c diff -u src/sys/arch/x86/acpi/acpi_machdep.c:1.6 src/sys/arch/x86/acpi/acpi_machdep.c:1.7 --- src/sys/arch/x86/acpi/acpi_machdep.c:1.6 Sun Mar 31 19:34:24 2013 +++ src/sys/arch/x86/acpi/acpi_machdep.c Sun Oct 6 16:34:48 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_machdep.c,v 1.6 2013/03/31 19:34:24 chs Exp $ */ +/* $NetBSD: acpi_machdep.c,v 1.7 2013/10/06 16:34:48 jakllsch Exp $ */ /* * Copyright 2001 Wasabi Systems, Inc. @@ -40,7 +40,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.6 2013/03/31 19:34:24 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.7 2013/10/06 16:34:48 jakllsch Exp $"); #include #include @@ -297,7 +297,7 @@ acpi_md_OsReadable(void *Pointer, uint32 BOOLEAN acpi_md_OsWritable(void *Pointer, uint32_t Length) { - BOOLEAN rv = FALSE; + BOOLEAN rv = TRUE; vaddr_t sva, eva; pt_entry_t *pte;
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: chs Date: Sun Mar 31 19:34:25 UTC 2013 Modified Files: src/sys/arch/x86/acpi: acpi_machdep.c Log Message: yet more fixes for PR 47648 / PR 47016: when using a temporary mp_intr_map, initialize the "flags" field as well as "redir" since apic_set_redir() uses both. fix how the flags field is change when applying an override, the trigger and polarity sub-fields aren't just one bit like they are in redir. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/arch/x86/acpi/acpi_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_machdep.c diff -u src/sys/arch/x86/acpi/acpi_machdep.c:1.5 src/sys/arch/x86/acpi/acpi_machdep.c:1.6 --- src/sys/arch/x86/acpi/acpi_machdep.c:1.5 Mon Mar 25 01:30:37 2013 +++ src/sys/arch/x86/acpi/acpi_machdep.c Sun Mar 31 19:34:24 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_machdep.c,v 1.5 2013/03/25 01:30:37 chs Exp $ */ +/* $NetBSD: acpi_machdep.c,v 1.6 2013/03/31 19:34:24 chs Exp $ */ /* * Copyright 2001 Wasabi Systems, Inc. @@ -40,7 +40,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.5 2013/03/25 01:30:37 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.6 2013/03/31 19:34:24 chs Exp $"); #include #include @@ -163,12 +163,14 @@ acpi_md_OsInstallInterruptHandler(uint32 if (polarity == ACPI_MADT_POLARITY_ACTIVE_HIGH || (!sci && polarity == ACPI_MADT_POLARITY_CONFORMS)) { mpflags &= ~MPS_INTPO_ACTLO; + mpflags |= MPS_INTPO_ACTHI; redir &= ~IOAPIC_REDLO_ACTLO; } if (trigger == ACPI_MADT_TRIGGER_EDGE || (!sci && trigger == ACPI_MADT_TRIGGER_CONFORMS)) { type = IST_EDGE; mpflags &= ~(MPS_INTTR_LEVEL << 2); + mpflags |= (MPS_INTTR_EDGE << 2); redir &= ~IOAPIC_REDLO_LEVEL; } } @@ -200,6 +202,7 @@ acpi_md_OsInstallInterruptHandler(uint32 mipp = &sc->sc_pins[pin].ip_map; *mipp = &tmpmap; tmpmap.redir = redir; + tmpmap.flags = mpflags; } } else #endif
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: jruoho Date: Thu Dec 6 04:43:29 UTC 2012 Modified Files: src/sys/arch/x86/acpi: acpi_cpu_md.c Log Message: Disable C1E also on K8, if present. From Imre Vadasz in PR install/47224. To generate a diff of this commit: cvs rdiff -u -r1.71 -r1.72 src/sys/arch/x86/acpi/acpi_cpu_md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_cpu_md.c diff -u src/sys/arch/x86/acpi/acpi_cpu_md.c:1.71 src/sys/arch/x86/acpi/acpi_cpu_md.c:1.72 --- src/sys/arch/x86/acpi/acpi_cpu_md.c:1.71 Sat Feb 11 22:09:47 2012 +++ src/sys/arch/x86/acpi/acpi_cpu_md.c Thu Dec 6 04:43:29 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_cpu_md.c,v 1.71 2012/02/11 22:09:47 jruoho Exp $ */ +/* $NetBSD: acpi_cpu_md.c,v 1.72 2012/12/06 04:43:29 jruoho Exp $ */ /*- * Copyright (c) 2010, 2011 Jukka Ruohonen @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.71 2012/02/11 22:09:47 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.72 2012/12/06 04:43:29 jruoho Exp $"); #include #include @@ -253,6 +253,12 @@ acpicpu_md_flags(void) case 0x0f: /* + * Disable C1E if present. + */ + if (rdmsr_safe(MSR_CMPHALT, &msr) != EFAULT) +val |= ACPICPU_FLAG_C_C1E; + + /* * Evaluate support for the "FID/VID * algorithm" also used by powernow(4). */ @@ -268,6 +274,9 @@ acpicpu_md_flags(void) case 0x10: case 0x11: + /* + * Disable C1E if present. + */ if (rdmsr_safe(MSR_CMPHALT, &msr) != EFAULT) val |= ACPICPU_FLAG_C_C1E;
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: jakllsch Date: Sun Aug 26 01:04:03 UTC 2012 Modified Files: src/sys/arch/x86/acpi: acpi_wakeup.c Log Message: It turns out we're actually waiting for other processors to be unbusy, not busy. Unbreaks ACPI suspend on uniprocessor. Probably fixes unnoticed bugs on MP. Needs pullup to netbsd-6. To generate a diff of this commit: cvs rdiff -u -r1.31 -r1.32 src/sys/arch/x86/acpi/acpi_wakeup.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_wakeup.c diff -u src/sys/arch/x86/acpi/acpi_wakeup.c:1.31 src/sys/arch/x86/acpi/acpi_wakeup.c:1.32 --- src/sys/arch/x86/acpi/acpi_wakeup.c:1.31 Fri Apr 20 22:23:24 2012 +++ src/sys/arch/x86/acpi/acpi_wakeup.c Sun Aug 26 01:04:03 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_wakeup.c,v 1.31 2012/04/20 22:23:24 rmind Exp $ */ +/* $NetBSD: acpi_wakeup.c,v 1.32 2012/08/26 01:04:03 jakllsch Exp $ */ /*- * Copyright (c) 2002, 2011 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.31 2012/04/20 22:23:24 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.32 2012/08/26 01:04:03 jakllsch Exp $"); /*- * Copyright (c) 2001 Takanori Watanabe @@ -62,7 +62,7 @@ __KERNEL_RCSID(0, "$NetBSD: acpi_wakeup. */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.31 2012/04/20 22:23:24 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.32 2012/08/26 01:04:03 jakllsch Exp $"); #include #include @@ -320,7 +320,7 @@ acpi_md_sleep(int state) /* Save and suspend Application Processors. */ x86_broadcast_ipi(X86_IPI_ACPI_CPU_SLEEP); cid = cpu_index(curcpu()); - while (!kcpuset_isotherset(kcpuset_running, cid)) { + while (kcpuset_isotherset(kcpuset_running, cid)) { delay(1); } #endif
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: jruoho Date: Sat Feb 11 22:09:47 UTC 2012 Modified Files: src/sys/arch/x86/acpi: acpi_cpu_md.c Log Message: Fix missing case for AMD 0x15. To generate a diff of this commit: cvs rdiff -u -r1.70 -r1.71 src/sys/arch/x86/acpi/acpi_cpu_md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_cpu_md.c diff -u src/sys/arch/x86/acpi/acpi_cpu_md.c:1.70 src/sys/arch/x86/acpi/acpi_cpu_md.c:1.71 --- src/sys/arch/x86/acpi/acpi_cpu_md.c:1.70 Sat Feb 11 22:07:53 2012 +++ src/sys/arch/x86/acpi/acpi_cpu_md.c Sat Feb 11 22:09:47 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_cpu_md.c,v 1.70 2012/02/11 22:07:53 jruoho Exp $ */ +/* $NetBSD: acpi_cpu_md.c,v 1.71 2012/02/11 22:09:47 jruoho Exp $ */ /*- * Copyright (c) 2010, 2011 Jukka Ruohonen @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.70 2012/02/11 22:07:53 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.71 2012/02/11 22:09:47 jruoho Exp $"); #include #include @@ -553,7 +553,8 @@ acpicpu_md_pstate_init(struct acpicpu_so case 0x10: case 0x11: case 0x12: - case 0x14: /* AMD Fusion */ + case 0x14: + case 0x15: msr.ps_control_addr = MSR_10H_CONTROL; msr.ps_control_mask = __BITS(0, 2);
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: jruoho Date: Sat Feb 11 22:07:53 UTC 2012 Modified Files: src/sys/arch/x86/acpi: acpi_cpu_md.c Log Message: Add non-XPSS support for AMD family 15h a.k.a. "Bulldozer". Ok releng@. To generate a diff of this commit: cvs rdiff -u -r1.69 -r1.70 src/sys/arch/x86/acpi/acpi_cpu_md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_cpu_md.c diff -u src/sys/arch/x86/acpi/acpi_cpu_md.c:1.69 src/sys/arch/x86/acpi/acpi_cpu_md.c:1.70 --- src/sys/arch/x86/acpi/acpi_cpu_md.c:1.69 Tue Nov 15 07:20:30 2011 +++ src/sys/arch/x86/acpi/acpi_cpu_md.c Sat Feb 11 22:07:53 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_cpu_md.c,v 1.69 2011/11/15 07:20:30 jruoho Exp $ */ +/* $NetBSD: acpi_cpu_md.c,v 1.70 2012/02/11 22:07:53 jruoho Exp $ */ /*- * Copyright (c) 2010, 2011 Jukka Ruohonen @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.69 2011/11/15 07:20:30 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.70 2012/02/11 22:07:53 jruoho Exp $"); #include #include @@ -68,7 +68,7 @@ __KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md. #define MSR_CMPHALT_BMSTS __BIT(29) /* - * AMD families 10h, 11h, 12h, and 14h. + * AMD families 10h, 11h, 12h, 14h, and 15h. */ #define MSR_10H_LIMIT 0xc0010061 #define MSR_10H_CONTROL 0xc0010062 @@ -275,6 +275,7 @@ acpicpu_md_flags(void) case 0x12: case 0x14: /* AMD Fusion */ + case 0x15: /* AMD Bulldozer */ /* * Like with Intel, detect invariant TSC,
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: rmind Date: Mon Jan 30 21:47:24 UTC 2012 Modified Files: src/sys/arch/x86/acpi: acpi_machdep.c Log Message: acpi_md_ncpus: use kcpuset_attached instead. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/x86/acpi/acpi_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_machdep.c diff -u src/sys/arch/x86/acpi/acpi_machdep.c:1.2 src/sys/arch/x86/acpi/acpi_machdep.c:1.3 --- src/sys/arch/x86/acpi/acpi_machdep.c:1.2 Fri Jul 1 18:22:39 2011 +++ src/sys/arch/x86/acpi/acpi_machdep.c Mon Jan 30 21:47:24 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_machdep.c,v 1.2 2011/07/01 18:22:39 dyoung Exp $ */ +/* $NetBSD: acpi_machdep.c,v 1.3 2012/01/30 21:47:24 rmind Exp $ */ /* * Copyright 2001 Wasabi Systems, Inc. @@ -40,11 +40,12 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.2 2011/07/01 18:22:39 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.3 2012/01/30 21:47:24 rmind Exp $"); #include #include #include +#include #include #include @@ -72,8 +73,6 @@ __KERNEL_RCSID(0, "$NetBSD: acpi_machdep #include "opt_mpbios.h" #include "opt_acpi.h" -extern uint32_t cpus_attached; - ACPI_STATUS acpi_md_OsInitialize(void) { @@ -280,7 +279,7 @@ acpi_md_OsEnableInterrupt(void) uint32_t acpi_md_ncpus(void) { - return popcount32(cpus_attached); + return kcpuset_countset(kcpuset_attached); } void
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: jruoho Date: Tue Nov 15 07:20:31 UTC 2011 Modified Files: src/sys/arch/x86/acpi: acpi_cpu_md.c Log Message: Add support for AMD family 12h. Also revert revision 1.67, as it implies maintenance burden for limited value. XXX: Need to add family 15h too. To generate a diff of this commit: cvs rdiff -u -r1.68 -r1.69 src/sys/arch/x86/acpi/acpi_cpu_md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_cpu_md.c diff -u src/sys/arch/x86/acpi/acpi_cpu_md.c:1.68 src/sys/arch/x86/acpi/acpi_cpu_md.c:1.69 --- src/sys/arch/x86/acpi/acpi_cpu_md.c:1.68 Tue Oct 18 05:08:24 2011 +++ src/sys/arch/x86/acpi/acpi_cpu_md.c Tue Nov 15 07:20:30 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_cpu_md.c,v 1.68 2011/10/18 05:08:24 jruoho Exp $ */ +/* $NetBSD: acpi_cpu_md.c,v 1.69 2011/11/15 07:20:30 jruoho Exp $ */ /*- * Copyright (c) 2010, 2011 Jukka Ruohonen @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.68 2011/10/18 05:08:24 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.69 2011/11/15 07:20:30 jruoho Exp $"); #include #include @@ -68,7 +68,7 @@ __KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md. #define MSR_CMPHALT_BMSTS __BIT(29) /* - * AMD families 10h, 11h, and 14h + * AMD families 10h, 11h, 12h, and 14h. */ #define MSR_10H_LIMIT 0xc0010061 #define MSR_10H_CONTROL 0xc0010062 @@ -107,7 +107,6 @@ static char native_idle_text[16]; void (*native_idle)(void) = NULL; static int acpicpu_md_quirk_piix4(const struct pci_attach_args *); -static void acpicpu_md_quirk_amd(struct acpicpu_pstate *, uint32_t); static void acpicpu_md_pstate_hwf_reset(void *, void *); static int acpicpu_md_pstate_fidvid_get(struct acpicpu_softc *, uint32_t *); @@ -274,6 +273,7 @@ acpicpu_md_flags(void) /* FALLTHROUGH */ + case 0x12: case 0x14: /* AMD Fusion */ /* @@ -336,55 +336,6 @@ acpicpu_md_quirk_piix4(const struct pci_ return 0; } -static void -acpicpu_md_quirk_amd(struct acpicpu_pstate *ps, uint32_t i) -{ - struct cpu_info *ci = &cpu_info_primary; - uint32_t family, fid, freq, did, zeta; - uint64_t val; - - if (i > 7 || cpu_vendor != CPUVENDOR_AMD) - return; - - family = CPUID2FAMILY(ci->ci_signature); - - if (family == 0xf) - family += CPUID2EXTFAMILY(ci->ci_signature); - - switch (family) { - - case 0x10: - zeta = 0x10; - break; - - case 0x11: - zeta = 0x08; - break; - - default: - return; - } - - /* - * The following eight P-state control MSRs define - * the static per-core values; the MSB indicates - * whether the state is enabled, and the first eight - * bits define the frequency divisor and multiplier. - */ - val = rdmsr(MSR_10H_CONFIG + i); - - if ((val & __BIT(63)) == 0) - return; - - fid = __SHIFTOUT(val, __BITS(0, 5)); - did = __SHIFTOUT(val, __BITS(6, 8)); - - freq = 100 * (fid + zeta) >> did; - - if (freq != 0 && ps->ps_freq != freq) - ps->ps_freq = freq; -} - void acpicpu_md_quirk_c1e(void) { @@ -600,6 +551,7 @@ acpicpu_md_pstate_init(struct acpicpu_so case 0x10: case 0x11: + case 0x12: case 0x14: /* AMD Fusion */ msr.ps_control_addr = MSR_10H_CONTROL; msr.ps_control_mask = __BITS(0, 2); @@ -647,13 +599,6 @@ acpicpu_md_pstate_init(struct acpicpu_so if (msr.ps_control_mask != 0) ps->ps_control_mask = msr.ps_control_mask; - /* - * Some AMD systems may round the frequencies - * reported in the tables. Try to fix these. - */ - if (cpu_vendor == CPUVENDOR_AMD) - acpicpu_md_quirk_amd(ps, i); - i++; }
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: jruoho Date: Sat Sep 24 19:41:40 UTC 2011 Modified Files: src/sys/arch/x86/acpi: acpi_cpu_md.c Log Message: Try to obtain reliable MHz values for AMD familiesi 10h and 11h. To generate a diff of this commit: cvs rdiff -u -r1.66 -r1.67 src/sys/arch/x86/acpi/acpi_cpu_md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_cpu_md.c diff -u src/sys/arch/x86/acpi/acpi_cpu_md.c:1.66 src/sys/arch/x86/acpi/acpi_cpu_md.c:1.67 --- src/sys/arch/x86/acpi/acpi_cpu_md.c:1.66 Sat Sep 24 11:17:25 2011 +++ src/sys/arch/x86/acpi/acpi_cpu_md.c Sat Sep 24 19:41:40 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_cpu_md.c,v 1.66 2011/09/24 11:17:25 jruoho Exp $ */ +/* $NetBSD: acpi_cpu_md.c,v 1.67 2011/09/24 19:41:40 jruoho Exp $ */ /*- * Copyright (c) 2010, 2011 Jukka Ruohonen @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.66 2011/09/24 11:17:25 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.67 2011/09/24 19:41:40 jruoho Exp $"); #include #include @@ -106,6 +106,7 @@ static char native_idle_text[16]; void (*native_idle)(void) = NULL; static int acpicpu_md_quirk_piix4(const struct pci_attach_args *); +static void acpicpu_md_quirk_amd(struct acpicpu_pstate *, uint32_t); static void acpicpu_md_pstate_hwf_reset(void *, void *); static int acpicpu_md_pstate_fidvid_get(struct acpicpu_softc *, uint32_t *); @@ -334,6 +335,55 @@ acpicpu_md_quirk_piix4(const struct pci_ return 0; } +static void +acpicpu_md_quirk_amd(struct acpicpu_pstate *ps, uint32_t i) +{ + struct cpu_info *ci = &cpu_info_primary; + uint32_t family, fid, freq, did, zeta; + uint64_t val; + + if (i > 7 || cpu_vendor != CPUVENDOR_AMD) + return; + + family = CPUID2FAMILY(ci->ci_signature); + + if (family == 0xf) + family += CPUID2EXTFAMILY(ci->ci_signature); + + switch (family) { + + case 0x10: + zeta = 0x10; + break; + + case 0x11: + zeta = 0x08; + break; + + default: + return; + } + + /* + * The following eight P-state control MSRs define + * the static per-core values; the MSB indicates + * whether the state is enabled, and the first eight + * bits define the frequency divisor and multiplier. + */ + val = rdmsr(MSR_10H_CONFIG + i); + + if ((val & __BIT(63)) == 0) + return; + + fid = __SHIFTOUT(val, __BITS(0, 5)); + did = __SHIFTOUT(val, __BITS(6, 8)); + + freq = 100 * (fid + zeta) >> did; + + if (freq != 0 && ps->ps_freq != freq) + ps->ps_freq = freq; +} + void acpicpu_md_quirk_c1e(void) { @@ -596,6 +646,13 @@ acpicpu_md_pstate_init(struct acpicpu_so if (msr.ps_control_mask != 0) ps->ps_control_mask = msr.ps_control_mask; + /* + * Some AMD systems may round the frequencies + * reported in the tables. Try to fix these. + */ + if (cpu_vendor == CPUVENDOR_AMD) + acpicpu_md_quirk_amd(ps, i); + i++; }
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: jruoho Date: Sat Sep 24 11:17:26 UTC 2011 Modified Files: src/sys/arch/x86/acpi: acpi_cpu_md.c Log Message: Be more intelligent; read the MSR_CMPHALT with rdmsr_safe() and set the C1E-flag based on this. Pointed out by jmcneill@. To generate a diff of this commit: cvs rdiff -u -r1.65 -r1.66 src/sys/arch/x86/acpi/acpi_cpu_md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_cpu_md.c diff -u src/sys/arch/x86/acpi/acpi_cpu_md.c:1.65 src/sys/arch/x86/acpi/acpi_cpu_md.c:1.66 --- src/sys/arch/x86/acpi/acpi_cpu_md.c:1.65 Sat Sep 24 10:59:02 2011 +++ src/sys/arch/x86/acpi/acpi_cpu_md.c Sat Sep 24 11:17:25 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_cpu_md.c,v 1.65 2011/09/24 10:59:02 jruoho Exp $ */ +/* $NetBSD: acpi_cpu_md.c,v 1.66 2011/09/24 11:17:25 jruoho Exp $ */ /*- * Copyright (c) 2010, 2011 Jukka Ruohonen @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.65 2011/09/24 10:59:02 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.66 2011/09/24 11:17:25 jruoho Exp $"); #include #include @@ -147,6 +147,7 @@ struct pci_attach_args pa; uint32_t family, val = 0; uint32_t regs[4]; + uint64_t msr; if (acpi_md_ncpus() == 1) val |= ACPICPU_FLAG_C_BM; @@ -265,7 +266,10 @@ case 0x10: case 0x11: - val |= ACPICPU_FLAG_C_C1E; + + if (rdmsr_safe(MSR_CMPHALT, &msr) != EFAULT) +val |= ACPICPU_FLAG_C_C1E; + /* FALLTHROUGH */ case 0x14: /* AMD Fusion */ @@ -336,8 +340,7 @@ const uint64_t c1e = MSR_CMPHALT_SMI | MSR_CMPHALT_C1E; uint64_t val; - if (__predict_false(rdmsr_safe(MSR_CMPHALT, &val) == EFAULT)) - return; + val = rdmsr(MSR_CMPHALT); if ((val & c1e) != 0) wrmsr(MSR_CMPHALT, val & ~c1e);
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: jruoho Date: Sat Sep 24 10:59:02 UTC 2011 Modified Files: src/sys/arch/x86/acpi: acpi_cpu_md.c Log Message: As the detection of C1E is not entirely clear-cut, use rdmsr_safe() when reading the AMD "interrupt pending and CMP-halt register". To generate a diff of this commit: cvs rdiff -u -r1.64 -r1.65 src/sys/arch/x86/acpi/acpi_cpu_md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_cpu_md.c diff -u src/sys/arch/x86/acpi/acpi_cpu_md.c:1.64 src/sys/arch/x86/acpi/acpi_cpu_md.c:1.65 --- src/sys/arch/x86/acpi/acpi_cpu_md.c:1.64 Wed Jul 13 07:34:55 2011 +++ src/sys/arch/x86/acpi/acpi_cpu_md.c Sat Sep 24 10:59:02 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_cpu_md.c,v 1.64 2011/07/13 07:34:55 jruoho Exp $ */ +/* $NetBSD: acpi_cpu_md.c,v 1.65 2011/09/24 10:59:02 jruoho Exp $ */ /*- * Copyright (c) 2010, 2011 Jukka Ruohonen @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.64 2011/07/13 07:34:55 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.65 2011/09/24 10:59:02 jruoho Exp $"); #include #include @@ -336,7 +336,8 @@ const uint64_t c1e = MSR_CMPHALT_SMI | MSR_CMPHALT_C1E; uint64_t val; - val = rdmsr(MSR_CMPHALT); + if (__predict_false(rdmsr_safe(MSR_CMPHALT, &val) == EFAULT)) + return; if ((val & c1e) != 0) wrmsr(MSR_CMPHALT, val & ~c1e);
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: christos Date: Thu Sep 15 12:32:30 UTC 2011 Modified Files: src/sys/arch/x86/acpi: Makefile.wakecode.inc Log Message: fix typo, revert to previous version To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/arch/x86/acpi/Makefile.wakecode.inc Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/Makefile.wakecode.inc diff -u src/sys/arch/x86/acpi/Makefile.wakecode.inc:1.7 src/sys/arch/x86/acpi/Makefile.wakecode.inc:1.8 --- src/sys/arch/x86/acpi/Makefile.wakecode.inc:1.7 Wed Sep 14 10:58:43 2011 +++ src/sys/arch/x86/acpi/Makefile.wakecode.inc Thu Sep 15 08:32:30 2011 @@ -1,9 +1,8 @@ -# $NetBSD: Makefile.wakecode.inc,v 1.7 2011/09/14 14:58:43 christos Exp $ +# $NetBSD: Makefile.wakecode.inc,v 1.8 2011/09/15 12:32:30 christos Exp $ # FreeBSD: src/sys/i386/acpica/Makefile,v 1.3 2002/05/01 21:54:07 peter Exp ACPI_WAKECODE_S= ${S}/arch/${MACHINE}/acpi/acpi_wakecode.S ACPI_GENWAKECODE= ${S}/arch/x86/acpi/genwakecode.sh -ACPI_WAKEUP_C= ${S}/arch/x86/acpi/acpi_wakeup.c ACPI_GENCMD= AWK=${TOOL_AWK:Q} \ HEXDUMP=${TOOL_HEXDUMP:Q} \ SED=${TOOL_SED:Q} \ @@ -21,4 +20,4 @@ ${ACPI_GENCMD} ${ACPI_GENWAKECODE} > acpi_wakecode.h rm -f acpi_wakecode.bin acpi_wakecode.o acpi_wakecode.bin.map -acpi_wakeup.o acpu_wakeup.d: acpi_wakecode.h +acpi_wakeup.o acpi_wakeup.d: acpi_wakecode.h
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: christos Date: Wed Sep 14 14:58:43 UTC 2011 Modified Files: src/sys/arch/x86/acpi: Makefile.wakecode.inc Log Message: revert previous; bug was in the position of the inclusion of the file. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/arch/x86/acpi/Makefile.wakecode.inc Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/Makefile.wakecode.inc diff -u src/sys/arch/x86/acpi/Makefile.wakecode.inc:1.6 src/sys/arch/x86/acpi/Makefile.wakecode.inc:1.7 --- src/sys/arch/x86/acpi/Makefile.wakecode.inc:1.6 Wed Sep 14 09:13:21 2011 +++ src/sys/arch/x86/acpi/Makefile.wakecode.inc Wed Sep 14 10:58:43 2011 @@ -1,8 +1,9 @@ -# $NetBSD: Makefile.wakecode.inc,v 1.6 2011/09/14 13:13:21 christos Exp $ +# $NetBSD: Makefile.wakecode.inc,v 1.7 2011/09/14 14:58:43 christos Exp $ # FreeBSD: src/sys/i386/acpica/Makefile,v 1.3 2002/05/01 21:54:07 peter Exp ACPI_WAKECODE_S= ${S}/arch/${MACHINE}/acpi/acpi_wakecode.S ACPI_GENWAKECODE= ${S}/arch/x86/acpi/genwakecode.sh +ACPI_WAKEUP_C= ${S}/arch/x86/acpi/acpi_wakeup.c ACPI_GENCMD= AWK=${TOOL_AWK:Q} \ HEXDUMP=${TOOL_HEXDUMP:Q} \ SED=${TOOL_SED:Q} \ @@ -20,4 +21,4 @@ ${ACPI_GENCMD} ${ACPI_GENWAKECODE} > acpi_wakecode.h rm -f acpi_wakecode.bin acpi_wakecode.o acpi_wakecode.bin.map -acpi_wakeup.o: acpi_wakecode.h +acpi_wakeup.o acpu_wakeup.d: acpi_wakecode.h
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: christos Date: Wed Sep 14 13:13:21 UTC 2011 Modified Files: src/sys/arch/x86/acpi: Makefile.wakecode.inc Log Message: Don't depend on the .d file here; since this is the only rule, acpi_wakeup.d will never be build! To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/arch/x86/acpi/Makefile.wakecode.inc Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/Makefile.wakecode.inc diff -u src/sys/arch/x86/acpi/Makefile.wakecode.inc:1.5 src/sys/arch/x86/acpi/Makefile.wakecode.inc:1.6 --- src/sys/arch/x86/acpi/Makefile.wakecode.inc:1.5 Fri May 20 09:14:58 2011 +++ src/sys/arch/x86/acpi/Makefile.wakecode.inc Wed Sep 14 09:13:21 2011 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.wakecode.inc,v 1.5 2011/05/20 13:14:58 joerg Exp $ +# $NetBSD: Makefile.wakecode.inc,v 1.6 2011/09/14 13:13:21 christos Exp $ # FreeBSD: src/sys/i386/acpica/Makefile,v 1.3 2002/05/01 21:54:07 peter Exp ACPI_WAKECODE_S= ${S}/arch/${MACHINE}/acpi/acpi_wakecode.S @@ -20,4 +20,4 @@ ${ACPI_GENCMD} ${ACPI_GENWAKECODE} > acpi_wakecode.h rm -f acpi_wakecode.bin acpi_wakecode.o acpi_wakecode.bin.map -acpi_wakeup.o acpi_wakeup.d: acpi_wakecode.h +acpi_wakeup.o: acpi_wakecode.h
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: jruoho Date: Thu Jun 23 08:10:36 UTC 2011 Modified Files: src/sys/arch/x86/acpi: acpi_cpu_md.c Log Message: Fix bug pointed out by njoly@. To generate a diff of this commit: cvs rdiff -u -r1.62 -r1.63 src/sys/arch/x86/acpi/acpi_cpu_md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_cpu_md.c diff -u src/sys/arch/x86/acpi/acpi_cpu_md.c:1.62 src/sys/arch/x86/acpi/acpi_cpu_md.c:1.63 --- src/sys/arch/x86/acpi/acpi_cpu_md.c:1.62 Wed Jun 22 08:49:54 2011 +++ src/sys/arch/x86/acpi/acpi_cpu_md.c Thu Jun 23 08:10:35 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_cpu_md.c,v 1.62 2011/06/22 08:49:54 jruoho Exp $ */ +/* $NetBSD: acpi_cpu_md.c,v 1.63 2011/06/23 08:10:35 jruoho Exp $ */ /*- * Copyright (c) 2010, 2011 Jukka Ruohonen @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.62 2011/06/22 08:49:54 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.63 2011/06/23 08:10:35 jruoho Exp $"); #include #include @@ -433,21 +433,27 @@ { uint64_t xc, val; - /* - * Make sure EST is enabled. - */ - if ((sc->sc_flags & ACPICPU_FLAG_P_FFH) != 0) { + switch (cpu_vendor) { - val = rdmsr(MSR_MISC_ENABLE); + case CPUVENDOR_IDT: + case CPUVENDOR_INTEL: - if ((val & MSR_MISC_ENABLE_EST) == 0) { + /* + * Make sure EST is enabled. + */ + if ((sc->sc_flags & ACPICPU_FLAG_P_FFH) != 0) { - val |= MSR_MISC_ENABLE_EST; - wrmsr(MSR_MISC_ENABLE, val); val = rdmsr(MSR_MISC_ENABLE); - if ((val & MSR_MISC_ENABLE_EST) == 0) -return ENOTTY; + if ((val & MSR_MISC_ENABLE_EST) == 0) { + +val |= MSR_MISC_ENABLE_EST; +wrmsr(MSR_MISC_ENABLE, val); +val = rdmsr(MSR_MISC_ENABLE); + +if ((val & MSR_MISC_ENABLE_EST) == 0) + return ENOTTY; + } } }
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: jruoho Date: Mon Jun 20 15:39:54 UTC 2011 Modified Files: src/sys/arch/x86/acpi: acpi_pdc.c Log Message: Use acpi_match_cpu_handle() from acpi_util.c and only evaluate the _PDC control method for CPUs that are enabled in the MADT. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/x86/acpi/acpi_pdc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_pdc.c diff -u src/sys/arch/x86/acpi/acpi_pdc.c:1.1 src/sys/arch/x86/acpi/acpi_pdc.c:1.2 --- src/sys/arch/x86/acpi/acpi_pdc.c:1.1 Sun Jun 12 10:11:52 2011 +++ src/sys/arch/x86/acpi/acpi_pdc.c Mon Jun 20 15:39:54 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_pdc.c,v 1.1 2011/06/12 10:11:52 jruoho Exp $ */ +/* $NetBSD: acpi_pdc.c,v 1.2 2011/06/20 15:39:54 jruoho Exp $ */ /*- * Copyright (c) 2010, 2011 Jukka Ruohonen @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_pdc.c,v 1.1 2011/06/12 10:11:52 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_pdc.c,v 1.2 2011/06/20 15:39:54 jruoho Exp $"); #include @@ -47,12 +47,11 @@ static uint32_t flags = 0; static ACPI_STATUS acpi_md_pdc_walk(ACPI_HANDLE, uint32_t,void *,void **); -static ACPI_STATUS acpi_md_pdc_set(ACPI_HANDLE, uint32_t); +static void acpi_md_pdc_set(ACPI_HANDLE, uint32_t); uint32_t acpi_md_pdc(void) { - char *hid = __UNCONST("ACPI0007"); struct cpu_info *ci = curcpu(); uint32_t regs[4]; @@ -104,21 +103,26 @@ * As the _PDC must be evaluated before the internal namespace * is built, we have no option but to walk with the interpreter. */ - (void)AcpiGetDevices(hid, acpi_md_pdc_walk, NULL, NULL); - - (void)AcpiWalkNamespace(ACPI_TYPE_PROCESSOR, ACPI_ROOT_OBJECT, + (void)AcpiWalkNamespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, UINT32_MAX, acpi_md_pdc_walk, NULL, NULL, NULL); return flags; } static ACPI_STATUS -acpi_md_pdc_walk(ACPI_HANDLE hdl, uint32_t level, void *context, void **status) +acpi_md_pdc_walk(ACPI_HANDLE hdl, uint32_t level, void *aux, void **sta) { - return acpi_md_pdc_set(hdl, flags); + struct cpu_info *ci; + + ci = acpi_match_cpu_handle(hdl); + + if (ci != NULL) + acpi_md_pdc_set(hdl, flags); + + return AE_OK; } -static ACPI_STATUS +static void acpi_md_pdc_set(ACPI_HANDLE hdl, uint32_t val) { ACPI_OBJECT_LIST arg; @@ -137,6 +141,4 @@ obj.Buffer.Pointer = (void *)cap; (void)AcpiEvaluateObject(hdl, "_PDC", &arg, NULL); - - return AE_OK; }
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: jruoho Date: Mon Jun 6 07:42:33 UTC 2011 Modified Files: src/sys/arch/x86/acpi: acpi_cpu_md.c Log Message: When getting the frequency, use APERF/MPERF as a fallback method. To generate a diff of this commit: cvs rdiff -u -r1.59 -r1.60 src/sys/arch/x86/acpi/acpi_cpu_md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_cpu_md.c diff -u src/sys/arch/x86/acpi/acpi_cpu_md.c:1.59 src/sys/arch/x86/acpi/acpi_cpu_md.c:1.60 --- src/sys/arch/x86/acpi/acpi_cpu_md.c:1.59 Tue May 31 14:45:36 2011 +++ src/sys/arch/x86/acpi/acpi_cpu_md.c Mon Jun 6 07:42:32 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_cpu_md.c,v 1.59 2011/05/31 14:45:36 jruoho Exp $ */ +/* $NetBSD: acpi_cpu_md.c,v 1.60 2011/06/06 07:42:32 jruoho Exp $ */ /*- * Copyright (c) 2010, 2011 Jukka Ruohonen @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.59 2011/05/31 14:45:36 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.60 2011/06/06 07:42:32 jruoho Exp $"); #include #include @@ -755,6 +755,18 @@ } } + /* + * If the value was not found, try APERF/MPERF. + * The state is P0 if the return value is 100 %. + */ + if ((sc->sc_flags & ACPICPU_FLAG_P_HWF) != 0) { + + if (acpicpu_md_pstate_hwf(sc->sc_ci) == 100) { + *freq = sc->sc_pstate[0].ps_freq; + return 0; + } + } + return EIO; }
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: jruoho Date: Tue May 31 14:45:37 UTC 2011 Modified Files: src/sys/arch/x86/acpi: acpi_cpu_md.c Log Message: Remove the sanity check that tested the internal consistency of the "FID/VID algorithm" used by K8. Tested by cegger@. The check is still included in the original powernow(4) (where possible failures have probably gone unnoticed because the driver is less noisy). To generate a diff of this commit: cvs rdiff -u -r1.58 -r1.59 src/sys/arch/x86/acpi/acpi_cpu_md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_cpu_md.c diff -u src/sys/arch/x86/acpi/acpi_cpu_md.c:1.58 src/sys/arch/x86/acpi/acpi_cpu_md.c:1.59 --- src/sys/arch/x86/acpi/acpi_cpu_md.c:1.58 Mon Apr 4 20:37:55 2011 +++ src/sys/arch/x86/acpi/acpi_cpu_md.c Tue May 31 14:45:36 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_cpu_md.c,v 1.58 2011/04/04 20:37:55 dyoung Exp $ */ +/* $NetBSD: acpi_cpu_md.c,v 1.59 2011/05/31 14:45:36 jruoho Exp $ */ /*- * Copyright (c) 2010, 2011 Jukka Ruohonen @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.58 2011/04/04 20:37:55 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.59 2011/05/31 14:45:36 jruoho Exp $"); #include #include @@ -917,9 +917,6 @@ return rv; } - if (cfid != fid || cvid != vid) - return EIO; - return 0; }
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: joerg Date: Fri May 20 13:14:58 UTC 2011 Modified Files: src/sys/arch/x86/acpi: Makefile.wakecode.inc Log Message: LLVM's assembler parser doesn't support .code32 yet, so disable it as needed. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/x86/acpi/Makefile.wakecode.inc Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/Makefile.wakecode.inc diff -u src/sys/arch/x86/acpi/Makefile.wakecode.inc:1.4 src/sys/arch/x86/acpi/Makefile.wakecode.inc:1.5 --- src/sys/arch/x86/acpi/Makefile.wakecode.inc:1.4 Sun Jan 18 13:55:31 2009 +++ src/sys/arch/x86/acpi/Makefile.wakecode.inc Fri May 20 13:14:58 2011 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.wakecode.inc,v 1.4 2009/01/18 13:55:31 hans Exp $ +# $NetBSD: Makefile.wakecode.inc,v 1.5 2011/05/20 13:14:58 joerg Exp $ # FreeBSD: src/sys/i386/acpica/Makefile,v 1.3 2002/05/01 21:54:07 peter Exp ACPI_WAKECODE_S= ${S}/arch/${MACHINE}/acpi/acpi_wakecode.S @@ -8,9 +8,12 @@ SED=${TOOL_SED:Q} \ ${HOST_SH} +AFLAGS.acpi_wakecode.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:} -I${.CURDIR} + + acpi_wakecode.h: ${ACPI_WAKECODE_S} ${ACPI_GENWAKECODE} ${_MKTARGET_CREATE} - ${CC} -I${.CURDIR} -c ${ACPI_WAKECODE_S} + ${CC} ${AFLAGS.acpi_wakecode.S} -c ${ACPI_WAKECODE_S} ${LD} -M -Map acpi_wakecode.bin.map -z defs -nostdlib \ --oformat binary -e wakeup_16 -Ttext 0 \ -o acpi_wakecode.bin acpi_wakecode.o
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: jruoho Date: Thu Mar 24 11:52:53 UTC 2011 Modified Files: src/sys/arch/x86/acpi: acpi_cpu_md.c Log Message: Reset APERF and MPERF only after interrupts have been enabled. To generate a diff of this commit: cvs rdiff -u -r1.56 -r1.57 src/sys/arch/x86/acpi/acpi_cpu_md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_cpu_md.c diff -u src/sys/arch/x86/acpi/acpi_cpu_md.c:1.56 src/sys/arch/x86/acpi/acpi_cpu_md.c:1.57 --- src/sys/arch/x86/acpi/acpi_cpu_md.c:1.56 Thu Mar 24 05:10:05 2011 +++ src/sys/arch/x86/acpi/acpi_cpu_md.c Thu Mar 24 11:52:53 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_cpu_md.c,v 1.56 2011/03/24 05:10:05 jruoho Exp $ */ +/* $NetBSD: acpi_cpu_md.c,v 1.57 2011/03/24 11:52:53 jruoho Exp $ */ /*- * Copyright (c) 2010, 2011 Jukka Ruohonen @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.56 2011/03/24 05:10:05 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.57 2011/03/24 11:52:53 jruoho Exp $"); #include #include @@ -475,6 +475,16 @@ int acpicpu_md_pstate_start(struct acpicpu_softc *sc) { + uint64_t xc; + + /* + * Reset the APERF and MPERF counters. + */ + if ((sc->sc_flags & ACPICPU_FLAG_P_HWF) != 0) { + xc = xc_broadcast(0, acpicpu_md_pstate_hwf_reset, NULL, NULL); + xc_wait(xc); + } + return acpicpu_md_pstate_sysctl_init(); } @@ -493,7 +503,7 @@ struct cpu_info *ci = sc->sc_ci; struct acpicpu_pstate *ps, msr; uint32_t family, i = 0; - uint64_t val, xc; + uint64_t val; (void)memset(&msr, 0, sizeof(struct acpicpu_pstate)); @@ -616,14 +626,6 @@ i++; } - /* - * Reset the APERF and MPERF counters. - */ - if ((sc->sc_flags & ACPICPU_FLAG_P_HWF) != 0) { - xc = xc_unicast(0, acpicpu_md_pstate_hwf_reset, sc, NULL, ci); - xc_wait(xc); - } - return 0; }
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: jruoho Date: Sat Mar 5 06:39:55 UTC 2011 Modified Files: src/sys/arch/x86/acpi: acpi_cpu_md.c Log Message: If the P-state control mask is set, do a proper read-modify-write. To generate a diff of this commit: cvs rdiff -u -r1.53 -r1.54 src/sys/arch/x86/acpi/acpi_cpu_md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_cpu_md.c diff -u src/sys/arch/x86/acpi/acpi_cpu_md.c:1.53 src/sys/arch/x86/acpi/acpi_cpu_md.c:1.54 --- src/sys/arch/x86/acpi/acpi_cpu_md.c:1.53 Fri Mar 4 12:10:49 2011 +++ src/sys/arch/x86/acpi/acpi_cpu_md.c Sat Mar 5 06:39:55 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_cpu_md.c,v 1.53 2011/03/04 12:10:49 jruoho Exp $ */ +/* $NetBSD: acpi_cpu_md.c,v 1.54 2011/03/05 06:39:55 jruoho Exp $ */ /*- * Copyright (c) 2010, 2011 Jukka Ruohonen @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.53 2011/03/04 12:10:49 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.54 2011/03/05 06:39:55 jruoho Exp $"); #include #include @@ -761,7 +761,7 @@ int acpicpu_md_pstate_set(struct acpicpu_pstate *ps) { - uint64_t val; + uint64_t val = 0; if (__predict_false(ps->ps_control_addr == 0)) return EINVAL; @@ -769,10 +769,15 @@ if ((ps->ps_flags & ACPICPU_FLAG_P_FIDVID) != 0) return acpicpu_md_pstate_fidvid_set(ps); - val = ps->ps_control; + /* + * If the mask is set, do a read-modify-write. + */ + if (__predict_true(ps->ps_control_mask != 0)) { + val = rdmsr(ps->ps_control_addr); + val &= ~ps->ps_control_mask; + } - if (__predict_true(ps->ps_control_mask != 0)) - val = val & ps->ps_control_mask; + val |= ps->ps_control; wrmsr(ps->ps_control_addr, val); DELAY(ps->ps_latency);
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: jruoho Date: Wed Mar 2 06:23:17 UTC 2011 Modified Files: src/sys/arch/x86/acpi: acpi_cpu_md.c Log Message: Adjust the detection of Turbo Boost to prevent a theoretical array OOB access. To generate a diff of this commit: cvs rdiff -u -r1.51 -r1.52 src/sys/arch/x86/acpi/acpi_cpu_md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_cpu_md.c diff -u src/sys/arch/x86/acpi/acpi_cpu_md.c:1.51 src/sys/arch/x86/acpi/acpi_cpu_md.c:1.52 --- src/sys/arch/x86/acpi/acpi_cpu_md.c:1.51 Wed Mar 2 06:17:09 2011 +++ src/sys/arch/x86/acpi/acpi_cpu_md.c Wed Mar 2 06:23:17 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_cpu_md.c,v 1.51 2011/03/02 06:17:09 jruoho Exp $ */ +/* $NetBSD: acpi_cpu_md.c,v 1.52 2011/03/02 06:23:17 jruoho Exp $ */ /*- * Copyright (c) 2010, 2011 Jukka Ruohonen @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.51 2011/03/02 06:17:09 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.52 2011/03/02 06:23:17 jruoho Exp $"); #include #include @@ -541,7 +541,8 @@ * in Intel Core(tm) Microarchitectures (Nehalem) * Based Processors. White Paper, November 2008. */ - if ((sc->sc_flags & ACPICPU_FLAG_P_TURBO) != 0) { + if (sc->sc_pstate_count > 2 && + (sc->sc_flags & ACPICPU_FLAG_P_TURBO) != 0) { ps = &sc->sc_pstate[0];
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: jruoho Date: Tue Mar 1 05:02:16 UTC 2011 Modified Files: src/sys/arch/x86/acpi: acpi_cpu_md.c Log Message: Remove the cross-call from the APERF/MPERF -function. To generate a diff of this commit: cvs rdiff -u -r1.49 -r1.50 src/sys/arch/x86/acpi/acpi_cpu_md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_cpu_md.c diff -u src/sys/arch/x86/acpi/acpi_cpu_md.c:1.49 src/sys/arch/x86/acpi/acpi_cpu_md.c:1.50 --- src/sys/arch/x86/acpi/acpi_cpu_md.c:1.49 Tue Mar 1 04:35:48 2011 +++ src/sys/arch/x86/acpi/acpi_cpu_md.c Tue Mar 1 05:02:16 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_cpu_md.c,v 1.49 2011/03/01 04:35:48 jruoho Exp $ */ +/* $NetBSD: acpi_cpu_md.c,v 1.50 2011/03/01 05:02:16 jruoho Exp $ */ /*- * Copyright (c) 2010, 2011 Jukka Ruohonen @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.49 2011/03/01 04:35:48 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.50 2011/03/01 05:02:16 jruoho Exp $"); #include #include @@ -101,7 +101,6 @@ static int acpicpu_md_quirk_piix4(struct pci_attach_args *); static void acpicpu_md_pstate_percent_reset(struct acpicpu_softc *); -static void acpicpu_md_pstate_percent_status(void *, void *); static int acpicpu_md_pstate_fidvid_get(struct acpicpu_softc *, uint32_t *); static int acpicpu_md_pstate_fidvid_set(struct acpicpu_pstate *); @@ -621,23 +620,11 @@ return 0; } -/* - * Returns the percentage of the actual frequency in - * terms of the maximum frequency of the calling CPU - * since the last call. A value zero implies an error. - */ uint8_t acpicpu_md_pstate_percent(struct acpicpu_softc *sc) { - struct cpu_info *ci = sc->sc_ci; uint64_t aperf, mperf; - uint64_t xc, rv = 0; - - if (__predict_false((sc->sc_flags & ACPICPU_FLAG_P) == 0)) - return 0; - - if (__predict_false((sc->sc_flags & ACPICPU_FLAG_P_HW) == 0)) - return 0; + uint64_t rv = 0; /* * Read the IA32_APERF and IA32_MPERF counters. The first @@ -647,6 +634,10 @@ * read without delay, and that only the ratio between * IA32_APERF and IA32_MPERF is architecturally defined. * + * The function thus returns the percentage of the actual + * frequency in terms of the maximum frequency of the calling + * CPU since the last call. A value zero implies an error. + * * For further details, refer to: * * Intel Corporation: Intel 64 and IA-32 Architectures @@ -657,13 +648,19 @@ * Guide (BKDG) for AMD Family 10h Processors. Section * 2.4.5, Revision 3.48, April 2010. */ - x86_disable_intr(); + if (__predict_false((sc->sc_flags & ACPICPU_FLAG_P) == 0)) + return 0; + + if (__predict_false((sc->sc_flags & ACPICPU_FLAG_P_HW) == 0)) + return 0; aperf = sc->sc_pstate_aperf; mperf = sc->sc_pstate_mperf; - xc = xc_unicast(0, acpicpu_md_pstate_percent_status, sc, NULL, ci); - xc_wait(xc); + x86_disable_intr(); + + sc->sc_pstate_aperf = rdmsr(MSR_APERF); + sc->sc_pstate_mperf = rdmsr(MSR_MPERF); x86_enable_intr(); @@ -677,15 +674,6 @@ } static void -acpicpu_md_pstate_percent_status(void *arg1, void *arg2) -{ - struct acpicpu_softc *sc = arg1; - - sc->sc_pstate_aperf = rdmsr(MSR_APERF); - sc->sc_pstate_mperf = rdmsr(MSR_MPERF); -} - -static void acpicpu_md_pstate_percent_reset(struct acpicpu_softc *sc) { struct msr_rw_info msr;
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: jruoho Date: Sun Feb 27 17:27:28 UTC 2011 Modified Files: src/sys/arch/x86/acpi: acpi_cpu_md.c Log Message: Claim to support the dependency coordination during the _PDC/_OSC query. (Although we do not actually support it.) Only after these bits are set, many Intel-based BIOSes are willing to relinquish the necessary information. To generate a diff of this commit: cvs rdiff -u -r1.46 -r1.47 src/sys/arch/x86/acpi/acpi_cpu_md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_cpu_md.c diff -u src/sys/arch/x86/acpi/acpi_cpu_md.c:1.46 src/sys/arch/x86/acpi/acpi_cpu_md.c:1.47 --- src/sys/arch/x86/acpi/acpi_cpu_md.c:1.46 Fri Feb 25 17:23:34 2011 +++ src/sys/arch/x86/acpi/acpi_cpu_md.c Sun Feb 27 17:27:28 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_cpu_md.c,v 1.46 2011/02/25 17:23:34 jruoho Exp $ */ +/* $NetBSD: acpi_cpu_md.c,v 1.47 2011/02/27 17:27:28 jruoho Exp $ */ /*- * Copyright (c) 2010, 2011 Jukka Ruohonen @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.46 2011/02/25 17:23:34 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.47 2011/02/27 17:27:28 jruoho Exp $"); #include #include @@ -130,10 +130,15 @@ return val; /* - * Basic SMP C-states (required for _CST). + * Basic SMP C-states (required for e.g. _CST). */ val |= ACPICPU_PDC_C_C1PT | ACPICPU_PDC_C_C2C3; + /* + * Claim to support dependency coordination. + */ + val |= ACPICPU_PDC_P_SW | ACPICPU_PDC_C_SW | ACPICPU_PDC_T_SW; + /* * If MONITOR/MWAIT is available, announce * support for native instructions in all C-states.
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: jruoho Date: Fri Feb 25 17:23:35 UTC 2011 Modified Files: src/sys/arch/x86/acpi: acpi_cpu_md.c Log Message: Fix an oversigh; the APERF and MPERF counters are per-CPU, so also reset these by broadcasting to all CPUs with x86_msr_xcall(9). To generate a diff of this commit: cvs rdiff -u -r1.45 -r1.46 src/sys/arch/x86/acpi/acpi_cpu_md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_cpu_md.c diff -u src/sys/arch/x86/acpi/acpi_cpu_md.c:1.45 src/sys/arch/x86/acpi/acpi_cpu_md.c:1.46 --- src/sys/arch/x86/acpi/acpi_cpu_md.c:1.45 Fri Feb 25 17:07:30 2011 +++ src/sys/arch/x86/acpi/acpi_cpu_md.c Fri Feb 25 17:23:34 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_cpu_md.c,v 1.45 2011/02/25 17:07:30 jruoho Exp $ */ +/* $NetBSD: acpi_cpu_md.c,v 1.46 2011/02/25 17:23:34 jruoho Exp $ */ /*- * Copyright (c) 2010, 2011 Jukka Ruohonen @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.45 2011/02/25 17:07:30 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.46 2011/02/25 17:23:34 jruoho Exp $"); #include #include @@ -666,12 +666,25 @@ static void acpicpu_md_pstate_percent_reset(struct acpicpu_softc *sc) { + struct msr_rw_info msr; + uint64_t xc; KASSERT((sc->sc_flags & ACPICPU_FLAG_P) != 0); KASSERT((sc->sc_flags & ACPICPU_FLAG_P_HW) != 0); - wrmsr(MSR_APERF, 0); - wrmsr(MSR_MPERF, 0); + msr.msr_value = 0; + msr.msr_read = false; + msr.msr_type = MSR_APERF; + + xc = xc_broadcast(0, (xcfunc_t)x86_msr_xcall, &msr, NULL); + xc_wait(xc); + + msr.msr_value = 0; + msr.msr_read = false; + msr.msr_type = MSR_MPERF; + + xc = xc_broadcast(0, (xcfunc_t)x86_msr_xcall, &msr, NULL); + xc_wait(xc); sc->sc_pstate_aperf = 0; sc->sc_pstate_mperf = 0;
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: jruoho Date: Fri Feb 25 17:07:30 UTC 2011 Modified Files: src/sys/arch/x86/acpi: acpi_cpu_md.c Log Message: Add couple of comments. To generate a diff of this commit: cvs rdiff -u -r1.44 -r1.45 src/sys/arch/x86/acpi/acpi_cpu_md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_cpu_md.c diff -u src/sys/arch/x86/acpi/acpi_cpu_md.c:1.44 src/sys/arch/x86/acpi/acpi_cpu_md.c:1.45 --- src/sys/arch/x86/acpi/acpi_cpu_md.c:1.44 Fri Feb 25 16:54:36 2011 +++ src/sys/arch/x86/acpi/acpi_cpu_md.c Fri Feb 25 17:07:30 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_cpu_md.c,v 1.44 2011/02/25 16:54:36 jruoho Exp $ */ +/* $NetBSD: acpi_cpu_md.c,v 1.45 2011/02/25 17:07:30 jruoho Exp $ */ /*- * Copyright (c) 2010, 2011 Jukka Ruohonen @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.44 2011/02/25 16:54:36 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.45 2011/02/25 17:07:30 jruoho Exp $"); #include #include @@ -274,6 +274,10 @@ case 0x0f: + /* + * Evaluate support for the "FID/VID + * algorithm" also used by powernow(4). + */ if ((regs[3] & CPUID_APM_FID) == 0) break; @@ -370,6 +374,9 @@ bool ipi = false; int i; + /* + * Save the cpu_idle(9) loop used by default. + */ x86_cpu_idle_get(&native_idle, native_idle_text, size); for (i = 0; i < ACPI_C_STATE_COUNT; i++) {
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: jruoho Date: Fri Feb 25 16:54:36 UTC 2011 Modified Files: src/sys/arch/x86/acpi: acpi_cpu_md.c Log Message: Also declare support for APERF/MPERF during the BIOS _PDC/_OSC query. To generate a diff of this commit: cvs rdiff -u -r1.43 -r1.44 src/sys/arch/x86/acpi/acpi_cpu_md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_cpu_md.c diff -u src/sys/arch/x86/acpi/acpi_cpu_md.c:1.43 src/sys/arch/x86/acpi/acpi_cpu_md.c:1.44 --- src/sys/arch/x86/acpi/acpi_cpu_md.c:1.43 Fri Feb 25 12:08:35 2011 +++ src/sys/arch/x86/acpi/acpi_cpu_md.c Fri Feb 25 16:54:36 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_cpu_md.c,v 1.43 2011/02/25 12:08:35 jruoho Exp $ */ +/* $NetBSD: acpi_cpu_md.c,v 1.44 2011/02/25 16:54:36 jruoho Exp $ */ /*- * Copyright (c) 2010, 2011 Jukka Ruohonen @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.43 2011/02/25 12:08:35 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.44 2011/02/25 16:54:36 jruoho Exp $"); #include #include @@ -122,6 +122,7 @@ acpicpu_md_cap(void) { struct cpu_info *ci = curcpu(); + uint32_t regs[4]; uint32_t val = 0; if (cpu_vendor != CPUVENDOR_IDT && @@ -149,6 +150,17 @@ if ((ci->ci_feat_val[0] & CPUID_ACPI) != 0) val |= ACPICPU_PDC_T_FFH; + /* + * Declare support for APERF and MPERF. + */ + if (cpuid_level >= 0x06) { + + x86_cpuid(0x0006, regs); + + if ((regs[2] & CPUID_DSPM_HWF) != 0) + val |= ACPICPU_PDC_P_HW; + } + return val; } @@ -212,7 +224,7 @@ */ if (cpuid_level >= 0x06) { - x86_cpuid(0x06, regs); + x86_cpuid(0x0006, regs); if ((regs[2] & CPUID_DSPM_HWF) != 0) val |= ACPICPU_FLAG_P_HW; @@ -300,7 +312,7 @@ x86_cpuid(0x0006, regs); -if ((regs[2] & __BIT(0)) != 0) +if ((regs[2] & CPUID_DSPM_HWF) != 0) val |= ACPICPU_FLAG_P_HW; }
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: jruoho Date: Fri Feb 25 10:59:32 UTC 2011 Modified Files: src/sys/arch/x86/acpi: acpi_cpu_md.c Log Message: Add support for APERF and MPERF on AMD processors. To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/sys/arch/x86/acpi/acpi_cpu_md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_cpu_md.c diff -u src/sys/arch/x86/acpi/acpi_cpu_md.c:1.41 src/sys/arch/x86/acpi/acpi_cpu_md.c:1.42 --- src/sys/arch/x86/acpi/acpi_cpu_md.c:1.41 Fri Feb 25 09:16:00 2011 +++ src/sys/arch/x86/acpi/acpi_cpu_md.c Fri Feb 25 10:59:32 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_cpu_md.c,v 1.41 2011/02/25 09:16:00 jruoho Exp $ */ +/* $NetBSD: acpi_cpu_md.c,v 1.42 2011/02/25 10:59:32 jruoho Exp $ */ /*- * Copyright (c) 2010, 2011 Jukka Ruohonen @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.41 2011/02/25 09:16:00 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.42 2011/02/25 10:59:32 jruoho Exp $"); #include #include @@ -278,6 +278,11 @@ case 0x14: /* AMD Fusion */ + /* + * Like with Intel, detect invariant TSC, + * MSR-based P-states, and AMD's "turbo" + * (Core Performance Boost), respectively. + */ if ((regs[3] & CPUID_APM_TSC) != 0) val &= ~ACPICPU_FLAG_C_TSC; @@ -287,6 +292,18 @@ if ((regs[3] & CPUID_APM_CPB) != 0) val |= ACPICPU_FLAG_P_TURBO; + /* + * Also check for APERF and MPERF, + * first available in the family 10h. + */ + if (cpuid_level >= 0x06) { + +x86_cpuid(0x0006, regs); + +if ((regs[2] & __BIT(0)) != 0) + val |= ACPICPU_FLAG_P_HW; + } + break; } @@ -438,14 +455,14 @@ if ((val & est) == 0) return ENOTTY; } - - /* - * Reset the APERF and MPERF counters. - */ - if ((sc->sc_flags & ACPICPU_FLAG_P_HW) != 0) - acpicpu_md_pstate_percent_reset(sc); } + /* + * Reset the APERF and MPERF counters. + */ + if ((sc->sc_flags & ACPICPU_FLAG_P_HW) != 0) + acpicpu_md_pstate_percent_reset(sc); + return acpicpu_md_pstate_sysctl_init(); } @@ -594,6 +611,10 @@ * Intel Corporation: Intel 64 and IA-32 Architectures * Software Developer's Manual. Section 13.2, Volume 3A: * System Programming Guide, Part 1. July, 2008. + * + * Advanced Micro Devices: BIOS and Kernel Developer's + * Guide (BKDG) for AMD Family 10h Processors. Section + * 2.4.5, Revision 3.48, April 2010. */ x86_disable_intr();
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: jmcneill Date: Thu Feb 24 13:19:37 UTC 2011 Modified Files: src/sys/arch/x86/acpi: acpi_cpu_md.c Log Message: add support for Family 14h (AMD Fusion) To generate a diff of this commit: cvs rdiff -u -r1.39 -r1.40 src/sys/arch/x86/acpi/acpi_cpu_md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_cpu_md.c diff -u src/sys/arch/x86/acpi/acpi_cpu_md.c:1.39 src/sys/arch/x86/acpi/acpi_cpu_md.c:1.40 --- src/sys/arch/x86/acpi/acpi_cpu_md.c:1.39 Tue Feb 15 17:50:46 2011 +++ src/sys/arch/x86/acpi/acpi_cpu_md.c Thu Feb 24 13:19:36 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_cpu_md.c,v 1.39 2011/02/15 17:50:46 jruoho Exp $ */ +/* $NetBSD: acpi_cpu_md.c,v 1.40 2011/02/24 13:19:36 jmcneill Exp $ */ /*- * Copyright (c) 2010 Jukka Ruohonen @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.39 2011/02/15 17:50:46 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.40 2011/02/24 13:19:36 jmcneill Exp $"); #include #include @@ -60,7 +60,7 @@ #define MSR_CMPHALT_BMSTS __BIT(29) /* - * AMD families 10h and 11h. + * AMD families 10h, 11h, and 14h */ #define MSR_10H_LIMIT 0xc0010061 #define MSR_10H_CONTROL 0xc0010062 @@ -271,6 +271,10 @@ case 0x10: case 0x11: + val |= ACPICPU_FLAG_C_C1E; + /* FALLTHROUGH */ + + case 0x14: /* AMD Fusion */ if ((regs[3] & CPUID_APM_TSC) != 0) val &= ~ACPICPU_FLAG_C_TSC; @@ -281,7 +285,6 @@ if ((regs[3] & CPUID_APM_CPB) != 0) val |= ACPICPU_FLAG_P_TURBO; - val |= ACPICPU_FLAG_C_C1E; break; } @@ -495,6 +498,7 @@ case 0x10: case 0x11: + case 0x14: /* AMD Fusion */ msr.ps_control_addr = MSR_10H_CONTROL; msr.ps_control_mask = __BITS(0, 2);
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: jruoho Date: Wed Feb 16 18:55:50 UTC 2011 Modified Files: src/sys/arch/x86/acpi: acpi_wakeup.c Log Message: Explicitly re-enable the SCI interrupt when the wakeup starts (and before interrupts are enabled). A workaround for a BIOS bug. Fixes the interrupt storm reported by Taylor R. Campbell in PR # 44581. To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/sys/arch/x86/acpi/acpi_wakeup.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_wakeup.c diff -u src/sys/arch/x86/acpi/acpi_wakeup.c:1.27 src/sys/arch/x86/acpi/acpi_wakeup.c:1.28 --- src/sys/arch/x86/acpi/acpi_wakeup.c:1.27 Thu Jan 13 03:45:38 2011 +++ src/sys/arch/x86/acpi/acpi_wakeup.c Wed Feb 16 18:55:50 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_wakeup.c,v 1.27 2011/01/13 03:45:38 jruoho Exp $ */ +/* $NetBSD: acpi_wakeup.c,v 1.28 2011/02/16 18:55:50 jruoho Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.27 2011/01/13 03:45:38 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.28 2011/02/16 18:55:50 jruoho Exp $"); /*- * Copyright (c) 2001 Takanori Watanabe @@ -342,6 +342,13 @@ inittodr(time_second); /* + * The BIOS should always re-enable the SCI upon + * resume from the S3 state. The following is a + * workaround for systems that fail to do this. + */ + (void)AcpiWriteBitRegister(ACPI_BITREG_SCI_ENABLE, 1); + + /* * Clear fixed events (see e.g. ACPI 3.0, p. 62). * Also prevent GPEs from misfiring by disabling * all GPEs before interrupts are enabled. The
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: jruoho Date: Tue Feb 15 17:50:47 UTC 2011 Modified Files: src/sys/arch/x86/acpi: acpi_cpu_md.c Log Message: Fix and add comments. To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.39 src/sys/arch/x86/acpi/acpi_cpu_md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_cpu_md.c diff -u src/sys/arch/x86/acpi/acpi_cpu_md.c:1.38 src/sys/arch/x86/acpi/acpi_cpu_md.c:1.39 --- src/sys/arch/x86/acpi/acpi_cpu_md.c:1.38 Thu Jan 13 03:40:50 2011 +++ src/sys/arch/x86/acpi/acpi_cpu_md.c Tue Feb 15 17:50:46 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_cpu_md.c,v 1.38 2011/01/13 03:40:50 jruoho Exp $ */ +/* $NetBSD: acpi_cpu_md.c,v 1.39 2011/02/15 17:50:46 jruoho Exp $ */ /*- * Copyright (c) 2010 Jukka Ruohonen @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.38 2011/01/13 03:40:50 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.39 2011/02/15 17:50:46 jruoho Exp $"); #include #include @@ -164,6 +164,10 @@ if ((ci->ci_feat_val[1] & CPUID2_MONITOR) != 0) val |= ACPICPU_FLAG_C_FFH; + /* + * By default, assume that the local APIC timer + * as well as TSC are stalled during C3 sleep. + */ val |= ACPICPU_FLAG_C_APIC | ACPICPU_FLAG_C_TSC; switch (cpu_vendor) { @@ -180,8 +184,19 @@ case CPUVENDOR_INTEL: + /* + * Bus master control and arbitration should be + * available on all supported Intel CPUs (to be + * sure, this is double-checked later from the + * firmware data). These flags imply that it is + * not necessary to flush caches before C3 state. + */ val |= ACPICPU_FLAG_C_BM | ACPICPU_FLAG_C_ARB; + /* + * Check if we can use "native", MSR-based, + * access. If not, we have to resort to I/O. + */ if ((ci->ci_feat_val[1] & CPUID2_EST) != 0) val |= ACPICPU_FLAG_P_FFH; @@ -503,7 +518,7 @@ * Fill the P-state structures with MSR addresses that are * known to be correct. If we do not know the addresses, * leave the values intact. If a vendor uses XPSS, we do - * not necessary need to do anything to support new CPUs. + * not necessarily need to do anything to support new CPUs. */ while (i < sc->sc_pstate_count) {
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: jruoho Date: Thu Jan 13 03:45:38 UTC 2011 Modified Files: src/sys/arch/x86/acpi: acpi_wakeup.c Log Message: Add a comment. To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/sys/arch/x86/acpi/acpi_wakeup.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_wakeup.c diff -u src/sys/arch/x86/acpi/acpi_wakeup.c:1.26 src/sys/arch/x86/acpi/acpi_wakeup.c:1.27 --- src/sys/arch/x86/acpi/acpi_wakeup.c:1.26 Fri Dec 31 09:19:43 2010 +++ src/sys/arch/x86/acpi/acpi_wakeup.c Thu Jan 13 03:45:38 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_wakeup.c,v 1.26 2010/12/31 09:19:43 jruoho Exp $ */ +/* $NetBSD: acpi_wakeup.c,v 1.27 2011/01/13 03:45:38 jruoho Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.26 2010/12/31 09:19:43 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.27 2011/01/13 03:45:38 jruoho Exp $"); /*- * Copyright (c) 2001 Takanori Watanabe @@ -341,12 +341,19 @@ initrtclock(TIMER_FREQ); inittodr(time_second); - AcpiClearEvent(ACPI_EVENT_PMTIMER); - AcpiClearEvent(ACPI_EVENT_GLOBAL); - AcpiClearEvent(ACPI_EVENT_POWER_BUTTON); - AcpiClearEvent(ACPI_EVENT_SLEEP_BUTTON); - AcpiClearEvent(ACPI_EVENT_RTC); - AcpiHwDisableAllGpes (); + /* + * Clear fixed events (see e.g. ACPI 3.0, p. 62). + * Also prevent GPEs from misfiring by disabling + * all GPEs before interrupts are enabled. The + * AcpiLeaveSleepState() function will enable + * and handle the general purpose events later. + */ + (void)AcpiClearEvent(ACPI_EVENT_PMTIMER); + (void)AcpiClearEvent(ACPI_EVENT_GLOBAL); + (void)AcpiClearEvent(ACPI_EVENT_POWER_BUTTON); + (void)AcpiClearEvent(ACPI_EVENT_SLEEP_BUTTON); + (void)AcpiClearEvent(ACPI_EVENT_RTC); + (void)AcpiHwDisableAllGpes(); acpi_pci_link_resume();
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: jruoho Date: Thu Dec 30 17:06:17 UTC 2010 Modified Files: src/sys/arch/x86/acpi: acpi_cpu_md.c Log Message: Add an additional assertion for the control MSR address. To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/sys/arch/x86/acpi/acpi_cpu_md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_cpu_md.c diff -u src/sys/arch/x86/acpi/acpi_cpu_md.c:1.36 src/sys/arch/x86/acpi/acpi_cpu_md.c:1.37 --- src/sys/arch/x86/acpi/acpi_cpu_md.c:1.36 Tue Nov 30 18:44:07 2010 +++ src/sys/arch/x86/acpi/acpi_cpu_md.c Thu Dec 30 17:06:17 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_cpu_md.c,v 1.36 2010/11/30 18:44:07 jruoho Exp $ */ +/* $NetBSD: acpi_cpu_md.c,v 1.37 2010/12/30 17:06:17 jruoho Exp $ */ /*- * Copyright (c) 2010 Jukka Ruohonen @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.36 2010/11/30 18:44:07 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.37 2010/12/30 17:06:17 jruoho Exp $"); #include #include @@ -588,6 +588,9 @@ uint64_t xc; int rv = 0; + if (__predict_false(ps->ps_control_addr == 0)) + return EINVAL; + if ((ps->ps_flags & ACPICPU_FLAG_P_FIDVID) != 0) return acpicpu_md_pstate_fidvid_set(ps);
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: jruoho Date: Tue Nov 30 18:44:07 UTC 2010 Modified Files: src/sys/arch/x86/acpi: acpi_cpu_md.c Log Message: Fix boolean brain freeze. To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/sys/arch/x86/acpi/acpi_cpu_md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_cpu_md.c diff -u src/sys/arch/x86/acpi/acpi_cpu_md.c:1.35 src/sys/arch/x86/acpi/acpi_cpu_md.c:1.36 --- src/sys/arch/x86/acpi/acpi_cpu_md.c:1.35 Tue Nov 30 04:31:00 2010 +++ src/sys/arch/x86/acpi/acpi_cpu_md.c Tue Nov 30 18:44:07 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_cpu_md.c,v 1.35 2010/11/30 04:31:00 jruoho Exp $ */ +/* $NetBSD: acpi_cpu_md.c,v 1.36 2010/11/30 18:44:07 jruoho Exp $ */ /*- * Copyright (c) 2010 Jukka Ruohonen @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.35 2010/11/30 04:31:00 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.36 2010/11/30 18:44:07 jruoho Exp $"); #include #include @@ -603,7 +603,11 @@ xc = xc_broadcast(0, (xcfunc_t)x86_msr_xcall, &msr, NULL); xc_wait(xc); - if (acpicpu_pstate_status != false) { + /* + * Due several problems, we bypass the + * relatively expensive status check. + */ + if (acpicpu_pstate_status != true) { DELAY(ps->ps_latency); return 0; }
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: jruoho Date: Tue Aug 24 10:29:53 UTC 2010 Modified Files: src/sys/arch/x86/acpi: acpi_cpu_md.c Log Message: As all reported P-state failures so far have centered around the status- check (today it was christos@' laptop), follow Linux and disable this rather expensive sanity-check for the time being. A hypothesis about the cause of the failures relates to the absence of cross-CPU coordination in the current implementation. To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/sys/arch/x86/acpi/acpi_cpu_md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_cpu_md.c diff -u src/sys/arch/x86/acpi/acpi_cpu_md.c:1.32 src/sys/arch/x86/acpi/acpi_cpu_md.c:1.33 --- src/sys/arch/x86/acpi/acpi_cpu_md.c:1.32 Tue Aug 24 07:28:00 2010 +++ src/sys/arch/x86/acpi/acpi_cpu_md.c Tue Aug 24 10:29:53 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_cpu_md.c,v 1.32 2010/08/24 07:28:00 jruoho Exp $ */ +/* $NetBSD: acpi_cpu_md.c,v 1.33 2010/08/24 10:29:53 jruoho Exp $ */ /*- * Copyright (c) 2010 Jukka Ruohonen @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.32 2010/08/24 07:28:00 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.33 2010/08/24 10:29:53 jruoho Exp $"); #include #include @@ -48,6 +48,8 @@ #include #include +#define ACPICPU_P_STATE_STATUS 0 + /* * AMD families 10h and 11h. */ @@ -417,13 +419,24 @@ (void)memset(&msr, 0, sizeof(struct acpicpu_pstate)); - if ((sc->sc_flags & ACPICPU_FLAG_P_FIDVID) != 0) - msr.ps_flags = ACPICPU_FLAG_P_FIDVID; - switch (cpu_vendor) { case CPUVENDOR_IDT: case CPUVENDOR_INTEL: + + /* + * If the so-called Turbo Boost is present, + * the P0-state is always the "turbo state". + * + * For discussion, see: + * + * Intel Corporation: Intel Turbo Boost Technology + * in Intel Core(tm) Microarchitectures (Nehalem) + * Based Processors. White Paper, November 2008. + */ + if ((sc->sc_flags & ACPICPU_FLAG_P_TURBO) != 0) + sc->sc_pstate[0].ps_flags |= ACPICPU_FLAG_P_TURBO; + msr.ps_control_addr = MSR_PERF_CTL; msr.ps_control_mask = __BITS(0, 15); @@ -433,6 +446,9 @@ case CPUVENDOR_AMD: + if ((sc->sc_flags & ACPICPU_FLAG_P_FIDVID) != 0) + msr.ps_flags |= ACPICPU_FLAG_P_FIDVID; + family = CPUID2FAMILY(ci->ci_signature); if (family == 0xf) @@ -494,26 +510,6 @@ i++; } - /* - * When the state is P0 and Turbo Boost has been - * detected, we need to skip the status check as - * BIOS may not report right comparison values for - * the IA32_PERF_STATUS register. Note that this - * issue is specific to Intel. For discussion, see: - * - * Intel Corporation: Intel Turbo Boost Technology - * in Intel Core(tm) Microarchitectures (Nehalem) - * Based Processors. White Paper, November 2008. - */ - if (cpu_vendor != CPUVENDOR_INTEL) - return 0; - - if ((sc->sc_flags & ACPICPU_FLAG_P_TURBO) == 0) - return 0; - - if (sc->sc_pstate[1].ps_freq + 1 == sc->sc_pstate[0].ps_freq) - sc->sc_pstate[0].ps_flags |= ACPICPU_FLAG_P_TURBO; - return 0; } @@ -584,24 +580,15 @@ xc = xc_broadcast(0, (xcfunc_t)x86_msr_xcall, &msr, NULL); xc_wait(xc); - if (__predict_false(ps->ps_status == 0)) - goto out; - - if (__predict_false(ps->ps_status_addr == 0)) - goto out; - - if ((ps->ps_flags & ACPICPU_FLAG_P_TURBO) != 0) - goto out; + if (ACPICPU_P_STATE_STATUS == 0) { + DELAY(ps->ps_latency); + return 0; + } xc = xc_broadcast(0, (xcfunc_t)acpicpu_md_pstate_status, ps, &rv); xc_wait(xc); return rv; - -out: - DELAY(ps->ps_latency); - - return 0; } static void
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: jruoho Date: Sun Aug 22 04:42:57 UTC 2010 Modified Files: src/sys/arch/x86/acpi: acpi_cpu_md.c Log Message: Still DELAY(9) a little even when we do not do the status-check. To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/sys/arch/x86/acpi/acpi_cpu_md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_cpu_md.c diff -u src/sys/arch/x86/acpi/acpi_cpu_md.c:1.29 src/sys/arch/x86/acpi/acpi_cpu_md.c:1.30 --- src/sys/arch/x86/acpi/acpi_cpu_md.c:1.29 Sat Aug 21 18:25:45 2010 +++ src/sys/arch/x86/acpi/acpi_cpu_md.c Sun Aug 22 04:42:57 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_cpu_md.c,v 1.29 2010/08/21 18:25:45 jruoho Exp $ */ +/* $NetBSD: acpi_cpu_md.c,v 1.30 2010/08/22 04:42:57 jruoho Exp $ */ /*- * Copyright (c) 2010 Jukka Ruohonen @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.29 2010/08/21 18:25:45 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.30 2010/08/22 04:42:57 jruoho Exp $"); #include #include @@ -510,18 +510,23 @@ xc_wait(xc); if (__predict_false(ps->ps_status == 0)) - return 0; + goto out; if (__predict_false(ps->ps_status_addr == 0)) - return 0; + goto out; if ((ps->ps_flags & ACPICPU_FLAG_P_TURBO) != 0) - return 0; + goto out; xc = xc_broadcast(0, (xcfunc_t)acpicpu_md_pstate_status, ps, &rv); xc_wait(xc); return rv; + +out: + DELAY(ps->ps_latency); + + return 0; } static void @@ -587,8 +592,10 @@ xc = xc_broadcast(0, (xcfunc_t)x86_msr_xcall, &msr, NULL); xc_wait(xc); - if (ts->ts_status == 0) + if (ts->ts_status == 0) { + DELAY(ts->ts_latency); return 0; + } xc = xc_broadcast(0, (xcfunc_t)acpicpu_md_tstate_status, ts, &rv); xc_wait(xc);
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: jruoho Date: Sat Aug 21 15:37:35 UTC 2010 Modified Files: src/sys/arch/x86/acpi: acpi_cpu_md.c Log Message: When we do the sanity check that a P- or T-state transition was successful, compare also against the control-field. There appears to be many BIOSes in the field that report a zero value in the status-field. It is unclear whether this should be taken as a hint that the status-check is not necessary also during P-state transitions. If we still see timeouts (EAGAIN), this should be reverted and the status-check should be bypassed if ps->ps_status is 0. To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/sys/arch/x86/acpi/acpi_cpu_md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_cpu_md.c diff -u src/sys/arch/x86/acpi/acpi_cpu_md.c:1.27 src/sys/arch/x86/acpi/acpi_cpu_md.c:1.28 --- src/sys/arch/x86/acpi/acpi_cpu_md.c:1.27 Sat Aug 21 09:16:28 2010 +++ src/sys/arch/x86/acpi/acpi_cpu_md.c Sat Aug 21 15:37:35 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_cpu_md.c,v 1.27 2010/08/21 09:16:28 jruoho Exp $ */ +/* $NetBSD: acpi_cpu_md.c,v 1.28 2010/08/21 15:37:35 jruoho Exp $ */ /*- * Copyright (c) 2010 Jukka Ruohonen @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.27 2010/08/21 09:16:28 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.28 2010/08/21 15:37:35 jruoho Exp $"); #include #include @@ -466,12 +466,12 @@ if (__predict_false(ps == NULL)) return ENODEV; - if (ps->ps_status_addr == 0) + if (__predict_false(ps->ps_status_addr == 0)) return EINVAL; val = rdmsr(ps->ps_status_addr); - if (ps->ps_status_mask != 0) + if (__predict_true(ps->ps_status_mask != 0)) val = val & ps->ps_status_mask; for (i = 0; i < sc->sc_pstate_count; i++) { @@ -481,7 +481,7 @@ if (ps->ps_freq == 0) continue; - if (val == ps->ps_status) { + if (val == ps->ps_status || val == ps->ps_control) { *freq = ps->ps_freq; return 0; } @@ -535,7 +535,7 @@ if (__predict_true(ps->ps_status_mask != 0)) val = val & ps->ps_status_mask; - if (val == ps->ps_status) + if (val == ps->ps_status || val == ps->ps_control) return; DELAY(ps->ps_latency); @@ -560,7 +560,7 @@ if (ts->ts_percent == 0) continue; - if (val == ts->ts_control || val == ts->ts_status) { + if (val == ts->ts_status || val == ts->ts_control) { *percent = ts->ts_percent; return 0; } @@ -604,7 +604,7 @@ val = rdmsr(MSR_THERM_CONTROL); - if (val == ts->ts_status) + if (val == ts->ts_status || val == ts->ts_control) return; DELAY(ts->ts_latency);
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: jruoho Date: Sat Aug 21 09:16:28 UTC 2010 Modified Files: src/sys/arch/x86/acpi: acpi_cpu_md.c Log Message: Use an inverse logic when filling the (X)PSS structures -- if we know the addresses, we trust ourselves more than a random BIOS in the field. To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/sys/arch/x86/acpi/acpi_cpu_md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_cpu_md.c diff -u src/sys/arch/x86/acpi/acpi_cpu_md.c:1.26 src/sys/arch/x86/acpi/acpi_cpu_md.c:1.27 --- src/sys/arch/x86/acpi/acpi_cpu_md.c:1.26 Sat Aug 21 07:18:34 2010 +++ src/sys/arch/x86/acpi/acpi_cpu_md.c Sat Aug 21 09:16:28 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_cpu_md.c,v 1.26 2010/08/21 07:18:34 jruoho Exp $ */ +/* $NetBSD: acpi_cpu_md.c,v 1.27 2010/08/21 09:16:28 jruoho Exp $ */ /*- * Copyright (c) 2010 Jukka Ruohonen @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.26 2010/08/21 07:18:34 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.27 2010/08/21 09:16:28 jruoho Exp $"); #include #include @@ -402,24 +402,24 @@ /* * Fill the P-state structures with MSR addresses that are - * known to be correct. But only do this when the values - * reported by BIOS are absent. If a vendor uses XPSS, we - * do not necessary need to do anything to support new CPUs. + * known to be correct. If we do not know the addresses, + * leave the values intact. If a vendor uses XPSS, we do + * not necessary need to do anything to support new CPUs. */ while (i < sc->sc_pstate_count) { ps = &sc->sc_pstate[i]; - if (ps->ps_status_addr == 0) + if (msr.ps_status_addr != 0) ps->ps_status_addr = msr.ps_status_addr; - if (ps->ps_status_mask == 0) + if (msr.ps_status_mask != 0) ps->ps_status_mask = msr.ps_status_mask; - if (ps->ps_control_addr == 0) + if (msr.ps_control_addr != 0) ps->ps_control_addr = msr.ps_control_addr; - if (ps->ps_control_mask == 0) + if (msr.ps_control_mask != 0) ps->ps_control_mask = msr.ps_control_mask; i++;
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: jruoho Date: Sat Aug 21 07:18:34 UTC 2010 Modified Files: src/sys/arch/x86/acpi: acpi_cpu_md.c Log Message: Add a comment. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/sys/arch/x86/acpi/acpi_cpu_md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_cpu_md.c diff -u src/sys/arch/x86/acpi/acpi_cpu_md.c:1.25 src/sys/arch/x86/acpi/acpi_cpu_md.c:1.26 --- src/sys/arch/x86/acpi/acpi_cpu_md.c:1.25 Sat Aug 21 06:45:50 2010 +++ src/sys/arch/x86/acpi/acpi_cpu_md.c Sat Aug 21 07:18:34 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_cpu_md.c,v 1.25 2010/08/21 06:45:50 jruoho Exp $ */ +/* $NetBSD: acpi_cpu_md.c,v 1.26 2010/08/21 07:18:34 jruoho Exp $ */ /*- * Copyright (c) 2010 Jukka Ruohonen @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.25 2010/08/21 06:45:50 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.26 2010/08/21 07:18:34 jruoho Exp $"); #include #include @@ -400,6 +400,12 @@ return ENODEV; } + /* + * Fill the P-state structures with MSR addresses that are + * known to be correct. But only do this when the values + * reported by BIOS are absent. If a vendor uses XPSS, we + * do not necessary need to do anything to support new CPUs. + */ while (i < sc->sc_pstate_count) { ps = &sc->sc_pstate[i];
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: jruoho Date: Sat Aug 21 05:10:43 UTC 2010 Modified Files: src/sys/arch/x86/acpi: acpi_cpu_md.c Log Message: Add a quirk for Turbo Boost. It was observed that at least Sverre Froyen's ThinkPad T500 reports values that do not match readings from the IA32_PERF_STATUS register. This only applied to the P0-state. Thus, for now, skip the status check if Turbo Boost has been detected and the requested state is P0. This needs to be revisited once Turbo Boost actually works in NetBSD. It is unclear whether this is a BIOS flaw or not; these values may well be what we get from IA32_PERF_STATUS once the CPU actually uses the +133.33 MHz boost. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/sys/arch/x86/acpi/acpi_cpu_md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_cpu_md.c diff -u src/sys/arch/x86/acpi/acpi_cpu_md.c:1.23 src/sys/arch/x86/acpi/acpi_cpu_md.c:1.24 --- src/sys/arch/x86/acpi/acpi_cpu_md.c:1.23 Sat Aug 21 04:36:29 2010 +++ src/sys/arch/x86/acpi/acpi_cpu_md.c Sat Aug 21 05:10:43 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_cpu_md.c,v 1.23 2010/08/21 04:36:29 jruoho Exp $ */ +/* $NetBSD: acpi_cpu_md.c,v 1.24 2010/08/21 05:10:43 jruoho Exp $ */ /*- * Copyright (c) 2010 Jukka Ruohonen @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.23 2010/08/21 04:36:29 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.24 2010/08/21 05:10:43 jruoho Exp $"); #include #include @@ -156,8 +156,8 @@ if ((regs[2] & __BIT(0)) != 0) /* ECX.06[0] */ val |= ACPICPU_FLAG_P_HW; - if ((regs[0] & __BIT(1)) != 0) -val |= ACPICPU_FLAG_P_TURBO; /* EAX.06[1] */ + if ((regs[0] & __BIT(1)) != 0) /* EAX.06[1] */ +val |= ACPICPU_FLAG_P_TURBO; } /* @@ -166,7 +166,7 @@ * at constant rate. Depending on the CPU, this may * affect P- and T-state changes, but especially * relevant are C-states; with variant TSC, states - * larger than C1 will completely stop the timer. + * larger than C1 may completely stop the counter. */ x86_cpuid(0x8000, regs); @@ -415,6 +415,30 @@ i++; } + /* + * When the state is P0 and Turbo Boost has been + * detected, we need to skip the status check as + * BIOS may not report right comparison values for + * the IA32_PERF_STATUS MSR. Note that this is a + * BIOS issue, and that for instance AMD documents + * clearly state that vendors should never expose + * "turbo" in the ACPI objects (namely, in _PSS). + * + * For discussion, see: + * + * Intel Corporation: Intel Turbo Boost Technology + * in Intel Core(tm) Microarchitectures (Nehalem) + * Based Processors. White Paper, November 2008. + */ + if (cpu_vendor != CPUVENDOR_INTEL) + return 0; + + if ((sc->sc_flags & ACPICPU_FLAG_P_TURBO) == 0) + return 0; + + if (sc->sc_pstate[1].ps_freq + 1 == sc->sc_pstate[0].ps_freq) + sc->sc_pstate[0].ps_flags |= ACPICPU_FLAG_P_TURBO; + return 0; } @@ -471,7 +495,7 @@ msr.msr_type = ps->ps_control_addr; msr.msr_value = ps->ps_control; - if (ps->ps_control_mask != 0) { + if (__predict_true(ps->ps_control_mask != 0)) { msr.msr_mask = ps->ps_control_mask; msr.msr_read = true; } @@ -479,7 +503,10 @@ xc = xc_broadcast(0, (xcfunc_t)x86_msr_xcall, &msr, NULL); xc_wait(xc); - if (ps->ps_status_addr == 0) + if (__predict_false(ps->ps_status_addr == 0)) + return 0; + + if ((ps->ps_flags & ACPICPU_FLAG_P_TURBO) != 0) return 0; xc = xc_broadcast(0, (xcfunc_t)acpicpu_md_pstate_status, ps, &rv); @@ -499,7 +526,7 @@ val = rdmsr(ps->ps_status_addr); - if (ps->ps_status_mask != 0) + if (__predict_true(ps->ps_status_mask != 0)) val = val & ps->ps_status_mask; if (val == ps->ps_status)
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: jruoho Date: Sat Aug 21 04:36:29 UTC 2010 Modified Files: src/sys/arch/x86/acpi: acpi_cpu_md.c Log Message: Detect Intel's Turbo Boost and presence of IA32_APERF/IA32_MPERF. The former is required for a quirk, and the latter is needed for hardware P-state coordination (once acpicpu(4) will support fine-grained coordination). To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sys/arch/x86/acpi/acpi_cpu_md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_cpu_md.c diff -u src/sys/arch/x86/acpi/acpi_cpu_md.c:1.22 src/sys/arch/x86/acpi/acpi_cpu_md.c:1.23 --- src/sys/arch/x86/acpi/acpi_cpu_md.c:1.22 Sat Aug 21 03:55:24 2010 +++ src/sys/arch/x86/acpi/acpi_cpu_md.c Sat Aug 21 04:36:29 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_cpu_md.c,v 1.22 2010/08/21 03:55:24 jruoho Exp $ */ +/* $NetBSD: acpi_cpu_md.c,v 1.23 2010/08/21 04:36:29 jruoho Exp $ */ /*- * Copyright (c) 2010 Jukka Ruohonen @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.22 2010/08/21 03:55:24 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.23 2010/08/21 04:36:29 jruoho Exp $"); #include #include @@ -146,6 +146,21 @@ val |= ACPICPU_FLAG_T_FFH; /* + * See if MSR_APERF, MSR_MPERF, + * and Turbo Boost are available. + */ + if (cpuid_level >= 0x06) { + + x86_cpuid(0x06, regs); + + if ((regs[2] & __BIT(0)) != 0) /* ECX.06[0] */ +val |= ACPICPU_FLAG_P_HW; + + if ((regs[0] & __BIT(1)) != 0) +val |= ACPICPU_FLAG_P_TURBO; /* EAX.06[1] */ + } + + /* * Detect whether TSC is invariant. If it is not, * we keep the flag to note that TSC will not run * at constant rate. Depending on the CPU, this may
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: jruoho Date: Sat Aug 21 02:47:38 UTC 2010 Modified Files: src/sys/arch/x86/acpi: acpi_cpu_md.c Log Message: Properly detect AMD hardware P-state support. Also detect "core boost" (only present in some models of family 10h). To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/sys/arch/x86/acpi/acpi_cpu_md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_cpu_md.c diff -u src/sys/arch/x86/acpi/acpi_cpu_md.c:1.20 src/sys/arch/x86/acpi/acpi_cpu_md.c:1.21 --- src/sys/arch/x86/acpi/acpi_cpu_md.c:1.20 Fri Aug 20 07:00:17 2010 +++ src/sys/arch/x86/acpi/acpi_cpu_md.c Sat Aug 21 02:47:37 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_cpu_md.c,v 1.20 2010/08/20 07:00:17 jruoho Exp $ */ +/* $NetBSD: acpi_cpu_md.c,v 1.21 2010/08/21 02:47:37 jruoho Exp $ */ /*- * Copyright (c) 2010 Jukka Ruohonen @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.20 2010/08/20 07:00:17 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.21 2010/08/21 02:47:37 jruoho Exp $"); #include #include @@ -111,6 +111,7 @@ struct cpu_info *ci = curcpu(); struct pci_attach_args pa; uint32_t family, val = 0; + uint32_t regs[4]; if (acpicpu_md_cpus_running() == 1) val |= ACPICPU_FLAG_C_BM; @@ -144,8 +145,13 @@ case 0x10: case 0x11: - if ((ci->ci_feat_val[2] & CPUID_APM_HWP) != 0) + x86_cpuid(0x8007, regs); + + if ((regs[3] & CPUID_APM_HWP) != 0) val |= ACPICPU_FLAG_P_FFH; + + if ((regs[3] & CPUID_APM_CPB) != 0) +val |= ACPICPU_FLAG_P_TURBO; } break;
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: jruoho Date: Fri Aug 20 07:00:17 UTC 2010 Modified Files: src/sys/arch/x86/acpi: acpi_cpu_md.c Log Message: Check if SpeedStep is enabled. If it is disabled, try to enable it. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sys/arch/x86/acpi/acpi_cpu_md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_cpu_md.c diff -u src/sys/arch/x86/acpi/acpi_cpu_md.c:1.19 src/sys/arch/x86/acpi/acpi_cpu_md.c:1.20 --- src/sys/arch/x86/acpi/acpi_cpu_md.c:1.19 Fri Aug 20 06:34:32 2010 +++ src/sys/arch/x86/acpi/acpi_cpu_md.c Fri Aug 20 07:00:17 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_cpu_md.c,v 1.19 2010/08/20 06:34:32 jruoho Exp $ */ +/* $NetBSD: acpi_cpu_md.c,v 1.20 2010/08/20 07:00:17 jruoho Exp $ */ /*- * Copyright (c) 2010 Jukka Ruohonen @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.19 2010/08/20 06:34:32 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.20 2010/08/20 07:00:17 jruoho Exp $"); #include #include @@ -254,6 +254,27 @@ int acpicpu_md_pstate_start(void) { + const uint64_t est = __BIT(16); + uint64_t val; + + switch (cpu_vendor) { + + case CPUVENDOR_IDT: + case CPUVENDOR_INTEL: + + val = rdmsr(MSR_MISC_ENABLE); + + if ((val & est) == 0) { + + val |= est; + + wrmsr(MSR_MISC_ENABLE, val); + val = rdmsr(MSR_MISC_ENABLE); + + if ((val & est) == 0) +return ENOTTY; + } + } return acpicpu_md_pstate_sysctl_init(); }
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: jruoho Date: Thu Aug 19 21:40:45 UTC 2010 Modified Files: src/sys/arch/x86/acpi: acpi_cpu_md.c Log Message: Properly calculate the AMD CPU family. To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/sys/arch/x86/acpi/acpi_cpu_md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_cpu_md.c diff -u src/sys/arch/x86/acpi/acpi_cpu_md.c:1.17 src/sys/arch/x86/acpi/acpi_cpu_md.c:1.18 --- src/sys/arch/x86/acpi/acpi_cpu_md.c:1.17 Thu Aug 19 18:30:24 2010 +++ src/sys/arch/x86/acpi/acpi_cpu_md.c Thu Aug 19 21:40:45 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_cpu_md.c,v 1.17 2010/08/19 18:30:24 jruoho Exp $ */ +/* $NetBSD: acpi_cpu_md.c,v 1.18 2010/08/19 21:40:45 jruoho Exp $ */ /*- * Copyright (c) 2010 Jukka Ruohonen @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.17 2010/08/19 18:30:24 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.18 2010/08/19 21:40:45 jruoho Exp $"); #include #include @@ -109,7 +109,7 @@ { struct cpu_info *ci = curcpu(); struct pci_attach_args pa; - uint32_t val = 0; + uint32_t family, val = 0; if (acpicpu_md_cpus_running() == 1) val |= ACPICPU_FLAG_C_BM; @@ -133,7 +133,12 @@ case CPUVENDOR_AMD: - switch (CPUID2FAMILY(ci->ci_signature)) { + family = CPUID2FAMILY(ci->ci_signature); + + if (family == 0xf) + family += CPUID2EXTFAMILY(ci->ci_signature); + + switch (family) { case 0x10: case 0x11: @@ -461,7 +466,7 @@ { struct acpicpu_pstate *ps, msr; struct cpu_info *ci = curcpu(); - uint32_t i = 0; + uint32_t family, i = 0; (void)memset(&msr, 0, sizeof(struct acpicpu_pstate)); @@ -478,7 +483,12 @@ case CPUVENDOR_AMD: - switch (CPUID2FAMILY(ci->ci_signature)) { + family = CPUID2FAMILY(ci->ci_signature); + + if (family == 0xf) + family += CPUID2EXTFAMILY(ci->ci_signature); + + switch (family) { case 0x10: case 0x11:
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: jruoho Date: Thu Aug 19 18:30:24 UTC 2010 Modified Files: src/sys/arch/x86/acpi: acpi_cpu_md.c Log Message: Add native P-state support for AMD family 10h and 11h processors. Both are supported irrespective of XPSS. Family 10h tested by jakll...@. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/arch/x86/acpi/acpi_cpu_md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_cpu_md.c diff -u src/sys/arch/x86/acpi/acpi_cpu_md.c:1.16 src/sys/arch/x86/acpi/acpi_cpu_md.c:1.17 --- src/sys/arch/x86/acpi/acpi_cpu_md.c:1.16 Thu Aug 19 11:08:33 2010 +++ src/sys/arch/x86/acpi/acpi_cpu_md.c Thu Aug 19 18:30:24 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_cpu_md.c,v 1.16 2010/08/19 11:08:33 jmcneill Exp $ */ +/* $NetBSD: acpi_cpu_md.c,v 1.17 2010/08/19 18:30:24 jruoho Exp $ */ /*- * Copyright (c) 2010 Jukka Ruohonen @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.16 2010/08/19 11:08:33 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.17 2010/08/19 18:30:24 jruoho Exp $"); #include #include @@ -48,6 +48,14 @@ #include #include +#define MSR_0FH_CONTROL 0xc0010041 /* Family 0Fh (and K7). */ +#define MSR_0FH_STATUS 0xc0010042 + +#define MSR_10H_LIMIT 0xc0010061 /* Families 10h and 11h. */ +#define MSR_10H_CONTROL 0xc0010062 +#define MSR_10H_STATUS 0xc0010063 +#define MSR_10H_CONFIG 0xc0010064 + static char native_idle_text[16]; void (*native_idle)(void) = NULL; void (*native_cpu_freq_init)(int) = NULL; @@ -68,13 +76,9 @@ struct cpu_info *ci = curcpu(); uint32_t val = 0; - switch (cpu_vendor) { - case CPUVENDOR_INTEL: - case CPUVENDOR_IDT: - break; - default: + if (cpu_vendor != CPUVENDOR_IDT && + cpu_vendor != CPUVENDOR_INTEL) return val; - } /* * Basic SMP C-states (required for _CST). @@ -115,8 +119,9 @@ switch (cpu_vendor) { - case CPUVENDOR_INTEL: case CPUVENDOR_IDT: + case CPUVENDOR_INTEL: + if ((ci->ci_feat_val[1] & CPUID2_EST) != 0) val |= ACPICPU_FLAG_P_FFH; @@ -124,27 +129,19 @@ val |= ACPICPU_FLAG_T_FFH; val |= ACPICPU_FLAG_C_BM | ACPICPU_FLAG_C_ARB; - - /* - * Bus master arbitration is not - * needed on some recent Intel CPUs. - */ - if (cpu_vendor == CPUVENDOR_INTEL && - CPUID2FAMILY(ci->ci_signature) > 15) - val &= ~ACPICPU_FLAG_C_ARB; - - if (cpu_vendor == CPUVENDOR_INTEL && - CPUID2FAMILY(ci->ci_signature) == 6 && - CPUID2MODEL(ci->ci_signature) >= 15) - val &= ~ACPICPU_FLAG_C_ARB; - break; case CPUVENDOR_AMD: - /* - * XXX: Deal with (non-XPSS) PowerNow! and C1E. - */ + switch (CPUID2FAMILY(ci->ci_signature)) { + + case 0x10: + case 0x11: + + if ((ci->ci_feat_val[2] & CPUID_APM_HWP) != 0) +val |= ACPICPU_FLAG_P_FFH; + } + break; } @@ -463,14 +460,15 @@ acpicpu_md_pstate_pss(struct acpicpu_softc *sc) { struct acpicpu_pstate *ps, msr; + struct cpu_info *ci = curcpu(); uint32_t i = 0; (void)memset(&msr, 0, sizeof(struct acpicpu_pstate)); switch (cpu_vendor) { - case CPUVENDOR_INTEL: case CPUVENDOR_IDT: + case CPUVENDOR_INTEL: msr.ps_control_addr = MSR_PERF_CTL; msr.ps_control_mask = __BITS(0, 15); @@ -480,8 +478,22 @@ case CPUVENDOR_AMD: - if ((sc->sc_flags & ACPICPU_FLAG_P_XPSS) == 0) - return EOPNOTSUPP; + switch (CPUID2FAMILY(ci->ci_signature)) { + + case 0x10: + case 0x11: + msr.ps_control_addr = MSR_10H_CONTROL; + msr.ps_control_mask = __BITS(0, 2); + + msr.ps_status_addr = MSR_10H_STATUS; + msr.ps_status_mask = __BITS(0, 2); + break; + + default: + + if ((sc->sc_flags & ACPICPU_FLAG_P_XPSS) == 0) +return EOPNOTSUPP; + } break; @@ -527,7 +539,7 @@ } if (__predict_false(ps == NULL)) - return EINVAL; + return ENODEV; if (ps->ps_status_addr == 0) return EINVAL; @@ -611,10 +623,6 @@ uint64_t val; uint32_t i; - if (cpu_vendor != CPUVENDOR_INTEL && - cpu_vendor != CPUVENDOR_IDT) - return ENODEV; - val = rdmsr(MSR_THERM_CONTROL); for (i = 0; i < sc->sc_tstate_count; i++) { @@ -640,10 +648,6 @@ uint64_t xc; int rv = 0; - if (cpu_vendor != CPUVENDOR_INTEL && - cpu_vendor != CPUVENDOR_IDT) - return ENODEV; - msr.msr_read = true; msr.msr_type = MSR_THERM_CONTROL; msr.msr_value = ts->ts_control;
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: jmcneill Date: Thu Aug 19 11:08:33 UTC 2010 Modified Files: src/sys/arch/x86/acpi: acpi_cpu_md.c Log Message: VIA CPUs can have EST as well, so treat them the same as Intel To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/arch/x86/acpi/acpi_cpu_md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_cpu_md.c diff -u src/sys/arch/x86/acpi/acpi_cpu_md.c:1.15 src/sys/arch/x86/acpi/acpi_cpu_md.c:1.16 --- src/sys/arch/x86/acpi/acpi_cpu_md.c:1.15 Wed Aug 18 18:32:20 2010 +++ src/sys/arch/x86/acpi/acpi_cpu_md.c Thu Aug 19 11:08:33 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_cpu_md.c,v 1.15 2010/08/18 18:32:20 jruoho Exp $ */ +/* $NetBSD: acpi_cpu_md.c,v 1.16 2010/08/19 11:08:33 jmcneill Exp $ */ /*- * Copyright (c) 2010 Jukka Ruohonen @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.15 2010/08/18 18:32:20 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.16 2010/08/19 11:08:33 jmcneill Exp $"); #include #include @@ -68,8 +68,13 @@ struct cpu_info *ci = curcpu(); uint32_t val = 0; - if (cpu_vendor != CPUVENDOR_INTEL) + switch (cpu_vendor) { + case CPUVENDOR_INTEL: + case CPUVENDOR_IDT: + break; + default: return val; + } /* * Basic SMP C-states (required for _CST). @@ -111,7 +116,7 @@ switch (cpu_vendor) { case CPUVENDOR_INTEL: - + case CPUVENDOR_IDT: if ((ci->ci_feat_val[1] & CPUID2_EST) != 0) val |= ACPICPU_FLAG_P_FFH; @@ -124,10 +129,12 @@ * Bus master arbitration is not * needed on some recent Intel CPUs. */ - if (CPUID2FAMILY(ci->ci_signature) > 15) + if (cpu_vendor == CPUVENDOR_INTEL && + CPUID2FAMILY(ci->ci_signature) > 15) val &= ~ACPICPU_FLAG_C_ARB; - if (CPUID2FAMILY(ci->ci_signature) == 6 && + if (cpu_vendor == CPUVENDOR_INTEL && + CPUID2FAMILY(ci->ci_signature) == 6 && CPUID2MODEL(ci->ci_signature) >= 15) val &= ~ACPICPU_FLAG_C_ARB; @@ -251,6 +258,7 @@ switch (cpu_vendor) { case CPUVENDOR_INTEL: + case CPUVENDOR_IDT: str = "est"; break; @@ -462,6 +470,7 @@ switch (cpu_vendor) { case CPUVENDOR_INTEL: + case CPUVENDOR_IDT: msr.ps_control_addr = MSR_PERF_CTL; msr.ps_control_mask = __BITS(0, 15); @@ -602,7 +611,8 @@ uint64_t val; uint32_t i; - if (cpu_vendor != CPUVENDOR_INTEL) + if (cpu_vendor != CPUVENDOR_INTEL && + cpu_vendor != CPUVENDOR_IDT) return ENODEV; val = rdmsr(MSR_THERM_CONTROL); @@ -630,7 +640,8 @@ uint64_t xc; int rv = 0; - if (cpu_vendor != CPUVENDOR_INTEL) + if (cpu_vendor != CPUVENDOR_INTEL && + cpu_vendor != CPUVENDOR_IDT) return ENODEV; msr.msr_read = true;
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: jruoho Date: Wed Aug 18 16:08:50 UTC 2010 Modified Files: src/sys/arch/x86/acpi: acpi_cpu_md.c Log Message: Check the status of P- and T-state transformations on all CPUs. This is still not ideal, as ACPI gives us information about "cross logical processor dependencies". For instance, a single MSR call on one CPU may cause all other CPUs in the same domain to follow the state shift. Thus, rather than using xc_broadcast(9), we should xc_unicast(9) on per-domain or per-CPU-set basis. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/arch/x86/acpi/acpi_cpu_md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_cpu_md.c diff -u src/sys/arch/x86/acpi/acpi_cpu_md.c:1.13 src/sys/arch/x86/acpi/acpi_cpu_md.c:1.14 --- src/sys/arch/x86/acpi/acpi_cpu_md.c:1.13 Wed Aug 18 04:12:29 2010 +++ src/sys/arch/x86/acpi/acpi_cpu_md.c Wed Aug 18 16:08:50 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_cpu_md.c,v 1.13 2010/08/18 04:12:29 jruoho Exp $ */ +/* $NetBSD: acpi_cpu_md.c,v 1.14 2010/08/18 16:08:50 jruoho Exp $ */ /*- * Copyright (c) 2010 Jukka Ruohonen @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.13 2010/08/18 04:12:29 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.14 2010/08/18 16:08:50 jruoho Exp $"); #include #include @@ -56,6 +56,8 @@ static int acpicpu_md_pstate_sysctl_get(SYSCTLFN_PROTO); static int acpicpu_md_pstate_sysctl_set(SYSCTLFN_PROTO); static int acpicpu_md_pstate_sysctl_all(SYSCTLFN_PROTO); +static void acpicpu_md_pstate_status(void *, void *); +static void acpicpu_md_tstate_status(void *, void *); extern uint32_t cpus_running; extern struct acpicpu_softc **acpicpu_sc; @@ -513,8 +515,8 @@ acpicpu_md_pstate_set(struct acpicpu_pstate *ps) { struct msr_rw_info msr; - uint64_t xc, val; - int i; + uint64_t xc; + int rv = 0; switch (cpu_vendor) { @@ -552,6 +554,19 @@ if (ps->ps_status_addr == 0) return 0; + xc = xc_broadcast(0, (xcfunc_t)acpicpu_md_pstate_status, ps, &rv); + xc_wait(xc); + + return rv; +} + +static void +acpicpu_md_pstate_status(void *arg1, void *arg2) +{ + struct acpicpu_pstate *ps = arg1; + uint64_t val; + int i; + for (i = val = 0; i < ACPICPU_P_STATE_RETRY; i++) { val = rdmsr(ps->ps_status_addr); @@ -560,32 +575,25 @@ val = val & ps->ps_status_mask; if (val == ps->ps_status) - return 0; + return; DELAY(ps->ps_latency); } - return EAGAIN; + *(uintptr_t *)arg2 = EAGAIN; } int acpicpu_md_tstate_get(struct acpicpu_softc *sc, uint32_t *percent) { struct acpicpu_tstate *ts; - uint64_t val, sta; + uint64_t val; uint32_t i; - switch (cpu_vendor) { - - case CPUVENDOR_INTEL: - sta = MSR_THERM_CONTROL; - break; - - default: + if (cpu_vendor != CPUVENDOR_INTEL) return ENODEV; - } - val = rdmsr(sta); + val = rdmsr(MSR_THERM_CONTROL); for (i = 0; i < sc->sc_tstate_count; i++) { @@ -607,23 +615,16 @@ acpicpu_md_tstate_set(struct acpicpu_tstate *ts) { struct msr_rw_info msr; - uint64_t xc, val, sta; - uint32_t i; - - switch (cpu_vendor) { - - case CPUVENDOR_INTEL: - msr.msr_read = true; - msr.msr_type = MSR_THERM_CONTROL; - msr.msr_value = ts->ts_control; - msr.msr_mask = __BITS(1, 4); - - sta = MSR_THERM_CONTROL; - break; + uint64_t xc; + int rv = 0; - default: + if (cpu_vendor != CPUVENDOR_INTEL) return ENODEV; - } + + msr.msr_read = true; + msr.msr_type = MSR_THERM_CONTROL; + msr.msr_value = ts->ts_control; + msr.msr_mask = __BITS(1, 4); xc = xc_broadcast(0, (xcfunc_t)x86_msr_xcall, &msr, NULL); xc_wait(xc); @@ -631,15 +632,28 @@ if (ts->ts_status == 0) return 0; + xc = xc_broadcast(0, (xcfunc_t)acpicpu_md_tstate_status, ts, &rv); + xc_wait(xc); + + return rv; +} + +static void +acpicpu_md_tstate_status(void *arg1, void *arg2) +{ + struct acpicpu_tstate *ts = arg1; + uint64_t val; + int i; + for (i = val = 0; i < ACPICPU_T_STATE_RETRY; i++) { - val = rdmsr(sta); + val = rdmsr(MSR_THERM_CONTROL); if (val == ts->ts_status) - return 0; + return; DELAY(ts->ts_latency); } - return EAGAIN; + *(uintptr_t *)arg2 = EAGAIN; }
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: jruoho Date: Wed Aug 18 04:12:29 UTC 2010 Modified Files: src/sys/arch/x86/acpi: acpi_cpu_md.c Log Message: Add MD support for the vendor-independent extended PSS. Some conforming AMD systems are known to work. Alas, not all of them. We still need to deal with the variety of different PowerNow! revisions. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sys/arch/x86/acpi/acpi_cpu_md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_cpu_md.c diff -u src/sys/arch/x86/acpi/acpi_cpu_md.c:1.12 src/sys/arch/x86/acpi/acpi_cpu_md.c:1.13 --- src/sys/arch/x86/acpi/acpi_cpu_md.c:1.12 Sat Aug 14 05:13:20 2010 +++ src/sys/arch/x86/acpi/acpi_cpu_md.c Wed Aug 18 04:12:29 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_cpu_md.c,v 1.12 2010/08/14 05:13:20 jruoho Exp $ */ +/* $NetBSD: acpi_cpu_md.c,v 1.13 2010/08/18 04:12:29 jruoho Exp $ */ /*- * Copyright (c) 2010 Jukka Ruohonen @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.12 2010/08/14 05:13:20 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.13 2010/08/18 04:12:29 jruoho Exp $"); #include #include @@ -56,7 +56,6 @@ static int acpicpu_md_pstate_sysctl_get(SYSCTLFN_PROTO); static int acpicpu_md_pstate_sysctl_set(SYSCTLFN_PROTO); static int acpicpu_md_pstate_sysctl_all(SYSCTLFN_PROTO); -static int acpicpu_md_tstate_get_status(uint64_t *); extern uint32_t cpus_running; extern struct acpicpu_softc **acpicpu_sc; @@ -135,7 +134,7 @@ case CPUVENDOR_AMD: /* - * XXX: Deal with PowerNow! and C1E here. + * XXX: Deal with (non-XPSS) PowerNow! and C1E. */ break; } @@ -253,6 +252,10 @@ str = "est"; break; + case CPUVENDOR_AMD: + str = "powernow"; + break; + default: return ENODEV; } @@ -449,37 +452,61 @@ int acpicpu_md_pstate_get(struct acpicpu_softc *sc, uint32_t *freq) { - struct acpicpu_pstate *ps; + struct acpicpu_pstate *ps = NULL; uint64_t val; uint32_t i; - switch (cpu_vendor) { + for (i = 0; i < sc->sc_pstate_count; i++) { - case CPUVENDOR_INTEL: + ps = &sc->sc_pstate[i]; - val = rdmsr(MSR_PERF_STATUS); - val = val & 0x; + if (ps->ps_freq != 0) + break; + } - for (i = 0; i < sc->sc_pstate_count; i++) { + if (__predict_false(ps == NULL)) + return EINVAL; - ps = &sc->sc_pstate[i]; + switch (cpu_vendor) { - if (ps->ps_freq == 0) -continue; + case CPUVENDOR_INTEL: + ps->ps_status_addr = MSR_PERF_STATUS; + ps->ps_status_mask = __BITS(0, 15); + break; - if (val == ps->ps_status) { -*freq = ps->ps_freq; -return 0; - } - } + case CPUVENDOR_AMD: - return EIO; + if ((ps->ps_flags & ACPICPU_FLAG_P_XPSS) == 0) + return EOPNOTSUPP; + + break; default: return ENODEV; } - return 0; + if (ps->ps_status_addr == 0) + return EINVAL; + + val = rdmsr(ps->ps_status_addr); + + if (ps->ps_status_mask != 0) + val = val & ps->ps_status_mask; + + for (i = 0; i < sc->sc_pstate_count; i++) { + + ps = &sc->sc_pstate[i]; + + if (ps->ps_freq == 0) + continue; + + if (val == ps->ps_status) { + *freq = ps->ps_freq; + return 0; + } + } + + return EIO; } int @@ -492,23 +519,45 @@ switch (cpu_vendor) { case CPUVENDOR_INTEL: - msr.msr_read = true; - msr.msr_type = MSR_PERF_CTL; - msr.msr_value = ps->ps_control; - msr.msr_mask = 0xULL; + ps->ps_control_addr = MSR_PERF_CTL; + ps->ps_control_mask = __BITS(0, 15); + + ps->ps_status_addr = MSR_PERF_STATUS; + ps->ps_status_mask = __BITS(0, 15); + break; + + case CPUVENDOR_AMD: + + if ((ps->ps_flags & ACPICPU_FLAG_P_XPSS) == 0) + return EOPNOTSUPP; + break; default: return ENODEV; } + msr.msr_read = false; + msr.msr_type = ps->ps_control_addr; + msr.msr_value = ps->ps_control; + + if (ps->ps_control_mask != 0) { + msr.msr_mask = ps->ps_control_mask; + msr.msr_read = true; + } + xc = xc_broadcast(0, (xcfunc_t)x86_msr_xcall, &msr, NULL); xc_wait(xc); + if (ps->ps_status_addr == 0) + return 0; + for (i = val = 0; i < ACPICPU_P_STATE_RETRY; i++) { - val = rdmsr(MSR_PERF_STATUS); - val = val & 0x; + val = rdmsr(ps->ps_status_addr); + + if (ps->ps_status_mask != 0) + val = val & ps->ps_status_mask; if (val == ps->ps_status) return 0; @@ -523,14 +572,20 @@ acpicpu_md_tstate_get(struct acpicpu_softc *sc, uint32_t *percent) { struct acpicpu_tstate *ts; - uint64_t val; + uint64_t val, sta; uint32_t i; - int rv; - rv = acpicpu_md_tstate_get_status(&val); + switch (cpu_vendor) { - if (rv != 0) - return rv; + case CPUVENDOR_INTEL: + sta = MSR_THERM_CONTROL; + break; + + default: + return ENODEV; + } + + val = rdmsr(sta); for (i = 0; i < sc->sc_tstate_count; i++) { @@ -548,29 +603,12 @@ return EIO; } -static int -acpicpu_md_tstate_get_status(uint64_t *val) -{ - - switch (cpu_vendor) { - - case C
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: jruoho Date: Wed Aug 4 16:16:55 UTC 2010 Modified Files: src/sys/arch/x86/acpi: acpi_cpu_md.c Log Message: Run a xcall(9) to ensure that all CPUs are out from the ACPI idle-loop before detachment. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/x86/acpi/acpi_cpu_md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_cpu_md.c diff -u src/sys/arch/x86/acpi/acpi_cpu_md.c:1.3 src/sys/arch/x86/acpi/acpi_cpu_md.c:1.4 --- src/sys/arch/x86/acpi/acpi_cpu_md.c:1.3 Fri Jul 23 13:54:21 2010 +++ src/sys/arch/x86/acpi/acpi_cpu_md.c Wed Aug 4 16:16:55 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_cpu_md.c,v 1.3 2010/07/23 13:54:21 jruoho Exp $ */ +/* $NetBSD: acpi_cpu_md.c,v 1.4 2010/08/04 16:16:55 jruoho Exp $ */ /*- * Copyright (c) 2010 Jukka Ruohonen @@ -27,11 +27,12 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.3 2010/07/23 13:54:21 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.4 2010/08/04 16:16:55 jruoho Exp $"); #include #include #include +#include #include #include @@ -143,14 +144,13 @@ x86_cpu_idle_set(acpicpu_cstate_idle, "acpi"); x86_enable_intr(); - DELAY(1); - return 0; } int acpicpu_md_idle_stop(void) { + uint64_t xc; KASSERT(native_idle != NULL); KASSERT(native_idle_text[0] != '\0'); @@ -159,7 +159,12 @@ x86_cpu_idle_set(native_idle, native_idle_text); x86_enable_intr(); - DELAY(1); + /* + * Run a cross-call to ensure that all CPUs are + * out from the ACPI idle-loop before detachment. + */ + xc = xc_broadcast(0, (xcfunc_t)nullop, NULL, NULL); + xc_wait(xc); return 0; }
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: jruoho Date: Thu Jul 29 11:40:08 UTC 2010 Modified Files: src/sys/arch/x86/acpi: acpi_wakeup.c Log Message: Remove the custom acpi_md_s4bios(). Use ACPICA's native AcpiEnterSleepStateS4bios() instead. Minimum functional change. ok jmcneill@ To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/sys/arch/x86/acpi/acpi_wakeup.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_wakeup.c diff -u src/sys/arch/x86/acpi/acpi_wakeup.c:1.24 src/sys/arch/x86/acpi/acpi_wakeup.c:1.25 --- src/sys/arch/x86/acpi/acpi_wakeup.c:1.24 Wed Jul 28 18:10:31 2010 +++ src/sys/arch/x86/acpi/acpi_wakeup.c Thu Jul 29 11:40:08 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_wakeup.c,v 1.24 2010/07/28 18:10:31 jruoho Exp $ */ +/* $NetBSD: acpi_wakeup.c,v 1.25 2010/07/29 11:40:08 jruoho Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.24 2010/07/28 18:10:31 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.25 2010/07/29 11:40:08 jruoho Exp $"); /*- * Copyright (c) 2001 Takanori Watanabe @@ -116,12 +116,14 @@ int acpi_md_vesa_modenum = 0; /* Referenced by arch/x86/x86/genfb_machdep.c */ static int acpi_md_beep_on_reset = 0; +static int acpi_md_s4bios(void); static int sysctl_md_acpi_vbios_reset(SYSCTLFN_ARGS); static int sysctl_md_acpi_beep_on_reset(SYSCTLFN_ARGS); /* Implemented in acpi_wakeup_low.S. */ int acpi_md_sleep_prepare(int); -int acpi_md_sleep_exit(int); +int acpi_md_sleep_exit(int); + /* Referenced by acpi_wakeup_low.S. */ void acpi_md_sleep_enter(int); @@ -179,70 +181,29 @@ #undef WAKECODE_BCOPY } -/* - * S4 sleep using S4BIOS support, from FreeBSD. - * - * FreeBSD: src/sys/dev/acpica/acpica_support.c,v 1.4 2002/03/12 09:45:17 dfr Exp - */ - -static ACPI_STATUS -enter_s4_with_bios(void) +static int +acpi_md_s4bios(void) { + ACPI_TABLE_FACS *facs; ACPI_STATUS rv; - uint32_t val; - - /* - * Run the _PTS and _GTS methods. - */ - (void)acpi_eval_set_integer(NULL, "\\_PTS", ACPI_STATE_S4); - (void)acpi_eval_set_integer(NULL, "\\_GTS", ACPI_STATE_S4); - - /* - * Clear wake status. - */ - (void)AcpiWriteBitRegister(ACPI_BITREG_WAKE_STATUS, 1); - - /* - * Enable wake GPEs. - */ - (void)AcpiHwDisableAllGpes(); - (void)AcpiHwEnableAllWakeupGpes(); - - /* - * Flush caches. - */ - ACPI_FLUSH_CPU_CACHE(); - - /* - * Write the value to command port and wait until we enter sleep state. - */ - do { - AcpiOsStall(100); - - (void)AcpiOsWritePort(AcpiGbl_FADT.SmiCommand, - AcpiGbl_FADT.S4BiosRequest, 8); - - rv = AcpiReadBitRegister(ACPI_BITREG_WAKE_STATUS, &val); - if (ACPI_FAILURE(rv)) - break; + rv = AcpiGetTable(ACPI_SIG_FACS, 0, (ACPI_TABLE_HEADER **)&facs); - } while (val == 0); + if (ACPI_FAILURE(rv) || facs == NULL) + return 0; - /* - * Enable runtime GPEs. - */ - (void)AcpiHwDisableAllGpes(); - (void)AcpiHwEnableAllRuntimeGpes(); + if ((facs->Flags & ACPI_FACS_S4_BIOS_PRESENT) == 0) + return 0; - return AE_OK; + return 1; } void acpi_md_sleep_enter(int state) { - ACPI_STATUS status; - struct cpu_info *ci; + static int s4bios = -1; + struct cpu_info *ci; + ACPI_STATUS rv; ci = curcpu(); @@ -262,26 +223,28 @@ ACPI_FLUSH_CPU_CACHE(); - if (state == ACPI_STATE_S4) { - ACPI_TABLE_FACS *facs; - status = AcpiGetTable(ACPI_SIG_FACS, 0, (ACPI_TABLE_HEADER **)&facs); - if (ACPI_FAILURE(status)) { - printf("acpi: S4BIOS not supported: cannot load FACS\n"); - return; - } - if (facs == NULL || - (facs->Flags & ACPI_FACS_S4_BIOS_PRESENT) == 0) { - printf("acpi: S4BIOS not supported: not present"); + switch (state) { + + case ACPI_STATE_S4: + + if (s4bios < 0) + s4bios = acpi_md_s4bios(); + + if (s4bios == 0) { + aprint_error("acpi0: S4 not supported\n"); return; } - status = enter_s4_with_bios(); - } else { - status = AcpiEnterSleepState(state); + + rv = AcpiEnterSleepStateS4bios(); + break; + + default: + rv = AcpiEnterSleepState(state); + break; } - if (ACPI_FAILURE(status)) { - printf("acpi: AcpiEnterSleepState failed: %s\n", - AcpiFormatException(status)); + if (ACPI_FAILURE(rv)) { + aprint_error("acpi0: failed to enter S%d\n", state); return; } @@ -353,7 +316,7 @@ /* Save and suspend Application Processors */ x86_broadcast_ipi(X86_IPI_ACPI_CPU_SLEEP); while (cpus_running != curcpu()->ci_cpumask) - delay(1); + delay(1); #endif if (acpi_md_sleep_prepare(state))
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: jruoho Date: Wed Jul 28 18:10:32 UTC 2010 Modified Files: src/sys/arch/x86/acpi: acpi_wakeup.c Log Message: Use acpi_eval_set_integer(), KNF. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/sys/arch/x86/acpi/acpi_wakeup.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_wakeup.c diff -u src/sys/arch/x86/acpi/acpi_wakeup.c:1.23 src/sys/arch/x86/acpi/acpi_wakeup.c:1.24 --- src/sys/arch/x86/acpi/acpi_wakeup.c:1.23 Wed Apr 14 19:32:35 2010 +++ src/sys/arch/x86/acpi/acpi_wakeup.c Wed Jul 28 18:10:31 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_wakeup.c,v 1.23 2010/04/14 19:32:35 jruoho Exp $ */ +/* $NetBSD: acpi_wakeup.c,v 1.24 2010/07/28 18:10:31 jruoho Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.23 2010/04/14 19:32:35 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.24 2010/07/28 18:10:31 jruoho Exp $"); /*- * Copyright (c) 2001 Takanori Watanabe @@ -188,53 +188,54 @@ static ACPI_STATUS enter_s4_with_bios(void) { - ACPI_OBJECT_LIST ArgList; - ACPI_OBJECT Arg; - uint32_t ret; - ACPI_STATUS status; + ACPI_STATUS rv; + uint32_t val; - /* run the _PTS and _GTS methods */ - - (void)memset(&ArgList, 0, sizeof(ArgList)); - - ArgList.Count = 1; - ArgList.Pointer = &Arg; - - (void)memset(&Arg, 0, sizeof(Arg)); - - Arg.Type = ACPI_TYPE_INTEGER; - Arg.Integer.Value = ACPI_STATE_S4; - - AcpiEvaluateObject(NULL, "\\_PTS", &ArgList, NULL); - AcpiEvaluateObject(NULL, "\\_GTS", &ArgList, NULL); - - /* clear wake status */ - - AcpiWriteBitRegister(ACPI_BITREG_WAKE_STATUS, 1); + /* + * Run the _PTS and _GTS methods. + */ + (void)acpi_eval_set_integer(NULL, "\\_PTS", ACPI_STATE_S4); + (void)acpi_eval_set_integer(NULL, "\\_GTS", ACPI_STATE_S4); - AcpiHwDisableAllGpes(); - AcpiHwEnableAllWakeupGpes(); + /* + * Clear wake status. + */ + (void)AcpiWriteBitRegister(ACPI_BITREG_WAKE_STATUS, 1); - /* flush caches */ + /* + * Enable wake GPEs. + */ + (void)AcpiHwDisableAllGpes(); + (void)AcpiHwEnableAllWakeupGpes(); + /* + * Flush caches. + */ ACPI_FLUSH_CPU_CACHE(); /* - * write the value to command port and wait until we enter sleep state + * Write the value to command port and wait until we enter sleep state. */ do { AcpiOsStall(100); - AcpiOsWritePort(AcpiGbl_FADT.SmiCommand, -AcpiGbl_FADT.S4BiosRequest, 8); - status = AcpiReadBitRegister(ACPI_BITREG_WAKE_STATUS, &ret); - if (ACPI_FAILURE(status)) + + (void)AcpiOsWritePort(AcpiGbl_FADT.SmiCommand, + AcpiGbl_FADT.S4BiosRequest, 8); + + rv = AcpiReadBitRegister(ACPI_BITREG_WAKE_STATUS, &val); + + if (ACPI_FAILURE(rv)) break; - } while (!ret); - AcpiHwDisableAllGpes(); - AcpiHwEnableAllRuntimeGpes(); + } while (val == 0); + + /* + * Enable runtime GPEs. + */ + (void)AcpiHwDisableAllGpes(); + (void)AcpiHwEnableAllRuntimeGpes(); - return (AE_OK); + return AE_OK; } void
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: jruoho Date: Sun Apr 11 09:52:10 UTC 2010 Modified Files: src/sys/arch/x86/acpi: acpi_wakeup.c Log Message: Use CTLTYPE_BOOL. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/sys/arch/x86/acpi/acpi_wakeup.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_wakeup.c diff -u src/sys/arch/x86/acpi/acpi_wakeup.c:1.21 src/sys/arch/x86/acpi/acpi_wakeup.c:1.22 --- src/sys/arch/x86/acpi/acpi_wakeup.c:1.21 Sun Feb 28 13:56:49 2010 +++ src/sys/arch/x86/acpi/acpi_wakeup.c Sun Apr 11 09:52:09 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_wakeup.c,v 1.21 2010/02/28 13:56:49 jruoho Exp $ */ +/* $NetBSD: acpi_wakeup.c,v 1.22 2010/04/11 09:52:09 jruoho Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.21 2010/02/28 13:56:49 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.22 2010/04/11 09:52:09 jruoho Exp $"); /*- * Copyright (c) 2001 Takanori Watanabe @@ -444,7 +444,7 @@ 0, NULL, 0, CTL_CREATE, CTL_EOL) != 0) return; if (sysctl_createv(NULL, 0, &node, &ssnode, CTLFLAG_READWRITE, - CTLTYPE_INT, "acpi_beep_on_reset", NULL, sysctl_md_acpi_beep_on_reset, + CTLTYPE_BOOL, "acpi_beep_on_reset", NULL, sysctl_md_acpi_beep_on_reset, 0, NULL, 0, CTL_CREATE, CTL_EOL) != 0) return;
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: joerg Date: Wed Sep 2 15:42:31 UTC 2009 Modified Files: src/sys/arch/x86/acpi: acpi_wakeup.c Log Message: Be a bit more noisy by telling the user VGA_POST is missing in the kernel config when trying machdep.acpi_vbios_reset=2. To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/sys/arch/x86/acpi/acpi_wakeup.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_wakeup.c diff -u src/sys/arch/x86/acpi/acpi_wakeup.c:1.17 src/sys/arch/x86/acpi/acpi_wakeup.c:1.18 --- src/sys/arch/x86/acpi/acpi_wakeup.c:1.17 Wed Sep 2 15:25:07 2009 +++ src/sys/arch/x86/acpi/acpi_wakeup.c Wed Sep 2 15:42:31 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_wakeup.c,v 1.17 2009/09/02 15:25:07 joerg Exp $ */ +/* $NetBSD: acpi_wakeup.c,v 1.18 2009/09/02 15:42:31 joerg Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.17 2009/09/02 15:25:07 joerg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.18 2009/09/02 15:42:31 joerg Exp $"); /*- * Copyright (c) 2001 Takanori Watanabe @@ -466,8 +466,11 @@ return EINVAL; #ifndef VGA_POST - if (t == 2) + if (t == 2) { + aprint_error("WARNING: machdep.acpi_vbios_reset=2 " + "unsupported (no option VGA_POST in kernel config)\n"); return EINVAL; + } #endif acpi_md_vbios_reset = t;
CVS commit: src/sys/arch/x86/acpi
Module Name:src Committed By: joerg Date: Wed Sep 2 15:25:07 UTC 2009 Modified Files: src/sys/arch/x86/acpi: acpi_wakeup.c Log Message: Don't allow machdep.acpi_vbios_reset=2 if option VGA_POST is missing. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/arch/x86/acpi/acpi_wakeup.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/acpi/acpi_wakeup.c diff -u src/sys/arch/x86/acpi/acpi_wakeup.c:1.16 src/sys/arch/x86/acpi/acpi_wakeup.c:1.17 --- src/sys/arch/x86/acpi/acpi_wakeup.c:1.16 Mon Aug 24 02:15:46 2009 +++ src/sys/arch/x86/acpi/acpi_wakeup.c Wed Sep 2 15:25:07 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_wakeup.c,v 1.16 2009/08/24 02:15:46 jmcneill Exp $ */ +/* $NetBSD: acpi_wakeup.c,v 1.17 2009/09/02 15:25:07 joerg Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.16 2009/08/24 02:15:46 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.17 2009/09/02 15:25:07 joerg Exp $"); /*- * Copyright (c) 2001 Takanori Watanabe @@ -103,6 +103,8 @@ #include #include +#include "opt_vga.h" + #include "acpi_wakecode.h" /* Address is also hard-coded in acpi_wakecode.S */ @@ -463,6 +465,11 @@ if (t < 0 || t > 2) return EINVAL; +#ifndef VGA_POST + if (t == 2) + return EINVAL; +#endif + acpi_md_vbios_reset = t; return 0;