Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/fdt Do not sort cpu nodes when enumerating so they a...
details: https://anonhg.NetBSD.org/src/rev/9fc3caff3147
branches: trunk
changeset: 447144:9fc3caff3147
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Wed Jan 02 14:54:54 2019 +0000
description:
Do not sort cpu nodes when enumerating so they attach in the order listed
in the devicetree.
diffstat:
sys/dev/fdt/cpus.c | 15 ++++++++++-----
sys/dev/fdt/fdtbus.c | 40 ++++++++++++++++++++++++----------------
sys/dev/fdt/fdtvar.h | 3 ++-
3 files changed, 36 insertions(+), 22 deletions(-)
diffs (135 lines):
diff -r 7cca2213598d -r 9fc3caff3147 sys/dev/fdt/cpus.c
--- a/sys/dev/fdt/cpus.c Wed Jan 02 14:31:33 2019 +0000
+++ b/sys/dev/fdt/cpus.c Wed Jan 02 14:54:54 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpus.c,v 1.4 2018/09/09 21:15:21 jmcneill Exp $ */
+/* $NetBSD: cpus.c,v 1.5 2019/01/02 14:54:54 jmcneill Exp $ */
/*-
* Copyright (c) 2017 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpus.c,v 1.4 2018/09/09 21:15:21 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpus.c,v 1.5 2019/01/02 14:54:54 jmcneill Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -42,7 +42,7 @@
static int cpus_match(device_t, cfdata_t, void *);
static void cpus_attach(device_t, device_t, void *);
-static bool cpus_bus_match(void *, int);
+static bool cpus_cpu_enabled(int);
CFATTACH_DECL_NEW(cpus, 0, cpus_match, cpus_attach, NULL, NULL);
@@ -59,15 +59,20 @@
{
struct fdt_attach_args * const faa = aux;
const int phandle = faa->faa_phandle;
+ int child;
aprint_naive("\n");
aprint_normal("\n");
- fdt_add_bus_match(self, phandle, faa, cpus_bus_match, NULL);
+ for (child = OF_child(phandle); child; child = OF_peer(child)) {
+ if (!cpus_cpu_enabled(child))
+ continue;
+ fdt_add_child(self, child, faa, 0);
+ }
}
static bool
-cpus_bus_match(void *priv, int child)
+cpus_cpu_enabled(int child)
{
const char *s;
diff -r 7cca2213598d -r 9fc3caff3147 sys/dev/fdt/fdtbus.c
--- a/sys/dev/fdt/fdtbus.c Wed Jan 02 14:31:33 2019 +0000
+++ b/sys/dev/fdt/fdtbus.c Wed Jan 02 14:54:54 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fdtbus.c,v 1.24 2018/09/23 19:32:03 jmcneill Exp $ */
+/* $NetBSD: fdtbus.c,v 1.25 2019/01/02 14:54:54 jmcneill Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fdtbus.c,v 1.24 2018/09/23 19:32:03 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdtbus.c,v 1.25 2019/01/02 14:54:54 jmcneill Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -198,27 +198,35 @@
fdt_add_bus_match(device_t bus, const int phandle, struct fdt_attach_args *faa,
bool (*fn)(void *, int), void *fnarg)
{
- struct fdt_node *node;
int child;
for (child = OF_child(phandle); child; child = OF_peer(child)) {
if (fn && !fn(fnarg, child))
continue;
- /* Add the node to our device list */
- node = kmem_alloc(sizeof(*node), KM_SLEEP);
- node->n_bus = bus;
- node->n_dev = NULL;
- node->n_phandle = child;
- node->n_name = fdtbus_get_string(child, "name");
- node->n_order = fdt_get_order(child);
- node->n_faa = *faa;
- node->n_faa.faa_phandle = child;
- node->n_faa.faa_name = node->n_name;
+ fdt_add_child(bus, child, faa, fdt_get_order(child));
+ }
+}
+
+void
+fdt_add_child(device_t bus, const int child, struct fdt_attach_args *faa,
+ u_int order)
+{
+ struct fdt_node *node;
- fdt_add_node(node);
- fdt_need_rescan = true;
- }
+ /* Add the node to our device list */
+ node = kmem_alloc(sizeof(*node), KM_SLEEP);
+ node->n_bus = bus;
+ node->n_dev = NULL;
+ node->n_phandle = child;
+ node->n_name = fdtbus_get_string(child, "name");
+ node->n_order = order;
+ node->n_faa = *faa;
+ node->n_faa.faa_phandle = child;
+ node->n_faa.faa_name = node->n_name;
+
+ fdt_add_node(node);
+ fdt_need_rescan = true;
}
static int
diff -r 7cca2213598d -r 9fc3caff3147 sys/dev/fdt/fdtvar.h
--- a/sys/dev/fdt/fdtvar.h Wed Jan 02 14:31:33 2019 +0000
+++ b/sys/dev/fdt/fdtvar.h Wed Jan 02 14:54:54 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fdtvar.h,v 1.42 2018/09/15 13:42:41 jakllsch Exp $ */
+/* $NetBSD: fdtvar.h,v 1.43 2019/01/02 14:54:54 jmcneill Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -362,6 +362,7 @@
void fdt_add_bus(device_t, int, struct fdt_attach_args *);
void fdt_add_bus_match(device_t, int, struct fdt_attach_args *,
bool (*)(void *, int), void *);
+void fdt_add_child(device_t, int, struct fdt_attach_args *, u_int);
void fdt_remove_byhandle(int);
void fdt_remove_bycompat(const char *[]);
Home |
Main Index |
Thread Index |
Old Index