Source-Changes-D archive

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

Re: CVS commit: src/sys/dev/acpi



On Sun, Jul 18, 2010 at 08:59:33PM -0400, Christos Zoulas wrote:
> 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.

Can you (and others who might have the same problem) test the attached diff?

There might be a more elegant way to do this, but including the MADT ID in
<x86/cpu.h> is probably the least invasive one.  There is still the case
where the MADT IDs and ACPI processor object IDs do not match, and the case
where a BIOS writer was unable to enumerate numbers in ascending order.

- Jukka.


Index: include/cpu.h
===================================================================
RCS file: /cvsroot/src/sys/arch/x86/include/cpu.h,v
retrieving revision 1.23
diff -u -p -r1.23 cpu.h
--- include/cpu.h       24 Jul 2010 00:45:56 -0000      1.23
+++ include/cpu.h       30 Jul 2010 07:06:50 -0000
@@ -95,6 +95,7 @@ struct cpu_info {
        int     ci_fpused;              /* XEN: FPU was used by curlwp */
        cpuid_t ci_cpuid;               /* our CPU ID */
        int     ci_cpumask;             /* (1 << CPU ID) */
+       uint32_t ci_acpiid;             /* our ACPI/MADT ID */
        uint32_t ci_initapicid;         /* our intitial APIC ID */
        struct cpu_data ci_data;        /* MI per-cpu data */
 
Index: include/cpuvar.h
===================================================================
RCS file: /cvsroot/src/sys/arch/x86/include/cpuvar.h,v
retrieving revision 1.33
diff -u -p -r1.33 cpuvar.h
--- include/cpuvar.h    6 Jul 2010 20:50:35 -0000       1.33
+++ include/cpuvar.h    30 Jul 2010 07:06:50 -0000
@@ -79,6 +79,7 @@ extern const struct cpu_functions mp_cpu
 #define CPU_ROLE_AP    2
 
 struct cpu_attach_args {
+       int cpu_id;
        int cpu_number;
        int cpu_role;
        const struct cpu_functions *cpu_func;
Index: x86/cpu.c
===================================================================
RCS file: /cvsroot/src/sys/arch/x86/x86/cpu.c,v
retrieving revision 1.73
diff -u -p -r1.73 cpu.c
--- x86/cpu.c   24 Jul 2010 00:45:56 -0000      1.73
+++ x86/cpu.c   30 Jul 2010 07:06:50 -0000
@@ -330,6 +330,7 @@ cpu_attach(device_t parent, device_t sel
        ci->ci_self = ci;
        sc->sc_info = ci;
        ci->ci_dev = self;
+       ci->ci_acpiid = caa->cpu_id;
        ci->ci_cpuid = caa->cpu_number;
        ci->ci_func = caa->cpu_func;
 
Index: x86/mpacpi.c
===================================================================
RCS file: /cvsroot/src/sys/arch/x86/x86/mpacpi.c,v
retrieving revision 1.87
diff -u -p -r1.87 mpacpi.c
--- x86/mpacpi.c        27 Apr 2010 05:34:14 -0000      1.87
+++ x86/mpacpi.c        30 Jul 2010 07:06:51 -0000
@@ -383,6 +383,7 @@ mpacpi_config_cpu(ACPI_SUBTABLE_HEADER *
                                caa.cpu_role = CPU_ROLE_AP;
                        else
                                caa.cpu_role = CPU_ROLE_BP;
+                       caa.cpu_id = lapic->ProcessorId;
                        caa.cpu_number = lapic->Id;
                        caa.cpu_func = &mp_cpu_funcs;
                        locs[CPUBUSCF_APID] = caa.cpu_number;
@@ -409,6 +410,7 @@ mpacpi_config_cpu(ACPI_SUBTABLE_HEADER *
                                caa.cpu_role = CPU_ROLE_AP;
                        else
                                caa.cpu_role = CPU_ROLE_BP;
+                       caa.cpu_id = x2apic->Uid;
                        caa.cpu_number = x2apic->LocalApicId;
                        caa.cpu_func = &mp_cpu_funcs;
                        locs[CPUBUSCF_APID] = caa.cpu_number;
Index: x86/mpbios.c
===================================================================
RCS file: /cvsroot/src/sys/arch/x86/x86/mpbios.c,v
retrieving revision 1.57
diff -u -p -r1.57 mpbios.c
--- x86/mpbios.c        18 Apr 2010 23:47:51 -0000      1.57
+++ x86/mpbios.c        30 Jul 2010 07:06:51 -0000
@@ -717,6 +717,7 @@ mpbios_cpu(const uint8_t *ent, device_t 
        else
                caa.cpu_role = CPU_ROLE_AP;
 
+       caa.cpu_id = entry->apic_id;
        caa.cpu_number = entry->apic_id;
        caa.cpu_func = &mp_cpu_funcs;
        locs[CPUBUSCF_APID] = caa.cpu_number;
Index: acpi_cpu.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpi_cpu.c,v
retrieving revision 1.10
diff -u -p -r1.10 acpi_cpu.c
--- acpi_cpu.c  30 Jul 2010 06:11:14 -0000      1.10
+++ acpi_cpu.c  30 Jul 2010 07:08:02 -0000
@@ -270,8 +270,12 @@ acpicpu_id(uint32_t id)
 
        for (CPU_INFO_FOREACH(cii, ci)) {
 
-               if (id == ci->ci_cpuid)
+               if (id == ci->ci_acpiid) {
+                       printf("ACPI CPU: "
+                           "ACPI ID %u, MADT ID %u, LAPIC ID %u\n",
+                           id, ci->ci_acpiid, (uint32_t)ci->ci_cpuid);
                        return id;
+               }
        }
 
        return 0xFFFFFF;


Home | Main Index | Thread Index | Old Index