diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2009-01-02 20:01:46 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2009-01-02 20:01:46 +0000 |
commit | 54c1a267ee03f17fbdc0378c6d405ec22b5084e1 (patch) | |
tree | 613377b516d928e6ee0d663d202baa261955f183 /sys | |
parent | a7487b767b66b30a8946c509c05cf7be68529cde (diff) |
Make IOMMU code use the generic _bus_dmamem_map() and _bus_dmamem_unmap().
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/sparc64/dev/iommu.c | 86 | ||||
-rw-r--r-- | sys/arch/sparc64/dev/iommuvar.h | 5 | ||||
-rw-r--r-- | sys/arch/sparc64/dev/psycho.c | 4 | ||||
-rw-r--r-- | sys/arch/sparc64/dev/pyro.c | 4 | ||||
-rw-r--r-- | sys/arch/sparc64/dev/sbus.c | 4 | ||||
-rw-r--r-- | sys/arch/sparc64/dev/schizo.c | 4 | ||||
-rw-r--r-- | sys/arch/sparc64/dev/viommu.c | 86 | ||||
-rw-r--r-- | sys/arch/sparc64/dev/viommuvar.h | 5 | ||||
-rw-r--r-- | sys/arch/sparc64/dev/vpci.c | 4 |
9 files changed, 9 insertions, 193 deletions
diff --git a/sys/arch/sparc64/dev/iommu.c b/sys/arch/sparc64/dev/iommu.c index da801731294..8da5a614f16 100644 --- a/sys/arch/sparc64/dev/iommu.c +++ b/sys/arch/sparc64/dev/iommu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: iommu.c,v 1.52 2008/11/25 16:31:19 kettenis Exp $ */ +/* $OpenBSD: iommu.c,v 1.53 2009/01/02 20:01:45 kettenis Exp $ */ /* $NetBSD: iommu.c,v 1.47 2002/02/08 20:03:45 eeh Exp $ */ /* @@ -1618,90 +1618,6 @@ iommu_dvmamem_free(bus_dma_tag_t t, bus_dma_tag_t t0, bus_dma_segment_t *segs, } /* - * Map the DVMA mappings into the kernel pmap. - * Check the flags to see whether we're streaming or coherent. - */ -int -iommu_dvmamem_map(bus_dma_tag_t t, bus_dma_tag_t t0, bus_dma_segment_t *segs, - int nsegs, size_t size, caddr_t *kvap, int flags) -{ - struct vm_page *m; - vaddr_t va; - bus_addr_t addr; - struct pglist *mlist; - bus_addr_t cbit = 0; - - DPRINTF(IDB_BUSDMA, ("iommu_dvmamem_map: segp %p nsegs %d size %lx\n", - segs, nsegs, size)); - - /* - * Allocate some space in the kernel map, and then map these pages - * into this space. - */ - size = round_page(size); - va = uvm_km_valloc(kernel_map, size); - if (va == 0) - return (ENOMEM); - - *kvap = (caddr_t)va; - - /* - * digest flags: - */ -#if 0 - if (flags & BUS_DMA_COHERENT) /* Disable vcache */ - cbit |= PMAP_NVC; -#endif - if (flags & BUS_DMA_NOCACHE) /* sideffects */ - cbit |= PMAP_NC; - - /* - * Now take this and map it into the CPU. - */ - mlist = segs[0]._ds_mlist; - TAILQ_FOREACH(m, mlist, pageq) { -#ifdef DIAGNOSTIC - if (size == 0) - panic("iommu_dvmamem_map: size botch"); -#endif - addr = VM_PAGE_TO_PHYS(m); - DPRINTF(IDB_BUSDMA, ("iommu_dvmamem_map: " - "mapping va %lx at %llx\n", va, - (unsigned long long)addr | cbit)); - pmap_enter(pmap_kernel(), va, addr | cbit, - VM_PROT_READ | VM_PROT_WRITE, - VM_PROT_READ | VM_PROT_WRITE | PMAP_WIRED); - va += PAGE_SIZE; - size -= PAGE_SIZE; - } - pmap_update(pmap_kernel()); - - return (0); -} - -/* - * Unmap DVMA mappings from kernel - */ -void -iommu_dvmamem_unmap(bus_dma_tag_t t, bus_dma_tag_t t0, caddr_t kva, - size_t size) -{ - - DPRINTF(IDB_BUSDMA, ("iommu_dvmamem_unmap: kvm %p size %lx\n", - kva, size)); - -#ifdef DIAGNOSTIC - if ((u_long)kva & PAGE_MASK) - panic("iommu_dvmamem_unmap"); -#endif - - size = round_page(size); - pmap_remove(pmap_kernel(), (vaddr_t)kva, size); - pmap_update(pmap_kernel()); - uvm_km_free(kernel_map, (vaddr_t)kva, size); -} - -/* * Create a new iomap. */ struct iommu_map_state * diff --git a/sys/arch/sparc64/dev/iommuvar.h b/sys/arch/sparc64/dev/iommuvar.h index 99d233b82de..abd7609e431 100644 --- a/sys/arch/sparc64/dev/iommuvar.h +++ b/sys/arch/sparc64/dev/iommuvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: iommuvar.h,v 1.13 2008/07/12 13:08:04 kettenis Exp $ */ +/* $OpenBSD: iommuvar.h,v 1.14 2009/01/02 20:01:45 kettenis Exp $ */ /* $NetBSD: iommuvar.h,v 1.9 2001/10/07 20:30:41 eeh Exp $ */ /* @@ -142,9 +142,6 @@ int iommu_dvmamem_alloc(bus_dma_tag_t, bus_dma_tag_t, bus_size_t, bus_size_t, bus_size_t, bus_dma_segment_t *, int, int *, int); void iommu_dvmamem_free(bus_dma_tag_t, bus_dma_tag_t, bus_dma_segment_t *, int); -int iommu_dvmamem_map(bus_dma_tag_t, bus_dma_tag_t, bus_dma_segment_t *, - int, size_t, caddr_t *, int); -void iommu_dvmamem_unmap(bus_dma_tag_t, bus_dma_tag_t, caddr_t, size_t); #define IOMMUREG_READ(is, reg) \ bus_space_read_8((is)->is_bustag, \ diff --git a/sys/arch/sparc64/dev/psycho.c b/sys/arch/sparc64/dev/psycho.c index 6a2c004696b..ce63af93ee2 100644 --- a/sys/arch/sparc64/dev/psycho.c +++ b/sys/arch/sparc64/dev/psycho.c @@ -1,4 +1,4 @@ -/* $OpenBSD: psycho.c,v 1.63 2008/11/25 16:31:19 kettenis Exp $ */ +/* $OpenBSD: psycho.c,v 1.64 2009/01/02 20:01:45 kettenis Exp $ */ /* $NetBSD: psycho.c,v 1.39 2001/10/07 20:30:41 eeh Exp $ */ /* @@ -983,8 +983,6 @@ psycho_alloc_dma_tag(struct psycho_pbm *pp) dt->_dmamap_sync = psycho_sabre_dvmamap_sync; dt->_dmamem_alloc = iommu_dvmamem_alloc; dt->_dmamem_free = iommu_dvmamem_free; - dt->_dmamem_map = iommu_dvmamem_map; - dt->_dmamem_unmap = iommu_dvmamem_unmap; return (dt); } diff --git a/sys/arch/sparc64/dev/pyro.c b/sys/arch/sparc64/dev/pyro.c index 8f8fa75052d..b4c6907965f 100644 --- a/sys/arch/sparc64/dev/pyro.c +++ b/sys/arch/sparc64/dev/pyro.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pyro.c,v 1.15 2008/12/21 19:40:41 kettenis Exp $ */ +/* $OpenBSD: pyro.c,v 1.16 2009/01/02 20:01:45 kettenis Exp $ */ /* * Copyright (c) 2002 Jason L. Wright (jason@thought.net) @@ -392,8 +392,6 @@ pyro_alloc_dma_tag(struct pyro_pbm *pbm) dt->_dmamap_sync = iommu_dvmamap_sync; dt->_dmamem_alloc = iommu_dvmamem_alloc; dt->_dmamem_free = iommu_dvmamem_free; - dt->_dmamem_map = iommu_dvmamem_map; - dt->_dmamem_unmap = iommu_dvmamem_unmap; return (dt); } diff --git a/sys/arch/sparc64/dev/sbus.c b/sys/arch/sparc64/dev/sbus.c index bd929c56858..26b2fb4ffd3 100644 --- a/sys/arch/sparc64/dev/sbus.c +++ b/sys/arch/sparc64/dev/sbus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sbus.c,v 1.35 2008/06/26 05:42:13 ray Exp $ */ +/* $OpenBSD: sbus.c,v 1.36 2009/01/02 20:01:45 kettenis Exp $ */ /* $NetBSD: sbus.c,v 1.46 2001/10/07 20:30:41 eeh Exp $ */ /*- @@ -814,8 +814,6 @@ sbus_alloc_dma_tag(struct sbus_softc *sc, bus_dma_tag_t psdt) sdt->_dmamap_sync = iommu_dvmamap_sync; sdt->_dmamem_alloc = iommu_dvmamem_alloc; sdt->_dmamem_free = iommu_dvmamem_free; - sdt->_dmamem_map = iommu_dvmamem_map; - sdt->_dmamem_unmap = iommu_dvmamem_unmap; return (sdt); } diff --git a/sys/arch/sparc64/dev/schizo.c b/sys/arch/sparc64/dev/schizo.c index 7bd0ee04e59..c50da5b257a 100644 --- a/sys/arch/sparc64/dev/schizo.c +++ b/sys/arch/sparc64/dev/schizo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: schizo.c,v 1.57 2008/12/19 21:03:58 kettenis Exp $ */ +/* $OpenBSD: schizo.c,v 1.58 2009/01/02 20:01:45 kettenis Exp $ */ /* * Copyright (c) 2002 Jason L. Wright (jason@thought.net) @@ -612,8 +612,6 @@ schizo_alloc_dma_tag(struct schizo_pbm *pbm) dt->_dmamap_sync = iommu_dvmamap_sync; dt->_dmamem_alloc = iommu_dvmamem_alloc; dt->_dmamem_free = iommu_dvmamem_free; - dt->_dmamem_map = iommu_dvmamem_map; - dt->_dmamem_unmap = iommu_dvmamem_unmap; return (dt); } diff --git a/sys/arch/sparc64/dev/viommu.c b/sys/arch/sparc64/dev/viommu.c index 5ac065da559..3c159c1841a 100644 --- a/sys/arch/sparc64/dev/viommu.c +++ b/sys/arch/sparc64/dev/viommu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: viommu.c,v 1.1 2008/03/09 18:56:45 kettenis Exp $ */ +/* $OpenBSD: viommu.c,v 1.2 2009/01/02 20:01:45 kettenis Exp $ */ /* $NetBSD: iommu.c,v 1.47 2002/02/08 20:03:45 eeh Exp $ */ /* @@ -901,90 +901,6 @@ viommu_dvmamem_free(bus_dma_tag_t t, bus_dma_tag_t t0, bus_dma_segment_t *segs, } /* - * Map the DVMA mappings into the kernel pmap. - * Check the flags to see whether we're streaming or coherent. - */ -int -viommu_dvmamem_map(bus_dma_tag_t t, bus_dma_tag_t t0, bus_dma_segment_t *segs, - int nsegs, size_t size, caddr_t *kvap, int flags) -{ - struct vm_page *m; - vaddr_t va; - bus_addr_t addr; - struct pglist *mlist; - bus_addr_t cbit = 0; - - DPRINTF(IDB_BUSDMA, ("iommu_dvmamem_map: segp %p nsegs %d size %lx\n", - segs, nsegs, size)); - - /* - * Allocate some space in the kernel map, and then map these pages - * into this space. - */ - size = round_page(size); - va = uvm_km_valloc(kernel_map, size); - if (va == 0) - return (ENOMEM); - - *kvap = (caddr_t)va; - - /* - * digest flags: - */ -#if 0 - if (flags & BUS_DMA_COHERENT) /* Disable vcache */ - cbit |= PMAP_NVC; -#endif - if (flags & BUS_DMA_NOCACHE) /* sideffects */ - cbit |= PMAP_NC; - - /* - * Now take this and map it into the CPU. - */ - mlist = segs[0]._ds_mlist; - TAILQ_FOREACH(m, mlist, pageq) { -#ifdef DIAGNOSTIC - if (size == 0) - panic("iommu_dvmamem_map: size botch"); -#endif - addr = VM_PAGE_TO_PHYS(m); - DPRINTF(IDB_BUSDMA, ("iommu_dvmamem_map: " - "mapping va %lx at %llx\n", va, - (unsigned long long)addr | cbit)); - pmap_enter(pmap_kernel(), va, addr | cbit, - VM_PROT_READ | VM_PROT_WRITE, - VM_PROT_READ | VM_PROT_WRITE | PMAP_WIRED); - va += PAGE_SIZE; - size -= PAGE_SIZE; - } - pmap_update(pmap_kernel()); - - return (0); -} - -/* - * Unmap DVMA mappings from kernel - */ -void -viommu_dvmamem_unmap(bus_dma_tag_t t, bus_dma_tag_t t0, caddr_t kva, - size_t size) -{ - - DPRINTF(IDB_BUSDMA, ("iommu_dvmamem_unmap: kvm %p size %lx\n", - kva, size)); - -#ifdef DIAGNOSTIC - if ((u_long)kva & PAGE_MASK) - panic("iommu_dvmamem_unmap"); -#endif - - size = round_page(size); - pmap_remove(pmap_kernel(), (vaddr_t)kva, size); - pmap_update(pmap_kernel()); - uvm_km_free(kernel_map, (vaddr_t)kva, size); -} - -/* * Create a new iomap. */ struct iommu_map_state * diff --git a/sys/arch/sparc64/dev/viommuvar.h b/sys/arch/sparc64/dev/viommuvar.h index 418f9dba6fd..1b7ed074cdd 100644 --- a/sys/arch/sparc64/dev/viommuvar.h +++ b/sys/arch/sparc64/dev/viommuvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: viommuvar.h,v 1.1 2008/03/09 18:56:45 kettenis Exp $ */ +/* $OpenBSD: viommuvar.h,v 1.2 2009/01/02 20:01:45 kettenis Exp $ */ /* * Copyright (c) 2008 Mark Kettenis * @@ -39,8 +39,5 @@ int viommu_dvmamem_alloc(bus_dma_tag_t, bus_dma_tag_t, bus_size_t, bus_size_t, bus_size_t, bus_dma_segment_t *, int, int *, int); void viommu_dvmamem_free(bus_dma_tag_t, bus_dma_tag_t, bus_dma_segment_t *, int); -int viommu_dvmamem_map(bus_dma_tag_t, bus_dma_tag_t, bus_dma_segment_t *, - int, size_t, caddr_t *, int); -void viommu_dvmamem_unmap(bus_dma_tag_t, bus_dma_tag_t, caddr_t, size_t); #endif diff --git a/sys/arch/sparc64/dev/vpci.c b/sys/arch/sparc64/dev/vpci.c index 30718c69c4e..a9c20dcdfd4 100644 --- a/sys/arch/sparc64/dev/vpci.c +++ b/sys/arch/sparc64/dev/vpci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vpci.c,v 1.2 2008/04/08 22:05:19 kettenis Exp $ */ +/* $OpenBSD: vpci.c,v 1.3 2009/01/02 20:01:45 kettenis Exp $ */ /* * Copyright (c) 2008 Mark Kettenis <kettenis@openbsd.org> * @@ -309,8 +309,6 @@ vpci_alloc_dma_tag(struct vpci_pbm *pbm) dt->_dmamap_sync = viommu_dvmamap_sync; dt->_dmamem_alloc = viommu_dvmamem_alloc; dt->_dmamem_free = viommu_dvmamem_free; - dt->_dmamem_map = viommu_dvmamem_map; - dt->_dmamem_unmap = viommu_dvmamem_unmap; return (dt); } |