I decided my loop was too fancy so I just deleted it and replaced it
with a simple flag. If the driver uses permanent maps the flag gets
set and addmaps from user space have no effect. If the driver doesn't
use permanent maps everything should work the old way.

If this looks good I can check it in.
===== linux/drm_bufs.h 1.8 vs edited =====
--- 1.8/linux/drm_bufs.h	Sun Sep  5 21:22:06 2004
+++ edited/linux/drm_bufs.h	Mon Sep  6 20:07:59 2004
@@ -59,6 +59,8 @@
 	return order;
 }
 
+static int permanent_maps = 0;
+
  /**
  * Adjusts the memory offset to its absolute value according to the mapping
  * type.  Adds the map to the map list drm_device::maplist. Adds MTRR's where
@@ -116,7 +118,8 @@
 	down(&dev->struct_sem);
 	list_add(&list->head, &dev->maplist->head);
 	up(&dev->struct_sem);
-	
+
+	permanent_maps = 1;	
 	DRM_DEBUG("finished\n");
 
 	return 0;
@@ -175,20 +178,10 @@
 	switch ( map->type ) {
 	case _DRM_REGISTERS:
 	case _DRM_FRAME_BUFFER: {
-		/* after all the drivers switch to permanent mapping this should just return an error */
-        	struct list_head *_list;
-
-		/* if map already exists, return the existing one instead of creating a new one */
-		list_for_each( _list, &dev->maplist->head ) {
-			drm_map_list_t *_entry = list_entry( _list, drm_map_list_t, head );
-			if ( _entry->map && _entry->map->type == map->type ) {
-				DRM(free)( map, sizeof(*map), DRM_MEM_MAPS );
-				map = _entry->map;
-				DRM_DEBUG( "Found existing: offset = 0x%08lx, size = 0x%08lx, type = %d\n",
-					map->offset, map->size, map->type );
-				goto found_it;
-			}
-		}
+		/* When using permanent maps ignore the request */
+		if (permanent_maps)
+			goto ignore_it;
+			
 #if !defined(__sparc__) && !defined(__alpha__) && !defined(__ia64__)
 		if ( map->offset + map->size < map->offset ||
 		     map->offset < virt_to_phys(high_memory) ) {
@@ -264,7 +257,7 @@
 	down(&dev->struct_sem);
 	list_add(&list->head, &dev->maplist->head);
  	up(&dev->struct_sem);
-found_it:
+ignore_it:
 	if ( copy_to_user( argp, map, sizeof(*map) ) )
 		return -EFAULT;
 	if ( map->type != _DRM_SHM ) {

Reply via email to