Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/alpha Add a mechanism to allow a platform to option...
details: https://anonhg.NetBSD.org/src/rev/d2d140ad68e3
branches: trunk
changeset: 940678:d2d140ad68e3
user: thorpej <thorpej%NetBSD.org@localhost>
date: Wed Oct 14 00:59:50 2020 +0000
description:
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
diffstat:
sys/arch/alpha/alpha/api_up1000.c | 5 +-
sys/arch/alpha/alpha/dec_2000_300.c | 5 +-
sys/arch/alpha/alpha/machdep.c | 78 ++++++++++++++++++++++++++++++---
sys/arch/alpha/include/alpha.h | 3 +-
sys/arch/alpha/include/cpuconf.h | 3 +-
sys/arch/alpha/include/vmparam.h | 5 +-
sys/arch/alpha/jensenio/jensenio_dma.c | 21 +++++++-
sys/arch/alpha/jensenio/jenseniovar.h | 3 +-
sys/arch/alpha/pci/irongate_dma.c | 21 +++++++-
sys/arch/alpha/pci/irongatevar.h | 3 +-
10 files changed, 122 insertions(+), 25 deletions(-)
diffs (truncated from 355 to 300 lines):
diff -r 20d972904e21 -r d2d140ad68e3 sys/arch/alpha/alpha/api_up1000.c
--- a/sys/arch/alpha/alpha/api_up1000.c Tue Oct 13 21:27:18 2020 +0000
+++ b/sys/arch/alpha/alpha/api_up1000.c Wed Oct 14 00:59:50 2020 +0000
@@ -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 @@
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
diff -r 20d972904e21 -r d2d140ad68e3 sys/arch/alpha/alpha/dec_2000_300.c
--- a/sys/arch/alpha/alpha/dec_2000_300.c Tue Oct 13 21:27:18 2020 +0000
+++ b/sys/arch/alpha/alpha/dec_2000_300.c Wed Oct 14 00:59:50 2020 +0000
@@ -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 @@
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
diff -r 20d972904e21 -r d2d140ad68e3 sys/arch/alpha/alpha/machdep.c
--- a/sys/arch/alpha/alpha/machdep.c Tue Oct 13 21:27:18 2020 +0000
+++ b/sys/arch/alpha/alpha/machdep.c Wed Oct 14 00:59:50 2020 +0000
@@ -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 @@
[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 @@
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 @@
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 @@
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);
}
}
diff -r 20d972904e21 -r d2d140ad68e3 sys/arch/alpha/include/alpha.h
--- a/sys/arch/alpha/include/alpha.h Tue Oct 13 21:27:18 2020 +0000
+++ b/sys/arch/alpha/include/alpha.h Wed Oct 14 00:59:50 2020 +0000
@@ -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 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 *);
diff -r 20d972904e21 -r d2d140ad68e3 sys/arch/alpha/include/cpuconf.h
--- a/sys/arch/alpha/include/cpuconf.h Tue Oct 13 21:27:18 2020 +0000
+++ b/sys/arch/alpha/include/cpuconf.h Wed Oct 14 00:59:50 2020 +0000
@@ -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 @@
void (*mcheck_handler)(unsigned long, struct trapframe *,
unsigned long, unsigned long);
void (*powerdown)(void);
+ void (*page_physload)(unsigned long, unsigned long);
};
/*
diff -r 20d972904e21 -r d2d140ad68e3 sys/arch/alpha/include/vmparam.h
--- a/sys/arch/alpha/include/vmparam.h Tue Oct 13 21:27:18 2020 +0000
+++ b/sys/arch/alpha/include/vmparam.h Wed Oct 14 00:59:50 2020 +0000
@@ -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_ */
diff -r 20d972904e21 -r d2d140ad68e3 sys/arch/alpha/jensenio/jensenio_dma.c
--- a/sys/arch/alpha/jensenio/jensenio_dma.c Tue Oct 13 21:27:18 2020 +0000
+++ b/sys/arch/alpha/jensenio/jensenio_dma.c Wed Oct 14 00:59:50 2020 +0000
@@ -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 @@
#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;
diff -r 20d972904e21 -r d2d140ad68e3 sys/arch/alpha/jensenio/jenseniovar.h
--- a/sys/arch/alpha/jensenio/jenseniovar.h Tue Oct 13 21:27:18 2020 +0000
+++ b/sys/arch/alpha/jensenio/jenseniovar.h Wed Oct 14 00:59:50 2020 +0000
@@ -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 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 *);
diff -r 20d972904e21 -r d2d140ad68e3 sys/arch/alpha/pci/irongate_dma.c
--- a/sys/arch/alpha/pci/irongate_dma.c Tue Oct 13 21:27:18 2020 +0000
+++ b/sys/arch/alpha/pci/irongate_dma.c Wed Oct 14 00:59:50 2020 +0000
@@ -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.
Home |
Main Index |
Thread Index |
Old Index