Module Name: src Committed By: thorpej Date: Wed Oct 14 00:59:50 UTC 2020
Modified Files: src/sys/arch/alpha/alpha: api_up1000.c dec_2000_300.c machdep.c src/sys/arch/alpha/include: alpha.h cpuconf.h vmparam.h src/sys/arch/alpha/jensenio: jensenio_dma.c jenseniovar.h src/sys/arch/alpha/pci: irongate_dma.c irongatevar.h Log Message: Add a mechanism to allow a platform to optionally shelter some region of physical memory from random allocations from the default VM page free list. Use this hook to shelter regions within 0-16MB of physical RAM on Jensen and Irongate systems; those platforms do not have SGMAP DMA, and so we need to shelter this range so that devices using ISA DMA (e.g. floppy controller) have an opportunity to allocate DMA-safe memory. PR port-alpha/27087 To generate a diff of this commit: cvs rdiff -u -r1.30 -r1.31 src/sys/arch/alpha/alpha/api_up1000.c cvs rdiff -u -r1.19 -r1.20 src/sys/arch/alpha/alpha/dec_2000_300.c cvs rdiff -u -r1.367 -r1.368 src/sys/arch/alpha/alpha/machdep.c cvs rdiff -u -r1.43 -r1.44 src/sys/arch/alpha/include/alpha.h cvs rdiff -u -r1.16 -r1.17 src/sys/arch/alpha/include/cpuconf.h cvs rdiff -u -r1.39 -r1.40 src/sys/arch/alpha/include/vmparam.h cvs rdiff -u -r1.6 -r1.7 src/sys/arch/alpha/jensenio/jensenio_dma.c cvs rdiff -u -r1.5 -r1.6 src/sys/arch/alpha/jensenio/jenseniovar.h cvs rdiff -u -r1.7 -r1.8 src/sys/arch/alpha/pci/irongate_dma.c cvs rdiff -u -r1.6 -r1.7 src/sys/arch/alpha/pci/irongatevar.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/api_up1000.c diff -u src/sys/arch/alpha/alpha/api_up1000.c:1.30 src/sys/arch/alpha/alpha/api_up1000.c:1.31 --- src/sys/arch/alpha/alpha/api_up1000.c:1.30 Sat Oct 13 17:58:54 2012 +++ src/sys/arch/alpha/alpha/api_up1000.c Wed Oct 14 00:59:50 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: api_up1000.c,v 1.30 2012/10/13 17:58:54 jdc Exp $ */ +/* $NetBSD: api_up1000.c,v 1.31 2020/10/14 00:59:50 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: api_up1000.c,v 1.30 2012/10/13 17:58:54 jdc Exp $"); +__KERNEL_RCSID(0, "$NetBSD: api_up1000.c,v 1.31 2020/10/14 00:59:50 thorpej Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -103,6 +103,7 @@ api_up1000_init(void) platform.iobus = "irongate"; platform.cons_init = api_up1000_cons_init; platform.device_register = api_up1000_device_register; + platform.page_physload = irongate_page_physload; } static void Index: src/sys/arch/alpha/alpha/dec_2000_300.c diff -u src/sys/arch/alpha/alpha/dec_2000_300.c:1.19 src/sys/arch/alpha/alpha/dec_2000_300.c:1.20 --- src/sys/arch/alpha/alpha/dec_2000_300.c:1.19 Sat Oct 13 17:58:54 2012 +++ src/sys/arch/alpha/alpha/dec_2000_300.c Wed Oct 14 00:59:50 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dec_2000_300.c,v 1.19 2012/10/13 17:58:54 jdc Exp $ */ +/* $NetBSD: dec_2000_300.c,v 1.20 2020/10/14 00:59:50 thorpej Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -60,7 +60,7 @@ #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: dec_2000_300.c,v 1.19 2012/10/13 17:58:54 jdc Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dec_2000_300.c,v 1.20 2020/10/14 00:59:50 thorpej Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -116,6 +116,7 @@ dec_2000_300_init(void) platform.iobus = "jensenio"; platform.cons_init = dec_2000_300_cons_init; platform.device_register = dec_2000_300_device_register; + platform.page_physload = jensenio_page_physload; } static void Index: src/sys/arch/alpha/alpha/machdep.c diff -u src/sys/arch/alpha/alpha/machdep.c:1.367 src/sys/arch/alpha/alpha/machdep.c:1.368 --- src/sys/arch/alpha/alpha/machdep.c:1.367 Sat Oct 10 21:59:03 2020 +++ src/sys/arch/alpha/alpha/machdep.c Wed Oct 14 00:59:50 2020 @@ -1,7 +1,7 @@ -/* $NetBSD: machdep.c,v 1.367 2020/10/10 21:59:03 thorpej Exp $ */ +/* $NetBSD: machdep.c,v 1.368 2020/10/14 00:59:50 thorpej Exp $ */ /*- - * Copyright (c) 1998, 1999, 2000, 2019 The NetBSD Foundation, Inc. + * Copyright (c) 1998, 1999, 2000, 2019, 2020 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -67,7 +67,7 @@ #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.367 2020/10/10 21:59:03 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.368 2020/10/14 00:59:50 thorpej Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -216,6 +216,69 @@ const pcu_ops_t * const pcu_ops_md_defs[ [PCU_FPU] = &fpu_ops, }; +static void +alpha_page_physload(unsigned long const start_pfn, unsigned long const end_pfn) +{ + + /* + * Some Alpha platforms may have unique requirements about + * how physical memory is managed (e.g. reserving memory + * ranges due to lack of SGMAP DMA). + */ + if (platform.page_physload != NULL) { + (*platform.page_physload)(start_pfn, end_pfn); + return; + } + + uvm_page_physload(start_pfn, end_pfn, start_pfn, end_pfn, + VM_FREELIST_DEFAULT); +} + +void +alpha_page_physload_sheltered(unsigned long const start_pfn, + unsigned long const end_pfn, unsigned long const shelter_start_pfn, + unsigned long const shelter_end_pfn) +{ + + /* + * If the added region ends before or starts after the sheltered + * region, then it just goes on the default freelist. + */ + if (end_pfn <= shelter_start_pfn || start_pfn >= shelter_end_pfn) { + uvm_page_physload(start_pfn, end_pfn, + start_pfn, end_pfn, VM_FREELIST_DEFAULT); + return; + } + + /* + * Load any portion that comes before the sheltered region. + */ + if (start_pfn < shelter_start_pfn) { + KASSERT(end_pfn > shelter_start_pfn); + uvm_page_physload(start_pfn, shelter_start_pfn, + start_pfn, shelter_start_pfn, VM_FREELIST_DEFAULT); + } + + /* + * Load the portion that overlaps that sheltered region. + */ + const unsigned long ov_start = MAX(start_pfn, shelter_start_pfn); + const unsigned long ov_end = MIN(end_pfn, shelter_end_pfn); + KASSERT(ov_start >= shelter_start_pfn); + KASSERT(ov_end <= shelter_end_pfn); + uvm_page_physload(ov_start, ov_end, ov_start, ov_end, + VM_FREELIST_SHELTERED); + + /* + * Load any portion that comes after the sheltered region. + */ + if (end_pfn > shelter_end_pfn) { + KASSERT(start_pfn < shelter_end_pfn); + uvm_page_physload(shelter_end_pfn, end_pfn, + shelter_end_pfn, end_pfn, VM_FREELIST_DEFAULT); + } +} + void alpha_init(u_long xxx_pfn __unused, u_long ptb, u_long bim, u_long bip, u_long biv) @@ -535,8 +598,7 @@ nobootinfo: printf("Loading chunk before kernel: " "0x%lx / 0x%lx\n", pfn0, kernstartpfn); #endif - uvm_page_physload(pfn0, kernstartpfn, - pfn0, kernstartpfn, VM_FREELIST_DEFAULT); + alpha_page_physload(pfn0, kernstartpfn); } if (kernendpfn < pfn1) { /* @@ -546,8 +608,7 @@ nobootinfo: printf("Loading chunk after kernel: " "0x%lx / 0x%lx\n", kernendpfn, pfn1); #endif - uvm_page_physload(kernendpfn, pfn1, - kernendpfn, pfn1, VM_FREELIST_DEFAULT); + alpha_page_physload(kernendpfn, pfn1); } } else { /* @@ -557,8 +618,7 @@ nobootinfo: printf("Loading cluster %d: 0x%lx / 0x%lx\n", i, pfn0, pfn1); #endif - uvm_page_physload(pfn0, pfn1, pfn0, pfn1, - VM_FREELIST_DEFAULT); + alpha_page_physload(pfn0, pfn1); } } Index: src/sys/arch/alpha/include/alpha.h diff -u src/sys/arch/alpha/include/alpha.h:1.43 src/sys/arch/alpha/include/alpha.h:1.44 --- src/sys/arch/alpha/include/alpha.h:1.43 Sat Oct 10 03:05:04 2020 +++ src/sys/arch/alpha/include/alpha.h Wed Oct 14 00:59:50 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: alpha.h,v 1.43 2020/10/10 03:05:04 thorpej Exp $ */ +/* $NetBSD: alpha.h,v 1.44 2020/10/14 00:59:50 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -84,6 +84,7 @@ void XentRestart(void); /* MAGIC */ void XentSys(uint64_t, uint64_t, uint64_t); /* MAGIC */ void XentUna(uint64_t, uint64_t, uint64_t); /* MAGIC */ void alpha_init(u_long, u_long, u_long, u_long, u_long); +void alpha_page_physload_sheltered(u_long, u_long, u_long, u_long); void ast(struct trapframe *); int badaddr(void *, size_t); int badaddr_read(void *, size_t, void *); Index: src/sys/arch/alpha/include/cpuconf.h diff -u src/sys/arch/alpha/include/cpuconf.h:1.16 src/sys/arch/alpha/include/cpuconf.h:1.17 --- src/sys/arch/alpha/include/cpuconf.h:1.16 Mon Sep 28 16:27:47 2020 +++ src/sys/arch/alpha/include/cpuconf.h Wed Oct 14 00:59:50 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: cpuconf.h,v 1.16 2020/09/28 16:27:47 thorpej Exp $ */ +/* $NetBSD: cpuconf.h,v 1.17 2020/10/14 00:59:50 thorpej Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved. @@ -70,6 +70,7 @@ struct platform { void (*mcheck_handler)(unsigned long, struct trapframe *, unsigned long, unsigned long); void (*powerdown)(void); + void (*page_physload)(unsigned long, unsigned long); }; /* Index: src/sys/arch/alpha/include/vmparam.h diff -u src/sys/arch/alpha/include/vmparam.h:1.39 src/sys/arch/alpha/include/vmparam.h:1.40 --- src/sys/arch/alpha/include/vmparam.h:1.39 Sat Aug 29 20:08:08 2020 +++ src/sys/arch/alpha/include/vmparam.h Wed Oct 14 00:59:50 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: vmparam.h,v 1.39 2020/08/29 20:08:08 thorpej Exp $ */ +/* $NetBSD: vmparam.h,v 1.40 2020/10/14 00:59:50 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -125,7 +125,8 @@ #define VM_PHYSSEG_MAX 16 /* XXX */ #define VM_PHYSSEG_STRAT VM_PSTRAT_BSEARCH -#define VM_NFREELIST 1 +#define VM_NFREELIST 2 #define VM_FREELIST_DEFAULT 0 +#define VM_FREELIST_SHELTERED 1 #endif /* ! _ALPHA_VMPARAM_H_ */ Index: src/sys/arch/alpha/jensenio/jensenio_dma.c diff -u src/sys/arch/alpha/jensenio/jensenio_dma.c:1.6 src/sys/arch/alpha/jensenio/jensenio_dma.c:1.7 --- src/sys/arch/alpha/jensenio/jensenio_dma.c:1.6 Sat Oct 10 21:59:03 2020 +++ src/sys/arch/alpha/jensenio/jensenio_dma.c Wed Oct 14 00:59:50 2020 @@ -1,7 +1,7 @@ -/* $NetBSD: jensenio_dma.c,v 1.6 2020/10/10 21:59:03 thorpej Exp $ */ +/* $NetBSD: jensenio_dma.c,v 1.7 2020/10/14 00:59:50 thorpej Exp $ */ /*- - * Copyright (c) 2000 The NetBSD Foundation, Inc. + * Copyright (c) 2000, 2020 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -47,7 +47,7 @@ #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: jensenio_dma.c,v 1.6 2020/10/10 21:59:03 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: jensenio_dma.c,v 1.7 2020/10/14 00:59:50 thorpej Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -65,9 +65,24 @@ __KERNEL_RCSID(0, "$NetBSD: jensenio_dma #include <alpha/jensenio/jenseniovar.h> +#include <machine/alpha.h> + bus_dma_tag_t jensenio_dma_get_tag(bus_dma_tag_t, alpha_bus_t); void +jensenio_page_physload(unsigned long const start_pfn, + unsigned long const end_pfn) +{ + /* + * The Jensen does not have SGMAP DMA. For this reason, we + * need to protect the first 16MB of RAM from random allocations + * in order to give ISA DMA a snowball's chance of working. + */ + alpha_page_physload_sheltered(start_pfn, end_pfn, + 0, alpha_btop(0x1000000)); +} + +void jensenio_dma_init(struct jensenio_config *jcp) { bus_dma_tag_t t; Index: src/sys/arch/alpha/jensenio/jenseniovar.h diff -u src/sys/arch/alpha/jensenio/jenseniovar.h:1.5 src/sys/arch/alpha/jensenio/jenseniovar.h:1.6 --- src/sys/arch/alpha/jensenio/jenseniovar.h:1.5 Fri Sep 25 03:40:11 2020 +++ src/sys/arch/alpha/jensenio/jenseniovar.h Wed Oct 14 00:59:50 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: jenseniovar.h,v 1.5 2020/09/25 03:40:11 thorpej Exp $ */ +/* $NetBSD: jenseniovar.h,v 1.6 2020/10/14 00:59:50 thorpej Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -88,6 +88,7 @@ struct jensenio_scb_intrhand { struct evcnt jih_evcnt; }; +void jensenio_page_physload(unsigned long, unsigned long); void jensenio_init(struct jensenio_config *, int); void jensenio_bus_io_init(bus_space_tag_t, void *); void jensenio_bus_intio_init(bus_space_tag_t, void *); Index: src/sys/arch/alpha/pci/irongate_dma.c diff -u src/sys/arch/alpha/pci/irongate_dma.c:1.7 src/sys/arch/alpha/pci/irongate_dma.c:1.8 --- src/sys/arch/alpha/pci/irongate_dma.c:1.7 Sat Oct 10 21:59:04 2020 +++ src/sys/arch/alpha/pci/irongate_dma.c Wed Oct 14 00:59:50 2020 @@ -1,7 +1,7 @@ -/* $NetBSD: irongate_dma.c,v 1.7 2020/10/10 21:59:04 thorpej Exp $ */ +/* $NetBSD: irongate_dma.c,v 1.8 2020/10/14 00:59:50 thorpej Exp $ */ /*- - * Copyright (c) 2000 The NetBSD Foundation, Inc. + * Copyright (c) 2000, 2020 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -44,7 +44,7 @@ #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: irongate_dma.c,v 1.7 2020/10/10 21:59:04 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: irongate_dma.c,v 1.8 2020/10/14 00:59:50 thorpej Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -64,9 +64,24 @@ __KERNEL_RCSID(0, "$NetBSD: irongate_dma #include <dev/isa/isareg.h> #include <dev/isa/isavar.h> +#include <machine/alpha.h> + bus_dma_tag_t irongate_dma_get_tag(bus_dma_tag_t, alpha_bus_t); void +irongate_page_physload(unsigned long const start_pfn, + unsigned long const end_pfn) +{ + /* + * The Irongate does not have SGMAP DMA. For this reason, we + * need to protect the first 16MB of RAM from random allocations + * in order to give ISA DMA a snowball's chance of working. + */ + alpha_page_physload_sheltered(start_pfn, end_pfn, + 0, alpha_btop(0x1000000)); +} + +void irongate_dma_init(struct irongate_config *icp) { bus_dma_tag_t t; Index: src/sys/arch/alpha/pci/irongatevar.h diff -u src/sys/arch/alpha/pci/irongatevar.h:1.6 src/sys/arch/alpha/pci/irongatevar.h:1.7 --- src/sys/arch/alpha/pci/irongatevar.h:1.6 Mon Feb 6 02:14:14 2012 +++ src/sys/arch/alpha/pci/irongatevar.h Wed Oct 14 00:59:50 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: irongatevar.h,v 1.6 2012/02/06 02:14:14 matt Exp $ */ +/* $NetBSD: irongatevar.h,v 1.7 2020/10/14 00:59:50 thorpej Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -59,6 +59,7 @@ struct irongate_softc { struct irongate_config *sc_icp; }; +void irongate_page_physload(unsigned long, unsigned long); void irongate_init(struct irongate_config *, int); void irongate_pci_init(pci_chipset_tag_t, void *); void irongate_dma_init(struct irongate_config *);