Home | History | Annotate | Line # | Download | only in pci
ttwoga_dma.c revision 1.3.126.1
      1  1.3.126.1     yamt /* $NetBSD: ttwoga_dma.c,v 1.3.126.1 2008/05/18 12:31:24 yamt Exp $ */
      2        1.1  thorpej 
      3        1.1  thorpej /*-
      4        1.1  thorpej  * Copyright (c) 1999 The NetBSD Foundation, Inc.
      5        1.1  thorpej  * All rights reserved.
      6        1.1  thorpej  *
      7        1.1  thorpej  * This code is derived from software contributed to The NetBSD Foundation
      8        1.1  thorpej  * by Jason R. Thorpe.
      9        1.1  thorpej  *
     10        1.1  thorpej  * Redistribution and use in source and binary forms, with or without
     11        1.1  thorpej  * modification, are permitted provided that the following conditions
     12        1.1  thorpej  * are met:
     13        1.1  thorpej  * 1. Redistributions of source code must retain the above copyright
     14        1.1  thorpej  *    notice, this list of conditions and the following disclaimer.
     15        1.1  thorpej  * 2. Redistributions in binary form must reproduce the above copyright
     16        1.1  thorpej  *    notice, this list of conditions and the following disclaimer in the
     17        1.1  thorpej  *    documentation and/or other materials provided with the distribution.
     18        1.1  thorpej  *
     19        1.1  thorpej  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20        1.1  thorpej  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21        1.1  thorpej  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22        1.1  thorpej  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23        1.1  thorpej  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24        1.1  thorpej  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25        1.1  thorpej  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26        1.1  thorpej  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27        1.1  thorpej  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28        1.1  thorpej  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29        1.1  thorpej  * POSSIBILITY OF SUCH DAMAGE.
     30        1.1  thorpej  */
     31        1.1  thorpej 
     32        1.1  thorpej #include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
     33        1.1  thorpej 
     34  1.3.126.1     yamt __KERNEL_RCSID(0, "$NetBSD: ttwoga_dma.c,v 1.3.126.1 2008/05/18 12:31:24 yamt Exp $");
     35        1.1  thorpej 
     36        1.1  thorpej #include <sys/param.h>
     37        1.1  thorpej #include <sys/systm.h>
     38        1.1  thorpej #include <sys/kernel.h>
     39        1.1  thorpej #include <sys/device.h>
     40        1.1  thorpej 
     41        1.1  thorpej #include <uvm/uvm_extern.h>
     42        1.1  thorpej 
     43        1.1  thorpej #define	_ALPHA_BUS_DMA_PRIVATE
     44        1.1  thorpej #include <machine/bus.h>
     45        1.1  thorpej 
     46        1.1  thorpej #include <dev/pci/pcireg.h>
     47        1.1  thorpej #include <dev/pci/pcivar.h>
     48        1.1  thorpej 
     49        1.1  thorpej #include <alpha/pci/ttwogareg.h>
     50        1.1  thorpej #include <alpha/pci/ttwogavar.h>
     51        1.1  thorpej 
     52        1.1  thorpej bus_dma_tag_t ttwoga_dma_get_tag(bus_dma_tag_t, alpha_bus_t);
     53        1.1  thorpej 
     54        1.1  thorpej int	ttwoga_bus_dmamap_load_sgmap(bus_dma_tag_t, bus_dmamap_t, void *,
     55        1.1  thorpej 	    bus_size_t, struct proc *, int);
     56        1.1  thorpej 
     57        1.1  thorpej int	ttwoga_bus_dmamap_load_mbuf_sgmap(bus_dma_tag_t, bus_dmamap_t,
     58        1.1  thorpej 	    struct mbuf *, int);
     59        1.1  thorpej 
     60        1.1  thorpej int	ttwoga_bus_dmamap_load_uio_sgmap(bus_dma_tag_t, bus_dmamap_t,
     61        1.1  thorpej 	    struct uio *, int);
     62        1.1  thorpej 
     63        1.1  thorpej int	ttwoga_bus_dmamap_load_raw_sgmap(bus_dma_tag_t, bus_dmamap_t,
     64        1.1  thorpej 	    bus_dma_segment_t *, int, bus_size_t, int);
     65        1.1  thorpej 
     66        1.1  thorpej void	ttwoga_bus_dmamap_unload_sgmap(bus_dma_tag_t, bus_dmamap_t);
     67        1.1  thorpej 
     68        1.1  thorpej /*
     69        1.1  thorpej  * Direct-mapped window: 1G at 1G
     70        1.1  thorpej  */
     71        1.1  thorpej #define	TTWOGA_DIRECT_MAPPED_BASE	(1UL*1024UL*1024UL*1024UL)
     72        1.1  thorpej #define	TTWOGA_DIRECT_MAPPED_SIZE	(1UL*1024UL*1024UL*1024UL)
     73        1.1  thorpej 
     74        1.1  thorpej /*
     75        1.1  thorpej  * SGMAP window: 8M at 8M
     76        1.1  thorpej  */
     77        1.1  thorpej #define	TTWOGA_SGMAP_MAPPED_BASE	(8UL*1024UL*1024UL)
     78        1.1  thorpej #define	TTWOGA_SGMAP_MAPPED_SIZE	(8UL*1024UL*1024UL)
     79        1.1  thorpej 
     80        1.3  thorpej /* T2 has a 256-byte out-bound DMA prefetch threshold. */
     81        1.3  thorpej #define	TTWOGA_SGMAP_PFTHRESH		256
     82        1.3  thorpej 
     83        1.1  thorpej /*
     84        1.1  thorpej  * Macro to flush the T2 Gate Array scatter/gather TLB.
     85        1.1  thorpej  */
     86        1.1  thorpej #define	TTWOGA_TLB_INVALIDATE(tcp)					\
     87        1.1  thorpej do {									\
     88        1.1  thorpej 	u_int64_t temp;							\
     89        1.1  thorpej 									\
     90        1.1  thorpej 	alpha_mb();							\
     91        1.1  thorpej 	temp = T2GA((tcp), T2_IOCSR);					\
     92        1.1  thorpej 	T2GA((tcp), T2_IOCSR) = temp | IOCSR_FTLB;			\
     93        1.1  thorpej 	alpha_mb();							\
     94        1.1  thorpej 	alpha_mb();	/* MAGIC */					\
     95        1.1  thorpej 	T2GA((tcp), T2_IOCSR) = temp;					\
     96        1.1  thorpej 	alpha_mb();							\
     97        1.1  thorpej 	alpha_mb();	/* MAGIC */					\
     98        1.1  thorpej } while (0)
     99        1.1  thorpej 
    100        1.1  thorpej void
    101        1.1  thorpej ttwoga_dma_init(struct ttwoga_config *tcp)
    102        1.1  thorpej {
    103        1.1  thorpej 	bus_dma_tag_t t;
    104        1.1  thorpej 
    105        1.1  thorpej 	/*
    106        1.1  thorpej 	 * Initialize the DMA tag used for direct-mapped DMA.
    107        1.1  thorpej 	 */
    108        1.1  thorpej 	t = &tcp->tc_dmat_direct;
    109        1.1  thorpej 	t->_cookie = tcp;
    110        1.1  thorpej 	t->_wbase = TTWOGA_DIRECT_MAPPED_BASE;
    111        1.1  thorpej 	t->_wsize = TTWOGA_DIRECT_MAPPED_SIZE;
    112        1.1  thorpej 	t->_next_window = NULL;
    113        1.1  thorpej 	t->_boundary = 0;
    114        1.1  thorpej 	t->_sgmap = NULL;
    115        1.1  thorpej 	t->_get_tag = ttwoga_dma_get_tag;
    116        1.1  thorpej 	t->_dmamap_create = _bus_dmamap_create;
    117        1.1  thorpej 	t->_dmamap_destroy = _bus_dmamap_destroy;
    118        1.1  thorpej 	t->_dmamap_load = _bus_dmamap_load_direct;
    119        1.1  thorpej 	t->_dmamap_load_mbuf = _bus_dmamap_load_mbuf_direct;
    120        1.1  thorpej 	t->_dmamap_load_uio = _bus_dmamap_load_uio_direct;
    121        1.1  thorpej 	t->_dmamap_load_raw = _bus_dmamap_load_raw_direct;
    122        1.1  thorpej 	t->_dmamap_unload = _bus_dmamap_unload;
    123        1.1  thorpej 	t->_dmamap_sync = _bus_dmamap_sync;
    124        1.1  thorpej 
    125        1.1  thorpej 	t->_dmamem_alloc = _bus_dmamem_alloc;
    126        1.1  thorpej 	t->_dmamem_free = _bus_dmamem_free;
    127        1.1  thorpej 	t->_dmamem_map = _bus_dmamem_map;
    128        1.1  thorpej 	t->_dmamem_unmap = _bus_dmamem_unmap;
    129        1.1  thorpej 	t->_dmamem_mmap = _bus_dmamem_mmap;
    130        1.1  thorpej 
    131        1.1  thorpej 	/*
    132        1.1  thorpej 	 * Initialize the DMA tag used for sgmap-mapped DMA.
    133        1.1  thorpej 	 */
    134        1.1  thorpej 	t = &tcp->tc_dmat_sgmap;
    135        1.1  thorpej 	t->_cookie = tcp;
    136        1.1  thorpej 	t->_wbase = TTWOGA_SGMAP_MAPPED_BASE;
    137        1.1  thorpej 	t->_wsize = TTWOGA_SGMAP_MAPPED_SIZE;
    138        1.1  thorpej 	t->_next_window = NULL;
    139        1.1  thorpej 	t->_boundary = 0;
    140        1.1  thorpej 	t->_sgmap = &tcp->tc_sgmap;
    141        1.3  thorpej 	t->_pfthresh = TTWOGA_SGMAP_PFTHRESH;
    142        1.1  thorpej 	t->_get_tag = ttwoga_dma_get_tag;
    143        1.2  thorpej 	t->_dmamap_create = alpha_sgmap_dmamap_create;
    144        1.2  thorpej 	t->_dmamap_destroy = alpha_sgmap_dmamap_destroy;
    145        1.1  thorpej 	t->_dmamap_load = ttwoga_bus_dmamap_load_sgmap;
    146        1.1  thorpej 	t->_dmamap_load_mbuf = ttwoga_bus_dmamap_load_mbuf_sgmap;
    147        1.1  thorpej 	t->_dmamap_load_uio = ttwoga_bus_dmamap_load_uio_sgmap;
    148        1.1  thorpej 	t->_dmamap_load_raw = ttwoga_bus_dmamap_load_raw_sgmap;
    149        1.1  thorpej 	t->_dmamap_unload = ttwoga_bus_dmamap_unload_sgmap;
    150        1.1  thorpej 	t->_dmamap_sync = _bus_dmamap_sync;
    151        1.1  thorpej 
    152        1.1  thorpej 	t->_dmamem_alloc = _bus_dmamem_alloc;
    153        1.1  thorpej 	t->_dmamem_free = _bus_dmamem_free;
    154        1.1  thorpej 	t->_dmamem_map = _bus_dmamem_map;
    155        1.1  thorpej 	t->_dmamem_unmap = _bus_dmamem_unmap;
    156        1.1  thorpej 	t->_dmamem_mmap = _bus_dmamem_mmap;
    157        1.1  thorpej 
    158        1.1  thorpej 	/*
    159        1.1  thorpej 	 * Disable the SGMAP TLB, and flush it.  We reenable it if
    160        1.1  thorpej 	 * we have a Sable or a Gamma with T3 or T4; Gamma with T2
    161        1.1  thorpej 	 * has a TLB bug apparently severe enough to require disabling
    162        1.1  thorpej 	 * it.
    163        1.1  thorpej 	 */
    164        1.1  thorpej 	alpha_mb();
    165        1.1  thorpej 	T2GA(tcp, T2_IOCSR) &= ~IOCSR_ETLB;
    166        1.1  thorpej 	alpha_mb();
    167        1.1  thorpej 	alpha_mb();	/* MAGIC */
    168        1.1  thorpej 
    169        1.1  thorpej 	TTWOGA_TLB_INVALIDATE(tcp);
    170        1.1  thorpej 
    171        1.1  thorpej 	/*
    172        1.1  thorpej 	 * XXX We might want to make sure our DMA windows don't
    173        1.1  thorpej 	 * XXX overlap with PCI memory space!
    174        1.1  thorpej 	 */
    175        1.1  thorpej 
    176        1.1  thorpej 	/*
    177        1.1  thorpej 	 * Set up window 1 as a 1G direct-mapped window
    178        1.1  thorpej 	 * starting at 1G.
    179        1.1  thorpej 	 */
    180        1.1  thorpej 	T2GA(tcp, T2_WBASE1) = 0;
    181        1.1  thorpej 	alpha_mb();
    182        1.1  thorpej 
    183        1.1  thorpej 	T2GA(tcp, T2_WMASK1) = (TTWOGA_DIRECT_MAPPED_SIZE - 1) & WMASKx_PWM;
    184        1.1  thorpej 	alpha_mb();
    185        1.1  thorpej 
    186        1.1  thorpej 	T2GA(tcp, T2_TBASE1) = 0;
    187        1.1  thorpej 	alpha_mb();
    188        1.1  thorpej 
    189        1.1  thorpej 	T2GA(tcp, T2_WBASE1) = TTWOGA_DIRECT_MAPPED_BASE |
    190        1.1  thorpej 	    ((TTWOGA_DIRECT_MAPPED_BASE + (TTWOGA_DIRECT_MAPPED_SIZE - 1)) >>
    191        1.1  thorpej 	     WBASEx_PWxA_SHIFT) | WBASEx_PWE;
    192        1.1  thorpej 	alpha_mb();
    193        1.1  thorpej 
    194        1.1  thorpej 	/*
    195        1.1  thorpej 	 * Initialize the SGMAP.
    196        1.1  thorpej 	 */
    197        1.1  thorpej 	alpha_sgmap_init(t, &tcp->tc_sgmap, "ttwoga_sgmap",
    198        1.1  thorpej 	    TTWOGA_SGMAP_MAPPED_BASE, 0, TTWOGA_SGMAP_MAPPED_SIZE,
    199        1.1  thorpej 	    sizeof(u_int64_t), NULL, 0);
    200        1.1  thorpej 
    201        1.1  thorpej 	/*
    202        1.1  thorpej 	 * Set up window 2 as an 8MB SGMAP-mapped window
    203        1.1  thorpej 	 * starting at 8MB.
    204        1.1  thorpej 	 */
    205        1.1  thorpej #ifdef DIAGNOSTIC
    206        1.1  thorpej 	if ((TTWOGA_SGMAP_MAPPED_BASE & WBASEx_PWSA) !=
    207        1.1  thorpej 	    TTWOGA_SGMAP_MAPPED_BASE)
    208        1.1  thorpej 		panic("ttwoga_dma_init: SGMAP base inconsistency");
    209        1.1  thorpej #endif
    210        1.1  thorpej 	T2GA(tcp, T2_WBASE2) = 0;
    211        1.1  thorpej 	alpha_mb();
    212        1.1  thorpej 
    213        1.1  thorpej 	T2GA(tcp, T2_WMASK2) = (TTWOGA_SGMAP_MAPPED_SIZE - 1) & WMASKx_PWM;
    214        1.1  thorpej 	alpha_mb();
    215        1.1  thorpej 
    216        1.1  thorpej 	T2GA(tcp, T2_TBASE2) = tcp->tc_sgmap.aps_ptpa >> 1;
    217        1.1  thorpej 	alpha_mb();
    218        1.1  thorpej 
    219        1.1  thorpej 	T2GA(tcp, T2_WBASE2) = TTWOGA_SGMAP_MAPPED_BASE |
    220        1.1  thorpej 	    ((TTWOGA_SGMAP_MAPPED_BASE + (TTWOGA_SGMAP_MAPPED_SIZE - 1)) >>
    221        1.1  thorpej 	     WBASEx_PWxA_SHIFT) | WBASEx_SGE | WBASEx_PWE;
    222        1.1  thorpej 	alpha_mb();
    223        1.1  thorpej 
    224        1.1  thorpej 	/*
    225        1.1  thorpej 	 * Enable SGMAP TLB on Sable or Gamma with T3 or T4; see above.
    226        1.1  thorpej 	 */
    227        1.1  thorpej 	if (alpha_implver() == ALPHA_IMPLVER_EV4 ||
    228        1.1  thorpej 	    tcp->tc_rev >= TRN_T3) {
    229        1.1  thorpej 		alpha_mb();
    230        1.1  thorpej 		T2GA(tcp, T2_IOCSR) |= IOCSR_ETLB;
    231        1.1  thorpej 		alpha_mb();
    232        1.1  thorpej 		alpha_mb();	/* MAGIC */
    233        1.1  thorpej 		tcp->tc_use_tlb = 1;
    234        1.1  thorpej 	}
    235        1.1  thorpej 
    236        1.1  thorpej 	/* XXX XXX BEGIN XXX XXX */
    237        1.1  thorpej 	{							/* XXX */
    238        1.1  thorpej 		extern paddr_t alpha_XXX_dmamap_or;		/* XXX */
    239        1.1  thorpej 		alpha_XXX_dmamap_or = TTWOGA_DIRECT_MAPPED_BASE;/* XXX */
    240        1.1  thorpej 	}							/* XXX */
    241        1.1  thorpej 	/* XXX XXX END XXX XXX */
    242        1.1  thorpej }
    243        1.1  thorpej 
    244        1.1  thorpej /*
    245        1.1  thorpej  * Return the bus dma tag to be used for the specified bus type.
    246        1.1  thorpej  * INTERNAL USE ONLY!
    247        1.1  thorpej  */
    248        1.1  thorpej bus_dma_tag_t
    249        1.1  thorpej ttwoga_dma_get_tag(bus_dma_tag_t t, alpha_bus_t bustype)
    250        1.1  thorpej {
    251        1.1  thorpej 	struct ttwoga_config *tcp = t->_cookie;
    252        1.1  thorpej 
    253        1.1  thorpej 	switch (bustype) {
    254        1.1  thorpej 	case ALPHA_BUS_PCI:
    255        1.1  thorpej 	case ALPHA_BUS_EISA:
    256        1.1  thorpej 		/*
    257        1.1  thorpej 		 * Systems with a T2 Gate Array can have 2G
    258        1.1  thorpej 		 * of memory, but we only get a direct-mapped
    259        1.1  thorpej 		 * window of 1G!
    260        1.1  thorpej 		 *
    261        1.1  thorpej 		 * XXX FIX THIS SOMEDAY!
    262        1.1  thorpej 		 */
    263        1.1  thorpej 		return (&tcp->tc_dmat_direct);
    264        1.1  thorpej 
    265        1.1  thorpej 	case ALPHA_BUS_ISA:
    266        1.1  thorpej 		/*
    267        1.1  thorpej 		 * ISA doesn't have enough address bits to use
    268        1.1  thorpej 		 * the direct-mapped DMA window, so we must use
    269        1.1  thorpej 		 * SGMAPs.
    270        1.1  thorpej 		 */
    271        1.1  thorpej 		return (&tcp->tc_dmat_sgmap);
    272        1.1  thorpej 
    273        1.1  thorpej 	default:
    274        1.1  thorpej 		panic("ttwoga_dma_get_tag: shouldn't be here, really...");
    275        1.1  thorpej 	}
    276        1.1  thorpej }
    277        1.1  thorpej 
    278        1.1  thorpej /*
    279        1.1  thorpej  * Load a T2 SGMAP-mapped DMA map with a liner buffer.
    280        1.1  thorpej  */
    281        1.1  thorpej int
    282        1.1  thorpej ttwoga_bus_dmamap_load_sgmap(bus_dma_tag_t t, bus_dmamap_t map, void *buf,
    283        1.1  thorpej     bus_size_t buflen, struct proc *p, int flags)
    284        1.1  thorpej {
    285        1.1  thorpej 	struct ttwoga_config *tcp = t->_cookie;
    286        1.1  thorpej 	int error;
    287        1.1  thorpej 
    288        1.1  thorpej 	error = pci_sgmap_pte64_load(t, map, buf, buflen, p, flags,
    289        1.1  thorpej 	    t->_sgmap);
    290        1.1  thorpej 	if (error == 0 && tcp->tc_use_tlb)
    291        1.1  thorpej 		TTWOGA_TLB_INVALIDATE(tcp);
    292        1.1  thorpej 
    293        1.1  thorpej 	return (error);
    294        1.1  thorpej }
    295        1.1  thorpej 
    296        1.1  thorpej /*
    297        1.1  thorpej  * Load a T2 SGMAP-mapped DMA map with an mbuf chain.
    298        1.1  thorpej  */
    299        1.1  thorpej int
    300        1.1  thorpej ttwoga_bus_dmamap_load_mbuf_sgmap(bus_dma_tag_t t, bus_dmamap_t map,
    301        1.1  thorpej     struct mbuf *m, int flags)
    302        1.1  thorpej {
    303        1.1  thorpej 	struct ttwoga_config *tcp = t->_cookie;
    304        1.1  thorpej 	int error;
    305        1.1  thorpej 
    306        1.1  thorpej 	error = pci_sgmap_pte64_load_mbuf(t, map, m, flags, t->_sgmap);
    307        1.1  thorpej 	if (error == 0 && tcp->tc_use_tlb)
    308        1.1  thorpej 		TTWOGA_TLB_INVALIDATE(tcp);
    309        1.1  thorpej 
    310        1.1  thorpej 	return (error);
    311        1.1  thorpej }
    312        1.1  thorpej 
    313        1.1  thorpej /*
    314        1.1  thorpej  * Load a T2 SGMAP-mapped DMA map with a uio.
    315        1.1  thorpej  */
    316        1.1  thorpej int
    317        1.1  thorpej ttwoga_bus_dmamap_load_uio_sgmap(bus_dma_tag_t t, bus_dmamap_t map,
    318        1.1  thorpej     struct uio *uio, int flags)
    319        1.1  thorpej {
    320        1.1  thorpej 	struct ttwoga_config *tcp = t->_cookie;
    321        1.1  thorpej 	int error;
    322        1.1  thorpej 
    323        1.1  thorpej 	error = pci_sgmap_pte64_load_uio(t, map, uio, flags, t->_sgmap);
    324        1.1  thorpej 	if (error == 0 && tcp->tc_use_tlb)
    325        1.1  thorpej 		TTWOGA_TLB_INVALIDATE(tcp);
    326        1.1  thorpej 
    327        1.1  thorpej 	return (error);
    328        1.1  thorpej }
    329        1.1  thorpej 
    330        1.1  thorpej /*
    331        1.1  thorpej  * Load a T2 SGMAP-mapped DMA map with raw memory.
    332        1.1  thorpej  */
    333        1.1  thorpej int
    334        1.1  thorpej ttwoga_bus_dmamap_load_raw_sgmap(bus_dma_tag_t t, bus_dmamap_t map,
    335        1.1  thorpej     bus_dma_segment_t *segs, int nsegs, bus_size_t size, int flags)
    336        1.1  thorpej {
    337        1.1  thorpej 	struct ttwoga_config *tcp = t->_cookie;
    338        1.1  thorpej 	int error;
    339        1.1  thorpej 
    340        1.1  thorpej 	error = pci_sgmap_pte64_load_raw(t, map, segs, nsegs, size, flags,
    341        1.1  thorpej 	    t->_sgmap);
    342        1.1  thorpej 	if (error == 0 && tcp->tc_use_tlb)
    343        1.1  thorpej 		TTWOGA_TLB_INVALIDATE(tcp);
    344        1.1  thorpej 
    345        1.1  thorpej 	return (error);
    346        1.1  thorpej }
    347        1.1  thorpej 
    348        1.1  thorpej /*
    349        1.1  thorpej  * Unload an T2 DMA map.
    350        1.1  thorpej  */
    351        1.1  thorpej void
    352        1.1  thorpej ttwoga_bus_dmamap_unload_sgmap(bus_dma_tag_t t, bus_dmamap_t map)
    353        1.1  thorpej {
    354        1.1  thorpej 	struct ttwoga_config *tcp = t->_cookie;
    355        1.1  thorpej 
    356        1.1  thorpej 	/*
    357        1.1  thorpej 	 * Invalidate any SGMAP page table entries used by this
    358        1.1  thorpej 	 * mapping.
    359        1.1  thorpej 	 */
    360        1.1  thorpej 	pci_sgmap_pte64_unload(t, map, t->_sgmap);
    361        1.1  thorpej 	if (tcp->tc_use_tlb)
    362        1.1  thorpej 		TTWOGA_TLB_INVALIDATE(tcp);
    363        1.1  thorpej 
    364        1.1  thorpej 	/*
    365        1.1  thorpej 	 * Do the generic bits of the unload.
    366        1.1  thorpej 	 */
    367        1.1  thorpej 	_bus_dmamap_unload(t, map);
    368        1.1  thorpej }
    369