Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/alpha On LCA45 systems, look at the memory controll...



details:   https://anonhg.NetBSD.org/src/rev/b8e6477b6848
branches:  trunk
changeset: 1022414:b8e6477b6848
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Fri Jul 16 18:50:19 2021 +0000

description:
On LCA45 systems, look at the memory controller's Bcache configuration
to initialize uvmexp.ncolors rather than hard-coding a value per model
(some models can have more than one configuration).

diffstat:

 sys/arch/alpha/alpha/dec_alphabook1.c |   6 ++-
 sys/arch/alpha/alpha/dec_axppci_33.c  |  14 ++--------
 sys/arch/alpha/alpha/dec_eb66.c       |  11 ++-----
 sys/arch/alpha/pci/lca.c              |  47 +++++++++++++++++++++++++++++++++-
 sys/arch/alpha/pci/lcavar.h           |   4 ++-
 5 files changed, 58 insertions(+), 24 deletions(-)

diffs (221 lines):

diff -r d30a8fe1256c -r b8e6477b6848 sys/arch/alpha/alpha/dec_alphabook1.c
--- a/sys/arch/alpha/alpha/dec_alphabook1.c     Fri Jul 16 17:09:33 2021 +0000
+++ b/sys/arch/alpha/alpha/dec_alphabook1.c     Fri Jul 16 18:50:19 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dec_alphabook1.c,v 1.27 2012/10/13 17:58:54 jdc Exp $ */
+/* $NetBSD: dec_alphabook1.c,v 1.28 2021/07/16 18:50:19 thorpej Exp $ */
 
 /*
  * Copyright (c) 1995, 1996, 1997 Carnegie-Mellon University.
@@ -34,7 +34,7 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: dec_alphabook1.c,v 1.27 2012/10/13 17:58:54 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dec_alphabook1.c,v 1.28 2021/07/16 18:50:19 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -107,6 +107,8 @@
        platform.iobus = "lca";
        platform.cons_init = dec_alphabook1_cons_init;
        platform.device_register = dec_alphabook1_device_register;
+
+       lca_probe_bcache();
 }
 
 static void
diff -r d30a8fe1256c -r b8e6477b6848 sys/arch/alpha/alpha/dec_axppci_33.c
--- a/sys/arch/alpha/alpha/dec_axppci_33.c      Fri Jul 16 17:09:33 2021 +0000
+++ b/sys/arch/alpha/alpha/dec_axppci_33.c      Fri Jul 16 18:50:19 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dec_axppci_33.c,v 1.67 2012/10/13 17:58:54 jdc Exp $ */
+/* $NetBSD: dec_axppci_33.c,v 1.68 2021/07/16 18:50:19 thorpej Exp $ */
 
 /*
  * Copyright (c) 1995, 1996, 1997 Carnegie-Mellon University.
@@ -34,7 +34,7 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: dec_axppci_33.c,v 1.67 2012/10/13 17:58:54 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dec_axppci_33.c,v 1.68 2021/07/16 18:50:19 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -43,8 +43,6 @@
 #include <sys/conf.h>
 #include <dev/cons.h>
 
-#include <uvm/uvm_extern.h>
-
 #include <machine/rpb.h>
 #include <machine/alpha.h>
 #include <machine/autoconf.h>
@@ -156,13 +154,7 @@
 
        /* Leave nsio mapped to catch any accidental port space collisions  */
 
-       /*
-        * AXPpci33 systems have either 0, 256K, or 1M secondary
-        * caches.  Default to middle-of-the-road.
-        *
-        * XXX Dynamically size it!
-        */
-       uvmexp.ncolors = atop(256 * 1024);
+       lca_probe_bcache();
 }
 
 static void
diff -r d30a8fe1256c -r b8e6477b6848 sys/arch/alpha/alpha/dec_eb66.c
--- a/sys/arch/alpha/alpha/dec_eb66.c   Fri Jul 16 17:09:33 2021 +0000
+++ b/sys/arch/alpha/alpha/dec_eb66.c   Fri Jul 16 18:50:19 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dec_eb66.c,v 1.28 2012/10/13 17:58:54 jdc Exp $ */
+/* $NetBSD: dec_eb66.c,v 1.29 2021/07/16 18:50:19 thorpej Exp $ */
 
 /*
  * Copyright (c) 1995, 1996, 1997 Carnegie-Mellon University.
@@ -34,7 +34,7 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: dec_eb66.c,v 1.28 2012/10/13 17:58:54 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dec_eb66.c,v 1.29 2021/07/16 18:50:19 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -43,8 +43,6 @@
 #include <sys/conf.h>
 #include <dev/cons.h>
 
-#include <uvm/uvm_extern.h>
-
 #include <machine/rpb.h>
 #include <machine/autoconf.h>
 #include <machine/cpuconf.h>
@@ -110,10 +108,7 @@
        platform.cons_init = dec_eb66_cons_init;
        platform.device_register = dec_eb66_device_register;
 
-       /*
-        * EB66 systems have 1M secondary caches.
-        */
-       uvmexp.ncolors = atop(1 * 1024 * 1024);
+       lca_probe_bcache();
 }
 
 static void
diff -r d30a8fe1256c -r b8e6477b6848 sys/arch/alpha/pci/lca.c
--- a/sys/arch/alpha/pci/lca.c  Fri Jul 16 17:09:33 2021 +0000
+++ b/sys/arch/alpha/pci/lca.c  Fri Jul 16 18:50:19 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lca.c,v 1.55 2021/07/04 22:42:36 thorpej Exp $ */
+/* $NetBSD: lca.c,v 1.56 2021/07/16 18:50:19 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -58,13 +58,15 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: lca.c,v 1.55 2021/07/04 22:42:36 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lca.c,v 1.56 2021/07/16 18:50:19 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/kernel.h>
 #include <sys/device.h>
 
+#include <uvm/uvm_extern.h>
+
 #include <machine/autoconf.h>
 #include <machine/rpb.h>
 #include <machine/sysarch.h>
@@ -92,6 +94,16 @@
 struct lca_config lca_configuration;
 static int lcafound;
 
+static const u_int lca_bcache_sizes[__SHIFTOUT(MEMC_CAR_BCS, MEMC_CAR_BCS)] = {
+[BCS_64K]      =       64 * 1024,
+[BCS_128K]     =       128 * 1024,
+[BCS_256K]     =       256 * 1024,
+[BCS_512K]     =       512 * 1024,
+[BCS_1M]       =       1024 * 1024,
+[BCS_2M]       =       2048 * 1024,
+/* Other values are reserved and we treat them as 0. */
+};
+
 static int
 lcamatch(device_t parent, cfdata_t match, void *aux)
 {
@@ -108,6 +120,31 @@
 }
 
 /*
+ * Probe the memory controller's Bcache configuration.
+ */
+void
+lca_probe_bcache(void)
+{
+       const uint64_t car = REGVAL64(LCA_MEMC_CAR);
+
+       if (lca_configuration.lc_bcache_size != 0) {
+               /* Already done. */
+               return;
+       }
+
+       if (car & MEMC_CAR_BCE) {
+               lca_configuration.lc_bcache_size =
+                   lca_bcache_sizes[__SHIFTOUT(car, MEMC_CAR_BCS)];
+       } else {
+               lca_configuration.lc_bcache_size = 0;
+       }
+
+       if (lca_configuration.lc_bcache_size) {
+               uvmexp.ncolors = atop(lca_configuration.lc_bcache_size);
+       }
+}
+
+/*
  * Set up the chipset's function pointers.
  */
 void
@@ -188,6 +225,12 @@
 
        /* XXX print chipset information */
        aprint_normal("\n");
+       if (lcp->lc_bcache_size != 0) {
+               char buf[sizeof("256 KB")];
+               if (format_bytes(buf, sizeof(buf), lcp->lc_bcache_size) > 0) {
+                       aprint_normal_dev(self, "%s Bcache detected\n", buf);
+               }
+       }
 
        lca_dma_init(lcp);
 
diff -r d30a8fe1256c -r b8e6477b6848 sys/arch/alpha/pci/lcavar.h
--- a/sys/arch/alpha/pci/lcavar.h       Fri Jul 16 17:09:33 2021 +0000
+++ b/sys/arch/alpha/pci/lcavar.h       Fri Jul 16 18:50:19 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lcavar.h,v 1.11 2012/02/06 02:14:14 matt Exp $ */
+/* $NetBSD: lcavar.h,v 1.12 2021/07/16 18:50:19 thorpej Exp $ */
 
 /*
  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
@@ -52,6 +52,7 @@
 
        struct extent *lc_io_ex, *lc_d_mem_ex, *lc_s_mem_ex;
        int     lc_mallocsafe;
+       u_int   lc_bcache_size;
 };
 
 struct lca_softc {
@@ -60,6 +61,7 @@
        struct  lca_config *sc_lcp;
 };
 
+void   lca_probe_bcache(void);
 void   lca_init(struct lca_config *, int);
 void   lca_pci_init(pci_chipset_tag_t, void *);
 void   lca_dma_init(struct lca_config *);



Home | Main Index | Thread Index | Old Index