diff options
author | Dave Airlie <airlied@starflyer.(none)> | 2005-07-10 05:27:04 -0400 |
---|---|---|
committer | Dave Airlie <airlied@linux.ie> | 2005-07-10 05:27:04 -0400 |
commit | 836cf0465c422ee6d654060edd7c620d9cf0c09c (patch) | |
tree | 622ed9a2ca774818084ffdcfbf1622ef1735bb74 /drivers/char/drm/drm_drv.c | |
parent | d01cff408057fa925b2f766fa1fd5a305fd1acbf (diff) |
drm: cleanup buffer/map code
This is a patch from DRM CVS that cleans up some code that was in CVS
that I never moved to the kernel, this patch produces the result of the
cleanups and puts it into the kernel drm.
From: Eric Anholt <anholt@freebsd.org>, Jon Smirl, Dave Airlie
Signed-off-by: Dave Airlie <airlied@linux.ie>
Diffstat (limited to 'drivers/char/drm/drm_drv.c')
-rw-r--r-- | drivers/char/drm/drm_drv.c | 68 |
1 files changed, 16 insertions, 52 deletions
diff --git a/drivers/char/drm/drm_drv.c b/drivers/char/drm/drm_drv.c index 733af58fb3ac..6ba48f346fcf 100644 --- a/drivers/char/drm/drm_drv.c +++ b/drivers/char/drm/drm_drv.c | |||
@@ -132,9 +132,7 @@ static drm_ioctl_desc_t drm_ioctls[] = { | |||
132 | int drm_takedown( drm_device_t *dev ) | 132 | int drm_takedown( drm_device_t *dev ) |
133 | { | 133 | { |
134 | drm_magic_entry_t *pt, *next; | 134 | drm_magic_entry_t *pt, *next; |
135 | drm_map_t *map; | ||
136 | drm_map_list_t *r_list; | 135 | drm_map_list_t *r_list; |
137 | struct list_head *list, *list_next; | ||
138 | drm_vma_entry_t *vma, *vma_next; | 136 | drm_vma_entry_t *vma, *vma_next; |
139 | int i; | 137 | int i; |
140 | 138 | ||
@@ -142,6 +140,7 @@ int drm_takedown( drm_device_t *dev ) | |||
142 | 140 | ||
143 | if (dev->driver->pretakedown) | 141 | if (dev->driver->pretakedown) |
144 | dev->driver->pretakedown(dev); | 142 | dev->driver->pretakedown(dev); |
143 | DRM_DEBUG("driver pretakedown completed\n"); | ||
145 | 144 | ||
146 | if (dev->unique) { | 145 | if (dev->unique) { |
147 | drm_free(dev->unique, strlen(dev->unique) + 1, DRM_MEM_DRIVER); | 146 | drm_free(dev->unique, strlen(dev->unique) + 1, DRM_MEM_DRIVER); |
@@ -184,6 +183,10 @@ int drm_takedown( drm_device_t *dev ) | |||
184 | dev->agp->acquired = 0; | 183 | dev->agp->acquired = 0; |
185 | dev->agp->enabled = 0; | 184 | dev->agp->enabled = 0; |
186 | } | 185 | } |
186 | if (drm_core_check_feature(dev, DRIVER_SG) && dev->sg) { | ||
187 | drm_sg_cleanup(dev->sg); | ||
188 | dev->sg = NULL; | ||
189 | } | ||
187 | 190 | ||
188 | /* Clear vma list (only built for debugging) */ | 191 | /* Clear vma list (only built for debugging) */ |
189 | if ( dev->vmalist ) { | 192 | if ( dev->vmalist ) { |
@@ -195,56 +198,11 @@ int drm_takedown( drm_device_t *dev ) | |||
195 | } | 198 | } |
196 | 199 | ||
197 | if( dev->maplist ) { | 200 | if( dev->maplist ) { |
198 | list_for_each_safe( list, list_next, &dev->maplist->head ) { | 201 | while (!list_empty(&dev->maplist->head)) { |
199 | r_list = (drm_map_list_t *)list; | 202 | struct list_head *list = dev->maplist->head.next; |
200 | 203 | r_list = list_entry(list, drm_map_list_t, head); | |
201 | if ( ( map = r_list->map ) ) { | 204 | drm_rmmap_locked(dev, r_list->map); |
202 | drm_dma_handle_t dmah; | 205 | } |
203 | |||
204 | switch ( map->type ) { | ||
205 | case _DRM_REGISTERS: | ||
206 | case _DRM_FRAME_BUFFER: | ||
207 | if (drm_core_has_MTRR(dev)) { | ||
208 | if ( map->mtrr >= 0 ) { | ||
209 | int retcode; | ||
210 | retcode = mtrr_del( map->mtrr, | ||
211 | map->offset, | ||
212 | map->size ); | ||
213 | DRM_DEBUG( "mtrr_del=%d\n", retcode ); | ||
214 | } | ||
215 | } | ||
216 | drm_ioremapfree( map->handle, map->size, dev ); | ||
217 | break; | ||
218 | case _DRM_SHM: | ||
219 | vfree(map->handle); | ||
220 | break; | ||
221 | |||
222 | case _DRM_AGP: | ||
223 | /* Do nothing here, because this is all | ||
224 | * handled in the AGP/GART driver. | ||
225 | */ | ||
226 | break; | ||
227 | case _DRM_SCATTER_GATHER: | ||
228 | /* Handle it */ | ||
229 | if (drm_core_check_feature(dev, DRIVER_SG) && dev->sg) { | ||
230 | drm_sg_cleanup(dev->sg); | ||
231 | dev->sg = NULL; | ||
232 | } | ||
233 | break; | ||
234 | case _DRM_CONSISTENT: | ||
235 | dmah.vaddr = map->handle; | ||
236 | dmah.busaddr = map->offset; | ||
237 | dmah.size = map->size; | ||
238 | __drm_pci_free(dev, &dmah); | ||
239 | break; | ||
240 | } | ||
241 | drm_free(map, sizeof(*map), DRM_MEM_MAPS); | ||
242 | } | ||
243 | list_del( list ); | ||
244 | drm_free(r_list, sizeof(*r_list), DRM_MEM_MAPS); | ||
245 | } | ||
246 | drm_free(dev->maplist, sizeof(*dev->maplist), DRM_MEM_MAPS); | ||
247 | dev->maplist = NULL; | ||
248 | } | 206 | } |
249 | 207 | ||
250 | if (drm_core_check_feature(dev, DRIVER_DMA_QUEUE) && dev->queuelist ) { | 208 | if (drm_core_check_feature(dev, DRIVER_DMA_QUEUE) && dev->queuelist ) { |
@@ -273,6 +231,7 @@ int drm_takedown( drm_device_t *dev ) | |||
273 | } | 231 | } |
274 | up( &dev->struct_sem ); | 232 | up( &dev->struct_sem ); |
275 | 233 | ||
234 | DRM_DEBUG("takedown completed\n"); | ||
276 | return 0; | 235 | return 0; |
277 | } | 236 | } |
278 | 237 | ||
@@ -334,6 +293,11 @@ static void drm_cleanup( drm_device_t *dev ) | |||
334 | 293 | ||
335 | drm_takedown( dev ); | 294 | drm_takedown( dev ); |
336 | 295 | ||
296 | if (dev->maplist) { | ||
297 | drm_free(dev->maplist, sizeof(*dev->maplist), DRM_MEM_MAPS); | ||
298 | dev->maplist = NULL; | ||
299 | } | ||
300 | |||
337 | drm_ctxbitmap_cleanup( dev ); | 301 | drm_ctxbitmap_cleanup( dev ); |
338 | 302 | ||
339 | if (drm_core_has_MTRR(dev) && drm_core_has_AGP(dev) && | 303 | if (drm_core_has_MTRR(dev) && drm_core_has_AGP(dev) && |