diff options
author | Owain Ainsworth <oga@cvs.openbsd.org> | 2010-04-10 13:46:13 +0000 |
---|---|---|
committer | Owain Ainsworth <oga@cvs.openbsd.org> | 2010-04-10 13:46:13 +0000 |
commit | d6444ee5276f5e98579e476c5c3a20f339f79de7 (patch) | |
tree | 294e9943bc5c79370df0427dc570fdf603eed6d4 | |
parent | 81f066943e02124e73358f6ccc7e2fe4dbd1467a (diff) |
pmap_extract() does the equivalent of vtophys if pmap_kernel(), so instead of
doing if (p != NULL) pmap_extract() else vtophys() in a loop, just do
pmap_extract unconditionally.
ok miod@ (he found a typo, all hail miod!)
-rw-r--r-- | sys/arch/alpha/dev/bus_dma.c | 14 | ||||
-rw-r--r-- | sys/arch/alpha/dev/sgmap_typedep.c | 12 |
2 files changed, 15 insertions, 11 deletions
diff --git a/sys/arch/alpha/dev/bus_dma.c b/sys/arch/alpha/dev/bus_dma.c index ddd8099ec21..a58a0f3a78e 100644 --- a/sys/arch/alpha/dev/bus_dma.c +++ b/sys/arch/alpha/dev/bus_dma.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bus_dma.c,v 1.27 2010/03/29 19:21:58 oga Exp $ */ +/* $OpenBSD: bus_dma.c,v 1.28 2010/04/10 13:46:12 oga Exp $ */ /* $NetBSD: bus_dma.c,v 1.40 2000/07/17 04:47:56 thorpej Exp $ */ /*- @@ -137,10 +137,16 @@ _bus_dmamap_load_buffer_direct(t, map, buf, buflen, p, flags, int first; { bus_size_t sgsize; + pmap_t pmap; bus_addr_t curaddr, lastaddr, baddr, bmask; vaddr_t vaddr = (vaddr_t)buf; int seg; + if (p != NULL) + pmap = p->p_vmspace->vm_map.pmap; + else + pmap = pmap_kernel(); + lastaddr = *lastaddrp; bmask = ~(map->_dm_boundary - 1); @@ -148,11 +154,7 @@ _bus_dmamap_load_buffer_direct(t, map, buf, buflen, p, flags, /* * Get the physical address for this segment. */ - if (p != NULL) - pmap_extract(p->p_vmspace->vm_map.pmap, vaddr, - &curaddr); - else - curaddr = vtophys(vaddr); + pmap_extract(pmap, vaddr, &curaddr); /* * If we're beyond the current DMA window, indicate diff --git a/sys/arch/alpha/dev/sgmap_typedep.c b/sys/arch/alpha/dev/sgmap_typedep.c index 80a7d6abb53..7456cd16d64 100644 --- a/sys/arch/alpha/dev/sgmap_typedep.c +++ b/sys/arch/alpha/dev/sgmap_typedep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sgmap_typedep.c,v 1.11 2008/06/26 05:42:08 ray Exp $ */ +/* $OpenBSD: sgmap_typedep.c,v 1.12 2010/04/10 13:46:12 oga Exp $ */ /* $NetBSD: sgmap_typedep.c,v 1.17 2001/07/19 04:27:37 thorpej Exp $ */ /*- @@ -57,6 +57,7 @@ __C(SGMAP_TYPE,_load_buffer)(bus_dma_tag_t t, bus_dmamap_t map, void *buf, { vaddr_t endva, va = (vaddr_t)buf; paddr_t pa; + pmap_t pmap; bus_addr_t dmaoffset, sgva; bus_size_t sgvalen, boundary, alignment; SGMAP_PTE_TYPE *pte, *page_table = sgmap->aps_pt; @@ -79,6 +80,10 @@ __C(SGMAP_TYPE,_load_buffer)(bus_dma_tag_t t, bus_dmamap_t map, void *buf, dmaoffset, buflen); } #endif + if (p != NULL) + pmap = p->p_vmspace->vm_map.pmap; + else + pmap = pmap_kernel(); /* * Allocate the necessary virtual address space for the @@ -157,10 +162,7 @@ __C(SGMAP_TYPE,_load_buffer)(bus_dma_tag_t t, bus_dmamap_t map, void *buf, for (; va < endva; va += PAGE_SIZE, pteidx++, pte = &page_table[pteidx * SGMAP_PTE_SPACING]) { /* Get the physical address for this segment. */ - if (p != NULL) - (void) pmap_extract(p->p_vmspace->vm_map.pmap, va, &pa); - else - pa = vtophys(va); + (void)pmap_extract(pmap, va, &pa); /* Load the current PTE with this page. */ *pte = (pa >> SGPTE_PGADDR_SHIFT) | SGPTE_VALID; |