From 0b153da3949bc80744b13d7a50ed7c5a2251d2e2 Mon Sep 17 00:00:00 2001 From: kent Date: Tue, 28 Jan 2003 08:46:53 +0000 Subject: [PATCH] _bus_dmamem_unmap(): Sets the specified pages cacheable again because _bus_dmamem_map() might change them uncacheable. The code was provided by Dhoyashiki-san in kern/19919. --- sys/arch/i386/i386/bus_machdep.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/sys/arch/i386/i386/bus_machdep.c b/sys/arch/i386/i386/bus_machdep.c index 310f3586d43c..18030391c83d 100644 --- a/sys/arch/i386/i386/bus_machdep.c +++ b/sys/arch/i386/i386/bus_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: bus_machdep.c,v 1.18 2003/01/28 01:07:52 kent Exp $ */ +/* $NetBSD: bus_machdep.c,v 1.19 2003/01/28 08:46:53 kent Exp $ */ /*- * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: bus_machdep.c,v 1.18 2003/01/28 01:07:52 kent Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bus_machdep.c,v 1.19 2003/01/28 08:46:53 kent Exp $"); #include "opt_largepages.h" @@ -867,13 +867,33 @@ _bus_dmamem_unmap(t, kva, size) caddr_t kva; size_t size; { + pt_entry_t *pte; + vaddr_t va, endva; + int cpumask; + int marked; + cpumask = 0; + marked = 0; #ifdef DIAGNOSTIC if ((u_long)kva & PGOFSET) panic("_bus_dmamem_unmap"); #endif size = round_page(size); + /* + * mark pages cacheable again. + */ + for (va = (vaddr_t)kva, endva = (vaddr_t)kva + size; + va < endva; va += PAGE_SIZE) { + pte = kvtopte(va); + if ((*pte & PG_N) != 0) { + *pte &= ~PG_N; + pmap_tlb_shootdown(pmap_kernel(), va, *pte, &cpumask); + marked = 1; + } + } + if (marked) + pmap_tlb_shootnow(cpumask); uvm_km_free(kernel_map, (vaddr_t)kva, size); }