summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Smirl <jonsmirl@yahoo.com>2004-09-08 01:49:06 +0000
committerJon Smirl <jonsmirl@yahoo.com>2004-09-08 01:49:06 +0000
commit3bf785c9126a0bbc38b794096dbbddab5682c251 (patch)
treed4cd23b65798ccaf0751595d9db895f21e517a4a
parentb0c73b7fcb3f2504f2ab747bae75a98112071491 (diff)
Adjust permanent mapping code to account for more than one framebuffer map
-rw-r--r--linux-core/drm_bufs.c26
-rw-r--r--linux/drm_bufs.h26
2 files changed, 34 insertions, 18 deletions
diff --git a/linux-core/drm_bufs.c b/linux-core/drm_bufs.c
index 94fdaff1..6c1ec4c8 100644
--- a/linux-core/drm_bufs.c
+++ b/linux-core/drm_bufs.c
@@ -59,6 +59,7 @@ int DRM(order)( unsigned long size )
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
@@ -117,6 +118,7 @@ int DRM(initmap)( drm_device_t *dev, unsigned int offset, unsigned int size, int
list_add(&list->head, &dev->maplist->head);
up(&dev->struct_sem);
+ permanent_maps = 1;
DRM_DEBUG("finished\n");
return 0;
@@ -178,16 +180,22 @@ int DRM(addmap)( struct inode *inode, struct file *filp,
/* 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;
+ /* If permanent maps are implemented, maps must match */
+ if (permanent_maps) {
+ 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 &&
+ _entry->map->offset == map->offset &&
+ _entry->map->size == map->size ) {
+ 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;
+ }
}
+ /* addmap didn't match an existing permanent map, that's an error */
+ return -EINVAL;
}
#if !defined(__sparc__) && !defined(__alpha__) && !defined(__ia64__)
if ( map->offset + map->size < map->offset ||
diff --git a/linux/drm_bufs.h b/linux/drm_bufs.h
index 94fdaff1..6c1ec4c8 100644
--- a/linux/drm_bufs.h
+++ b/linux/drm_bufs.h
@@ -59,6 +59,7 @@ int DRM(order)( unsigned long size )
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
@@ -117,6 +118,7 @@ int DRM(initmap)( drm_device_t *dev, unsigned int offset, unsigned int size, int
list_add(&list->head, &dev->maplist->head);
up(&dev->struct_sem);
+ permanent_maps = 1;
DRM_DEBUG("finished\n");
return 0;
@@ -178,16 +180,22 @@ int DRM(addmap)( struct inode *inode, struct file *filp,
/* 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;
+ /* If permanent maps are implemented, maps must match */
+ if (permanent_maps) {
+ 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 &&
+ _entry->map->offset == map->offset &&
+ _entry->map->size == map->size ) {
+ 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;
+ }
}
+ /* addmap didn't match an existing permanent map, that's an error */
+ return -EINVAL;
}
#if !defined(__sparc__) && !defined(__alpha__) && !defined(__ia64__)
if ( map->offset + map->size < map->offset ||