summaryrefslogtreecommitdiff
path: root/linux-core
diff options
context:
space:
mode:
Diffstat (limited to 'linux-core')
-rw-r--r--linux-core/drmP.h19
-rw-r--r--linux-core/drm_ttm.c14
2 files changed, 22 insertions, 11 deletions
diff --git a/linux-core/drmP.h b/linux-core/drmP.h
index 43589342..d7494c23 100644
--- a/linux-core/drmP.h
+++ b/linux-core/drmP.h
@@ -1363,14 +1363,23 @@ extern int drm_bo_ioctl(DRM_IOCTL_ARGS);
static __inline__ unsigned long combine_64(uint32_t lo, uint32_t hi)
{
unsigned long ret = lo;
-
- if (sizeof(ret) > 4) {
- int shift = 32;
- lo |= (hi << shift);
- }
+#if (BITS_PER_LONG == 64)
+ ret |= (hi << 32);
+#endif
return ret;
}
+static __inline__ void split_32(unsigned long val, uint32_t *lo, uint32_t *hi)
+{
+ *lo = val & 0xFFFFFFFFUL;
+#if (BITS_PER_LONG == 64)
+ *hi = val >> 32;
+#else
+ *hi = 0;
+#endif
+}
+
+
/* Inline replacements for DRM_IOREMAP macros */
static __inline__ void drm_core_ioremap(struct drm_map *map,
struct drm_device *dev)
diff --git a/linux-core/drm_ttm.c b/linux-core/drm_ttm.c
index 6e132745..ecf3e0ac 100644
--- a/linux-core/drm_ttm.c
+++ b/linux-core/drm_ttm.c
@@ -828,7 +828,7 @@ int drm_ttm_object_create(drm_device_t *dev, unsigned long size,
map->offset = ttm->lhandle;
map->type = _DRM_TTM;
map->flags = _DRM_REMOVABLE;
- map->size = size;
+ map->size = ttm->num_pages * PAGE_SIZE;
map->handle = (void *)object;
if (drm_ht_just_insert_please(&dev->map_hash, &list->hash,
@@ -877,9 +877,7 @@ int drm_ttm_ioctl(drm_file_t *priv, drm_ttm_arg_t __user *data)
mutex_unlock(&dev->struct_mutex);
return ret;
}
- arg.handle = entry->base.hash.key;
- arg.user_token = entry->map_list.user_token;
- mutex_unlock(&dev->struct_mutex);
+ atomic_inc(&entry->usage);
break;
case drm_ttm_reference:
ret = drm_user_object_ref(priv, arg.handle, drm_ttm_type, &uo);
@@ -888,8 +886,6 @@ int drm_ttm_ioctl(drm_file_t *priv, drm_ttm_arg_t __user *data)
mutex_lock(&dev->struct_mutex);
uo = drm_lookup_user_object(priv, arg.handle);
entry = drm_user_object_entry(uo, drm_ttm_object_t, base);
- arg.user_token = entry->map_list.user_token;
- mutex_unlock(&dev->struct_mutex);
break;
case drm_ttm_unreference:
return drm_user_object_unref(priv, arg.handle, drm_ttm_type);
@@ -904,6 +900,12 @@ int drm_ttm_ioctl(drm_file_t *priv, drm_ttm_arg_t __user *data)
mutex_unlock(&dev->struct_mutex);
return ret;
}
+ arg.handle = entry->base.hash.key;
+ arg.user_token = entry->map_list.user_token;
+ split_32(entry->map_list.map->size, &arg.size_lo, &arg.size_hi);
+ atomic_dec(&entry->usage);
+ mutex_unlock(&dev->struct_mutex);
+
DRM_COPY_TO_USER_IOCTL((void __user *)data, arg, sizeof(arg));
return 0;
}