Source-Changes-HG archive

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

[src/trunk]: src/sys/arch sun4v: Update code to retrieve CPU clock frequency ...



details:   https://anonhg.NetBSD.org/src/rev/14b5f84c91ad
branches:  trunk
changeset: 826544:14b5f84c91ad
user:      palle <palle%NetBSD.org@localhost>
date:      Mon Sep 11 19:25:07 2017 +0000

description:
sun4v: Update code to retrieve CPU clock frequency so it can handle (future?) CPU clock frequencies above the 32-bit limit. ok mrg@

diffstat:

 sys/arch/sparc/include/promlib.h    |   3 ++-
 sys/arch/sparc/sparc/promlib.c      |  20 ++++++++++++++++++--
 sys/arch/sparc64/include/autoconf.h |   4 ++--
 sys/arch/sparc64/sparc64/autoconf.c |  10 +++++-----
 sys/arch/sparc64/sparc64/cpu.c      |  10 ++++++----
 5 files changed, 33 insertions(+), 14 deletions(-)

diffs (152 lines):

diff -r 4c0edeb44cc8 -r 14b5f84c91ad sys/arch/sparc/include/promlib.h
--- a/sys/arch/sparc/include/promlib.h  Mon Sep 11 15:24:28 2017 +0000
+++ b/sys/arch/sparc/include/promlib.h  Mon Sep 11 19:25:07 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: promlib.h,v 1.24 2010/01/21 11:40:01 martin Exp $ */
+/*     $NetBSD: promlib.h,v 1.25 2017/09/11 19:25:07 palle Exp $ */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -137,6 +137,7 @@
 /* Utility routines */
 int    prom_getprop(int, const char *, size_t, int *, void *);
 int    prom_getpropint(int, const char *, int);
+uint64_t prom_getpropuint64(int, const char *, uint64_t);
 char   *prom_getpropstring(int, const char *);
 char   *prom_getpropstringA(int, const char *, char *, size_t);
 void   prom_printf(const char *, ...);
diff -r 4c0edeb44cc8 -r 14b5f84c91ad sys/arch/sparc/sparc/promlib.c
--- a/sys/arch/sparc/sparc/promlib.c    Mon Sep 11 15:24:28 2017 +0000
+++ b/sys/arch/sparc/sparc/promlib.c    Mon Sep 11 19:25:07 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: promlib.c,v 1.45 2016/04/01 20:21:45 palle Exp $ */
+/*     $NetBSD: promlib.c,v 1.46 2017/09/11 19:25:07 palle Exp $ */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: promlib.c,v 1.45 2016/04/01 20:21:45 palle Exp $");
+__KERNEL_RCSID(0, "$NetBSD: promlib.c,v 1.46 2017/09/11 19:25:07 palle Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_sparc_arch.h"
@@ -265,6 +265,22 @@
 }
 
 /*
+ * Fetch an unsigned 64-bit integer (or pointer) property.
+ * The return value is the property, or the default if there was none.
+ */
+uint64_t
+prom_getpropuint64(int node, const char *name, uint64_t deflt)
+{
+       uint64_t uint64buf, *uint64p = &uint64buf;
+       int len = 2;
+
+       if (prom_getprop(node, name, sizeof(uint64_t), &len, &uint64p) != 0)
+               return deflt;
+
+       return uint64buf;
+}
+
+/*
  * Node Name Matching per IEEE 1275, section 4.3.6.
  */
 static int
diff -r 4c0edeb44cc8 -r 14b5f84c91ad sys/arch/sparc64/include/autoconf.h
--- a/sys/arch/sparc64/include/autoconf.h       Mon Sep 11 15:24:28 2017 +0000
+++ b/sys/arch/sparc64/include/autoconf.h       Mon Sep 11 19:25:07 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: autoconf.h,v 1.32 2013/10/26 18:47:27 jdc Exp $ */
+/*     $NetBSD: autoconf.h,v 1.33 2017/09/11 19:25:07 palle Exp $ */
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -133,7 +133,7 @@
  * `clockfreq' produces a printable representation of a clock frequency
  * (this is just a frill).
  */
-char   *clockfreq(long);
+char   *clockfreq(uint64_t);
 
 /* Kernel initialization routine. */
 void   bootstrap(void *, void *, void *, void *, void *);
diff -r 4c0edeb44cc8 -r 14b5f84c91ad sys/arch/sparc64/sparc64/autoconf.c
--- a/sys/arch/sparc64/sparc64/autoconf.c       Mon Sep 11 15:24:28 2017 +0000
+++ b/sys/arch/sparc64/sparc64/autoconf.c       Mon Sep 11 19:25:07 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: autoconf.c,v 1.211 2017/03/26 12:59:29 martin Exp $ */
+/*     $NetBSD: autoconf.c,v 1.212 2017/09/11 19:25:07 palle Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.211 2017/03/26 12:59:29 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.212 2017/09/11 19:25:07 palle Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -521,16 +521,16 @@
 }
 
 char *
-clockfreq(long freq)
+clockfreq(uint64_t freq)
 {
        static char buf[10];
        size_t len;
 
        freq /= 1000;
-       len = snprintf(buf, sizeof(buf), "%ld", freq / 1000);
+       len = snprintf(buf, sizeof(buf), "%" PRIu64, freq / 1000);
        freq %= 1000;
        if (freq)
-               snprintf(buf + len, sizeof(buf) - len, ".%03ld", freq);
+               snprintf(buf + len, sizeof(buf) - len, ".%03" PRIu64, freq);
        return buf;
 }
 
diff -r 4c0edeb44cc8 -r 14b5f84c91ad sys/arch/sparc64/sparc64/cpu.c
--- a/sys/arch/sparc64/sparc64/cpu.c    Mon Sep 11 15:24:28 2017 +0000
+++ b/sys/arch/sparc64/sparc64/cpu.c    Mon Sep 11 19:25:07 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu.c,v 1.131 2017/08/27 19:31:43 palle Exp $ */
+/*     $NetBSD: cpu.c,v 1.132 2017/09/11 19:25:07 palle Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -52,7 +52,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.131 2017/08/27 19:31:43 palle Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.132 2017/09/11 19:25:07 palle Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -421,7 +421,7 @@
 cpu_attach(device_t parent, device_t dev, void *aux)
 {
        int node;
-       unsigned int clk, sclk = 0;
+       uint64_t clk, sclk = 0;
        struct mainbus_attach_args *ma = aux;
        struct cpu_info *ci;
        const char *sep;
@@ -465,7 +465,9 @@
                             device_xname(dev), "timer");
        mutex_init(&ci->ci_ctx_lock, MUTEX_SPIN, IPL_VM);
 
-       clk = prom_getpropint(node, "clock-frequency", 0);
+       clk = prom_getpropuint64(node, "clock-frequency64", 0);
+       if (clk == 0)
+         clk = prom_getpropint(node, "clock-frequency", 0);
        if (clk == 0) {
                /*
                 * Try to find it in the OpenPROM root...



Home | Main Index | Thread Index | Old Index