aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/drm/drm_context.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/drm/drm_context.c')
-rw-r--r--drivers/char/drm/drm_context.c97
1 files changed, 48 insertions, 49 deletions
diff --git a/drivers/char/drm/drm_context.c b/drivers/char/drm/drm_context.c
index 83094c73da67..7fc055adec25 100644
--- a/drivers/char/drm/drm_context.c
+++ b/drivers/char/drm/drm_context.c
@@ -56,7 +56,7 @@
56 * in drm_device::context_sareas, while holding the drm_device::struct_mutex 56 * in drm_device::context_sareas, while holding the drm_device::struct_mutex
57 * lock. 57 * lock.
58 */ 58 */
59void drm_ctxbitmap_free(drm_device_t * dev, int ctx_handle) 59void drm_ctxbitmap_free(struct drm_device * dev, int ctx_handle)
60{ 60{
61 if (ctx_handle < 0) 61 if (ctx_handle < 0)
62 goto failed; 62 goto failed;
@@ -85,7 +85,7 @@ void drm_ctxbitmap_free(drm_device_t * dev, int ctx_handle)
85 * drm_device::context_sareas to accommodate the new entry while holding the 85 * drm_device::context_sareas to accommodate the new entry while holding the
86 * drm_device::struct_mutex lock. 86 * drm_device::struct_mutex lock.
87 */ 87 */
88static int drm_ctxbitmap_next(drm_device_t * dev) 88static int drm_ctxbitmap_next(struct drm_device * dev)
89{ 89{
90 int bit; 90 int bit;
91 91
@@ -100,7 +100,7 @@ static int drm_ctxbitmap_next(drm_device_t * dev)
100 if ((bit + 1) > dev->max_context) { 100 if ((bit + 1) > dev->max_context) {
101 dev->max_context = (bit + 1); 101 dev->max_context = (bit + 1);
102 if (dev->context_sareas) { 102 if (dev->context_sareas) {
103 drm_map_t **ctx_sareas; 103 struct drm_map **ctx_sareas;
104 104
105 ctx_sareas = drm_realloc(dev->context_sareas, 105 ctx_sareas = drm_realloc(dev->context_sareas,
106 (dev->max_context - 106 (dev->max_context -
@@ -147,7 +147,7 @@ static int drm_ctxbitmap_next(drm_device_t * dev)
147 * Allocates and initialize drm_device::ctx_bitmap and drm_device::context_sareas, while holding 147 * Allocates and initialize drm_device::ctx_bitmap and drm_device::context_sareas, while holding
148 * the drm_device::struct_mutex lock. 148 * the drm_device::struct_mutex lock.
149 */ 149 */
150int drm_ctxbitmap_init(drm_device_t * dev) 150int drm_ctxbitmap_init(struct drm_device * dev)
151{ 151{
152 int i; 152 int i;
153 int temp; 153 int temp;
@@ -180,7 +180,7 @@ int drm_ctxbitmap_init(drm_device_t * dev)
180 * Frees drm_device::ctx_bitmap and drm_device::context_sareas, while holding 180 * Frees drm_device::ctx_bitmap and drm_device::context_sareas, while holding
181 * the drm_device::struct_mutex lock. 181 * the drm_device::struct_mutex lock.
182 */ 182 */
183void drm_ctxbitmap_cleanup(drm_device_t * dev) 183void drm_ctxbitmap_cleanup(struct drm_device * dev)
184{ 184{
185 mutex_lock(&dev->struct_mutex); 185 mutex_lock(&dev->struct_mutex);
186 if (dev->context_sareas) 186 if (dev->context_sareas)
@@ -212,12 +212,12 @@ void drm_ctxbitmap_cleanup(drm_device_t * dev)
212int drm_getsareactx(struct inode *inode, struct file *filp, 212int drm_getsareactx(struct inode *inode, struct file *filp,
213 unsigned int cmd, unsigned long arg) 213 unsigned int cmd, unsigned long arg)
214{ 214{
215 drm_file_t *priv = filp->private_data; 215 struct drm_file *priv = filp->private_data;
216 drm_device_t *dev = priv->head->dev; 216 struct drm_device *dev = priv->head->dev;
217 drm_ctx_priv_map_t __user *argp = (void __user *)arg; 217 struct drm_ctx_priv_map __user *argp = (void __user *)arg;
218 drm_ctx_priv_map_t request; 218 struct drm_ctx_priv_map request;
219 drm_map_t *map; 219 struct drm_map *map;
220 drm_map_list_t *_entry; 220 struct drm_map_list *_entry;
221 221
222 if (copy_from_user(&request, argp, sizeof(request))) 222 if (copy_from_user(&request, argp, sizeof(request)))
223 return -EFAULT; 223 return -EFAULT;
@@ -233,7 +233,7 @@ int drm_getsareactx(struct inode *inode, struct file *filp,
233 mutex_unlock(&dev->struct_mutex); 233 mutex_unlock(&dev->struct_mutex);
234 234
235 request.handle = NULL; 235 request.handle = NULL;
236 list_for_each_entry(_entry, &dev->maplist->head, head) { 236 list_for_each_entry(_entry, &dev->maplist, head) {
237 if (_entry->map == map) { 237 if (_entry->map == map) {
238 request.handle = 238 request.handle =
239 (void *)(unsigned long)_entry->user_token; 239 (void *)(unsigned long)_entry->user_token;
@@ -263,20 +263,19 @@ int drm_getsareactx(struct inode *inode, struct file *filp,
263int drm_setsareactx(struct inode *inode, struct file *filp, 263int drm_setsareactx(struct inode *inode, struct file *filp,
264 unsigned int cmd, unsigned long arg) 264 unsigned int cmd, unsigned long arg)
265{ 265{
266 drm_file_t *priv = filp->private_data; 266 struct drm_file *priv = filp->private_data;
267 drm_device_t *dev = priv->head->dev; 267 struct drm_device *dev = priv->head->dev;
268 drm_ctx_priv_map_t request; 268 struct drm_ctx_priv_map request;
269 drm_map_t *map = NULL; 269 struct drm_map *map = NULL;
270 drm_map_list_t *r_list = NULL; 270 struct drm_map_list *r_list = NULL;
271 struct list_head *list;
272 271
273 if (copy_from_user(&request, 272 if (copy_from_user(&request,
274 (drm_ctx_priv_map_t __user *) arg, sizeof(request))) 273 (struct drm_ctx_priv_map __user *) arg,
274 sizeof(request)))
275 return -EFAULT; 275 return -EFAULT;
276 276
277 mutex_lock(&dev->struct_mutex); 277 mutex_lock(&dev->struct_mutex);
278 list_for_each(list, &dev->maplist->head) { 278 list_for_each_entry(r_list, &dev->maplist, head) {
279 r_list = list_entry(list, drm_map_list_t, head);
280 if (r_list->map 279 if (r_list->map
281 && r_list->user_token == (unsigned long)request.handle) 280 && r_list->user_token == (unsigned long)request.handle)
282 goto found; 281 goto found;
@@ -314,7 +313,7 @@ int drm_setsareactx(struct inode *inode, struct file *filp,
314 * 313 *
315 * Attempt to set drm_device::context_flag. 314 * Attempt to set drm_device::context_flag.
316 */ 315 */
317static int drm_context_switch(drm_device_t * dev, int old, int new) 316static int drm_context_switch(struct drm_device * dev, int old, int new)
318{ 317{
319 if (test_and_set_bit(0, &dev->context_flag)) { 318 if (test_and_set_bit(0, &dev->context_flag)) {
320 DRM_ERROR("Reentering -- FIXME\n"); 319 DRM_ERROR("Reentering -- FIXME\n");
@@ -342,7 +341,7 @@ static int drm_context_switch(drm_device_t * dev, int old, int new)
342 * hardware lock is held, clears the drm_device::context_flag and wakes up 341 * hardware lock is held, clears the drm_device::context_flag and wakes up
343 * drm_device::context_wait. 342 * drm_device::context_wait.
344 */ 343 */
345static int drm_context_switch_complete(drm_device_t * dev, int new) 344static int drm_context_switch_complete(struct drm_device * dev, int new)
346{ 345{
347 dev->last_context = new; /* PRE/POST: This is the _only_ writer. */ 346 dev->last_context = new; /* PRE/POST: This is the _only_ writer. */
348 dev->last_switch = jiffies; 347 dev->last_switch = jiffies;
@@ -372,9 +371,9 @@ static int drm_context_switch_complete(drm_device_t * dev, int new)
372int drm_resctx(struct inode *inode, struct file *filp, 371int drm_resctx(struct inode *inode, struct file *filp,
373 unsigned int cmd, unsigned long arg) 372 unsigned int cmd, unsigned long arg)
374{ 373{
375 drm_ctx_res_t res; 374 struct drm_ctx_res res;
376 drm_ctx_t __user *argp = (void __user *)arg; 375 struct drm_ctx_res __user *argp = (void __user *)arg;
377 drm_ctx_t ctx; 376 struct drm_ctx ctx;
378 int i; 377 int i;
379 378
380 if (copy_from_user(&res, argp, sizeof(res))) 379 if (copy_from_user(&res, argp, sizeof(res)))
@@ -409,11 +408,11 @@ int drm_resctx(struct inode *inode, struct file *filp,
409int drm_addctx(struct inode *inode, struct file *filp, 408int drm_addctx(struct inode *inode, struct file *filp,
410 unsigned int cmd, unsigned long arg) 409 unsigned int cmd, unsigned long arg)
411{ 410{
412 drm_file_t *priv = filp->private_data; 411 struct drm_file *priv = filp->private_data;
413 drm_device_t *dev = priv->head->dev; 412 struct drm_device *dev = priv->head->dev;
414 drm_ctx_list_t *ctx_entry; 413 struct drm_ctx_list *ctx_entry;
415 drm_ctx_t __user *argp = (void __user *)arg; 414 struct drm_ctx __user *argp = (void __user *)arg;
416 drm_ctx_t ctx; 415 struct drm_ctx ctx;
417 416
418 if (copy_from_user(&ctx, argp, sizeof(ctx))) 417 if (copy_from_user(&ctx, argp, sizeof(ctx)))
419 return -EFAULT; 418 return -EFAULT;
@@ -449,7 +448,7 @@ int drm_addctx(struct inode *inode, struct file *filp,
449 ctx_entry->tag = priv; 448 ctx_entry->tag = priv;
450 449
451 mutex_lock(&dev->ctxlist_mutex); 450 mutex_lock(&dev->ctxlist_mutex);
452 list_add(&ctx_entry->head, &dev->ctxlist->head); 451 list_add(&ctx_entry->head, &dev->ctxlist);
453 ++dev->ctx_count; 452 ++dev->ctx_count;
454 mutex_unlock(&dev->ctxlist_mutex); 453 mutex_unlock(&dev->ctxlist_mutex);
455 454
@@ -477,8 +476,8 @@ int drm_modctx(struct inode *inode, struct file *filp,
477int drm_getctx(struct inode *inode, struct file *filp, 476int drm_getctx(struct inode *inode, struct file *filp,
478 unsigned int cmd, unsigned long arg) 477 unsigned int cmd, unsigned long arg)
479{ 478{
480 drm_ctx_t __user *argp = (void __user *)arg; 479 struct drm_ctx __user *argp = (void __user *)arg;
481 drm_ctx_t ctx; 480 struct drm_ctx ctx;
482 481
483 if (copy_from_user(&ctx, argp, sizeof(ctx))) 482 if (copy_from_user(&ctx, argp, sizeof(ctx)))
484 return -EFAULT; 483 return -EFAULT;
@@ -505,11 +504,11 @@ int drm_getctx(struct inode *inode, struct file *filp,
505int drm_switchctx(struct inode *inode, struct file *filp, 504int drm_switchctx(struct inode *inode, struct file *filp,
506 unsigned int cmd, unsigned long arg) 505 unsigned int cmd, unsigned long arg)
507{ 506{
508 drm_file_t *priv = filp->private_data; 507 struct drm_file *priv = filp->private_data;
509 drm_device_t *dev = priv->head->dev; 508 struct drm_device *dev = priv->head->dev;
510 drm_ctx_t ctx; 509 struct drm_ctx ctx;
511 510
512 if (copy_from_user(&ctx, (drm_ctx_t __user *) arg, sizeof(ctx))) 511 if (copy_from_user(&ctx, (struct drm_ctx __user *) arg, sizeof(ctx)))
513 return -EFAULT; 512 return -EFAULT;
514 513
515 DRM_DEBUG("%d\n", ctx.handle); 514 DRM_DEBUG("%d\n", ctx.handle);
@@ -530,11 +529,11 @@ int drm_switchctx(struct inode *inode, struct file *filp,
530int drm_newctx(struct inode *inode, struct file *filp, 529int drm_newctx(struct inode *inode, struct file *filp,
531 unsigned int cmd, unsigned long arg) 530 unsigned int cmd, unsigned long arg)
532{ 531{
533 drm_file_t *priv = filp->private_data; 532 struct drm_file *priv = filp->private_data;
534 drm_device_t *dev = priv->head->dev; 533 struct drm_device *dev = priv->head->dev;
535 drm_ctx_t ctx; 534 struct drm_ctx ctx;
536 535
537 if (copy_from_user(&ctx, (drm_ctx_t __user *) arg, sizeof(ctx))) 536 if (copy_from_user(&ctx, (struct drm_ctx __user *) arg, sizeof(ctx)))
538 return -EFAULT; 537 return -EFAULT;
539 538
540 DRM_DEBUG("%d\n", ctx.handle); 539 DRM_DEBUG("%d\n", ctx.handle);
@@ -557,11 +556,11 @@ int drm_newctx(struct inode *inode, struct file *filp,
557int drm_rmctx(struct inode *inode, struct file *filp, 556int drm_rmctx(struct inode *inode, struct file *filp,
558 unsigned int cmd, unsigned long arg) 557 unsigned int cmd, unsigned long arg)
559{ 558{
560 drm_file_t *priv = filp->private_data; 559 struct drm_file *priv = filp->private_data;
561 drm_device_t *dev = priv->head->dev; 560 struct drm_device *dev = priv->head->dev;
562 drm_ctx_t ctx; 561 struct drm_ctx ctx;
563 562
564 if (copy_from_user(&ctx, (drm_ctx_t __user *) arg, sizeof(ctx))) 563 if (copy_from_user(&ctx, (struct drm_ctx __user *) arg, sizeof(ctx)))
565 return -EFAULT; 564 return -EFAULT;
566 565
567 DRM_DEBUG("%d\n", ctx.handle); 566 DRM_DEBUG("%d\n", ctx.handle);
@@ -575,10 +574,10 @@ int drm_rmctx(struct inode *inode, struct file *filp,
575 } 574 }
576 575
577 mutex_lock(&dev->ctxlist_mutex); 576 mutex_lock(&dev->ctxlist_mutex);
578 if (!list_empty(&dev->ctxlist->head)) { 577 if (!list_empty(&dev->ctxlist)) {
579 drm_ctx_list_t *pos, *n; 578 struct drm_ctx_list *pos, *n;
580 579
581 list_for_each_entry_safe(pos, n, &dev->ctxlist->head, head) { 580 list_for_each_entry_safe(pos, n, &dev->ctxlist, head) {
582 if (pos->handle == ctx.handle) { 581 if (pos->handle == ctx.handle) {
583 list_del(&pos->head); 582 list_del(&pos->head);
584 drm_free(pos, sizeof(*pos), DRM_MEM_CTXLIST); 583 drm_free(pos, sizeof(*pos), DRM_MEM_CTXLIST);