summaryrefslogtreecommitdiff
path: root/linux/drm_drv.h
diff options
context:
space:
mode:
Diffstat (limited to 'linux/drm_drv.h')
-rw-r--r--linux/drm_drv.h66
1 files changed, 47 insertions, 19 deletions
diff --git a/linux/drm_drv.h b/linux/drm_drv.h
index 7f652e43..4b97e40c 100644
--- a/linux/drm_drv.h
+++ b/linux/drm_drv.h
@@ -275,12 +275,6 @@ static int DRM(setup)( drm_device_t *dev )
dev->magiclist[i].tail = NULL;
}
- dev->maplist = DRM(alloc)(sizeof(*dev->maplist),
- DRM_MEM_MAPS);
- if(dev->maplist == NULL) return -ENOMEM;
- memset(dev->maplist, 0, sizeof(*dev->maplist));
- INIT_LIST_HEAD(&dev->maplist->head);
-
dev->ctxlist = DRM(alloc)(sizeof(*dev->ctxlist),
DRM_MEM_CTXLIST);
if(dev->ctxlist == NULL) return -ENOMEM;
@@ -420,17 +414,8 @@ static int DRM(takedown)( drm_device_t *dev )
switch ( map->type ) {
case _DRM_REGISTERS:
case _DRM_FRAME_BUFFER:
-#if __REALLY_HAVE_MTRR
- if ( map->mtrr >= 0 ) {
- int retcode;
- retcode = mtrr_del( map->mtrr,
- map->offset,
- map->size );
- DRM_DEBUG( "mtrr_del=%d\n", retcode );
- }
-#endif
- DRM(ioremapfree)( map->handle, map->size, dev );
- break;
+ continue;
+
case _DRM_SHM:
vfree(map->handle);
break;
@@ -457,8 +442,6 @@ static int DRM(takedown)( drm_device_t *dev )
list_del( list );
DRM(free)(r_list, sizeof(*r_list), DRM_MEM_MAPS);
}
- DRM(free)(dev->maplist, sizeof(*dev->maplist), DRM_MEM_MAPS);
- dev->maplist = NULL;
}
#if __HAVE_DMA_QUEUE || __HAVE_MULTIPLE_DMA_QUEUES
@@ -537,6 +520,11 @@ static int drm_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
dev->pci_func = PCI_FUNC(pdev->devfn);
dev->irq = pdev->irq;
+ dev->maplist = DRM(alloc)(sizeof(*dev->maplist), DRM_MEM_MAPS);
+ if(dev->maplist == NULL) return -ENOMEM;
+ memset(dev->maplist, 0, sizeof(*dev->maplist));
+ INIT_LIST_HEAD(&dev->maplist->head);
+
/* dev_priv_size can be changed by a driver in driver_register_fns */
dev->dev_priv_size = sizeof(u32);
DRM(driver_register_fns)(dev);
@@ -677,6 +665,10 @@ static int __init drm_init( void )
*/
static void __exit drm_cleanup( drm_device_t *dev )
{
+ drm_map_t *map;
+ drm_map_list_t *r_list;
+ struct list_head *list, *list_next;
+
DRM_DEBUG( "\n" );
if (!dev) {
DRM_ERROR("cleanup called no dev\n");
@@ -685,6 +677,42 @@ static void __exit drm_cleanup( drm_device_t *dev )
DRM(takedown)(dev);
+ if( dev->maplist ) {
+ list_for_each_safe( list, list_next, &dev->maplist->head ) {
+ r_list = (drm_map_list_t *)list;
+
+ if ( ( map = r_list->map ) ) {
+ switch ( map->type ) {
+ case _DRM_REGISTERS:
+ DRM(ioremapfree)( map->handle, map->size, dev );
+ break;
+
+ case _DRM_FRAME_BUFFER:
+#if __REALLY_HAVE_MTRR
+ if ( map->mtrr >= 0 ) {
+ int retcode;
+ retcode = mtrr_del( map->mtrr,
+ map->offset,
+ map->size );
+ DRM_DEBUG( "mtrr_del=%d\n", retcode );
+ }
+#endif
+ break;
+
+ case _DRM_SHM:
+ case _DRM_AGP:
+ case _DRM_SCATTER_GATHER:
+ DRM_DEBUG("Extra maplist item\n");
+ break;
+ }
+ DRM(free)(map, sizeof(*map), DRM_MEM_MAPS);
+ }
+ list_del( list );
+ DRM(free)(r_list, sizeof(*r_list), DRM_MEM_MAPS);
+ }
+ DRM(free)(dev->maplist, sizeof(*dev->maplist), DRM_MEM_MAPS);
+ dev->maplist = NULL;
+ }
if (DRM(fb_loaded)==0)
pci_disable_device(dev->pdev);