Module Name: src Committed By: martin Date: Thu Jan 9 16:23:42 UTC 2020
Modified Files: src/sys/arch/aarch64/aarch64: cpu.c src/sys/arch/arm/arm32: cpu.c src/sys/dev/fdt: fdtbus.c Log Message: 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.31 -r1.32 src/sys/arch/aarch64/aarch64/cpu.c cvs rdiff -u -r1.137 -r1.138 src/sys/arch/arm/arm32/cpu.c cvs rdiff -u -r1.30 -r1.31 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.31 src/sys/arch/aarch64/aarch64/cpu.c:1.32 --- src/sys/arch/aarch64/aarch64/cpu.c:1.31 Sat Dec 28 19:18:31 2019 +++ src/sys/arch/aarch64/aarch64/cpu.c Thu Jan 9 16:23:41 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.c,v 1.31 2019/12/28 19:18:31 jmcneill Exp $ */ +/* $NetBSD: cpu.c,v 1.32 2020/01/09 16:23:41 martin Exp $ */ /* * Copyright (c) 2017 Ryo Shimizu <r...@nerv.org> @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.31 2019/12/28 19:18:31 jmcneill Exp $"); +__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.32 2020/01/09 16:23:41 martin Exp $"); #include "locators.h" #include "opt_arm_debug.h" @@ -225,10 +225,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.137 src/sys/arch/arm/arm32/cpu.c:1.138 --- src/sys/arch/arm/arm32/cpu.c:1.137 Wed Jan 8 18:47:43 2020 +++ src/sys/arch/arm/arm32/cpu.c Thu Jan 9 16:23:42 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.c,v 1.137 2020/01/08 18:47:43 jmcneill Exp $ */ +/* $NetBSD: cpu.c,v 1.138 2020/01/09 16:23:42 martin 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.137 2020/01/08 18:47:43 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.138 2020/01/09 16:23:42 martin Exp $"); #include <sys/param.h> #include <sys/conf.h> @@ -679,6 +679,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"); @@ -688,7 +689,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.30 src/sys/dev/fdt/fdtbus.c:1.31 --- src/sys/dev/fdt/fdtbus.c:1.30 Tue Oct 1 23:32:52 2019 +++ src/sys/dev/fdt/fdtbus.c Thu Jan 9 16:23:41 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: fdtbus.c,v 1.30 2019/10/01 23:32:52 jmcneill Exp $ */ +/* $NetBSD: fdtbus.c,v 1.31 2020/01/09 16:23:41 martin Exp $ */ /*- * Copyright (c) 2015 Jared D. McNeill <jmcne...@invisible.ca> @@ -27,12 +27,13 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: fdtbus.c,v 1.30 2019/10/01 23:32:52 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fdtbus.c,v 1.31 2020/01/09 16:23:41 martin 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); }