Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/x86/x86 Implement pmap_kenter_pa(9) new flag argume...
details: https://anonhg.NetBSD.org/src/rev/b7feb93c423e
branches: trunk
changeset: 748854:b7feb93c423e
user: cegger <cegger%NetBSD.org@localhost>
date: Sat Nov 07 07:32:53 2009 +0000
description:
Implement pmap_kenter_pa(9) new flag argument in x86.
Make x86 bus_space(9) using it to eliminate an extra TLB flush.
Patch showed on tech-kern@ http://mail-index.netbsd.org/tech-kern/2009/11/04/msg006434.html
Thanks to Martin Husemann for spotting copy&pasto errors in the original patch version.
diffstat:
sys/arch/x86/x86/bus_space.c | 37 ++++++++++---------------------------
sys/arch/x86/x86/pmap.c | 9 +++++++--
2 files changed, 17 insertions(+), 29 deletions(-)
diffs (111 lines):
diff -r 5b0fe603c714 -r b7feb93c423e sys/arch/x86/x86/bus_space.c
--- a/sys/arch/x86/x86/bus_space.c Sat Nov 07 07:27:40 2009 +0000
+++ b/sys/arch/x86/x86/bus_space.c Sat Nov 07 07:32:53 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bus_space.c,v 1.25 2009/11/07 07:27:48 cegger Exp $ */
+/* $NetBSD: bus_space.c,v 1.26 2009/11/07 07:32:53 cegger Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bus_space.c,v 1.25 2009/11/07 07:27:48 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_space.c,v 1.26 2009/11/07 07:32:53 cegger Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -293,11 +293,14 @@
{
paddr_t pa, endpa;
vaddr_t va, sva;
- pt_entry_t *pte, xpte;
+ u_int pmapflags = 0;
pa = x86_trunc_page(bpa);
endpa = x86_round_page(bpa + size);
+ if (!cacheable)
+ pmapflags |= PMAP_NOCACHE;
+
#ifdef DIAGNOSTIC
if (endpa != 0 && endpa <= pa)
panic("x86_mem_add_mapping: overflow");
@@ -316,35 +319,15 @@
}
*bshp = (bus_space_handle_t)(sva + (bpa & PGOFSET));
- va = sva;
- xpte = 0;
- for (; pa != endpa; pa += PAGE_SIZE, va += PAGE_SIZE) {
- /*
- * PG_N doesn't exist on 386's, so we assume that
- * the mainboard has wired up device space non-cacheable
- * on those machines.
- *
- * XXX should hand this bit to pmap_kenter_pa to
- * save the extra invalidate!
- */
+ for (va = sva; pa != endpa; pa += PAGE_SIZE, va += PAGE_SIZE) {
#ifdef XEN
- pmap_kenter_ma(va, pa, VM_PROT_READ | VM_PROT_WRITE, 0);
+ pmap_kenter_ma(va, pa, VM_PROT_READ | VM_PROT_WRITE, pmapflags);
#else
- pmap_kenter_pa(va, pa, VM_PROT_READ | VM_PROT_WRITE, 0);
+ pmap_kenter_pa(va, pa, VM_PROT_READ | VM_PROT_WRITE, pmapflags);
#endif /* XEN */
-
- pte = kvtopte(va);
- if (cacheable)
- pmap_pte_clearbits(pte, PG_N);
- else
- pmap_pte_setbits(pte, PG_N);
- xpte |= *pte;
}
- kpreempt_disable();
- pmap_tlb_shootdown(pmap_kernel(), sva, sva + (endpa - pa), xpte);
- pmap_tlb_shootwait();
- kpreempt_enable();
+ pmap_update(pmap_kernel());
return 0;
}
diff -r 5b0fe603c714 -r b7feb93c423e sys/arch/x86/x86/pmap.c
--- a/sys/arch/x86/x86/pmap.c Sat Nov 07 07:27:40 2009 +0000
+++ b/sys/arch/x86/x86/pmap.c Sat Nov 07 07:32:53 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.95 2009/11/07 07:27:49 cegger Exp $ */
+/* $NetBSD: pmap.c,v 1.96 2009/11/07 07:32:53 cegger Exp $ */
/*
* Copyright (c) 2007 Manuel Bouyer.
@@ -149,7 +149,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.95 2009/11/07 07:27:49 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.96 2009/11/07 07:32:53 cegger Exp $");
#include "opt_user_ldt.h"
#include "opt_lockdebug.h"
@@ -1030,6 +1030,8 @@
#endif /* DOM0OPS */
npte = pmap_pa2pte(pa);
npte |= protection_codes[prot] | PG_k | PG_V | pmap_pg_g;
+ if (flags & PMAP_NOCACHE)
+ npte |= PG_N;
opte = pmap_pte_testset(pte, npte); /* zap! */
#if defined(DIAGNOSTIC)
/* XXX For now... */
@@ -1125,6 +1127,9 @@
npte = ma | ((prot & VM_PROT_WRITE) ? PG_RW : PG_RO) |
PG_V | PG_k;
+ if (flags & PMAP_NOCACHE)
+ npte |= PG_N;
+
#ifndef XEN
if ((cpu_feature & CPUID_NOX) && !(prot & VM_PROT_EXECUTE))
npte |= PG_NX;
Home |
Main Index |
Thread Index |
Old Index