Module Name: src Committed By: thorpej Date: Fri Jul 16 18:50:19 UTC 2021
Modified Files: src/sys/arch/alpha/alpha: dec_alphabook1.c dec_axppci_33.c dec_eb66.c src/sys/arch/alpha/pci: lca.c lcavar.h Log Message: 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). To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/sys/arch/alpha/alpha/dec_alphabook1.c cvs rdiff -u -r1.67 -r1.68 src/sys/arch/alpha/alpha/dec_axppci_33.c cvs rdiff -u -r1.28 -r1.29 src/sys/arch/alpha/alpha/dec_eb66.c cvs rdiff -u -r1.55 -r1.56 src/sys/arch/alpha/pci/lca.c cvs rdiff -u -r1.11 -r1.12 src/sys/arch/alpha/pci/lcavar.h 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/alpha/alpha/dec_alphabook1.c diff -u src/sys/arch/alpha/alpha/dec_alphabook1.c:1.27 src/sys/arch/alpha/alpha/dec_alphabook1.c:1.28 --- src/sys/arch/alpha/alpha/dec_alphabook1.c:1.27 Sat Oct 13 17:58:54 2012 +++ src/sys/arch/alpha/alpha/dec_alphabook1.c Fri Jul 16 18:50:19 2021 @@ -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 @@ dec_alphabook1_init(void) platform.iobus = "lca"; platform.cons_init = dec_alphabook1_cons_init; platform.device_register = dec_alphabook1_device_register; + + lca_probe_bcache(); } static void Index: src/sys/arch/alpha/alpha/dec_axppci_33.c diff -u src/sys/arch/alpha/alpha/dec_axppci_33.c:1.67 src/sys/arch/alpha/alpha/dec_axppci_33.c:1.68 --- src/sys/arch/alpha/alpha/dec_axppci_33.c:1.67 Sat Oct 13 17:58:54 2012 +++ src/sys/arch/alpha/alpha/dec_axppci_33.c Fri Jul 16 18:50:19 2021 @@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: dec_axppci_3 #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 @@ dec_axppci_33_init(void) /* 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 Index: src/sys/arch/alpha/alpha/dec_eb66.c diff -u src/sys/arch/alpha/alpha/dec_eb66.c:1.28 src/sys/arch/alpha/alpha/dec_eb66.c:1.29 --- src/sys/arch/alpha/alpha/dec_eb66.c:1.28 Sat Oct 13 17:58:54 2012 +++ src/sys/arch/alpha/alpha/dec_eb66.c Fri Jul 16 18:50:19 2021 @@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: dec_eb66.c,v #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 @@ dec_eb66_init(void) 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 Index: src/sys/arch/alpha/pci/lca.c diff -u src/sys/arch/alpha/pci/lca.c:1.55 src/sys/arch/alpha/pci/lca.c:1.56 --- src/sys/arch/alpha/pci/lca.c:1.55 Sun Jul 4 22:42:36 2021 +++ src/sys/arch/alpha/pci/lca.c Fri Jul 16 18:50:19 2021 @@ -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 @@ static int lca_bus_get_window(int, int, 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 @@ lcamatch(device_t parent, cfdata_t match } /* + * 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 @@ lcaattach(device_t parent, device_t self /* 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); Index: src/sys/arch/alpha/pci/lcavar.h diff -u src/sys/arch/alpha/pci/lcavar.h:1.11 src/sys/arch/alpha/pci/lcavar.h:1.12 --- src/sys/arch/alpha/pci/lcavar.h:1.11 Mon Feb 6 02:14:14 2012 +++ src/sys/arch/alpha/pci/lcavar.h Fri Jul 16 18:50:19 2021 @@ -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 lca_config { 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_softc { 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 *);