diff options
Diffstat (limited to 'drivers/char/drm/drm_drv.c')
-rw-r--r-- | drivers/char/drm/drm_drv.c | 152 |
1 files changed, 78 insertions, 74 deletions
diff --git a/drivers/char/drm/drm_drv.c b/drivers/char/drm/drm_drv.c index 4dff7554eb08..c4fa5a29582b 100644 --- a/drivers/char/drm/drm_drv.c +++ b/drivers/char/drm/drm_drv.c | |||
@@ -56,66 +56,66 @@ static int drm_version(struct inode *inode, struct file *filp, | |||
56 | 56 | ||
57 | /** Ioctl table */ | 57 | /** Ioctl table */ |
58 | static drm_ioctl_desc_t drm_ioctls[] = { | 58 | static drm_ioctl_desc_t drm_ioctls[] = { |
59 | [DRM_IOCTL_NR(DRM_IOCTL_VERSION)] = {drm_version, 0, 0}, | 59 | [DRM_IOCTL_NR(DRM_IOCTL_VERSION)] = {drm_version, 0}, |
60 | [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE)] = {drm_getunique, 0, 0}, | 60 | [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE)] = {drm_getunique, 0}, |
61 | [DRM_IOCTL_NR(DRM_IOCTL_GET_MAGIC)] = {drm_getmagic, 0, 0}, | 61 | [DRM_IOCTL_NR(DRM_IOCTL_GET_MAGIC)] = {drm_getmagic, 0}, |
62 | [DRM_IOCTL_NR(DRM_IOCTL_IRQ_BUSID)] = {drm_irq_by_busid, 0, 1}, | 62 | [DRM_IOCTL_NR(DRM_IOCTL_IRQ_BUSID)] = {drm_irq_by_busid, DRM_MASTER|DRM_ROOT_ONLY}, |
63 | [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP)] = {drm_getmap, 0, 0}, | 63 | [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP)] = {drm_getmap, 0}, |
64 | [DRM_IOCTL_NR(DRM_IOCTL_GET_CLIENT)] = {drm_getclient, 0, 0}, | 64 | [DRM_IOCTL_NR(DRM_IOCTL_GET_CLIENT)] = {drm_getclient, 0}, |
65 | [DRM_IOCTL_NR(DRM_IOCTL_GET_STATS)] = {drm_getstats, 0, 0}, | 65 | [DRM_IOCTL_NR(DRM_IOCTL_GET_STATS)] = {drm_getstats, 0}, |
66 | [DRM_IOCTL_NR(DRM_IOCTL_SET_VERSION)] = {drm_setversion, 0, 1}, | 66 | [DRM_IOCTL_NR(DRM_IOCTL_SET_VERSION)] = {drm_setversion, DRM_MASTER|DRM_ROOT_ONLY}, |
67 | 67 | [DRM_IOCTL_NR(DRM_IOCTL_SET_UNIQUE)] = {drm_setunique, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | |
68 | [DRM_IOCTL_NR(DRM_IOCTL_SET_UNIQUE)] = {drm_setunique, 1, 1}, | 68 | [DRM_IOCTL_NR(DRM_IOCTL_BLOCK)] = {drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, |
69 | [DRM_IOCTL_NR(DRM_IOCTL_BLOCK)] = {drm_noop, 1, 1}, | 69 | [DRM_IOCTL_NR(DRM_IOCTL_UNBLOCK)] = {drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, |
70 | [DRM_IOCTL_NR(DRM_IOCTL_UNBLOCK)] = {drm_noop, 1, 1}, | 70 | [DRM_IOCTL_NR(DRM_IOCTL_AUTH_MAGIC)] = {drm_authmagic, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, |
71 | [DRM_IOCTL_NR(DRM_IOCTL_AUTH_MAGIC)] = {drm_authmagic, 1, 1}, | 71 | |
72 | 72 | [DRM_IOCTL_NR(DRM_IOCTL_ADD_MAP)] = {drm_addmap_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | |
73 | [DRM_IOCTL_NR(DRM_IOCTL_ADD_MAP)] = {drm_addmap_ioctl, 1, 1}, | 73 | [DRM_IOCTL_NR(DRM_IOCTL_RM_MAP)] = {drm_rmmap_ioctl, DRM_AUTH}, |
74 | [DRM_IOCTL_NR(DRM_IOCTL_RM_MAP)] = {drm_rmmap_ioctl, 1, 0}, | 74 | |
75 | 75 | [DRM_IOCTL_NR(DRM_IOCTL_SET_SAREA_CTX)] = {drm_setsareactx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | |
76 | [DRM_IOCTL_NR(DRM_IOCTL_SET_SAREA_CTX)] = {drm_setsareactx, 1, 1}, | 76 | [DRM_IOCTL_NR(DRM_IOCTL_GET_SAREA_CTX)] = {drm_getsareactx, DRM_AUTH}, |
77 | [DRM_IOCTL_NR(DRM_IOCTL_GET_SAREA_CTX)] = {drm_getsareactx, 1, 0}, | 77 | |
78 | 78 | [DRM_IOCTL_NR(DRM_IOCTL_ADD_CTX)] = {drm_addctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | |
79 | [DRM_IOCTL_NR(DRM_IOCTL_ADD_CTX)] = {drm_addctx, 1, 1}, | 79 | [DRM_IOCTL_NR(DRM_IOCTL_RM_CTX)] = {drm_rmctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, |
80 | [DRM_IOCTL_NR(DRM_IOCTL_RM_CTX)] = {drm_rmctx, 1, 1}, | 80 | [DRM_IOCTL_NR(DRM_IOCTL_MOD_CTX)] = {drm_modctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, |
81 | [DRM_IOCTL_NR(DRM_IOCTL_MOD_CTX)] = {drm_modctx, 1, 1}, | 81 | [DRM_IOCTL_NR(DRM_IOCTL_GET_CTX)] = {drm_getctx, DRM_AUTH}, |
82 | [DRM_IOCTL_NR(DRM_IOCTL_GET_CTX)] = {drm_getctx, 1, 0}, | 82 | [DRM_IOCTL_NR(DRM_IOCTL_SWITCH_CTX)] = {drm_switchctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, |
83 | [DRM_IOCTL_NR(DRM_IOCTL_SWITCH_CTX)] = {drm_switchctx, 1, 1}, | 83 | [DRM_IOCTL_NR(DRM_IOCTL_NEW_CTX)] = {drm_newctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, |
84 | [DRM_IOCTL_NR(DRM_IOCTL_NEW_CTX)] = {drm_newctx, 1, 1}, | 84 | [DRM_IOCTL_NR(DRM_IOCTL_RES_CTX)] = {drm_resctx, DRM_AUTH}, |
85 | [DRM_IOCTL_NR(DRM_IOCTL_RES_CTX)] = {drm_resctx, 1, 0}, | 85 | |
86 | 86 | [DRM_IOCTL_NR(DRM_IOCTL_ADD_DRAW)] = {drm_adddraw, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | |
87 | [DRM_IOCTL_NR(DRM_IOCTL_ADD_DRAW)] = {drm_adddraw, 1, 1}, | 87 | [DRM_IOCTL_NR(DRM_IOCTL_RM_DRAW)] = {drm_rmdraw, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, |
88 | [DRM_IOCTL_NR(DRM_IOCTL_RM_DRAW)] = {drm_rmdraw, 1, 1}, | 88 | |
89 | 89 | [DRM_IOCTL_NR(DRM_IOCTL_LOCK)] = {drm_lock, DRM_AUTH}, | |
90 | [DRM_IOCTL_NR(DRM_IOCTL_LOCK)] = {drm_lock, 1, 0}, | 90 | [DRM_IOCTL_NR(DRM_IOCTL_UNLOCK)] = {drm_unlock, DRM_AUTH}, |
91 | [DRM_IOCTL_NR(DRM_IOCTL_UNLOCK)] = {drm_unlock, 1, 0}, | 91 | |
92 | 92 | [DRM_IOCTL_NR(DRM_IOCTL_FINISH)] = {drm_noop, DRM_AUTH}, | |
93 | [DRM_IOCTL_NR(DRM_IOCTL_FINISH)] = {drm_noop, 1, 0}, | 93 | |
94 | 94 | [DRM_IOCTL_NR(DRM_IOCTL_ADD_BUFS)] = {drm_addbufs, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | |
95 | [DRM_IOCTL_NR(DRM_IOCTL_ADD_BUFS)] = {drm_addbufs, 1, 1}, | 95 | [DRM_IOCTL_NR(DRM_IOCTL_MARK_BUFS)] = {drm_markbufs, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, |
96 | [DRM_IOCTL_NR(DRM_IOCTL_MARK_BUFS)] = {drm_markbufs, 1, 1}, | 96 | [DRM_IOCTL_NR(DRM_IOCTL_INFO_BUFS)] = {drm_infobufs, DRM_AUTH}, |
97 | [DRM_IOCTL_NR(DRM_IOCTL_INFO_BUFS)] = {drm_infobufs, 1, 0}, | 97 | [DRM_IOCTL_NR(DRM_IOCTL_MAP_BUFS)] = {drm_mapbufs, DRM_AUTH}, |
98 | [DRM_IOCTL_NR(DRM_IOCTL_MAP_BUFS)] = {drm_mapbufs, 1, 0}, | 98 | [DRM_IOCTL_NR(DRM_IOCTL_FREE_BUFS)] = {drm_freebufs, DRM_AUTH}, |
99 | [DRM_IOCTL_NR(DRM_IOCTL_FREE_BUFS)] = {drm_freebufs, 1, 0}, | ||
100 | /* The DRM_IOCTL_DMA ioctl should be defined by the driver. */ | 99 | /* The DRM_IOCTL_DMA ioctl should be defined by the driver. */ |
100 | [DRM_IOCTL_NR(DRM_IOCTL_DMA)] = {NULL, DRM_AUTH}, | ||
101 | 101 | ||
102 | [DRM_IOCTL_NR(DRM_IOCTL_CONTROL)] = {drm_control, 1, 1}, | 102 | [DRM_IOCTL_NR(DRM_IOCTL_CONTROL)] = {drm_control, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, |
103 | 103 | ||
104 | #if __OS_HAS_AGP | 104 | #if __OS_HAS_AGP |
105 | [DRM_IOCTL_NR(DRM_IOCTL_AGP_ACQUIRE)] = {drm_agp_acquire_ioctl, 1, 1}, | 105 | [DRM_IOCTL_NR(DRM_IOCTL_AGP_ACQUIRE)] = {drm_agp_acquire_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, |
106 | [DRM_IOCTL_NR(DRM_IOCTL_AGP_RELEASE)] = {drm_agp_release_ioctl, 1, 1}, | 106 | [DRM_IOCTL_NR(DRM_IOCTL_AGP_RELEASE)] = {drm_agp_release_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, |
107 | [DRM_IOCTL_NR(DRM_IOCTL_AGP_ENABLE)] = {drm_agp_enable_ioctl, 1, 1}, | 107 | [DRM_IOCTL_NR(DRM_IOCTL_AGP_ENABLE)] = {drm_agp_enable_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, |
108 | [DRM_IOCTL_NR(DRM_IOCTL_AGP_INFO)] = {drm_agp_info_ioctl, 1, 0}, | 108 | [DRM_IOCTL_NR(DRM_IOCTL_AGP_INFO)] = {drm_agp_info_ioctl, DRM_AUTH}, |
109 | [DRM_IOCTL_NR(DRM_IOCTL_AGP_ALLOC)] = {drm_agp_alloc, 1, 1}, | 109 | [DRM_IOCTL_NR(DRM_IOCTL_AGP_ALLOC)] = {drm_agp_alloc_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, |
110 | [DRM_IOCTL_NR(DRM_IOCTL_AGP_FREE)] = {drm_agp_free, 1, 1}, | 110 | [DRM_IOCTL_NR(DRM_IOCTL_AGP_FREE)] = {drm_agp_free_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, |
111 | [DRM_IOCTL_NR(DRM_IOCTL_AGP_BIND)] = {drm_agp_bind, 1, 1}, | 111 | [DRM_IOCTL_NR(DRM_IOCTL_AGP_BIND)] = {drm_agp_bind_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, |
112 | [DRM_IOCTL_NR(DRM_IOCTL_AGP_UNBIND)] = {drm_agp_unbind, 1, 1}, | 112 | [DRM_IOCTL_NR(DRM_IOCTL_AGP_UNBIND)] = {drm_agp_unbind_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, |
113 | #endif | 113 | #endif |
114 | 114 | ||
115 | [DRM_IOCTL_NR(DRM_IOCTL_SG_ALLOC)] = {drm_sg_alloc, 1, 1}, | 115 | [DRM_IOCTL_NR(DRM_IOCTL_SG_ALLOC)] = {drm_sg_alloc, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, |
116 | [DRM_IOCTL_NR(DRM_IOCTL_SG_FREE)] = {drm_sg_free, 1, 1}, | 116 | [DRM_IOCTL_NR(DRM_IOCTL_SG_FREE)] = {drm_sg_free, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, |
117 | 117 | ||
118 | [DRM_IOCTL_NR(DRM_IOCTL_WAIT_VBLANK)] = {drm_wait_vblank, 0, 0}, | 118 | [DRM_IOCTL_NR(DRM_IOCTL_WAIT_VBLANK)] = {drm_wait_vblank, 0}, |
119 | }; | 119 | }; |
120 | 120 | ||
121 | #define DRIVER_IOCTL_COUNT DRM_ARRAY_SIZE( drm_ioctls ) | 121 | #define DRIVER_IOCTL_COUNT DRM_ARRAY_SIZE( drm_ioctls ) |
@@ -129,7 +129,7 @@ static drm_ioctl_desc_t drm_ioctls[] = { | |||
129 | * | 129 | * |
130 | * \sa drm_device | 130 | * \sa drm_device |
131 | */ | 131 | */ |
132 | int drm_takedown(drm_device_t * dev) | 132 | int drm_lastclose(drm_device_t * dev) |
133 | { | 133 | { |
134 | drm_magic_entry_t *pt, *next; | 134 | drm_magic_entry_t *pt, *next; |
135 | drm_map_list_t *r_list; | 135 | drm_map_list_t *r_list; |
@@ -138,9 +138,9 @@ int drm_takedown(drm_device_t * dev) | |||
138 | 138 | ||
139 | DRM_DEBUG("\n"); | 139 | DRM_DEBUG("\n"); |
140 | 140 | ||
141 | if (dev->driver->pretakedown) | 141 | if (dev->driver->lastclose) |
142 | dev->driver->pretakedown(dev); | 142 | dev->driver->lastclose(dev); |
143 | DRM_DEBUG("driver pretakedown completed\n"); | 143 | DRM_DEBUG("driver lastclose completed\n"); |
144 | 144 | ||
145 | if (dev->unique) { | 145 | if (dev->unique) { |
146 | drm_free(dev->unique, strlen(dev->unique) + 1, DRM_MEM_DRIVER); | 146 | drm_free(dev->unique, strlen(dev->unique) + 1, DRM_MEM_DRIVER); |
@@ -233,7 +233,7 @@ int drm_takedown(drm_device_t * dev) | |||
233 | } | 233 | } |
234 | up(&dev->struct_sem); | 234 | up(&dev->struct_sem); |
235 | 235 | ||
236 | DRM_DEBUG("takedown completed\n"); | 236 | DRM_DEBUG("lastclose completed\n"); |
237 | return 0; | 237 | return 0; |
238 | } | 238 | } |
239 | 239 | ||
@@ -281,7 +281,7 @@ EXPORT_SYMBOL(drm_init); | |||
281 | /** | 281 | /** |
282 | * Called via cleanup_module() at module unload time. | 282 | * Called via cleanup_module() at module unload time. |
283 | * | 283 | * |
284 | * Cleans up all DRM device, calling takedown(). | 284 | * Cleans up all DRM device, calling drm_lastclose(). |
285 | * | 285 | * |
286 | * \sa drm_init | 286 | * \sa drm_init |
287 | */ | 287 | */ |
@@ -294,7 +294,7 @@ static void drm_cleanup(drm_device_t * dev) | |||
294 | return; | 294 | return; |
295 | } | 295 | } |
296 | 296 | ||
297 | drm_takedown(dev); | 297 | drm_lastclose(dev); |
298 | 298 | ||
299 | if (dev->maplist) { | 299 | if (dev->maplist) { |
300 | drm_free(dev->maplist, sizeof(*dev->maplist), DRM_MEM_MAPS); | 300 | drm_free(dev->maplist, sizeof(*dev->maplist), DRM_MEM_MAPS); |
@@ -317,8 +317,8 @@ static void drm_cleanup(drm_device_t * dev) | |||
317 | dev->agp = NULL; | 317 | dev->agp = NULL; |
318 | } | 318 | } |
319 | 319 | ||
320 | if (dev->driver->postcleanup) | 320 | if (dev->driver->unload) |
321 | dev->driver->postcleanup(dev); | 321 | dev->driver->unload(dev); |
322 | 322 | ||
323 | drm_put_head(&dev->primary); | 323 | drm_put_head(&dev->primary); |
324 | if (drm_put_dev(dev)) | 324 | if (drm_put_dev(dev)) |
@@ -342,12 +342,12 @@ void drm_exit(struct drm_driver *driver) | |||
342 | if (head->dev->driver != driver) | 342 | if (head->dev->driver != driver) |
343 | continue; | 343 | continue; |
344 | dev = head->dev; | 344 | dev = head->dev; |
345 | } | 345 | if (dev) { |
346 | if (dev) { | 346 | /* release the pci driver */ |
347 | /* release the pci driver */ | 347 | if (dev->pdev) |
348 | if (dev->pdev) | 348 | pci_dev_put(dev->pdev); |
349 | pci_dev_put(dev->pdev); | 349 | drm_cleanup(dev); |
350 | drm_cleanup(dev); | 350 | } |
351 | } | 351 | } |
352 | DRM_INFO("Module unloaded\n"); | 352 | DRM_INFO("Module unloaded\n"); |
353 | } | 353 | } |
@@ -432,14 +432,17 @@ static int drm_version(struct inode *inode, struct file *filp, | |||
432 | drm_device_t *dev = priv->head->dev; | 432 | drm_device_t *dev = priv->head->dev; |
433 | drm_version_t __user *argp = (void __user *)arg; | 433 | drm_version_t __user *argp = (void __user *)arg; |
434 | drm_version_t version; | 434 | drm_version_t version; |
435 | int ret; | 435 | int len; |
436 | 436 | ||
437 | if (copy_from_user(&version, argp, sizeof(version))) | 437 | if (copy_from_user(&version, argp, sizeof(version))) |
438 | return -EFAULT; | 438 | return -EFAULT; |
439 | 439 | ||
440 | /* version is a required function to return the personality module version */ | 440 | version.version_major = dev->driver->major; |
441 | if ((ret = dev->driver->version(&version))) | 441 | version.version_minor = dev->driver->minor; |
442 | return ret; | 442 | version.version_patchlevel = dev->driver->patchlevel; |
443 | DRM_COPY(version.name, dev->driver->name); | ||
444 | DRM_COPY(version.date, dev->driver->date); | ||
445 | DRM_COPY(version.desc, dev->driver->desc); | ||
443 | 446 | ||
444 | if (copy_to_user(argp, &version, sizeof(version))) | 447 | if (copy_to_user(argp, &version, sizeof(version))) |
445 | return -EFAULT; | 448 | return -EFAULT; |
@@ -493,8 +496,9 @@ int drm_ioctl(struct inode *inode, struct file *filp, | |||
493 | if (!func) { | 496 | if (!func) { |
494 | DRM_DEBUG("no function\n"); | 497 | DRM_DEBUG("no function\n"); |
495 | retcode = -EINVAL; | 498 | retcode = -EINVAL; |
496 | } else if ((ioctl->root_only && !capable(CAP_SYS_ADMIN)) || | 499 | } else if (((ioctl->flags & DRM_ROOT_ONLY) && !capable(CAP_SYS_ADMIN)) || |
497 | (ioctl->auth_needed && !priv->authenticated)) { | 500 | ((ioctl->flags & DRM_AUTH) && !priv->authenticated) || |
501 | ((ioctl->flags & DRM_MASTER) && !priv->master)) { | ||
498 | retcode = -EACCES; | 502 | retcode = -EACCES; |
499 | } else { | 503 | } else { |
500 | retcode = func(inode, filp, cmd, arg); | 504 | retcode = func(inode, filp, cmd, arg); |