acpi_cpu: binding processor object to pcpu struct.

Takanori Watanabe takawata at init-main.com
Tue Nov 25 10:33:18 PST 2008


In my box, processor does not binded properly to ACPI object, 
so I wrote the code as follows.
comment?

I'm afraid system pcpu unit number and cpu device instance number
may inconsistent, but without this change, ACPI namespace and 
pcpu struct does not match.

Index: acpi_cpu.c
===================================================================
--- acpi_cpu.c	($B%j%S%8%g%s(B 185289)
+++ acpi_cpu.c	($B:n6H%3%T!<(B)
@@ -241,7 +241,9 @@
      * in their Processor object as the ProcId values in the MADT.
      */
     acpi_id = obj->Processor.ProcId;
+
     AcpiOsFree(obj);
+
     if (acpi_pcpu_get_id(device_get_unit(dev), &acpi_id, &cpu_id) != 0)
 	return (ENXIO);
 
@@ -427,25 +429,35 @@
 
     KASSERT(acpi_id != NULL, ("Null acpi_id"));
     KASSERT(cpu_id != NULL, ("Null cpu_id"));
+
+    /*Check for cpu that have duplicate acpi_id probed.*/
+    for ( i = 0 ; i <= mp_maxid; i++){
+	    if (CPU_ABSENT(i))
+		    continue;
+	    pcpu_data = pcpu_find(i);
+	    if(cpu_softc[i]&& (pcpu_data->pc_acpi_id == *acpi_id)){
+		    return ESRCH;
+	    }
+    }
     for (i = 0; i <= mp_maxid; i++) {
 	if (CPU_ABSENT(i))
 	    continue;
 	pcpu_data = pcpu_find(i);
 	KASSERT(pcpu_data != NULL, ("no pcpu data for %d", i));
-	if (idx-- == 0) {
-	    /*
-	     * If pc_acpi_id was not initialized (e.g., a non-APIC UP box)
-	     * override it with the value from the ASL.  Otherwise, if the
-	     * two don't match, prefer the MADT-derived value.  Finally,
-	     * return the pc_cpuid to reference this processor.
-	     */
-	    if (pcpu_data->pc_acpi_id == 0xffffffff)
+	/*
+	 * If pc_acpi_id was not initialized (e.g., a non-APIC UP box)
+	 * override it with the value from the ASL.  Otherwise, if the
+	 * two don't match, prefer the MADT-derived value.  Finally,
+	 * return the pc_cpuid to reference this processor.
+	 */
+	if (pcpu_data->pc_acpi_id == 0xffffffff)
 		pcpu_data->pc_acpi_id = *acpi_id;
-	    else if (pcpu_data->pc_acpi_id != *acpi_id)
-		*acpi_id = pcpu_data->pc_acpi_id;
-	    *cpu_id = pcpu_data->pc_cpuid;
-	    return (0);
+	else if (pcpu_data->pc_acpi_id == *acpi_id){
+		*cpu_id = pcpu_data->pc_cpuid;
 	}
+	else
+		continue;
+	return 0;
     }
 
     return (ESRCH);


More information about the freebsd-acpi mailing list