diff options
Diffstat (limited to 'drivers/char/drm/drm_bufs.c')
-rw-r--r-- | drivers/char/drm/drm_bufs.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/drivers/char/drm/drm_bufs.c b/drivers/char/drm/drm_bufs.c index 4113bcba67fe..3407380b865a 100644 --- a/drivers/char/drm/drm_bufs.c +++ b/drivers/char/drm/drm_bufs.c | |||
@@ -60,6 +60,15 @@ int drm_order( unsigned long size ) | |||
60 | } | 60 | } |
61 | EXPORT_SYMBOL(drm_order); | 61 | EXPORT_SYMBOL(drm_order); |
62 | 62 | ||
63 | #ifdef CONFIG_COMPAT | ||
64 | /* | ||
65 | * Used to allocate 32-bit handles for _DRM_SHM regions | ||
66 | * The 0x10000000 value is chosen to be out of the way of | ||
67 | * FB/register and GART physical addresses. | ||
68 | */ | ||
69 | static unsigned int map32_handle = 0x10000000; | ||
70 | #endif | ||
71 | |||
63 | /** | 72 | /** |
64 | * Ioctl to specify a range of memory that is available for mapping by a non-root process. | 73 | * Ioctl to specify a range of memory that is available for mapping by a non-root process. |
65 | * | 74 | * |
@@ -187,16 +196,18 @@ int drm_addmap( struct inode *inode, struct file *filp, | |||
187 | 196 | ||
188 | down(&dev->struct_sem); | 197 | down(&dev->struct_sem); |
189 | list_add(&list->head, &dev->maplist->head); | 198 | list_add(&list->head, &dev->maplist->head); |
199 | #ifdef CONFIG_COMPAT | ||
200 | /* Assign a 32-bit handle for _DRM_SHM mappings */ | ||
201 | /* We do it here so that dev->struct_sem protects the increment */ | ||
202 | if (map->type == _DRM_SHM) | ||
203 | map->offset = map32_handle += PAGE_SIZE; | ||
204 | #endif | ||
190 | up(&dev->struct_sem); | 205 | up(&dev->struct_sem); |
191 | 206 | ||
192 | if ( copy_to_user( argp, map, sizeof(*map) ) ) | 207 | if ( copy_to_user( argp, map, sizeof(*map) ) ) |
193 | return -EFAULT; | 208 | return -EFAULT; |
194 | if ( map->type != _DRM_SHM ) { | 209 | if (copy_to_user(&argp->handle, &map->offset, sizeof(map->offset))) |
195 | if ( copy_to_user( &argp->handle, | 210 | return -EFAULT; |
196 | &map->offset, | ||
197 | sizeof(map->offset) ) ) | ||
198 | return -EFAULT; | ||
199 | } | ||
200 | return 0; | 211 | return 0; |
201 | } | 212 | } |
202 | 213 | ||
@@ -240,7 +251,7 @@ int drm_rmmap(struct inode *inode, struct file *filp, | |||
240 | r_list = list_entry(list, drm_map_list_t, head); | 251 | r_list = list_entry(list, drm_map_list_t, head); |
241 | 252 | ||
242 | if(r_list->map && | 253 | if(r_list->map && |
243 | r_list->map->handle == request.handle && | 254 | r_list->map->offset == (unsigned long) request.handle && |
244 | r_list->map->flags & _DRM_REMOVABLE) break; | 255 | r_list->map->flags & _DRM_REMOVABLE) break; |
245 | } | 256 | } |
246 | 257 | ||