[coreboot] New patch to review for coreboot: eb5dc56 AMD northbridges: replace alloc_dev() with alloc_find_dev()

Kyösti Mälkki (kyosti.malkki@gmail.com) gerrit at coreboot.org
Sat Jul 7 21:55:17 CEST 2012


Kyösti Mälkki (kyosti.malkki at gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/1186

-gerrit

commit eb5dc565c3f0604d8f501fb4273687b2b9ce2bd4
Author: Kyösti Mälkki <kyosti.malkki at gmail.com>
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 duplicating
    existing device_path and can be made SMP safe.
    
    Change-Id: I153dc1a5cab4f2eae4ab3a57af02841cb1a261c0
    Signed-off-by: Kyösti Mälkki <kyosti.malkki at gmail.com>
---
 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 3088f54..616a1c1 100644
--- a/src/northbridge/amd/agesa/family10/northbridge.c
+++ b/src/northbridge/amd/agesa/family10/northbridge.c
@@ -1410,21 +1410,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 5b22707..53629ed 100644
--- a/src/northbridge/amd/agesa/family15/northbridge.c
+++ b/src/northbridge/amd/agesa/family15/northbridge.c
@@ -1066,19 +1066,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 d967793..73aebad 100644
--- a/src/northbridge/amd/agesa/family15tn/northbridge.c
+++ b/src/northbridge/amd/agesa/family15tn/northbridge.c
@@ -1050,19 +1050,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 3b20684..8d654bd 100644
--- a/src/northbridge/amd/amdfam10/northbridge.c
+++ b/src/northbridge/amd/amdfam10/northbridge.c
@@ -1403,21 +1403,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 5eeeda2..17ea4f6 100644
--- a/src/northbridge/amd/amdk8/northbridge.c
+++ b/src/northbridge/amd/amdk8/northbridge.c
@@ -1289,21 +1289,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;
 			}
 




More information about the coreboot mailing list