Author: alc Date: Mon Sep 10 16:11:29 2012 New Revision: 240317 URL: http://svn.freebsd.org/changeset/base/240317
Log: Simplify pmap_unmapdev(). Since kmem_free() eventually calls pmap_remove(), pmap_unmapdev()'s own direct efforts to destroy the page table entries are redundant, so eliminate them. Don't set PTE_W on the page table entry in pmap_kenter{,_attr}() on MIPS. Setting PTE_W on MIPS is inconsistent with the implementation of this function on other architectures. Moreover, PTE_W should not be set, unless the pmap's wired mapping count is incremented, which pmap_kenter{,_attr}() doesn't do. MFC after: 10 days Modified: head/sys/amd64/amd64/pmap.c head/sys/i386/i386/pmap.c head/sys/i386/xen/pmap.c head/sys/mips/mips/pmap.c Modified: head/sys/amd64/amd64/pmap.c ============================================================================== --- head/sys/amd64/amd64/pmap.c Mon Sep 10 14:11:10 2012 (r240316) +++ head/sys/amd64/amd64/pmap.c Mon Sep 10 16:11:29 2012 (r240317) @@ -4998,7 +4998,7 @@ pmap_mapbios(vm_paddr_t pa, vm_size_t si void pmap_unmapdev(vm_offset_t va, vm_size_t size) { - vm_offset_t base, offset, tmpva; + vm_offset_t base, offset; /* If we gave a direct map region in pmap_mapdev, do nothing */ if (va >= DMAP_MIN_ADDRESS && va < DMAP_MAX_ADDRESS) @@ -5006,9 +5006,6 @@ pmap_unmapdev(vm_offset_t va, vm_size_t base = trunc_page(va); offset = va & PAGE_MASK; size = roundup(offset + size, PAGE_SIZE); - for (tmpva = base; tmpva < (base + size); tmpva += PAGE_SIZE) - pmap_kremove(tmpva); - pmap_invalidate_range(kernel_pmap, va, tmpva); kmem_free(kernel_map, base, size); } Modified: head/sys/i386/i386/pmap.c ============================================================================== --- head/sys/i386/i386/pmap.c Mon Sep 10 14:11:10 2012 (r240316) +++ head/sys/i386/i386/pmap.c Mon Sep 10 16:11:29 2012 (r240317) @@ -5011,16 +5011,13 @@ pmap_mapbios(vm_paddr_t pa, vm_size_t si void pmap_unmapdev(vm_offset_t va, vm_size_t size) { - vm_offset_t base, offset, tmpva; + vm_offset_t base, offset; if (va >= KERNBASE && va + size <= KERNBASE + KERNLOAD) return; base = trunc_page(va); offset = va & PAGE_MASK; size = roundup(offset + size, PAGE_SIZE); - for (tmpva = base; tmpva < (base + size); tmpva += PAGE_SIZE) - pmap_kremove(tmpva); - pmap_invalidate_range(kernel_pmap, va, tmpva); kmem_free(kernel_map, base, size); } Modified: head/sys/i386/xen/pmap.c ============================================================================== --- head/sys/i386/xen/pmap.c Mon Sep 10 14:11:10 2012 (r240316) +++ head/sys/i386/xen/pmap.c Mon Sep 10 16:11:29 2012 (r240317) @@ -3989,18 +3989,13 @@ pmap_mapbios(vm_paddr_t pa, vm_size_t si void pmap_unmapdev(vm_offset_t va, vm_size_t size) { - vm_offset_t base, offset, tmpva; + vm_offset_t base, offset; if (va >= KERNBASE && va + size <= KERNBASE + KERNLOAD) return; base = trunc_page(va); offset = va & PAGE_MASK; size = roundup(offset + size, PAGE_SIZE); - critical_enter(); - for (tmpva = base; tmpva < (base + size); tmpva += PAGE_SIZE) - pmap_kremove(tmpva); - pmap_invalidate_range(kernel_pmap, va, tmpva); - critical_exit(); kmem_free(kernel_map, base, size); } Modified: head/sys/mips/mips/pmap.c ============================================================================== --- head/sys/mips/mips/pmap.c Mon Sep 10 14:11:10 2012 (r240316) +++ head/sys/mips/mips/pmap.c Mon Sep 10 16:11:29 2012 (r240317) @@ -814,10 +814,10 @@ pmap_kenter_attr(vm_offset_t va, vm_padd #ifdef PMAP_DEBUG printf("pmap_kenter: va: %p -> pa: %p\n", (void *)va, (void *)pa); #endif - npte = TLBLO_PA_TO_PFN(pa) | PTE_D | PTE_V | PTE_G | PTE_W | attr; pte = pmap_pte(kernel_pmap, va); opte = *pte; + npte = TLBLO_PA_TO_PFN(pa) | attr | PTE_D | PTE_V | PTE_G; *pte = npte; if (pte_test(&opte, PTE_V) && opte != npte) pmap_update_page(kernel_pmap, va, npte); @@ -2946,7 +2946,7 @@ void pmap_unmapdev(vm_offset_t va, vm_size_t size) { #ifndef __mips_n64 - vm_offset_t base, offset, tmpva; + vm_offset_t base, offset; /* If the address is within KSEG1 then there is nothing to do */ if (va >= MIPS_KSEG1_START && va <= MIPS_KSEG1_END) @@ -2955,8 +2955,6 @@ pmap_unmapdev(vm_offset_t va, vm_size_t base = trunc_page(va); offset = va & PAGE_MASK; size = roundup(size + offset, PAGE_SIZE); - for (tmpva = base; tmpva < base + size; tmpva += PAGE_SIZE) - pmap_kremove(tmpva); kmem_free(kernel_map, base, size); #endif } _______________________________________________ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"