Module Name: src
Committed By: jmcneill
Date: Wed Jan 2 14:54:54 UTC 2019
Modified Files:
src/sys/dev/fdt: cpus.c fdtbus.c fdtvar.h
Log Message:
Do not sort cpu nodes when enumerating so they attach in the order listed
in the devicetree.
To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/fdt/cpus.c
cvs rdiff -u -r1.24 -r1.25 src/sys/dev/fdt/fdtbus.c
cvs rdiff -u -r1.42 -r1.43 src/sys/dev/fdt/fdtvar.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/fdt/cpus.c
diff -u src/sys/dev/fdt/cpus.c:1.4 src/sys/dev/fdt/cpus.c:1.5
--- src/sys/dev/fdt/cpus.c:1.4 Sun Sep 9 21:15:21 2018
+++ src/sys/dev/fdt/cpus.c Wed Jan 2 14:54:54 2019
@@ -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 <[email protected]>
@@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: cpus.c,v 1.4
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 @@ cpus_attach(device_t parent, device_t se
{
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;
Index: src/sys/dev/fdt/fdtbus.c
diff -u src/sys/dev/fdt/fdtbus.c:1.24 src/sys/dev/fdt/fdtbus.c:1.25
--- src/sys/dev/fdt/fdtbus.c:1.24 Sun Sep 23 19:32:03 2018
+++ src/sys/dev/fdt/fdtbus.c Wed Jan 2 14:54:54 2019
@@ -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 <[email protected]>
@@ -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,29 +198,37 @@ void
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_node(node);
- fdt_need_rescan = true;
+ 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;
+
+ /* 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
fdt_scan_submatch(device_t parent, cfdata_t cf, const int *locs, void *aux)
{
Index: src/sys/dev/fdt/fdtvar.h
diff -u src/sys/dev/fdt/fdtvar.h:1.42 src/sys/dev/fdt/fdtvar.h:1.43
--- src/sys/dev/fdt/fdtvar.h:1.42 Sat Sep 15 13:42:41 2018
+++ src/sys/dev/fdt/fdtvar.h Wed Jan 2 14:54:54 2019
@@ -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 <[email protected]>
@@ -362,6 +362,7 @@ const char * fdtbus_get_string_index(int
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 *[]);