aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Hibbits <jhibbits@FreeBSD.org>2026-01-21 04:16:04 +0000
committerJustin Hibbits <jhibbits@FreeBSD.org>2026-01-21 04:28:40 +0000
commitc611ef5747a5d2ceb094331d3dd74d5c8b523b9c (patch)
tree65864e71c2612074d5d3ecb3f71e5522afc9110c
parent12444a4da514e91fdf984b31e1691d042d5f88d2 (diff)
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.
-rw-r--r--sys/dev/dpaa/bman_fdt.c39
-rw-r--r--sys/dev/dpaa/qman_fdt.c40
2 files changed, 18 insertions, 61 deletions
diff --git a/sys/dev/dpaa/bman_fdt.c b/sys/dev/dpaa/bman_fdt.c
index dffec52d5248..34b29ad6e236 100644
--- a/sys/dev/dpaa/bman_fdt.c
+++ b/sys/dev/dpaa/bman_fdt.c
@@ -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", &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++;
diff --git a/sys/dev/dpaa/qman_fdt.c b/sys/dev/dpaa/qman_fdt.c
index 3f22ea4d651a..35016073ba0e 100644
--- a/sys/dev/dpaa/qman_fdt.c
+++ b/sys/dev/dpaa/qman_fdt.c
@@ -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", &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) {