tsp_dma.c revision 1.17 1 1.17 thorpej /* $NetBSD: tsp_dma.c,v 1.17 2021/05/27 22:11:31 thorpej Exp $ */
2 1.17 thorpej
3 1.17 thorpej /*-
4 1.17 thorpej * Copyright (c) 1997, 1998, 2021 The NetBSD Foundation, Inc.
5 1.17 thorpej * All rights reserved.
6 1.17 thorpej *
7 1.17 thorpej * This code is derived from software contributed to The NetBSD Foundation
8 1.17 thorpej * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9 1.17 thorpej * NASA Ames Research Center.
10 1.17 thorpej *
11 1.17 thorpej * Redistribution and use in source and binary forms, with or without
12 1.17 thorpej * modification, are permitted provided that the following conditions
13 1.17 thorpej * are met:
14 1.17 thorpej * 1. Redistributions of source code must retain the above copyright
15 1.17 thorpej * notice, this list of conditions and the following disclaimer.
16 1.17 thorpej * 2. Redistributions in binary form must reproduce the above copyright
17 1.17 thorpej * notice, this list of conditions and the following disclaimer in the
18 1.17 thorpej * documentation and/or other materials provided with the distribution.
19 1.17 thorpej *
20 1.17 thorpej * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21 1.17 thorpej * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22 1.17 thorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 1.17 thorpej * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24 1.17 thorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 1.17 thorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 1.17 thorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 1.17 thorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 1.17 thorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 1.17 thorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 1.17 thorpej * POSSIBILITY OF SUCH DAMAGE.
31 1.17 thorpej */
32 1.1 ross
33 1.1 ross /*-
34 1.1 ross * Copyright (c) 1999 by Ross Harvey. All rights reserved.
35 1.1 ross *
36 1.1 ross * Redistribution and use in source and binary forms, with or without
37 1.1 ross * modification, are permitted provided that the following conditions
38 1.1 ross * are met:
39 1.1 ross * 1. Redistributions of source code must retain the above copyright
40 1.1 ross * notice, this list of conditions and the following disclaimer.
41 1.1 ross * 2. Redistributions in binary form must reproduce the above copyright
42 1.1 ross * notice, this list of conditions and the following disclaimer in the
43 1.1 ross * documentation and/or other materials provided with the distribution.
44 1.1 ross * 3. All advertising materials mentioning features or use of this software
45 1.1 ross * must display the following acknowledgement:
46 1.1 ross * This product includes software developed by Ross Harvey.
47 1.1 ross * 4. The name of Ross Harvey may not be used to endorse or promote products
48 1.1 ross * derived from this software without specific prior written permission.
49 1.1 ross *
50 1.1 ross * THIS SOFTWARE IS PROVIDED BY ROSS HARVEY ``AS IS'' AND ANY EXPRESS
51 1.1 ross * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
52 1.1 ross * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURP0SE
53 1.1 ross * ARE DISCLAIMED. IN NO EVENT SHALL ROSS HARVEY BE LIABLE FOR ANY
54 1.1 ross * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
55 1.1 ross * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
56 1.1 ross * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
57 1.1 ross * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
58 1.1 ross * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
59 1.1 ross * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
60 1.1 ross * SUCH DAMAGE.
61 1.1 ross */
62 1.5 lukem
63 1.5 lukem #include <sys/cdefs.h>
64 1.17 thorpej __KERNEL_RCSID(0, "$NetBSD: tsp_dma.c,v 1.17 2021/05/27 22:11:31 thorpej Exp $");
65 1.1 ross
66 1.1 ross #include <sys/param.h>
67 1.1 ross #include <sys/systm.h>
68 1.1 ross #include <sys/kernel.h>
69 1.1 ross #include <sys/device.h>
70 1.1 ross #include <sys/malloc.h>
71 1.2 mrg
72 1.1 ross #include <machine/autoconf.h>
73 1.1 ross #define _ALPHA_BUS_DMA_PRIVATE
74 1.11 dyoung #include <sys/bus.h>
75 1.1 ross #include <machine/rpb.h>
76 1.1 ross
77 1.1 ross #include <dev/pci/pcireg.h>
78 1.1 ross #include <dev/pci/pcivar.h>
79 1.1 ross #include <alpha/pci/tsreg.h>
80 1.1 ross #include <alpha/pci/tsvar.h>
81 1.1 ross
82 1.1 ross #define tsp_dma() { Generate ctags(1) key. }
83 1.1 ross
84 1.1 ross #define EDIFF(a, b) (((a) | WSBA_ENA | WSBA_SG) != ((b) | WSBA_ENA | WSBA_SG))
85 1.1 ross
86 1.16 thorpej static bus_dma_tag_t tsp_dma_get_tag(bus_dma_tag_t, alpha_bus_t);
87 1.1 ross
88 1.16 thorpej static int tsp_bus_dmamap_load_sgmap(bus_dma_tag_t, bus_dmamap_t, void *,
89 1.16 thorpej bus_size_t, struct proc *, int);
90 1.1 ross
91 1.16 thorpej static int tsp_bus_dmamap_load_mbuf_sgmap(bus_dma_tag_t, bus_dmamap_t,
92 1.16 thorpej struct mbuf *, int);
93 1.1 ross
94 1.16 thorpej static int tsp_bus_dmamap_load_uio_sgmap(bus_dma_tag_t, bus_dmamap_t,
95 1.16 thorpej struct uio *, int);
96 1.1 ross
97 1.16 thorpej static int tsp_bus_dmamap_load_raw_sgmap(bus_dma_tag_t, bus_dmamap_t,
98 1.16 thorpej bus_dma_segment_t *, int, bus_size_t, int);
99 1.1 ross
100 1.16 thorpej static void tsp_bus_dmamap_unload_sgmap(bus_dma_tag_t, bus_dmamap_t);
101 1.1 ross
102 1.16 thorpej static void tsp_tlb_invalidate(struct tsp_config *);
103 1.1 ross
104 1.4 thorpej /*
105 1.4 thorpej * XXX Need to figure out what this is, if any. Initialize it to
106 1.4 thorpej * XXX something that should be safe.
107 1.4 thorpej */
108 1.4 thorpej #define TSP_SGMAP_PFTHRESH 256
109 1.4 thorpej
110 1.17 thorpej /*
111 1.17 thorpej * Quoting the 21272 programmer's reference manual:
112 1.17 thorpej *
113 1.17 thorpej * <quote>
114 1.17 thorpej * 10.1.4.4 Monster Window DMA Address Translation
115 1.17 thorpej *
116 1.17 thorpej * In case of a PCI dual-address cycle command, the high-order PCI address
117 1.17 thorpej * bits <63:40> are compared to the constant value 0x0000_01 (that is, bit
118 1.17 thorpej * <40> = 1; all other bits = 0). If these bits match, a monster window hit
119 1.17 thorpej * has occurred and the low-order PCI address bits <34:0> are used unchanged
120 1.17 thorpej * as the system address bits <34:0>. PCI address bits <39:35> are ignored.
121 1.17 thorpej * The high-order 32 PCI address bits are available on b_ad<31:0> in the
122 1.17 thorpej * second cycle of a DAC, and also on b_ad<63:32> in the first cycle of a
123 1.17 thorpej * DAC if b_req64_l is asserted.
124 1.17 thorpej * </quote>
125 1.17 thorpej *
126 1.17 thorpej * This means that we can address up to 32GB of RAM using a direct-mapped
127 1.17 thorpej * 64-bit DMA tag. This leaves us possibly having to fall back on SGMAP
128 1.17 thorpej * DMA on a Titan system (those support up to 64GB of RAM), and we may have
129 1.17 thorpej * to address that with an additional large SGMAP DAC window at another
130 1.17 thorpej * time.
131 1.17 thorpej */
132 1.17 thorpej #define TSP_MONSTER_DMA_WINDOW_BASE 0x100##00000000UL
133 1.17 thorpej #define TSP_MONSTER_DMA_WINDOW_SIZE 0x008##00000000UL
134 1.17 thorpej
135 1.1 ross void
136 1.9 dsl tsp_dma_init(struct tsp_config *pcp)
137 1.1 ross {
138 1.1 ross int i;
139 1.1 ross bus_dma_tag_t t;
140 1.1 ross struct ts_pchip *pccsr = pcp->pc_csr;
141 1.1 ross bus_addr_t dwbase, dwlen, sgwbase, sgwlen, tbase;
142 1.1 ross static struct map_expected {
143 1.12 matt uint32_t base, mask, enables;
144 1.1 ross } premap[4] = {
145 1.13 tsutsui { 0x00800000, 0x00700000, WSBA_ENA | WSBA_SG },
146 1.13 tsutsui { 0x80000000, 0x3ff00000, WSBA_ENA },
147 1.13 tsutsui { 0, 0, 0 },
148 1.13 tsutsui { 0, 0, 0 }
149 1.1 ross };
150 1.1 ross
151 1.1 ross alpha_mb();
152 1.1 ross for(i = 0; i < 4; ++i) {
153 1.1 ross if (EDIFF(pccsr->tsp_wsba[i].tsg_r, premap[i].base) ||
154 1.1 ross EDIFF(pccsr->tsp_wsm[i].tsg_r, premap[i].mask))
155 1.1 ross printf("tsp%d: window %d: %lx/base %lx/mask %lx"
156 1.1 ross " reinitialized\n",
157 1.1 ross pcp->pc_pslot, i,
158 1.1 ross pccsr->tsp_wsba[i].tsg_r,
159 1.1 ross pccsr->tsp_wsm[i].tsg_r,
160 1.1 ross pccsr->tsp_tba[i].tsg_r);
161 1.1 ross pccsr->tsp_wsba[i].tsg_r = premap[i].base | premap[i].enables;
162 1.1 ross pccsr->tsp_wsm[i].tsg_r = premap[i].mask;
163 1.1 ross }
164 1.17 thorpej
165 1.17 thorpej /* Ensure the Monster Window is enabled. */
166 1.17 thorpej pccsr->tsp_pctl.tsg_r |= PCTL_MWIN;
167 1.1 ross alpha_mb();
168 1.1 ross
169 1.1 ross /*
170 1.17 thorpej * Initialize the DMA tag used for direct-mapped 64-bit DMA.
171 1.17 thorpej */
172 1.17 thorpej t = &pcp->pc_dmat64_direct;
173 1.17 thorpej t->_cookie = pcp;
174 1.17 thorpej t->_wbase = TSP_MONSTER_DMA_WINDOW_BASE;
175 1.17 thorpej t->_wsize = TSP_MONSTER_DMA_WINDOW_SIZE;
176 1.17 thorpej t->_next_window = &pcp->pc_dmat_sgmap;
177 1.17 thorpej t->_boundary = 0;
178 1.17 thorpej t->_sgmap = NULL;
179 1.17 thorpej t->_get_tag = tsp_dma_get_tag;
180 1.17 thorpej t->_dmamap_create = _bus_dmamap_create;
181 1.17 thorpej t->_dmamap_destroy = _bus_dmamap_destroy;
182 1.17 thorpej t->_dmamap_load = _bus_dmamap_load_direct;
183 1.17 thorpej t->_dmamap_load_mbuf = _bus_dmamap_load_mbuf_direct;
184 1.17 thorpej t->_dmamap_load_uio = _bus_dmamap_load_uio_direct;
185 1.17 thorpej t->_dmamap_load_raw = _bus_dmamap_load_raw_direct;
186 1.17 thorpej t->_dmamap_unload = _bus_dmamap_unload;
187 1.17 thorpej t->_dmamap_sync = _bus_dmamap_sync;
188 1.17 thorpej
189 1.17 thorpej t->_dmamem_alloc = _bus_dmamem_alloc;
190 1.17 thorpej t->_dmamem_free = _bus_dmamem_free;
191 1.17 thorpej t->_dmamem_map = _bus_dmamem_map;
192 1.17 thorpej t->_dmamem_unmap = _bus_dmamem_unmap;
193 1.17 thorpej t->_dmamem_mmap = _bus_dmamem_mmap;
194 1.17 thorpej
195 1.17 thorpej /*
196 1.1 ross * Initialize the DMA tag used for direct-mapped DMA.
197 1.1 ross */
198 1.1 ross t = &pcp->pc_dmat_direct;
199 1.1 ross t->_cookie = pcp;
200 1.1 ross t->_wbase = dwbase = WSBA_ADDR(pccsr->tsp_wsba[1].tsg_r);
201 1.1 ross t->_wsize = dwlen = WSM_LEN(pccsr->tsp_wsm[1].tsg_r);
202 1.1 ross t->_next_window = &pcp->pc_dmat_sgmap;
203 1.1 ross t->_boundary = 0;
204 1.1 ross t->_sgmap = NULL;
205 1.1 ross t->_get_tag = tsp_dma_get_tag;
206 1.1 ross t->_dmamap_create = _bus_dmamap_create;
207 1.1 ross t->_dmamap_destroy = _bus_dmamap_destroy;
208 1.1 ross t->_dmamap_load = _bus_dmamap_load_direct;
209 1.1 ross t->_dmamap_load_mbuf = _bus_dmamap_load_mbuf_direct;
210 1.1 ross t->_dmamap_load_uio = _bus_dmamap_load_uio_direct;
211 1.1 ross t->_dmamap_load_raw = _bus_dmamap_load_raw_direct;
212 1.1 ross t->_dmamap_unload = _bus_dmamap_unload;
213 1.1 ross t->_dmamap_sync = _bus_dmamap_sync;
214 1.1 ross
215 1.1 ross t->_dmamem_alloc = _bus_dmamem_alloc;
216 1.1 ross t->_dmamem_free = _bus_dmamem_free;
217 1.1 ross t->_dmamem_map = _bus_dmamem_map;
218 1.1 ross t->_dmamem_unmap = _bus_dmamem_unmap;
219 1.1 ross t->_dmamem_mmap = _bus_dmamem_mmap;
220 1.1 ross
221 1.1 ross /*
222 1.1 ross * Initialize the DMA tag used for sgmap-mapped DMA.
223 1.1 ross */
224 1.1 ross t = &pcp->pc_dmat_sgmap;
225 1.1 ross t->_cookie = pcp;
226 1.1 ross t->_wbase = sgwbase = WSBA_ADDR(pccsr->tsp_wsba[0].tsg_r);
227 1.1 ross t->_wsize = sgwlen = WSM_LEN(pccsr->tsp_wsm[0].tsg_r);
228 1.1 ross t->_next_window = NULL;
229 1.1 ross t->_boundary = 0;
230 1.1 ross t->_sgmap = &pcp->pc_sgmap;
231 1.4 thorpej t->_pfthresh = TSP_SGMAP_PFTHRESH;
232 1.1 ross t->_get_tag = tsp_dma_get_tag;
233 1.3 thorpej t->_dmamap_create = alpha_sgmap_dmamap_create;
234 1.3 thorpej t->_dmamap_destroy = alpha_sgmap_dmamap_destroy;
235 1.1 ross t->_dmamap_load = tsp_bus_dmamap_load_sgmap;
236 1.1 ross t->_dmamap_load_mbuf = tsp_bus_dmamap_load_mbuf_sgmap;
237 1.1 ross t->_dmamap_load_uio = tsp_bus_dmamap_load_uio_sgmap;
238 1.1 ross t->_dmamap_load_raw = tsp_bus_dmamap_load_raw_sgmap;
239 1.1 ross t->_dmamap_unload = tsp_bus_dmamap_unload_sgmap;
240 1.1 ross t->_dmamap_sync = _bus_dmamap_sync;
241 1.1 ross
242 1.1 ross t->_dmamem_alloc = _bus_dmamem_alloc;
243 1.1 ross t->_dmamem_free = _bus_dmamem_free;
244 1.1 ross t->_dmamem_map = _bus_dmamem_map;
245 1.1 ross t->_dmamem_unmap = _bus_dmamem_unmap;
246 1.1 ross t->_dmamem_mmap = _bus_dmamem_mmap;
247 1.1 ross
248 1.1 ross /*
249 1.1 ross * Initialize the SGMAP. Align page table to 32k in case
250 1.1 ross * window is somewhat larger than expected.
251 1.1 ross */
252 1.1 ross alpha_sgmap_init(t, &pcp->pc_sgmap, "tsp_sgmap",
253 1.12 matt sgwbase, 0, sgwlen, sizeof(uint64_t), NULL, (32*1024));
254 1.1 ross
255 1.1 ross /*
256 1.1 ross * Enable window 0 and enable SG PTE mapping.
257 1.1 ross */
258 1.1 ross alpha_mb();
259 1.1 ross pccsr->tsp_wsba[0].tsg_r |= WSBA_SG | WSBA_ENA;
260 1.1 ross alpha_mb();
261 1.1 ross
262 1.1 ross /*
263 1.13 tsutsui * Enable window 1 in direct mode.
264 1.13 tsutsui */
265 1.13 tsutsui alpha_mb();
266 1.13 tsutsui pccsr->tsp_wsba[1].tsg_r =
267 1.13 tsutsui (pccsr->tsp_wsba[1].tsg_r & ~WSBA_SG) | WSBA_ENA;
268 1.13 tsutsui alpha_mb();
269 1.13 tsutsui
270 1.13 tsutsui /*
271 1.1 ross * Check windows for sanity, especially if we later decide to
272 1.1 ross * use the firmware's initialization in some cases.
273 1.1 ross */
274 1.1 ross if ((sgwbase <= dwbase && dwbase < sgwbase + sgwlen) ||
275 1.1 ross (dwbase <= sgwbase && sgwbase < dwbase + dwlen))
276 1.1 ross panic("tsp_dma_init: overlap");
277 1.1 ross
278 1.1 ross tbase = pcp->pc_sgmap.aps_ptpa;
279 1.1 ross if (tbase & ~0x7fffffc00UL)
280 1.1 ross panic("tsp_dma_init: bad page table address");
281 1.1 ross alpha_mb();
282 1.1 ross pccsr->tsp_tba[0].tsg_r = tbase;
283 1.1 ross alpha_mb();
284 1.1 ross
285 1.1 ross tsp_tlb_invalidate(pcp);
286 1.1 ross alpha_mb();
287 1.1 ross }
288 1.1 ross
289 1.1 ross /*
290 1.1 ross * Return the bus dma tag to be used for the specified bus type.
291 1.1 ross * INTERNAL USE ONLY!
292 1.1 ross */
293 1.16 thorpej static bus_dma_tag_t
294 1.9 dsl tsp_dma_get_tag(bus_dma_tag_t t, alpha_bus_t bustype)
295 1.1 ross {
296 1.1 ross struct tsp_config *pcp = t->_cookie;
297 1.1 ross
298 1.1 ross switch (bustype) {
299 1.1 ross case ALPHA_BUS_PCI:
300 1.1 ross case ALPHA_BUS_EISA:
301 1.1 ross /*
302 1.1 ross * The direct mapped window will work for most systems,
303 1.1 ross * most of the time. When it doesn't, we chain to the sgmap
304 1.1 ross * window automatically.
305 1.1 ross */
306 1.1 ross return (&pcp->pc_dmat_direct);
307 1.1 ross
308 1.1 ross case ALPHA_BUS_ISA:
309 1.1 ross /*
310 1.1 ross * ISA doesn't have enough address bits to use
311 1.1 ross * the direct-mapped DMA window, so we must use
312 1.1 ross * SGMAPs.
313 1.1 ross */
314 1.1 ross return (&pcp->pc_dmat_sgmap);
315 1.1 ross
316 1.1 ross default:
317 1.1 ross panic("tsp_dma_get_tag: shouldn't be here, really...");
318 1.1 ross }
319 1.1 ross }
320 1.1 ross
321 1.1 ross /*
322 1.1 ross * Load a TSP SGMAP-mapped DMA map with a linear buffer.
323 1.1 ross */
324 1.16 thorpej static int
325 1.9 dsl tsp_bus_dmamap_load_sgmap(bus_dma_tag_t t, bus_dmamap_t map, void *buf, bus_size_t buflen, struct proc *p, int flags)
326 1.1 ross {
327 1.1 ross int error;
328 1.1 ross
329 1.1 ross error = pci_sgmap_pte64_load(t, map, buf, buflen, p, flags,
330 1.1 ross t->_sgmap);
331 1.1 ross if (error == 0)
332 1.1 ross tsp_tlb_invalidate(t->_cookie);
333 1.1 ross
334 1.1 ross return (error);
335 1.1 ross }
336 1.1 ross
337 1.1 ross /*
338 1.1 ross * Load a TSP SGMAP-mapped DMA map with an mbuf chain.
339 1.1 ross */
340 1.16 thorpej static int
341 1.9 dsl tsp_bus_dmamap_load_mbuf_sgmap(bus_dma_tag_t t, bus_dmamap_t map, struct mbuf *m, int flags)
342 1.1 ross {
343 1.1 ross int error;
344 1.1 ross
345 1.1 ross error = pci_sgmap_pte64_load_mbuf(t, map, m, flags, t->_sgmap);
346 1.1 ross if (error == 0)
347 1.1 ross tsp_tlb_invalidate(t->_cookie);
348 1.1 ross
349 1.1 ross return (error);
350 1.1 ross }
351 1.1 ross
352 1.1 ross /*
353 1.1 ross * Load a TSP SGMAP-mapped DMA map with a uio.
354 1.1 ross */
355 1.16 thorpej static int
356 1.9 dsl tsp_bus_dmamap_load_uio_sgmap(bus_dma_tag_t t, bus_dmamap_t map, struct uio *uio, int flags)
357 1.1 ross {
358 1.1 ross int error;
359 1.1 ross
360 1.1 ross error = pci_sgmap_pte64_load_uio(t, map, uio, flags, t->_sgmap);
361 1.1 ross if (error == 0)
362 1.1 ross tsp_tlb_invalidate(t->_cookie);
363 1.1 ross
364 1.1 ross return (error);
365 1.1 ross }
366 1.1 ross
367 1.1 ross /*
368 1.1 ross * Load a TSP SGMAP-mapped DMA map with raw memory.
369 1.1 ross */
370 1.16 thorpej static int
371 1.9 dsl tsp_bus_dmamap_load_raw_sgmap(bus_dma_tag_t t, bus_dmamap_t map, bus_dma_segment_t *segs, int nsegs, bus_size_t size, int flags)
372 1.1 ross {
373 1.1 ross int error;
374 1.1 ross
375 1.1 ross error = pci_sgmap_pte64_load_raw(t, map, segs, nsegs, size, flags,
376 1.1 ross t->_sgmap);
377 1.1 ross if (error == 0)
378 1.1 ross tsp_tlb_invalidate(t->_cookie);
379 1.1 ross
380 1.1 ross return (error);
381 1.1 ross }
382 1.1 ross
383 1.1 ross /*
384 1.1 ross * Unload a TSP DMA map.
385 1.1 ross */
386 1.16 thorpej static void
387 1.9 dsl tsp_bus_dmamap_unload_sgmap(bus_dma_tag_t t, bus_dmamap_t map)
388 1.1 ross {
389 1.1 ross
390 1.1 ross /*
391 1.1 ross * Invalidate any SGMAP page table entries used by this
392 1.1 ross * mapping.
393 1.1 ross */
394 1.1 ross pci_sgmap_pte64_unload(t, map, t->_sgmap);
395 1.1 ross tsp_tlb_invalidate(t->_cookie);
396 1.1 ross
397 1.1 ross /*
398 1.1 ross * Do the generic bits of the unload.
399 1.1 ross */
400 1.15 thorpej _bus_dmamap_unload_common(t, map);
401 1.1 ross }
402 1.1 ross
403 1.1 ross /*
404 1.1 ross * Flush the TSP scatter/gather TLB.
405 1.1 ross */
406 1.16 thorpej static void
407 1.9 dsl tsp_tlb_invalidate(struct tsp_config *pcp)
408 1.1 ross {
409 1.1 ross
410 1.1 ross alpha_mb();
411 1.13 tsutsui *pcp->pc_tlbia = 0;
412 1.1 ross alpha_mb();
413 1.1 ross }
414