dpaa: Simplify CPU binding for bman and qman
If cpu-handle property doesn't exist simply iterate and assign the CPUs in sequence rather than following the convoluted search which may not bear fruit in some cases. If cpu-handle doesn't exist for one portal it probably doesn't exist for any of them.
This commit is contained in:
+9
-30
@@ -136,25 +136,6 @@ bman_portals_fdt_probe(device_t dev)
|
||||
return (BUS_PROBE_DEFAULT);
|
||||
}
|
||||
|
||||
static phandle_t
|
||||
bman_portal_find_cpu(int cpu)
|
||||
{
|
||||
phandle_t node;
|
||||
pcell_t reg;
|
||||
|
||||
node = OF_finddevice("/cpus");
|
||||
if (node == -1)
|
||||
return (node);
|
||||
|
||||
for (node = OF_child(node); node != 0; node = OF_peer(node)) {
|
||||
if (OF_getprop(node, "reg", ®, sizeof(reg)) <= 0)
|
||||
continue;
|
||||
if (reg == cpu)
|
||||
return (node);
|
||||
}
|
||||
return (-1);
|
||||
}
|
||||
|
||||
static int
|
||||
bman_portals_fdt_attach(device_t dev)
|
||||
{
|
||||
@@ -185,17 +166,15 @@ bman_portals_fdt_attach(device_t dev)
|
||||
}
|
||||
/* Checkout related cpu */
|
||||
if (OF_getprop(child, "cpu-handle", (void *)&cpu,
|
||||
sizeof(cpu)) <= 0) {
|
||||
cpu = bman_portal_find_cpu(cpus);
|
||||
if (cpu <= 0)
|
||||
continue;
|
||||
}
|
||||
/* Acquire cpu number */
|
||||
cpu_node = OF_instance_to_package(cpu);
|
||||
if (OF_getencprop(cpu_node, "reg", &cpu_num, sizeof(cpu_num)) <= 0) {
|
||||
device_printf(dev, "Could not retrieve CPU number.\n");
|
||||
return (ENXIO);
|
||||
}
|
||||
sizeof(cpu)) > 0) {
|
||||
cpu_node = OF_instance_to_package(cpu);
|
||||
/* Acquire cpu number */
|
||||
if (OF_getencprop(cpu_node, "reg", &cpu_num, sizeof(cpu_num)) <= 0) {
|
||||
device_printf(dev, "Could not retrieve CPU number.\n");
|
||||
return (ENXIO);
|
||||
}
|
||||
} else
|
||||
cpu_num = cpus;
|
||||
|
||||
cpus++;
|
||||
|
||||
|
||||
+9
-31
@@ -136,25 +136,6 @@ qman_portals_fdt_probe(device_t dev)
|
||||
return (BUS_PROBE_DEFAULT);
|
||||
}
|
||||
|
||||
static phandle_t
|
||||
qman_portal_find_cpu(int cpu)
|
||||
{
|
||||
phandle_t node;
|
||||
pcell_t reg;
|
||||
|
||||
node = OF_finddevice("/cpus");
|
||||
if (node == -1)
|
||||
return (-1);
|
||||
|
||||
for (node = OF_child(node); node != 0; node = OF_peer(node)) {
|
||||
if (OF_getprop(node, "reg", ®, sizeof(reg)) <= 0)
|
||||
continue;
|
||||
if (reg == cpu)
|
||||
return (node);
|
||||
}
|
||||
return (-1);
|
||||
}
|
||||
|
||||
static int
|
||||
qman_portals_fdt_attach(device_t dev)
|
||||
{
|
||||
@@ -213,18 +194,15 @@ qman_portals_fdt_attach(device_t dev)
|
||||
}
|
||||
/* Checkout related cpu */
|
||||
if (OF_getprop(child, "cpu-handle", (void *)&cpu,
|
||||
sizeof(cpu)) <= 0) {
|
||||
cpu = qman_portal_find_cpu(cpus);
|
||||
if (cpu <= 0)
|
||||
continue;
|
||||
}
|
||||
/* Acquire cpu number */
|
||||
cpu_node = OF_instance_to_package(cpu);
|
||||
if (OF_getencprop(cpu_node, "reg", &cpu_num, sizeof(cpu_num)) <= 0) {
|
||||
device_printf(dev, "Could not retrieve CPU number.\n");
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
sizeof(cpu)) > 0) {
|
||||
cpu_node = OF_instance_to_package(cpu);
|
||||
/* Acquire cpu number */
|
||||
if (OF_getencprop(cpu_node, "reg", &cpu_num, sizeof(cpu_num)) <= 0) {
|
||||
device_printf(dev, "Could not retrieve CPU number.\n");
|
||||
return (ENXIO);
|
||||
}
|
||||
} else
|
||||
cpu_num = cpus;
|
||||
cpus++;
|
||||
|
||||
if (ofw_bus_gen_setup_devinfo(&ofw_di, child) != 0) {
|
||||
|
||||
Reference in New Issue
Block a user