Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/acpi XXX: If this is not correct, revert or fix.



details:   https://anonhg.NetBSD.org/src/rev/bbece812de26
branches:  trunk
changeset: 756469:bbece812de26
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Jul 19 00:59:32 2010 +0000

description:
XXX: If this is not correct, revert or fix.
This makes my laptop boot instead of panic:

panic: kernel diagnostic assertion "native_idle != NULL" failed: file "../../../../arch/x86/acpi/acpi_cpu_md.c", line 155
fatal breakpoint trap in supervisor mode
type 1 code 0 rip ffffffff8022e4ad cs 8 rflags 246 cr2  0 cpl 0 rsp ffff80004c37db10

trace
breakpoint() at netbsd:breakpoint+0x5
panic() at netbsd:panic+0x2ba
kern_assert() at netbsd:kern_assert+0x2d
acpicpu_md_idle_stop() at netbsd:acpicpu_md_idle_stop+0x62
acpicpu_cstate_callback() at netbsd:acpicpu_cstate_callback+0x34
sysmon_task_queue_thread() at netbsd:sysmon_task_queue_thread+0x41

1. ACPI seems to define cpuids 1..n; we define 0..n-1. Adjust for that
2. My laptop is dual core, but ACPI reports 4 cpu nodes. Instead of
   attaching the unmatched ones, make the match fail. Do we want to
   attach and do nothing instead?
3. Create a flag, and only set it after we are completely initialized,
   so the sysmon thread does not try to access unitialized state.

diffstat:

 sys/dev/acpi/acpi_cpu.c        |  19 +++++++++++++------
 sys/dev/acpi/acpi_cpu.h        |   3 ++-
 sys/dev/acpi/acpi_cpu_cstate.c |   9 ++++++---
 3 files changed, 21 insertions(+), 10 deletions(-)

diffs (109 lines):

diff -r 67a75af52380 -r bbece812de26 sys/dev/acpi/acpi_cpu.c
--- a/sys/dev/acpi/acpi_cpu.c   Sun Jul 18 22:58:14 2010 +0000
+++ b/sys/dev/acpi/acpi_cpu.c   Mon Jul 19 00:59:32 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_cpu.c,v 1.2 2010/07/18 09:39:45 jruoho Exp $ */
+/* $NetBSD: acpi_cpu.c,v 1.3 2010/07/19 00:59:32 christos Exp $ */
 
 /*-
  * Copyright (c) 2010 Jukka Ruohonen <jruohonen%iki.fi@localhost>
@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_cpu.c,v 1.2 2010/07/18 09:39:45 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_cpu.c,v 1.3 2010/07/19 00:59:32 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/cpu.h>
@@ -77,6 +77,7 @@
 acpicpu_match(device_t parent, cfdata_t match, void *aux)
 {
        struct acpi_attach_args *aa = aux;
+       struct acpicpu_object ao;
 
        if (aa->aa_node->ad_type != ACPI_TYPE_PROCESSOR)
                return 0;
@@ -84,7 +85,10 @@
        if (acpi_match_hid(aa->aa_node->ad_devinfo, acpicpu_hid) != 0)
                return 1;
 
-       return acpicpu_object(aa->aa_node->ad_handle, NULL);
+       int rv = acpicpu_object(aa->aa_node->ad_handle, &ao);
+       if (rv == 0 || acpicpu_id(ao.ao_procid) == 0xFFFFFF)
+               return 0;
+       return 1;
 }
 
 static void
@@ -267,10 +271,10 @@
        CPU_INFO_ITERATOR cii;
        struct cpu_info *ci;
 
+       KASSERT(id != 0);
        for (CPU_INFO_FOREACH(cii, ci)) {
-
-               if (id == ci->ci_cpuid)
-                       return id;
+               if (id - 1 == ci->ci_cpuid)
+                       return id - 1;
        }
 
        return 0xFFFFFF;
@@ -434,6 +438,9 @@
 
        sc = device_private(self);
 
+       if ((sc->sc_flags & ACPICPU_FLAG_INIT) == 0)
+               return;
+
        switch (evt) {
 
        case ACPICPU_C_NOTIFY:
diff -r 67a75af52380 -r bbece812de26 sys/dev/acpi/acpi_cpu.h
--- a/sys/dev/acpi/acpi_cpu.h   Sun Jul 18 22:58:14 2010 +0000
+++ b/sys/dev/acpi/acpi_cpu.h   Mon Jul 19 00:59:32 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_cpu.h,v 1.2 2010/07/18 09:39:45 jruoho Exp $ */
+/* $NetBSD: acpi_cpu.h,v 1.3 2010/07/19 00:59:32 christos Exp $ */
 
 /*-
  * Copyright (c) 2010 Jukka Ruohonen <jruohonen%iki.fi@localhost>
@@ -86,6 +86,7 @@
 #define ACPICPU_FLAG_C_NOC3     __BIT(7)
 #define ACPICPU_FLAG_C_MWAIT    __BIT(8)
 #define ACPICPU_FLAG_C_C1E      __BIT(9)
+#define ACPICPU_FLAG_INIT       __BIT(31)
 
 struct acpicpu_cstate {
        uint64_t                 cs_stat;
diff -r 67a75af52380 -r bbece812de26 sys/dev/acpi/acpi_cpu_cstate.c
--- a/sys/dev/acpi/acpi_cpu_cstate.c    Sun Jul 18 22:58:14 2010 +0000
+++ b/sys/dev/acpi/acpi_cpu_cstate.c    Mon Jul 19 00:59:32 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_cpu_cstate.c,v 1.4 2010/07/18 20:20:04 jruoho Exp $ */
+/* $NetBSD: acpi_cpu_cstate.c,v 1.5 2010/07/19 00:59:32 christos Exp $ */
 
 /*-
  * Copyright (c) 2010 Jukka Ruohonen <jruohonen%iki.fi@localhost>
@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_cstate.c,v 1.4 2010/07/18 20:20:04 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_cstate.c,v 1.5 2010/07/19 00:59:32 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/cpu.h>
@@ -204,7 +204,10 @@
        if (rv != 0)
                return rv;
 
-       return RUN_ONCE(&once_start, acpicpu_md_idle_start);
+       rv = RUN_ONCE(&once_start, acpicpu_md_idle_start);
+       if (rv == 0)
+               sc->sc_flags |= ACPICPU_FLAG_INIT;
+       return rv;
 }
 
 bool



Home | Main Index | Thread Index | Old Index