svn commit: r260288 - head/sys/arm/arm
Ian Lepore
ian at FreeBSD.org
Sat Jan 4 21:38:41 UTC 2014
Author: ian
Date: Sat Jan 4 21:38:41 2014
New Revision: 260288
URL: http://svnweb.freebsd.org/changeset/base/260288
Log:
In pmap_mapdev(), first check whether a static mapping exists, and if so
use it rather than allocating kva space and making another mapping. In
pmap_unmapdev(), don't unmap/free if the mapping is static.
Modified:
head/sys/arm/arm/devmap.c
Modified: head/sys/arm/arm/devmap.c
==============================================================================
--- head/sys/arm/arm/devmap.c Sat Jan 4 21:32:53 2014 (r260287)
+++ head/sys/arm/arm/devmap.c Sat Jan 4 21:38:41 2014 (r260288)
@@ -207,13 +207,23 @@ arm_devmap_vtop(void * vpva, vm_size_t s
/*
* Map a set of physical memory pages into the kernel virtual address space.
- * Return a pointer to where it is mapped. This routine is intended to be used
- * for mapping device memory, NOT real memory.
+ * Return a pointer to where it is mapped.
+ *
+ * This uses a pre-established static mapping if one exists for the requested
+ * range, otherwise it allocates kva space and maps the physical pages into it.
+ *
+ * This routine is intended to be used for mapping device memory, NOT real
+ * memory; the mapping type is inherently PTE_DEVICE in pmap_kenter_device().
*/
void *
pmap_mapdev(vm_offset_t pa, vm_size_t size)
{
vm_offset_t va, tmpva, offset;
+ void * rva;
+
+ /* First look in the static mapping table. */
+ if ((rva = arm_devmap_ptov(pa, size)) != NULL)
+ return (rva);
offset = pa & PAGE_MASK;
pa = trunc_page(pa);
@@ -240,8 +250,13 @@ void
pmap_unmapdev(vm_offset_t va, vm_size_t size)
{
vm_offset_t tmpva, offset;
- vm_size_t origsize = size;
-
+ vm_size_t origsize;
+
+ /* Nothing to do if we find the mapping in the static table. */
+ if (arm_devmap_vtop((void*)va, size) != DEVMAP_PADDR_NOTFOUND)
+ return;
+
+ origsize = size;
offset = va & PAGE_MASK;
va = trunc_page(va);
size = round_page(size + offset);
More information about the svn-src-all
mailing list