Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/sparc64 On SUN4V make the mdesc data available earl...
details: https://anonhg.NetBSD.org/src/rev/8806d9f7deef
branches: trunk
changeset: 340461:8806d9f7deef
user: martin <martin%NetBSD.org@localhost>
date: Sun Sep 06 16:45:09 2015 +0000
description:
On SUN4V make the mdesc data available early in pmap_bootstrap, so we
can set up the uvm page colors correctly.
Based on code from palle@.
diffstat:
sys/arch/sparc64/include/cpu.h | 6 ++-
sys/arch/sparc64/include/mdesc.h | 8 +--
sys/arch/sparc64/sparc64/autoconf.c | 8 +---
sys/arch/sparc64/sparc64/cpu.c | 8 ++--
sys/arch/sparc64/sparc64/mdesc.c | 65 ++++++++++--------------------------
sys/arch/sparc64/sparc64/pmap.c | 24 ++++++++++---
6 files changed, 50 insertions(+), 69 deletions(-)
diffs (274 lines):
diff -r 38fcaf9e1346 -r 8806d9f7deef sys/arch/sparc64/include/cpu.h
--- a/sys/arch/sparc64/include/cpu.h Sun Sep 06 15:34:55 2015 +0000
+++ b/sys/arch/sparc64/include/cpu.h Sun Sep 06 16:45:09 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.h,v 1.115 2015/06/15 07:48:08 martin Exp $ */
+/* $NetBSD: cpu.h,v 1.116 2015/09/06 16:45:09 martin Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -275,6 +275,10 @@
void cpu_hatch(void);
void cpu_boot_secondary_processors(void);
+/* Helper functions to retrieve cache info */
+int cpu_ecache_associativity(int node);
+int cpu_ecache_size(int node);
+
/*
* Call a function on other cpus:
* multicast - send to everyone in the sparc64_cpuset_t
diff -r 38fcaf9e1346 -r 8806d9f7deef sys/arch/sparc64/include/mdesc.h
--- a/sys/arch/sparc64/include/mdesc.h Sun Sep 06 15:34:55 2015 +0000
+++ b/sys/arch/sparc64/include/mdesc.h Sun Sep 06 16:45:09 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mdesc.h,v 1.3 2015/03/22 19:33:21 palle Exp $ */
+/* $NetBSD: mdesc.h,v 1.4 2015/09/06 16:45:09 martin Exp $ */
/* $OpenBSD: mdesc.h,v 1.3 2014/11/30 22:26:14 kettenis Exp $ */
/*
* Copyright (c) 2009 Mark Kettenis
@@ -38,10 +38,8 @@
};
#ifdef _KERNEL
-extern vaddr_t mdesc;
-extern size_t mdesc_len;
-
-void mdesc_init(void);
+psize_t mdesc_get_len(void);
+void mdesc_init(vaddr_t, paddr_t, psize_t);
uint64_t mdesc_get_prop_val(int, const char *);
const char *mdesc_get_prop_str(int, const char *);
const char *mdesc_get_prop_data(int, const char *, size_t *);
diff -r 38fcaf9e1346 -r 8806d9f7deef sys/arch/sparc64/sparc64/autoconf.c
--- a/sys/arch/sparc64/sparc64/autoconf.c Sun Sep 06 15:34:55 2015 +0000
+++ b/sys/arch/sparc64/sparc64/autoconf.c Sun Sep 06 16:45:09 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: autoconf.c,v 1.204 2015/08/14 02:28:18 nakayama Exp $ */
+/* $NetBSD: autoconf.c,v 1.205 2015/09/06 16:45:09 martin Exp $ */
/*
* Copyright (c) 1996
@@ -48,7 +48,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.204 2015/08/14 02:28:18 nakayama Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.205 2015/09/06 16:45:09 martin Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
@@ -93,7 +93,6 @@
#include <machine/bootinfo.h>
#include <sparc64/sparc64/cache.h>
#include <sparc64/sparc64/timerreg.h>
-#include <machine/mdesc.h>
#include <dev/ata/atavar.h>
#include <dev/pci/pcivar.h>
@@ -482,9 +481,6 @@
cpu_configure(void)
{
- if (CPU_ISSUN4V)
- mdesc_init();
-
bool userconf = (boothowto & RB_USERCONF) != 0;
/* fetch boot device settings */
diff -r 38fcaf9e1346 -r 8806d9f7deef sys/arch/sparc64/sparc64/cpu.c
--- a/sys/arch/sparc64/sparc64/cpu.c Sun Sep 06 15:34:55 2015 +0000
+++ b/sys/arch/sparc64/sparc64/cpu.c Sun Sep 06 16:45:09 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.125 2015/05/07 04:03:38 palle Exp $ */
+/* $NetBSD: cpu.c,v 1.126 2015/09/06 16:45:09 martin Exp $ */
/*
* Copyright (c) 1996
@@ -52,7 +52,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.125 2015/05/07 04:03:38 palle Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.126 2015/09/06 16:45:09 martin Exp $");
#include "opt_multiprocessor.h"
@@ -263,7 +263,7 @@
return prom_getpropint(node, "dcache-associativity", 1);
}
-static int
+int
cpu_ecache_size(int node)
{
if (CPU_ISSUN4V)
@@ -290,7 +290,7 @@
return prom_getpropint(node, "ecache-nlines", 32768);
}
-static int
+int
cpu_ecache_associativity(int node)
{
if (CPU_ISSUN4V) {
diff -r 38fcaf9e1346 -r 8806d9f7deef sys/arch/sparc64/sparc64/mdesc.c
--- a/sys/arch/sparc64/sparc64/mdesc.c Sun Sep 06 15:34:55 2015 +0000
+++ b/sys/arch/sparc64/sparc64/mdesc.c Sun Sep 06 16:45:09 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mdesc.c,v 1.4 2015/03/22 19:33:21 palle Exp $ */
+/* $NetBSD: mdesc.c,v 1.5 2015/09/06 16:45:09 martin Exp $ */
/* $OpenBSD: mdesc.c,v 1.7 2014/11/30 22:26:15 kettenis Exp $ */
/*
* Copyright (c) 2009 Mark Kettenis
@@ -27,68 +27,39 @@
#include <machine/autoconf.h>
#include <machine/hypervisor.h>
#include <machine/mdesc.h>
+#include <machine/sparc64.h>
vaddr_t mdesc;
paddr_t mdesc_pa;
size_t mdesc_len;
-void
-mdesc_init(void)
+size_t
+mdesc_get_len(void)
{
- struct pglist mlist;
- struct vm_page *m;
- psize_t len, size;
- paddr_t pa;
- vaddr_t va;
- int err;
+ psize_t len = 0;
- pa = 0;
- len = 0; /* trick to determine actual buffer size */
- hv_mach_desc(pa, &len);
+ len = 0;
+ hv_mach_desc(0, &len);
KASSERT(len != 0);
-again:
- size = round_page(len);
+ return len;
+}
- TAILQ_INIT(&mlist);
- err = uvm_pglistalloc(len, 0, -1, PAGE_SIZE, 0, &mlist, 1, 0);
- if (err)
- panic("%s: out of memory", __func__);
-
- len = size;
- pa = VM_PAGE_TO_PHYS(TAILQ_FIRST(&mlist));
+void
+mdesc_init(vaddr_t va, paddr_t pa, size_t avail_len)
+{
+ psize_t len;
+ int64_t err;
+
+ len = avail_len;
err = hv_mach_desc(pa, &len);
if (err != H_EOK)
- goto fail;
-
- va = (vaddr_t)uvm_km_alloc(kernel_map, size, 0, UVM_KMF_VAONLY);
- if (va == 0)
- panic("%s: out of memory", __func__);
-
+ panic("hv_mach_desc() failed - err = %" PRId64 "\n", err);
+ KASSERT(len <= avail_len);
mdesc = (vaddr_t)va;
mdesc_pa = pa;
mdesc_len = len;
- TAILQ_FOREACH(m, &mlist, pageq.queue) {
- pa = VM_PAGE_TO_PHYS(m);
- pmap_kenter_pa(va, pa, VM_PROT_READ | VM_PROT_WRITE, 0);
- va += PAGE_SIZE;
- }
- pmap_update(pmap_kernel());
-
- return;
-
-fail:
- uvm_pglistfree(&mlist);
-
- /*
- * If the machine description was updated while we were trying
- * to fetch it, the allocated buffer may have been to small.
- * Try again in that case.
- */
- if (err == H_EINVAL && len > size)
- goto again;
-
return;
}
diff -r 38fcaf9e1346 -r 8806d9f7deef sys/arch/sparc64/sparc64/pmap.c
--- a/sys/arch/sparc64/sparc64/pmap.c Sun Sep 06 15:34:55 2015 +0000
+++ b/sys/arch/sparc64/sparc64/pmap.c Sun Sep 06 16:45:09 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.296 2015/06/15 07:48:08 martin Exp $ */
+/* $NetBSD: pmap.c,v 1.297 2015/09/06 16:45:09 martin Exp $ */
/*
*
* Copyright (C) 1996-1999 Eduardo Horvath.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.296 2015/06/15 07:48:08 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.297 2015/09/06 16:45:09 martin Exp $");
#undef NO_VCACHE /* Don't forget the locked TLB in dostart */
#define HWREF
@@ -62,6 +62,7 @@
#include <sparc64/sparc64/cache.h>
#ifdef SUN4V
#include <sparc64/hypervisor.h>
+#include <sparc64/mdesc.h>
#endif
#ifdef DDB
@@ -478,16 +479,15 @@
continue;
/* Found a CPU, get the E$ info. */
- size = prom_getpropint(node, "ecache-size", -1);
- if (size == -1) {
- /* XXX sun4v support missing */
+ size = cpu_ecache_size(node);
+ if (size == 0) {
prom_printf("pmap_calculate_colors: node %x has "
"no ecache-size\n", node);
/* If we can't get the E$ size, skip the node */
continue;
}
- assoc = prom_getpropint(node, "ecache-associativity", 1);
+ assoc = cpu_ecache_associativity(node);
color = size/assoc/PAGE_SIZE;
if (color > maxcolor)
maxcolor = color;
@@ -732,6 +732,18 @@
/* Initialize bootstrap allocator. */
kdata_alloc_init(kernelend + 1 * 1024 * 1024, ekdata);
+ /* make sure we have access to the mdesc data on SUN4V machines */
+ if (CPU_ISSUN4V) {
+ vaddr_t m_va;
+ psize_t m_len;
+ paddr_t m_pa;
+
+ m_len = mdesc_get_len();
+ m_va = kdata_alloc(m_len, 16);
+ m_pa = kdatap + (m_va - kdata);
+ mdesc_init(m_va, m_pa, m_len);
+ }
+
pmap_bootdebug();
pmap_alloc_bootargs();
pmap_mp_init();
Home |
Main Index |
Thread Index |
Old Index