Module Name: src
Committed By: snj
Date: Thu Jan 9 17:16:47 UTC 2020
Modified Files:
src/sys/arch/aarch64/aarch64 [netbsd-9]: cpu.c
src/sys/arch/arm/arm32 [netbsd-9]: cpu.c
src/sys/dev/fdt [netbsd-9]: fdtbus.c
Log Message:
Pull up following revision(s) (requested by martin in ticket #614):
sys/arch/aarch64/aarch64/cpu.c: 1.32
sys/arch/arm/arm32/cpu.c: 1.138
sys/dev/fdt/fdtbus.c: 1.31
When attaching the first fdtbus, use the root "comptabile" (or failing that:
"model") property to set the cpu model (in userland aka sysctl hw.model).
When attaching the first cpu, do not overwrite a cpu model if it already
had been set.
To generate a diff of this commit:
cvs rdiff -u -r1.20.2.2 -r1.20.2.3 src/sys/arch/aarch64/aarch64/cpu.c
cvs rdiff -u -r1.129.4.1 -r1.129.4.2 src/sys/arch/arm/arm32/cpu.c
cvs rdiff -u -r1.29.2.1 -r1.29.2.2 src/sys/dev/fdt/fdtbus.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/aarch64/aarch64/cpu.c
diff -u src/sys/arch/aarch64/aarch64/cpu.c:1.20.2.2 src/sys/arch/aarch64/aarch64/cpu.c:1.20.2.3
--- src/sys/arch/aarch64/aarch64/cpu.c:1.20.2.2 Sun Dec 29 09:40:59 2019
+++ src/sys/arch/aarch64/aarch64/cpu.c Thu Jan 9 17:16:47 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.20.2.2 2019/12/29 09:40:59 martin Exp $ */
+/* $NetBSD: cpu.c,v 1.20.2.3 2020/01/09 17:16:47 snj Exp $ */
/*
* Copyright (c) 2017 Ryo Shimizu <[email protected]>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.20.2.2 2019/12/29 09:40:59 martin Exp $");
+__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.20.2.3 2020/01/09 17:16:47 snj Exp $");
#include "locators.h"
#include "opt_arm_debug.h"
@@ -231,10 +231,14 @@ static void
cpu_identify(device_t self, struct cpu_info *ci)
{
char model[128];
+ const char *m;
identify_aarch64_model(ci->ci_id.ac_midr, model, sizeof(model));
- if (ci->ci_index == 0)
- cpu_setmodel("%s", model);
+ if (ci->ci_index == 0) {
+ m = cpu_getmodel();
+ if (m == NULL || *m == 0)
+ cpu_setmodel("%s", model);
+ }
aprint_naive("\n");
aprint_normal(": %s\n", model);
Index: src/sys/arch/arm/arm32/cpu.c
diff -u src/sys/arch/arm/arm32/cpu.c:1.129.4.1 src/sys/arch/arm/arm32/cpu.c:1.129.4.2
--- src/sys/arch/arm/arm32/cpu.c:1.129.4.1 Wed Oct 23 19:14:19 2019
+++ src/sys/arch/arm/arm32/cpu.c Thu Jan 9 17:16:47 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.129.4.1 2019/10/23 19:14:19 martin Exp $ */
+/* $NetBSD: cpu.c,v 1.129.4.2 2020/01/09 17:16:47 snj Exp $ */
/*
* Copyright (c) 1995 Mark Brinicombe.
@@ -46,7 +46,7 @@
#include "opt_multiprocessor.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.129.4.1 2019/10/23 19:14:19 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.129.4.2 2020/01/09 17:16:47 snj Exp $");
#include <sys/param.h>
#include <sys/conf.h>
@@ -672,6 +672,7 @@ identify_arm_cpu(device_t dv, struct cpu
const uint32_t arm_cpuid = ci->ci_arm_cpuid;
const char * const xname = device_xname(dv);
char model[128];
+ const char *m;
if (arm_cpuid == 0) {
aprint_error("Processor failed probe - no CPU ID\n");
@@ -681,7 +682,9 @@ identify_arm_cpu(device_t dv, struct cpu
const enum cpu_class cpu_class = identify_arm_model(arm_cpuid,
model, sizeof(model));
if (ci->ci_cpuid == 0) {
- cpu_setmodel("%s", model);
+ m = cpu_getmodel();
+ if (m == NULL || *m == 0)
+ cpu_setmodel("%s", model);
}
if (ci->ci_data.cpu_cc_freq != 0) {
Index: src/sys/dev/fdt/fdtbus.c
diff -u src/sys/dev/fdt/fdtbus.c:1.29.2.1 src/sys/dev/fdt/fdtbus.c:1.29.2.2
--- src/sys/dev/fdt/fdtbus.c:1.29.2.1 Thu Oct 3 17:23:11 2019
+++ src/sys/dev/fdt/fdtbus.c Thu Jan 9 17:16:47 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: fdtbus.c,v 1.29.2.1 2019/10/03 17:23:11 martin Exp $ */
+/* $NetBSD: fdtbus.c,v 1.29.2.2 2020/01/09 17:16:47 snj Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <[email protected]>
@@ -27,12 +27,13 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fdtbus.c,v 1.29.2.1 2019/10/03 17:23:11 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdtbus.c,v 1.29.2.2 2020/01/09 17:16:47 snj Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <sys/kmem.h>
+#include <sys/cpu.h>
#include <sys/bus.h>
@@ -120,7 +121,7 @@ fdt_attach(device_t parent, device_t sel
struct fdt_softc *sc = device_private(self);
const struct fdt_attach_args *faa = aux;
const int phandle = faa->faa_phandle;
- const char *descr;
+ const char *descr, *model;
sc->sc_dev = self;
sc->sc_phandle = phandle;
@@ -141,6 +142,13 @@ fdt_attach(device_t parent, device_t sel
if (OF_finddevice("/") != faa->faa_phandle)
return;
+ /* Set hw.model if available */
+ model = fdtbus_get_string(phandle, "compatible");
+ if (model)
+ cpu_setmodel(model);
+ else if (descr)
+ cpu_setmodel(descr);
+
/* Scan devices */
fdt_rescan(self, NULL, NULL);
}