From 459b234d79daaa8a003da9ea48775a5587d5ba2a Mon Sep 17 00:00:00 2001 From: Thomas Hellstrom Date: Wed, 23 Aug 2006 11:31:10 +0200 Subject: Allow multiple addMaps with the same 32-bit map offset. (Reported by Dave Airlie) --- linux-core/drm_bufs.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'linux-core/drm_bufs.c') diff --git a/linux-core/drm_bufs.c b/linux-core/drm_bufs.c index 2eeb401d..13b0b174 100644 --- a/linux-core/drm_bufs.c +++ b/linux-core/drm_bufs.c @@ -78,14 +78,16 @@ int drm_map_handle(drm_device_t *dev, drm_hash_item_t *hash, #error Unsupported long size. Neither 64 nor 32 bits. #endif - if (use_hashed_handle) { - return drm_ht_just_insert_please(&dev->map_hash, hash, - user_token, 32 - PAGE_SHIFT - 3, - PAGE_SHIFT, DRM_MAP_HASH_OFFSET); - } else { + if (!use_hashed_handle) { + int ret; hash->key = user_token; - return drm_ht_insert_item(&dev->map_hash, hash); + ret = drm_ht_insert_item(&dev->map_hash, hash); + if (!ret) + return 0; } + return drm_ht_just_insert_please(&dev->map_hash, hash, + user_token, 32 - PAGE_SHIFT - 3, + PAGE_SHIFT, DRM_MAP_HASH_OFFSET); } /** -- cgit v1.2.3 From ea5709997329a6c425261dcc454cf7dd97a81167 Mon Sep 17 00:00:00 2001 From: Thomas Hellstrom Date: Wed, 23 Aug 2006 13:49:13 +0200 Subject: Fix previous commit: Only fall back to hashed handles when there is a duplicate handle error. Not for other errors. --- linux-core/drm_bufs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'linux-core/drm_bufs.c') diff --git a/linux-core/drm_bufs.c b/linux-core/drm_bufs.c index 13b0b174..1d9c0386 100644 --- a/linux-core/drm_bufs.c +++ b/linux-core/drm_bufs.c @@ -82,8 +82,8 @@ int drm_map_handle(drm_device_t *dev, drm_hash_item_t *hash, int ret; hash->key = user_token; ret = drm_ht_insert_item(&dev->map_hash, hash); - if (!ret) - return 0; + if (ret != -EINVAL) + return ret; } return drm_ht_just_insert_please(&dev->map_hash, hash, user_token, 32 - PAGE_SHIFT - 3, -- cgit v1.2.3 From 60ddaaf2e07b57997bcbaef0576005b52130bd24 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sat, 19 Aug 2006 16:56:03 +1000 Subject: add static function, and remove bad attributions --- linux-core/drm_bufs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'linux-core/drm_bufs.c') diff --git a/linux-core/drm_bufs.c b/linux-core/drm_bufs.c index 1d9c0386..c2c84597 100644 --- a/linux-core/drm_bufs.c +++ b/linux-core/drm_bufs.c @@ -65,8 +65,8 @@ static drm_map_list_t *drm_find_matching_map(drm_device_t *dev, return NULL; } -int drm_map_handle(drm_device_t *dev, drm_hash_item_t *hash, - unsigned long user_token, int hashed_handle) +static int drm_map_handle(drm_device_t *dev, drm_hash_item_t *hash, + unsigned long user_token, int hashed_handle) { int use_hashed_handle; -- cgit v1.2.3 From 9b984b34e99f694e10251e15bc2ec1bc844dcca4 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sat, 19 Aug 2006 17:59:18 +1000 Subject: drm: lots of small cleanups and whitespace issues fixed up remove a mach64 warning, align a lot of things from linux kernel --- linux-core/drm_bufs.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'linux-core/drm_bufs.c') diff --git a/linux-core/drm_bufs.c b/linux-core/drm_bufs.c index c2c84597..abd7c829 100644 --- a/linux-core/drm_bufs.c +++ b/linux-core/drm_bufs.c @@ -292,13 +292,13 @@ static int drm_addmap_core(drm_device_t * dev, unsigned int offset, user_token = (map->type == _DRM_SHM) ? (unsigned long) map->handle : map->offset; - ret = drm_map_handle(dev, &list->hash, user_token, 0); + ret = drm_map_handle(dev, &list->hash, user_token, 0); if (ret) { - drm_free(map, sizeof(*map), DRM_MEM_MAPS); - drm_free(list, sizeof(*list), DRM_MEM_MAPS); - mutex_unlock(&dev->struct_mutex); - return ret; + drm_free(map, sizeof(*map), DRM_MEM_MAPS); + drm_free(list, sizeof(*list), DRM_MEM_MAPS); + mutex_unlock(&dev->struct_mutex); + return ret; } list->user_token = list->hash.key; @@ -386,7 +386,7 @@ int drm_rmmap_locked(drm_device_t *dev, drm_local_map_t *map) if (r_list->map == map) { list_del(list); - drm_ht_remove_key(&dev->map_hash, r_list->user_token); + drm_ht_remove_key(&dev->map_hash, r_list->user_token); drm_free(list, sizeof(*list), DRM_MEM_MAPS); break; } -- cgit v1.2.3