Kyösti Mälkki ([email protected]) just uploaded a new patch set to 
gerrit, which you can find at http://review.coreboot.org/1186

-gerrit

commit 1873e5b7103dbd639cce3f709d0f0d434eed5125
Author: Kyösti Mälkki <[email protected]>
Date:   Fri Jul 6 19:02:56 2012 +0300

    AMD northbridges: replace alloc_dev() with alloc_find_dev()
    
    Use of alloc_find_dev() prevents creation of a device duplicates
    for device_path and is SMP safe.
    
    Change-Id: I153dc1a5cab4f2eae4ab3a57af02841cb1a261c0
    Signed-off-by: Kyösti Mälkki <[email protected]>
---
 src/northbridge/amd/agesa/family10/northbridge.c   |   21 ++++++-------------
 src/northbridge/amd/agesa/family15/northbridge.c   |   19 ++++++-----------
 src/northbridge/amd/agesa/family15tn/northbridge.c |   19 ++++++-----------
 src/northbridge/amd/amdfam10/northbridge.c         |   21 ++++++-------------
 src/northbridge/amd/amdk8/northbridge.c            |   21 ++++++-------------
 5 files changed, 35 insertions(+), 66 deletions(-)

diff --git a/src/northbridge/amd/agesa/family10/northbridge.c 
b/src/northbridge/amd/agesa/family10/northbridge.c
index 8cc9475..330c545 100644
--- a/src/northbridge/amd/agesa/family10/northbridge.c
+++ b/src/northbridge/amd/agesa/family10/northbridge.c
@@ -1393,21 +1393,14 @@ static u32 cpu_bus_scan(device_t dev, u32 max)
                        }
                        cpu_path.apic.apic_id = (lapicid_start * (i/modules + 
1)) + ((i % modules) ? (j + (cores_found + 1)) : j);
 
-                       /* See if I can find the cpu */
-                       cpu = find_dev_path(cpu_bus, &cpu_path);
-
-                       /* Enable the cpu if I have the processor */
                        if (cdb_dev && cdb_dev->enabled) {
-                               if (!cpu) {
-                                       cpu = alloc_dev(cpu_bus, &cpu_path);
-                               }
-                               if (cpu) {
-                                       cpu->enabled = 1;
-                               }
-                       }
-
-                       /* Disable the cpu if I don't have the processor */
-                       if (cpu && (!cdb_dev || !cdb_dev->enabled)) {
+                               /* Enable the cpu if I have the processor */
+                               cpu = alloc_find_dev(cpu_bus, &cpu_path);
+                       } else {
+                               /* Disable the cpu if I don't have the 
processor */
+                               cpu = find_dev_path(cpu_bus, &cpu_path);
+                               if (!cpu)
+                                       continue;
                                cpu->enabled = 0;
                        }
 
diff --git a/src/northbridge/amd/agesa/family15/northbridge.c 
b/src/northbridge/amd/agesa/family15/northbridge.c
index d9a153b..a690e9c 100644
--- a/src/northbridge/amd/agesa/family15/northbridge.c
+++ b/src/northbridge/amd/agesa/family15/northbridge.c
@@ -1092,19 +1092,14 @@ static u32 cpu_bus_scan(device_t dev, u32 max)
                        printk(BIOS_SPEW, "node 0x%x core 0x%x apicid=0x%x\n",
                                        i, j, cpu_path.apic.apic_id);
 
-                       /* See if I can find the cpu */
-                       cpu = find_dev_path(cpu_bus, &cpu_path);
-                       /* Enable the cpu if I have the processor */
                        if (cdb_dev && cdb_dev->enabled) {
-                               if (!cpu) {
-                                       cpu = alloc_dev(cpu_bus, &cpu_path);
-                               }
-                               if (cpu) {
-                                       cpu->enabled = 1;
-                               }
-                       }
-                       /* Disable the cpu if I don't have the processor */
-                       if (cpu && (!cdb_dev || !cdb_dev->enabled)) {
+                               /* Enable the cpu if I have the processor */
+                               cpu = alloc_find_dev(cpu_bus, &cpu_path);
+                       } else {
+                               /* Disable the cpu if I don't have the 
processor */
+                               cpu = find_dev_path(cpu_bus, &cpu_path);
+                               if (!cpu)
+                                       continue;
                                cpu->enabled = 0;
                        }
                        /* Report what I have done */
diff --git a/src/northbridge/amd/agesa/family15tn/northbridge.c 
b/src/northbridge/amd/agesa/family15tn/northbridge.c
index c63890d..44d2f05 100644
--- a/src/northbridge/amd/agesa/family15tn/northbridge.c
+++ b/src/northbridge/amd/agesa/family15tn/northbridge.c
@@ -1099,19 +1099,14 @@ static u32 cpu_bus_scan(device_t dev, u32 max)
                        printk(BIOS_SPEW, "node 0x%x core 0x%x apicid=0x%x\n",
                                        i, j, cpu_path.apic.apic_id);
 
-                       /* See if I can find the cpu */
-                       cpu = find_dev_path(cpu_bus, &cpu_path);
-                       /* Enable the cpu if I have the processor */
                        if (cdb_dev && cdb_dev->enabled) {
-                               if (!cpu) {
-                                       cpu = alloc_dev(cpu_bus, &cpu_path);
-                               }
-                               if (cpu) {
-                                       cpu->enabled = 1;
-                               }
-                       }
-                       /* Disable the cpu if I don't have the processor */
-                       if (cpu && (!cdb_dev || !cdb_dev->enabled)) {
+                               /* Enable the cpu if I have the processor */
+                               cpu = alloc_find_dev(cpu_bus, &cpu_path);
+                       } else {
+                               /* Disable the cpu if I don't have the 
processor */
+                               cpu = find_dev_path(cpu_bus, &cpu_path);
+                               if (!cpu)
+                                       continue;
                                cpu->enabled = 0;
                        }
                        /* Report what I have done */
diff --git a/src/northbridge/amd/amdfam10/northbridge.c 
b/src/northbridge/amd/amdfam10/northbridge.c
index aa15fdd..febaa37 100644
--- a/src/northbridge/amd/amdfam10/northbridge.c
+++ b/src/northbridge/amd/amdfam10/northbridge.c
@@ -1425,21 +1425,14 @@ static u32 cpu_bus_scan(device_t dev, u32 max)
                        cpu_path.type = DEVICE_PATH_APIC;
                        cpu_path.apic.apic_id = i * (nb_cfg_54?(siblings+1):1) 
+ j * (nb_cfg_54?1:64); // ?
 
-                       /* See if I can find the cpu */
-                       cpu = find_dev_path(cpu_bus, &cpu_path);
-
-                       /* Enable the cpu if I have the processor */
                        if (cdb_dev && cdb_dev->enabled) {
-                               if (!cpu) {
-                                       cpu = alloc_dev(cpu_bus, &cpu_path);
-                               }
-                               if (cpu) {
-                                       cpu->enabled = 1;
-                               }
-                       }
-
-                       /* Disable the cpu if I don't have the processor */
-                       if (cpu && (!cdb_dev || !cdb_dev->enabled)) {
+                               /* Enable the cpu if I have the processor */
+                               cpu = alloc_find_dev(cpu_bus, &cpu_path);
+                       } else {
+                               /* Disable the cpu if I don't have the 
processor */
+                               cpu = find_dev_path(cpu_bus, &cpu_path);
+                               if (!cpu)
+                                       continue;
                                cpu->enabled = 0;
                        }
 
diff --git a/src/northbridge/amd/amdk8/northbridge.c 
b/src/northbridge/amd/amdk8/northbridge.c
index bec02f0..3c69042 100644
--- a/src/northbridge/amd/amdk8/northbridge.c
+++ b/src/northbridge/amd/amdk8/northbridge.c
@@ -1327,21 +1327,14 @@ static u32 cpu_bus_scan(device_t dev, u32 max)
                        cpu_path.type = DEVICE_PATH_APIC;
                        cpu_path.apic.apic_id = i * (nb_cfg_54?(siblings+1):1) 
+ j * (nb_cfg_54?1:8);
 
-                       /* See if I can find the cpu */
-                       cpu = find_dev_path(cpu_bus, &cpu_path);
-
-                       /* Enable the cpu if I have the processor */
                        if (cpu_dev && cpu_dev->enabled) {
-                               if (!cpu) {
-                                       cpu = alloc_dev(cpu_bus, &cpu_path);
-                               }
-                               if (cpu) {
-                                       cpu->enabled = 1;
-                               }
-                       }
-
-                       /* Disable the cpu if I don't have the processor */
-                       if (cpu && (!cpu_dev || !cpu_dev->enabled)) {
+                               /* Enable the cpu if I have the processor */
+                               cpu = alloc_find_dev(cpu_bus, &cpu_path);
+                       } else {
+                               /* Disable the cpu if I don't have the 
processor */
+                               cpu = find_dev_path(cpu_bus, &cpu_path);
+                               if (!cpu)
+                                       continue;
                                cpu->enabled = 0;
                        }
 

-- 
coreboot mailing list: [email protected]
http://www.coreboot.org/mailman/listinfo/coreboot

Reply via email to