Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys When attaching the first fdtbus, use the root "comptabil...



details:   https://anonhg.NetBSD.org/src/rev/b877192ae8fe
branches:  trunk
changeset: 467015:b877192ae8fe
user:      martin <martin%NetBSD.org@localhost>
date:      Thu Jan 09 16:23:41 2020 +0000

description:
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.

diffstat:

 sys/arch/aarch64/aarch64/cpu.c |  12 ++++++++----
 sys/arch/arm/arm32/cpu.c       |   9 ++++++---
 sys/dev/fdt/fdtbus.c           |  14 +++++++++++---
 3 files changed, 25 insertions(+), 10 deletions(-)

diffs (119 lines):

diff -r ed89e444f5db -r b877192ae8fe sys/arch/aarch64/aarch64/cpu.c
--- a/sys/arch/aarch64/aarch64/cpu.c    Thu Jan 09 16:20:12 2020 +0000
+++ b/sys/arch/aarch64/aarch64/cpu.c    Thu Jan 09 16:23:41 2020 +0000
@@ -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 <ryo%nerv.org@localhost>
@@ -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 @@
 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);
diff -r ed89e444f5db -r b877192ae8fe sys/arch/arm/arm32/cpu.c
--- a/sys/arch/arm/arm32/cpu.c  Thu Jan 09 16:20:12 2020 +0000
+++ b/sys/arch/arm/arm32/cpu.c  Thu Jan 09 16:23:41 2020 +0000
@@ -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 @@
        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 @@
        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) {
diff -r ed89e444f5db -r b877192ae8fe sys/dev/fdt/fdtbus.c
--- a/sys/dev/fdt/fdtbus.c      Thu Jan 09 16:20:12 2020 +0000
+++ b/sys/dev/fdt/fdtbus.c      Thu Jan 09 16:23:41 2020 +0000
@@ -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 <jmcneill%invisible.ca@localhost>
@@ -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 @@
        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 @@
        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);
 }



Home | Main Index | Thread Index | Old Index