drm_memory.c revision 1.1.2.7 1 1.1.2.1 riastrad /* $NetBSD: drm_memory.c,v 1.1.2.7 2013/07/24 03:14:15 riastradh Exp $ */
2 1.1.2.1 riastrad
3 1.1.2.1 riastrad /*-
4 1.1.2.1 riastrad * Copyright (c) 2013 The NetBSD Foundation, Inc.
5 1.1.2.1 riastrad * All rights reserved.
6 1.1.2.1 riastrad *
7 1.1.2.1 riastrad * This code is derived from software contributed to The NetBSD Foundation
8 1.1.2.1 riastrad * by Taylor R. Campbell.
9 1.1.2.1 riastrad *
10 1.1.2.1 riastrad * Redistribution and use in source and binary forms, with or without
11 1.1.2.1 riastrad * modification, are permitted provided that the following conditions
12 1.1.2.1 riastrad * are met:
13 1.1.2.1 riastrad * 1. Redistributions of source code must retain the above copyright
14 1.1.2.1 riastrad * notice, this list of conditions and the following disclaimer.
15 1.1.2.1 riastrad * 2. Redistributions in binary form must reproduce the above copyright
16 1.1.2.1 riastrad * notice, this list of conditions and the following disclaimer in the
17 1.1.2.1 riastrad * documentation and/or other materials provided with the distribution.
18 1.1.2.1 riastrad *
19 1.1.2.1 riastrad * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 1.1.2.1 riastrad * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 1.1.2.1 riastrad * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 1.1.2.1 riastrad * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 1.1.2.1 riastrad * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 1.1.2.1 riastrad * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 1.1.2.1 riastrad * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 1.1.2.1 riastrad * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 1.1.2.1 riastrad * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 1.1.2.1 riastrad * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 1.1.2.1 riastrad * POSSIBILITY OF SUCH DAMAGE.
30 1.1.2.1 riastrad */
31 1.1.2.1 riastrad
32 1.1.2.1 riastrad #include <sys/cdefs.h>
33 1.1.2.1 riastrad __KERNEL_RCSID(0, "$NetBSD: drm_memory.c,v 1.1.2.7 2013/07/24 03:14:15 riastradh Exp $");
34 1.1.2.1 riastrad
35 1.1.2.1 riastrad #ifdef _KERNEL_OPT
36 1.1.2.1 riastrad #include "agp_i810.h"
37 1.1.2.1 riastrad #include "genfb.h"
38 1.1.2.1 riastrad #else
39 1.1.2.1 riastrad #define NAGP_I810 1 /* XXX WTF? */
40 1.1.2.1 riastrad #define NGENFB 0 /* XXX WTF? */
41 1.1.2.1 riastrad #endif
42 1.1.2.1 riastrad
43 1.1.2.1 riastrad #include <sys/bus.h>
44 1.1.2.1 riastrad
45 1.1.2.1 riastrad #if NAGP_I810 > 0
46 1.1.2.1 riastrad /* XXX include order botch -- shouldn't need to include pcivar.h */
47 1.1.2.1 riastrad #include <dev/pci/pcivar.h>
48 1.1.2.1 riastrad #include <dev/pci/agpvar.h>
49 1.1.2.1 riastrad #endif
50 1.1.2.1 riastrad
51 1.1.2.1 riastrad #if NGENFB > 0
52 1.1.2.1 riastrad #include <dev/wsfb/genfbvar.h>
53 1.1.2.1 riastrad #endif
54 1.1.2.1 riastrad
55 1.1.2.1 riastrad #include <drm/drmP.h>
56 1.1.2.1 riastrad
57 1.1.2.1 riastrad /*
58 1.1.2.1 riastrad * XXX drm_bus_borrow is a horrible kludge!
59 1.1.2.1 riastrad */
60 1.1.2.1 riastrad static bool
61 1.1.2.1 riastrad drm_bus_borrow(bus_addr_t base, bus_space_handle_t *handlep)
62 1.1.2.1 riastrad {
63 1.1.2.1 riastrad
64 1.1.2.1 riastrad #if NAGP_I810 > 0
65 1.1.2.1 riastrad if (agp_i810_borrow(base, handlep))
66 1.1.2.1 riastrad return true;
67 1.1.2.1 riastrad #endif
68 1.1.2.1 riastrad
69 1.1.2.1 riastrad #if NGENFB > 0
70 1.1.2.1 riastrad if (genfb_borrow(base, handlep))
71 1.1.2.1 riastrad return true;
72 1.1.2.1 riastrad #endif
73 1.1.2.1 riastrad
74 1.1.2.1 riastrad return false;
75 1.1.2.1 riastrad }
76 1.1.2.1 riastrad
77 1.1.2.1 riastrad void *
78 1.1.2.1 riastrad drm_ioremap(struct drm_device *dev, struct drm_local_map *map)
79 1.1.2.1 riastrad {
80 1.1.2.1 riastrad const bus_space_tag_t bst = dev->bst;
81 1.1.2.1 riastrad unsigned int unit;
82 1.1.2.1 riastrad int error;
83 1.1.2.1 riastrad
84 1.1.2.1 riastrad /*
85 1.1.2.1 riastrad * Search dev's bus maps for a match.
86 1.1.2.1 riastrad */
87 1.1.2.1 riastrad for (unit = 0; unit < dev->bus_nmaps; unit++) {
88 1.1.2.1 riastrad struct drm_bus_map *const bm = &dev->bus_maps[unit];
89 1.1.2.1 riastrad
90 1.1.2.1 riastrad /* Reject maps starting after the request. */
91 1.1.2.1 riastrad if (map->offset < bm->bm_base)
92 1.1.2.1 riastrad continue;
93 1.1.2.1 riastrad
94 1.1.2.1 riastrad /* Reject maps smaller than the request. */
95 1.1.2.1 riastrad if (bm->bm_size < map->size)
96 1.1.2.1 riastrad continue;
97 1.1.2.1 riastrad
98 1.1.2.1 riastrad /*
99 1.1.2.1 riastrad * Reject maps that the request doesn't fit in. (Make
100 1.1.2.1 riastrad * sure to avoid integer overflow.)
101 1.1.2.1 riastrad */
102 1.1.2.1 riastrad if ((bm->bm_size - map->size) <
103 1.1.2.1 riastrad (map->offset - bm->bm_base))
104 1.1.2.1 riastrad continue;
105 1.1.2.1 riastrad
106 1.1.2.1 riastrad /* Has it been mapped yet? If not, map it. */
107 1.1.2.1 riastrad if (bm->bm_mapped == 0) {
108 1.1.2.1 riastrad KASSERT(ISSET(bm->bm_flags, BUS_SPACE_MAP_LINEAR));
109 1.1.2.1 riastrad error = bus_space_map(bst, bm->bm_base,
110 1.1.2.1 riastrad bm->bm_size, bm->bm_flags, &bm->bm_bsh);
111 1.1.2.1 riastrad if (error) {
112 1.1.2.3 riastrad if (drm_bus_borrow(map->offset,
113 1.1.2.3 riastrad &map->lm_data.bus_space.bsh)) {
114 1.1.2.3 riastrad map->lm_data.bus_space.bus_map = NULL;
115 1.1.2.1 riastrad goto win;
116 1.1.2.1 riastrad }
117 1.1.2.1 riastrad return NULL;
118 1.1.2.1 riastrad }
119 1.1.2.1 riastrad }
120 1.1.2.1 riastrad
121 1.1.2.1 riastrad /* Mark it used and make a subregion just for the request. */
122 1.1.2.5 riastrad if (bm->bm_mapped == UINT_MAX)
123 1.1.2.5 riastrad return NULL;
124 1.1.2.1 riastrad bm->bm_mapped++;
125 1.1.2.1 riastrad error = bus_space_subregion(bst, bm->bm_bsh,
126 1.1.2.3 riastrad map->offset - bm->bm_base, map->size,
127 1.1.2.3 riastrad &map->lm_data.bus_space.bsh);
128 1.1.2.1 riastrad if (error) {
129 1.1.2.1 riastrad /*
130 1.1.2.1 riastrad * Back out: unmark it and, if nobody else was
131 1.1.2.1 riastrad * using it, unmap it.
132 1.1.2.1 riastrad */
133 1.1.2.5 riastrad KASSERT(bm->bm_mapped > 0);
134 1.1.2.1 riastrad if (--bm->bm_mapped == 0)
135 1.1.2.1 riastrad bus_space_unmap(bst, bm->bm_bsh,
136 1.1.2.1 riastrad bm->bm_size);
137 1.1.2.1 riastrad return NULL;
138 1.1.2.1 riastrad }
139 1.1.2.1 riastrad
140 1.1.2.1 riastrad /* Got it! */
141 1.1.2.3 riastrad map->lm_data.bus_space.bus_map = bm;
142 1.1.2.1 riastrad goto win;
143 1.1.2.1 riastrad }
144 1.1.2.1 riastrad
145 1.1.2.1 riastrad /*
146 1.1.2.1 riastrad * No dice. Try mapping it directly ourselves.
147 1.1.2.1 riastrad *
148 1.1.2.1 riastrad * XXX Is this sensible? What prevents us from clobbering some
149 1.1.2.1 riastrad * existing map? And what does this have to do with agp?
150 1.1.2.1 riastrad */
151 1.1.2.1 riastrad for (unit = 0; unit < dev->agp_nmaps; unit++) {
152 1.1.2.1 riastrad struct drm_bus_map *const bm = &dev->agp_maps[unit];
153 1.1.2.1 riastrad
154 1.1.2.1 riastrad /* Is this one allocated? */
155 1.1.2.1 riastrad if (bm->bm_mapped > 0) {
156 1.1.2.1 riastrad /*
157 1.1.2.1 riastrad * Make sure it has the same base.
158 1.1.2.1 riastrad *
159 1.1.2.1 riastrad * XXX Why must it be the same base? Can't we
160 1.1.2.1 riastrad * subregion here too?
161 1.1.2.1 riastrad */
162 1.1.2.1 riastrad if (bm->bm_base != map->offset)
163 1.1.2.1 riastrad continue;
164 1.1.2.1 riastrad
165 1.1.2.1 riastrad /* Make sure it's big enough. */
166 1.1.2.1 riastrad if (bm->bm_size < map->size)
167 1.1.2.1 riastrad continue;
168 1.1.2.1 riastrad
169 1.1.2.1 riastrad /* Mark it used and return it. */
170 1.1.2.5 riastrad if (bm->bm_mapped == UINT_MAX)
171 1.1.2.5 riastrad return NULL;
172 1.1.2.1 riastrad bm->bm_mapped++;
173 1.1.2.1 riastrad
174 1.1.2.1 riastrad /* XXX size is an input/output parameter too...? */
175 1.1.2.1 riastrad map->size = bm->bm_size;
176 1.1.2.1 riastrad
177 1.1.2.3 riastrad map->lm_data.bus_space.bsh = bm->bm_bsh;
178 1.1.2.3 riastrad map->lm_data.bus_space.bus_map = bm;
179 1.1.2.1 riastrad goto win;
180 1.1.2.1 riastrad } else {
181 1.1.2.1 riastrad const int flags = BUS_SPACE_MAP_PREFETCHABLE |
182 1.1.2.1 riastrad BUS_SPACE_MAP_LINEAR;
183 1.1.2.1 riastrad
184 1.1.2.1 riastrad /* Try mapping the request. */
185 1.1.2.1 riastrad error = bus_space_map(bst, map->offset, map->size,
186 1.1.2.1 riastrad flags, &bm->bm_bsh);
187 1.1.2.1 riastrad if (error)
188 1.1.2.1 riastrad return NULL; /* XXX Why not continue? */
189 1.1.2.1 riastrad
190 1.1.2.1 riastrad /* Got it. Allocate this bus map. */
191 1.1.2.5 riastrad KASSERT(bm->bm_mapped == 0);
192 1.1.2.1 riastrad bm->bm_mapped++;
193 1.1.2.1 riastrad bm->bm_base = map->offset;
194 1.1.2.1 riastrad bm->bm_size = map->size;
195 1.1.2.1 riastrad bm->bm_flags = flags; /* XXX What for? */
196 1.1.2.1 riastrad
197 1.1.2.3 riastrad map->lm_data.bus_space.bsh = bm->bm_bsh;
198 1.1.2.3 riastrad map->lm_data.bus_space.bus_map = bm;
199 1.1.2.1 riastrad goto win;
200 1.1.2.1 riastrad }
201 1.1.2.1 riastrad }
202 1.1.2.1 riastrad
203 1.1.2.1 riastrad return NULL;
204 1.1.2.1 riastrad
205 1.1.2.1 riastrad win:
206 1.1.2.3 riastrad map->lm_data.bus_space.bst = bst;
207 1.1.2.3 riastrad return bus_space_vaddr(bst, map->lm_data.bus_space.bsh);
208 1.1.2.1 riastrad }
209 1.1.2.1 riastrad
210 1.1.2.1 riastrad void
211 1.1.2.1 riastrad drm_iounmap(struct drm_device *dev, struct drm_local_map *map)
212 1.1.2.1 riastrad {
213 1.1.2.1 riastrad const bus_space_tag_t bst = dev->bst;
214 1.1.2.3 riastrad struct drm_bus_map *const bm = map->lm_data.bus_space.bus_map;
215 1.1.2.1 riastrad
216 1.1.2.1 riastrad /*
217 1.1.2.1 riastrad * bm may be null if we have committed the horrible deed of
218 1.1.2.1 riastrad * borrowing from agp_i810 or genfb.
219 1.1.2.1 riastrad */
220 1.1.2.1 riastrad if (bm != NULL) {
221 1.1.2.1 riastrad KASSERT(bm->bm_mapped > 0);
222 1.1.2.5 riastrad if (--bm->bm_mapped == 0)
223 1.1.2.1 riastrad bus_space_unmap(bst, bm->bm_bsh, bm->bm_size);
224 1.1.2.1 riastrad }
225 1.1.2.1 riastrad }
226 1.1.2.2 riastrad
227 1.1.2.2 riastrad /*
228 1.1.2.2 riastrad * Allocate a drm dma handle, allocate memory fit for DMA, and map it.
229 1.1.2.2 riastrad *
230 1.1.2.2 riastrad * XXX This is called drm_pci_alloc for hysterical raisins; it is not
231 1.1.2.2 riastrad * specific to PCI.
232 1.1.2.2 riastrad *
233 1.1.2.2 riastrad * XXX For now, we use non-blocking allocations because this is called
234 1.1.2.2 riastrad * by ioctls with the drm global mutex held.
235 1.1.2.2 riastrad *
236 1.1.2.2 riastrad * XXX Error information is lost because this returns NULL on failure,
237 1.1.2.2 riastrad * not even an error embedded in a pointer.
238 1.1.2.2 riastrad */
239 1.1.2.2 riastrad struct drm_dma_handle *
240 1.1.2.2 riastrad drm_pci_alloc(struct drm_device *dev, size_t size, size_t align)
241 1.1.2.2 riastrad {
242 1.1.2.2 riastrad int nsegs;
243 1.1.2.2 riastrad int error;
244 1.1.2.2 riastrad
245 1.1.2.2 riastrad /*
246 1.1.2.2 riastrad * Allocate a drm_dma_handle record.
247 1.1.2.2 riastrad */
248 1.1.2.4 riastrad struct drm_dma_handle *const dmah = kmem_alloc(sizeof(*dmah),
249 1.1.2.4 riastrad KM_NOSLEEP);
250 1.1.2.2 riastrad if (dmah == NULL) {
251 1.1.2.2 riastrad error = -ENOMEM;
252 1.1.2.2 riastrad goto out;
253 1.1.2.2 riastrad }
254 1.1.2.2 riastrad dmah->dmah_tag = dev->dmat;
255 1.1.2.2 riastrad
256 1.1.2.2 riastrad /*
257 1.1.2.2 riastrad * Allocate the requested amount of DMA-safe memory.
258 1.1.2.2 riastrad */
259 1.1.2.2 riastrad /* XXX errno NetBSD->Linux */
260 1.1.2.2 riastrad error = -bus_dmamem_alloc(dmah->dmah_tag, size, align, 0,
261 1.1.2.2 riastrad &dmah->dmah_seg, 1, &nsegs, BUS_DMA_NOWAIT);
262 1.1.2.2 riastrad if (error)
263 1.1.2.2 riastrad goto fail0;
264 1.1.2.2 riastrad KASSERT(nsegs == 1);
265 1.1.2.2 riastrad
266 1.1.2.2 riastrad /*
267 1.1.2.2 riastrad * XXX Old drm passed BUS_DMA_NOWAIT below but BUS_DMA_WAITOK
268 1.1.2.2 riastrad * above. WTF?
269 1.1.2.2 riastrad */
270 1.1.2.2 riastrad
271 1.1.2.2 riastrad /*
272 1.1.2.2 riastrad * Map the DMA-safe memory into kernel virtual address space.
273 1.1.2.2 riastrad */
274 1.1.2.2 riastrad /* XXX errno NetBSD->Linux */
275 1.1.2.2 riastrad error = -bus_dmamem_map(dmah->dmah_tag, &dmah->dmah_seg, 1, size,
276 1.1.2.2 riastrad &dmah->vaddr,
277 1.1.2.2 riastrad (BUS_DMA_NOWAIT | BUS_DMA_COHERENT | BUS_DMA_NOCACHE));
278 1.1.2.2 riastrad if (error)
279 1.1.2.2 riastrad goto fail1;
280 1.1.2.2 riastrad dmah->size = size;
281 1.1.2.2 riastrad
282 1.1.2.2 riastrad /*
283 1.1.2.2 riastrad * Create a map for DMA transfers.
284 1.1.2.2 riastrad */
285 1.1.2.2 riastrad /* XXX errno NetBSD->Linux */
286 1.1.2.2 riastrad error = -bus_dmamap_create(dmah->dmah_tag, size, 1, size, 0,
287 1.1.2.2 riastrad BUS_DMA_NOWAIT, &dmah->dmah_map);
288 1.1.2.2 riastrad if (error)
289 1.1.2.2 riastrad goto fail2;
290 1.1.2.2 riastrad
291 1.1.2.2 riastrad /*
292 1.1.2.2 riastrad * Load the kva buffer into the map for DMA transfers.
293 1.1.2.2 riastrad */
294 1.1.2.2 riastrad /* XXX errno NetBSD->Linux */
295 1.1.2.2 riastrad error = -bus_dmamap_load(dmah->dmah_tag, dmah->dmah_map, dmah->vaddr,
296 1.1.2.2 riastrad size, NULL, (BUS_DMA_NOWAIT | BUS_DMA_NOCACHE));
297 1.1.2.2 riastrad if (error)
298 1.1.2.2 riastrad goto fail3;
299 1.1.2.2 riastrad
300 1.1.2.2 riastrad /* Record the bus address for convenient reference. */
301 1.1.2.2 riastrad dmah->busaddr = dmah->dmah_map->dm_segs[0].ds_addr;
302 1.1.2.2 riastrad
303 1.1.2.2 riastrad /* Zero the DMA buffer. XXX Yikes! Is this necessary? */
304 1.1.2.2 riastrad memset(dmah->vaddr, 0, size);
305 1.1.2.2 riastrad
306 1.1.2.2 riastrad /* Success! */
307 1.1.2.2 riastrad return dmah;
308 1.1.2.2 riastrad
309 1.1.2.2 riastrad fail3: bus_dmamap_destroy(dmah->dmah_tag, dmah->dmah_map);
310 1.1.2.2 riastrad fail2: bus_dmamem_unmap(dmah->dmah_tag, dmah->vaddr, dmah->size);
311 1.1.2.2 riastrad fail1: bus_dmamem_free(dmah->dmah_tag, &dmah->dmah_seg, 1);
312 1.1.2.2 riastrad fail0: dmah->dmah_tag = NULL; /* XXX paranoia */
313 1.1.2.4 riastrad kmem_free(dmah, sizeof(*dmah));
314 1.1.2.2 riastrad out: DRM_DEBUG("drm_pci_alloc failed: %d\n", error);
315 1.1.2.2 riastrad return NULL;
316 1.1.2.2 riastrad }
317 1.1.2.2 riastrad
318 1.1.2.2 riastrad /*
319 1.1.2.4 riastrad * Release the bus DMA mappings and memory in dmah, and deallocate it.
320 1.1.2.2 riastrad */
321 1.1.2.2 riastrad void
322 1.1.2.4 riastrad drm_pci_free(struct drm_device *dev, struct drm_dma_handle *dmah)
323 1.1.2.2 riastrad {
324 1.1.2.2 riastrad
325 1.1.2.2 riastrad bus_dmamap_unload(dmah->dmah_tag, dmah->dmah_map);
326 1.1.2.2 riastrad bus_dmamap_destroy(dmah->dmah_tag, dmah->dmah_map);
327 1.1.2.2 riastrad bus_dmamem_unmap(dmah->dmah_tag, dmah->vaddr, dmah->size);
328 1.1.2.2 riastrad bus_dmamem_free(dmah->dmah_tag, &dmah->dmah_seg, 1);
329 1.1.2.2 riastrad dmah->dmah_tag = NULL; /* XXX paranoia */
330 1.1.2.4 riastrad kmem_free(dmah, sizeof(*dmah));
331 1.1.2.2 riastrad }
332 1.1.2.6 riastrad
333 1.1.2.6 riastrad /*
334 1.1.2.6 riastrad * Make sure the DMA-safe memory allocated for dev lies between
335 1.1.2.6 riastrad * min_addr and max_addr. Can be used multiple times to restrict the
336 1.1.2.6 riastrad * bounds further, but never to expand the bounds again.
337 1.1.2.6 riastrad *
338 1.1.2.6 riastrad * XXX Caller must guarantee nobody has used the tag yet,
339 1.1.2.6 riastrad * i.e. allocated any DMA memory.
340 1.1.2.6 riastrad */
341 1.1.2.6 riastrad int
342 1.1.2.6 riastrad drm_limit_dma_space(struct drm_device *dev, resource_size_t min_addr,
343 1.1.2.6 riastrad resource_size_t max_addr)
344 1.1.2.6 riastrad {
345 1.1.2.6 riastrad int error;
346 1.1.2.6 riastrad
347 1.1.2.6 riastrad KASSERT(min_addr <= max_addr);
348 1.1.2.6 riastrad
349 1.1.2.6 riastrad /*
350 1.1.2.6 riastrad * Limit it further if we have already limited it, and destroy
351 1.1.2.6 riastrad * the old subregion DMA tag.
352 1.1.2.6 riastrad */
353 1.1.2.6 riastrad if (dev->dmat_subregion_p) {
354 1.1.2.6 riastrad min_addr = MAX(min_addr, dev->dmat_subregion_min);
355 1.1.2.6 riastrad max_addr = MIN(max_addr, dev->dmat_subregion_max);
356 1.1.2.6 riastrad bus_dmatag_destroy(dev->dmat);
357 1.1.2.6 riastrad }
358 1.1.2.6 riastrad
359 1.1.2.6 riastrad /*
360 1.1.2.6 riastrad * Create a DMA tag for a subregion from the bus's DMA tag. If
361 1.1.2.6 riastrad * that fails, restore dev->dmat to the whole region so that we
362 1.1.2.6 riastrad * need not worry about dev->dmat being uninitialized (not that
363 1.1.2.6 riastrad * the caller should try to allocate DMA-safe memory on failure
364 1.1.2.6 riastrad * anyway, but...paranoia).
365 1.1.2.6 riastrad */
366 1.1.2.6 riastrad error = bus_dmatag_subregion(dev->bus_dmat, min_addr, max_addr,
367 1.1.2.6 riastrad &dev->dmat, BUS_DMA_WAITOK);
368 1.1.2.6 riastrad if (error) {
369 1.1.2.6 riastrad dev->dmat = dev->bus_dmat;
370 1.1.2.6 riastrad return error;
371 1.1.2.6 riastrad }
372 1.1.2.6 riastrad
373 1.1.2.6 riastrad /*
374 1.1.2.6 riastrad * Remember that we have a subregion tag so that we know to
375 1.1.2.6 riastrad * destroy it later, and record the bounds in case we need to
376 1.1.2.6 riastrad * limit them again.
377 1.1.2.6 riastrad */
378 1.1.2.6 riastrad dev->dmat_subregion_p = true;
379 1.1.2.6 riastrad dev->dmat_subregion_min = min_addr;
380 1.1.2.6 riastrad dev->dmat_subregion_max = max_addr;
381 1.1.2.6 riastrad
382 1.1.2.6 riastrad /* Success! */
383 1.1.2.6 riastrad return 0;
384 1.1.2.6 riastrad }
385