diff options
author | Dave Airlie <airlied@linux.ie> | 2007-05-25 15:01:51 -0400 |
---|---|---|
committer | Dave Airlie <airlied@linux.ie> | 2007-07-10 21:58:02 -0400 |
commit | bd1b331fae2813d9f03ceee649296f02edc0b893 (patch) | |
tree | 6139f72ebae88c332c754745f3d98cbe794ae4de /drivers/char/drm | |
parent | 4eb6bf6bfb580afaf1e1a1d30cba17a078530cf4 (diff) |
drm: cleanup use of Linux list handling macros
This makes the drms use of the list handling macros a lot cleaner
and more along the lines of how they should be used and uses them
in some more places.
Signed-off-by: Dave Airlie <airlied@linux.ie>
Diffstat (limited to 'drivers/char/drm')
-rw-r--r-- | drivers/char/drm/drmP.h | 32 | ||||
-rw-r--r-- | drivers/char/drm/drm_agpsupport.c | 28 | ||||
-rw-r--r-- | drivers/char/drm/drm_bufs.c | 43 | ||||
-rw-r--r-- | drivers/char/drm/drm_context.c | 12 | ||||
-rw-r--r-- | drivers/char/drm/drm_drv.c | 36 | ||||
-rw-r--r-- | drivers/char/drm/drm_fops.c | 47 | ||||
-rw-r--r-- | drivers/char/drm/drm_ioctl.c | 14 | ||||
-rw-r--r-- | drivers/char/drm/drm_irq.c | 20 | ||||
-rw-r--r-- | drivers/char/drm/drm_memory.c | 2 | ||||
-rw-r--r-- | drivers/char/drm/drm_os_linux.h | 2 | ||||
-rw-r--r-- | drivers/char/drm/drm_proc.c | 14 | ||||
-rw-r--r-- | drivers/char/drm/drm_stub.c | 8 | ||||
-rw-r--r-- | drivers/char/drm/drm_vm.c | 34 | ||||
-rw-r--r-- | drivers/char/drm/i810_dma.c | 6 | ||||
-rw-r--r-- | drivers/char/drm/i830_dma.c | 5 | ||||
-rw-r--r-- | drivers/char/drm/mga_dma.c | 2 | ||||
-rw-r--r-- | drivers/char/drm/sis_mm.c | 2 | ||||
-rw-r--r-- | drivers/char/drm/via_verifier.c | 4 |
18 files changed, 116 insertions, 195 deletions
diff --git a/drivers/char/drm/drmP.h b/drivers/char/drm/drmP.h index d494315752a2..22779582ee5b 100644 --- a/drivers/char/drm/drmP.h +++ b/drivers/char/drm/drmP.h | |||
@@ -279,20 +279,15 @@ typedef struct drm_devstate { | |||
279 | } drm_devstate_t; | 279 | } drm_devstate_t; |
280 | 280 | ||
281 | typedef struct drm_magic_entry { | 281 | typedef struct drm_magic_entry { |
282 | drm_hash_item_t hash_item; | ||
283 | struct list_head head; | 282 | struct list_head head; |
283 | drm_hash_item_t hash_item; | ||
284 | struct drm_file *priv; | 284 | struct drm_file *priv; |
285 | struct drm_magic_entry *next; | 285 | struct drm_magic_entry *next; |
286 | } drm_magic_entry_t; | 286 | } drm_magic_entry_t; |
287 | 287 | ||
288 | typedef struct drm_magic_head { | ||
289 | struct drm_magic_entry *head; | ||
290 | struct drm_magic_entry *tail; | ||
291 | } drm_magic_head_t; | ||
292 | |||
293 | typedef struct drm_vma_entry { | 288 | typedef struct drm_vma_entry { |
289 | struct list_head head; | ||
294 | struct vm_area_struct *vma; | 290 | struct vm_area_struct *vma; |
295 | struct drm_vma_entry *next; | ||
296 | pid_t pid; | 291 | pid_t pid; |
297 | } drm_vma_entry_t; | 292 | } drm_vma_entry_t; |
298 | 293 | ||
@@ -379,8 +374,7 @@ typedef struct drm_file { | |||
379 | uid_t uid; | 374 | uid_t uid; |
380 | drm_magic_t magic; | 375 | drm_magic_t magic; |
381 | unsigned long ioctl_count; | 376 | unsigned long ioctl_count; |
382 | struct drm_file *next; | 377 | struct list_head lhead; |
383 | struct drm_file *prev; | ||
384 | struct drm_head *head; | 378 | struct drm_head *head; |
385 | int remove_auth_on_close; | 379 | int remove_auth_on_close; |
386 | unsigned long lock_count; | 380 | unsigned long lock_count; |
@@ -449,8 +443,7 @@ typedef struct drm_agp_mem { | |||
449 | DRM_AGP_MEM *memory; | 443 | DRM_AGP_MEM *memory; |
450 | unsigned long bound; /**< address */ | 444 | unsigned long bound; /**< address */ |
451 | int pages; | 445 | int pages; |
452 | struct drm_agp_mem *prev; /**< previous entry */ | 446 | struct list_head head; |
453 | struct drm_agp_mem *next; /**< next entry */ | ||
454 | } drm_agp_mem_t; | 447 | } drm_agp_mem_t; |
455 | 448 | ||
456 | /** | 449 | /** |
@@ -460,7 +453,7 @@ typedef struct drm_agp_mem { | |||
460 | */ | 453 | */ |
461 | typedef struct drm_agp_head { | 454 | typedef struct drm_agp_head { |
462 | DRM_AGP_KERN agp_info; /**< AGP device information */ | 455 | DRM_AGP_KERN agp_info; /**< AGP device information */ |
463 | drm_agp_mem_t *memory; /**< memory entries */ | 456 | struct list_head memory; |
464 | unsigned long mode; /**< AGP mode */ | 457 | unsigned long mode; /**< AGP mode */ |
465 | struct agp_bridge_data *bridge; | 458 | struct agp_bridge_data *bridge; |
466 | int enabled; /**< whether the AGP bus as been enabled */ | 459 | int enabled; /**< whether the AGP bus as been enabled */ |
@@ -669,28 +662,27 @@ typedef struct drm_device { | |||
669 | 662 | ||
670 | /** \name Authentication */ | 663 | /** \name Authentication */ |
671 | /*@{ */ | 664 | /*@{ */ |
672 | drm_file_t *file_first; /**< file list head */ | 665 | struct list_head filelist; |
673 | drm_file_t *file_last; /**< file list tail */ | ||
674 | drm_open_hash_t magiclist; /**< magic hash table */ | 666 | drm_open_hash_t magiclist; /**< magic hash table */ |
675 | struct list_head magicfree; | 667 | struct list_head magicfree; |
676 | /*@} */ | 668 | /*@} */ |
677 | 669 | ||
678 | /** \name Memory management */ | 670 | /** \name Memory management */ |
679 | /*@{ */ | 671 | /*@{ */ |
680 | drm_map_list_t *maplist; /**< Linked list of regions */ | 672 | struct list_head maplist; /**< Linked list of regions */ |
681 | int map_count; /**< Number of mappable regions */ | 673 | int map_count; /**< Number of mappable regions */ |
682 | drm_open_hash_t map_hash; /**< User token hash table for maps */ | 674 | drm_open_hash_t map_hash; /**< User token hash table for maps */ |
683 | 675 | ||
684 | /** \name Context handle management */ | 676 | /** \name Context handle management */ |
685 | /*@{ */ | 677 | /*@{ */ |
686 | drm_ctx_list_t *ctxlist; /**< Linked list of context handles */ | 678 | struct list_head ctxlist; /**< Linked list of context handles */ |
687 | int ctx_count; /**< Number of context handles */ | 679 | int ctx_count; /**< Number of context handles */ |
688 | struct mutex ctxlist_mutex; /**< For ctxlist */ | 680 | struct mutex ctxlist_mutex; /**< For ctxlist */ |
689 | 681 | ||
690 | drm_map_t **context_sareas; /**< per-context SAREA's */ | 682 | drm_map_t **context_sareas; /**< per-context SAREA's */ |
691 | int max_context; | 683 | int max_context; |
692 | 684 | ||
693 | drm_vma_entry_t *vmalist; /**< List of vmas (for debugging) */ | 685 | struct list_head vmalist; /**< List of vmas (for debugging) */ |
694 | drm_lock_data_t lock; /**< Information on hardware lock */ | 686 | drm_lock_data_t lock; /**< Information on hardware lock */ |
695 | /*@} */ | 687 | /*@} */ |
696 | 688 | ||
@@ -725,8 +717,8 @@ typedef struct drm_device { | |||
725 | atomic_t vbl_received; | 717 | atomic_t vbl_received; |
726 | atomic_t vbl_received2; /**< number of secondary VBLANK interrupts */ | 718 | atomic_t vbl_received2; /**< number of secondary VBLANK interrupts */ |
727 | spinlock_t vbl_lock; | 719 | spinlock_t vbl_lock; |
728 | drm_vbl_sig_t vbl_sigs; /**< signal list to send on VBLANK */ | 720 | struct list_head vbl_sigs; /**< signal list to send on VBLANK */ |
729 | drm_vbl_sig_t vbl_sigs2; /**< signals to send on secondary VBLANK */ | 721 | struct list_head vbl_sigs2; /**< signals to send on secondary VBLANK */ |
730 | unsigned int vbl_pending; | 722 | unsigned int vbl_pending; |
731 | spinlock_t tasklet_lock; /**< For drm_locked_tasklet */ | 723 | spinlock_t tasklet_lock; /**< For drm_locked_tasklet */ |
732 | void (*locked_tasklet_func)(struct drm_device *dev); | 724 | void (*locked_tasklet_func)(struct drm_device *dev); |
@@ -1089,7 +1081,7 @@ static __inline__ struct drm_map *drm_core_findmap(struct drm_device *dev, | |||
1089 | unsigned int token) | 1081 | unsigned int token) |
1090 | { | 1082 | { |
1091 | drm_map_list_t *_entry; | 1083 | drm_map_list_t *_entry; |
1092 | list_for_each_entry(_entry, &dev->maplist->head, head) | 1084 | list_for_each_entry(_entry, &dev->maplist, head) |
1093 | if (_entry->user_token == token) | 1085 | if (_entry->user_token == token) |
1094 | return _entry->map; | 1086 | return _entry->map; |
1095 | return NULL; | 1087 | return NULL; |
diff --git a/drivers/char/drm/drm_agpsupport.c b/drivers/char/drm/drm_agpsupport.c index 40bfd9b01e39..54c59e7ec7b6 100644 --- a/drivers/char/drm/drm_agpsupport.c +++ b/drivers/char/drm/drm_agpsupport.c | |||
@@ -232,11 +232,7 @@ int drm_agp_alloc(drm_device_t *dev, drm_agp_buffer_t *request) | |||
232 | entry->memory = memory; | 232 | entry->memory = memory; |
233 | entry->bound = 0; | 233 | entry->bound = 0; |
234 | entry->pages = pages; | 234 | entry->pages = pages; |
235 | entry->prev = NULL; | 235 | list_add(&entry->head, &dev->agp->memory); |
236 | entry->next = dev->agp->memory; | ||
237 | if (dev->agp->memory) | ||
238 | dev->agp->memory->prev = entry; | ||
239 | dev->agp->memory = entry; | ||
240 | 236 | ||
241 | request->handle = entry->handle; | 237 | request->handle = entry->handle; |
242 | request->physical = memory->physical; | 238 | request->physical = memory->physical; |
@@ -262,10 +258,12 @@ int drm_agp_alloc_ioctl(struct inode *inode, struct file *filp, | |||
262 | return err; | 258 | return err; |
263 | 259 | ||
264 | if (copy_to_user(argp, &request, sizeof(request))) { | 260 | if (copy_to_user(argp, &request, sizeof(request))) { |
265 | drm_agp_mem_t *entry = dev->agp->memory; | 261 | drm_agp_mem_t *entry; |
266 | 262 | list_for_each_entry(entry, &dev->agp->memory, head) { | |
267 | dev->agp->memory = entry->next; | 263 | if (entry->handle == request.handle) |
268 | dev->agp->memory->prev = NULL; | 264 | break; |
265 | } | ||
266 | list_del(&entry->head); | ||
269 | drm_free_agp(entry->memory, entry->pages); | 267 | drm_free_agp(entry->memory, entry->pages); |
270 | drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS); | 268 | drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS); |
271 | return -EFAULT; | 269 | return -EFAULT; |
@@ -288,7 +286,7 @@ static drm_agp_mem_t *drm_agp_lookup_entry(drm_device_t * dev, | |||
288 | { | 286 | { |
289 | drm_agp_mem_t *entry; | 287 | drm_agp_mem_t *entry; |
290 | 288 | ||
291 | for (entry = dev->agp->memory; entry; entry = entry->next) { | 289 | list_for_each_entry(entry, &dev->agp->memory, head) { |
292 | if (entry->handle == handle) | 290 | if (entry->handle == handle) |
293 | return entry; | 291 | return entry; |
294 | } | 292 | } |
@@ -413,13 +411,7 @@ int drm_agp_free(drm_device_t *dev, drm_agp_buffer_t *request) | |||
413 | if (entry->bound) | 411 | if (entry->bound) |
414 | drm_unbind_agp(entry->memory); | 412 | drm_unbind_agp(entry->memory); |
415 | 413 | ||
416 | if (entry->prev) | 414 | list_del(&entry->head); |
417 | entry->prev->next = entry->next; | ||
418 | else | ||
419 | dev->agp->memory = entry->next; | ||
420 | |||
421 | if (entry->next) | ||
422 | entry->next->prev = entry->prev; | ||
423 | 415 | ||
424 | drm_free_agp(entry->memory, entry->pages); | 416 | drm_free_agp(entry->memory, entry->pages); |
425 | drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS); | 417 | drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS); |
@@ -472,7 +464,7 @@ drm_agp_head_t *drm_agp_init(drm_device_t * dev) | |||
472 | drm_free(head, sizeof(*head), DRM_MEM_AGPLISTS); | 464 | drm_free(head, sizeof(*head), DRM_MEM_AGPLISTS); |
473 | return NULL; | 465 | return NULL; |
474 | } | 466 | } |
475 | head->memory = NULL; | 467 | INIT_LIST_HEAD(&head->memory); |
476 | head->cant_use_aperture = head->agp_info.cant_use_aperture; | 468 | head->cant_use_aperture = head->agp_info.cant_use_aperture; |
477 | head->page_mask = head->agp_info.page_mask; | 469 | head->page_mask = head->agp_info.page_mask; |
478 | 470 | ||
diff --git a/drivers/char/drm/drm_bufs.c b/drivers/char/drm/drm_bufs.c index c11345856ffe..dac057879594 100644 --- a/drivers/char/drm/drm_bufs.c +++ b/drivers/char/drm/drm_bufs.c | |||
@@ -52,10 +52,8 @@ EXPORT_SYMBOL(drm_get_resource_len); | |||
52 | static drm_map_list_t *drm_find_matching_map(drm_device_t *dev, | 52 | static drm_map_list_t *drm_find_matching_map(drm_device_t *dev, |
53 | drm_local_map_t *map) | 53 | drm_local_map_t *map) |
54 | { | 54 | { |
55 | struct list_head *list; | 55 | drm_map_list_t *entry; |
56 | 56 | list_for_each_entry(entry, &dev->maplist, head) { | |
57 | list_for_each(list, &dev->maplist->head) { | ||
58 | drm_map_list_t *entry = list_entry(list, drm_map_list_t, head); | ||
59 | if (entry->map && map->type == entry->map->type && | 57 | if (entry->map && map->type == entry->map->type && |
60 | ((entry->map->offset == map->offset) || | 58 | ((entry->map->offset == map->offset) || |
61 | (map->type == _DRM_SHM && map->flags==_DRM_CONTAINS_LOCK))) { | 59 | (map->type == _DRM_SHM && map->flags==_DRM_CONTAINS_LOCK))) { |
@@ -237,14 +235,14 @@ static int drm_addmap_core(drm_device_t * dev, unsigned int offset, | |||
237 | * skipped and we double check that dev->agp->memory is | 235 | * skipped and we double check that dev->agp->memory is |
238 | * actually set as well as being invalid before EPERM'ing | 236 | * actually set as well as being invalid before EPERM'ing |
239 | */ | 237 | */ |
240 | for (entry = dev->agp->memory; entry; entry = entry->next) { | 238 | list_for_each_entry(entry, &dev->agp->memory, head) { |
241 | if ((map->offset >= entry->bound) && | 239 | if ((map->offset >= entry->bound) && |
242 | (map->offset + map->size <= entry->bound + entry->pages * PAGE_SIZE)) { | 240 | (map->offset + map->size <= entry->bound + entry->pages * PAGE_SIZE)) { |
243 | valid = 1; | 241 | valid = 1; |
244 | break; | 242 | break; |
245 | } | 243 | } |
246 | } | 244 | } |
247 | if (dev->agp->memory && !valid) { | 245 | if (!list_empty(&dev->agp->memory) && !valid) { |
248 | drm_free(map, sizeof(*map), DRM_MEM_MAPS); | 246 | drm_free(map, sizeof(*map), DRM_MEM_MAPS); |
249 | return -EPERM; | 247 | return -EPERM; |
250 | } | 248 | } |
@@ -289,7 +287,7 @@ static int drm_addmap_core(drm_device_t * dev, unsigned int offset, | |||
289 | list->map = map; | 287 | list->map = map; |
290 | 288 | ||
291 | mutex_lock(&dev->struct_mutex); | 289 | mutex_lock(&dev->struct_mutex); |
292 | list_add(&list->head, &dev->maplist->head); | 290 | list_add(&list->head, &dev->maplist); |
293 | 291 | ||
294 | /* Assign a 32-bit handle */ | 292 | /* Assign a 32-bit handle */ |
295 | /* We do it here so that dev->struct_mutex protects the increment */ | 293 | /* We do it here so that dev->struct_mutex protects the increment */ |
@@ -380,29 +378,24 @@ int drm_addmap_ioctl(struct inode *inode, struct file *filp, | |||
380 | */ | 378 | */ |
381 | int drm_rmmap_locked(drm_device_t *dev, drm_local_map_t *map) | 379 | int drm_rmmap_locked(drm_device_t *dev, drm_local_map_t *map) |
382 | { | 380 | { |
383 | struct list_head *list; | 381 | drm_map_list_t *r_list = NULL, *list_t; |
384 | drm_map_list_t *r_list = NULL; | ||
385 | drm_dma_handle_t dmah; | 382 | drm_dma_handle_t dmah; |
383 | int found = 0; | ||
386 | 384 | ||
387 | /* Find the list entry for the map and remove it */ | 385 | /* Find the list entry for the map and remove it */ |
388 | list_for_each(list, &dev->maplist->head) { | 386 | list_for_each_entry_safe(r_list, list_t, &dev->maplist, head) { |
389 | r_list = list_entry(list, drm_map_list_t, head); | ||
390 | |||
391 | if (r_list->map == map) { | 387 | if (r_list->map == map) { |
392 | list_del(list); | 388 | list_del(&r_list->head); |
393 | drm_ht_remove_key(&dev->map_hash, | 389 | drm_ht_remove_key(&dev->map_hash, |
394 | r_list->user_token >> PAGE_SHIFT); | 390 | r_list->user_token >> PAGE_SHIFT); |
395 | drm_free(list, sizeof(*list), DRM_MEM_MAPS); | 391 | drm_free(r_list, sizeof(*r_list), DRM_MEM_MAPS); |
392 | found = 1; | ||
396 | break; | 393 | break; |
397 | } | 394 | } |
398 | } | 395 | } |
399 | 396 | ||
400 | /* List has wrapped around to the head pointer, or it's empty and we | 397 | if (!found) |
401 | * didn't find anything. | ||
402 | */ | ||
403 | if (list == (&dev->maplist->head)) { | ||
404 | return -EINVAL; | 398 | return -EINVAL; |
405 | } | ||
406 | 399 | ||
407 | switch (map->type) { | 400 | switch (map->type) { |
408 | case _DRM_REGISTERS: | 401 | case _DRM_REGISTERS: |
@@ -460,7 +453,7 @@ int drm_rmmap_ioctl(struct inode *inode, struct file *filp, | |||
460 | drm_device_t *dev = priv->head->dev; | 453 | drm_device_t *dev = priv->head->dev; |
461 | drm_map_t request; | 454 | drm_map_t request; |
462 | drm_local_map_t *map = NULL; | 455 | drm_local_map_t *map = NULL; |
463 | struct list_head *list; | 456 | drm_map_list_t *r_list; |
464 | int ret; | 457 | int ret; |
465 | 458 | ||
466 | if (copy_from_user(&request, (drm_map_t __user *) arg, sizeof(request))) { | 459 | if (copy_from_user(&request, (drm_map_t __user *) arg, sizeof(request))) { |
@@ -468,9 +461,7 @@ int drm_rmmap_ioctl(struct inode *inode, struct file *filp, | |||
468 | } | 461 | } |
469 | 462 | ||
470 | mutex_lock(&dev->struct_mutex); | 463 | mutex_lock(&dev->struct_mutex); |
471 | list_for_each(list, &dev->maplist->head) { | 464 | list_for_each_entry(r_list, &dev->maplist, head) { |
472 | drm_map_list_t *r_list = list_entry(list, drm_map_list_t, head); | ||
473 | |||
474 | if (r_list->map && | 465 | if (r_list->map && |
475 | r_list->user_token == (unsigned long)request.handle && | 466 | r_list->user_token == (unsigned long)request.handle && |
476 | r_list->map->flags & _DRM_REMOVABLE) { | 467 | r_list->map->flags & _DRM_REMOVABLE) { |
@@ -482,7 +473,7 @@ int drm_rmmap_ioctl(struct inode *inode, struct file *filp, | |||
482 | /* List has wrapped around to the head pointer, or its empty we didn't | 473 | /* List has wrapped around to the head pointer, or its empty we didn't |
483 | * find anything. | 474 | * find anything. |
484 | */ | 475 | */ |
485 | if (list == (&dev->maplist->head)) { | 476 | if (list_empty(&dev->maplist) || !map) { |
486 | mutex_unlock(&dev->struct_mutex); | 477 | mutex_unlock(&dev->struct_mutex); |
487 | return -EINVAL; | 478 | return -EINVAL; |
488 | } | 479 | } |
@@ -606,14 +597,14 @@ int drm_addbufs_agp(drm_device_t * dev, drm_buf_desc_t * request) | |||
606 | 597 | ||
607 | /* Make sure buffers are located in AGP memory that we own */ | 598 | /* Make sure buffers are located in AGP memory that we own */ |
608 | valid = 0; | 599 | valid = 0; |
609 | for (agp_entry = dev->agp->memory; agp_entry; agp_entry = agp_entry->next) { | 600 | list_for_each_entry(agp_entry, &dev->agp->memory, head) { |
610 | if ((agp_offset >= agp_entry->bound) && | 601 | if ((agp_offset >= agp_entry->bound) && |
611 | (agp_offset + total * count <= agp_entry->bound + agp_entry->pages * PAGE_SIZE)) { | 602 | (agp_offset + total * count <= agp_entry->bound + agp_entry->pages * PAGE_SIZE)) { |
612 | valid = 1; | 603 | valid = 1; |
613 | break; | 604 | break; |
614 | } | 605 | } |
615 | } | 606 | } |
616 | if (dev->agp->memory && !valid) { | 607 | if (!list_empty(&dev->agp->memory) && !valid) { |
617 | DRM_DEBUG("zone invalid\n"); | 608 | DRM_DEBUG("zone invalid\n"); |
618 | return -EINVAL; | 609 | return -EINVAL; |
619 | } | 610 | } |
diff --git a/drivers/char/drm/drm_context.c b/drivers/char/drm/drm_context.c index 83094c73da67..e1f882dc55aa 100644 --- a/drivers/char/drm/drm_context.c +++ b/drivers/char/drm/drm_context.c | |||
@@ -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; |
@@ -268,15 +268,13 @@ int drm_setsareactx(struct inode *inode, struct file *filp, | |||
268 | drm_ctx_priv_map_t request; | 268 | drm_ctx_priv_map_t request; |
269 | drm_map_t *map = NULL; | 269 | drm_map_t *map = NULL; |
270 | drm_map_list_t *r_list = NULL; | 270 | drm_map_list_t *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 | (drm_ctx_priv_map_t __user *) arg, sizeof(request))) |
275 | return -EFAULT; | 274 | return -EFAULT; |
276 | 275 | ||
277 | mutex_lock(&dev->struct_mutex); | 276 | mutex_lock(&dev->struct_mutex); |
278 | list_for_each(list, &dev->maplist->head) { | 277 | 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 | 278 | if (r_list->map |
281 | && r_list->user_token == (unsigned long)request.handle) | 279 | && r_list->user_token == (unsigned long)request.handle) |
282 | goto found; | 280 | goto found; |
@@ -449,7 +447,7 @@ int drm_addctx(struct inode *inode, struct file *filp, | |||
449 | ctx_entry->tag = priv; | 447 | ctx_entry->tag = priv; |
450 | 448 | ||
451 | mutex_lock(&dev->ctxlist_mutex); | 449 | mutex_lock(&dev->ctxlist_mutex); |
452 | list_add(&ctx_entry->head, &dev->ctxlist->head); | 450 | list_add(&ctx_entry->head, &dev->ctxlist); |
453 | ++dev->ctx_count; | 451 | ++dev->ctx_count; |
454 | mutex_unlock(&dev->ctxlist_mutex); | 452 | mutex_unlock(&dev->ctxlist_mutex); |
455 | 453 | ||
@@ -575,10 +573,10 @@ int drm_rmctx(struct inode *inode, struct file *filp, | |||
575 | } | 573 | } |
576 | 574 | ||
577 | mutex_lock(&dev->ctxlist_mutex); | 575 | mutex_lock(&dev->ctxlist_mutex); |
578 | if (!list_empty(&dev->ctxlist->head)) { | 576 | if (!list_empty(&dev->ctxlist)) { |
579 | drm_ctx_list_t *pos, *n; | 577 | drm_ctx_list_t *pos, *n; |
580 | 578 | ||
581 | list_for_each_entry_safe(pos, n, &dev->ctxlist->head, head) { | 579 | list_for_each_entry_safe(pos, n, &dev->ctxlist, head) { |
582 | if (pos->handle == ctx.handle) { | 580 | if (pos->handle == ctx.handle) { |
583 | list_del(&pos->head); | 581 | list_del(&pos->head); |
584 | drm_free(pos, sizeof(*pos), DRM_MEM_CTXLIST); | 582 | drm_free(pos, sizeof(*pos), DRM_MEM_CTXLIST); |
diff --git a/drivers/char/drm/drm_drv.c b/drivers/char/drm/drm_drv.c index 8e77b7ed0f44..d7d10f118eaa 100644 --- a/drivers/char/drm/drm_drv.c +++ b/drivers/char/drm/drm_drv.c | |||
@@ -132,8 +132,8 @@ static drm_ioctl_desc_t drm_ioctls[] = { | |||
132 | int drm_lastclose(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, *list_t; |
136 | drm_vma_entry_t *vma, *vma_next; | 136 | drm_vma_entry_t *vma, *vma_temp; |
137 | int i; | 137 | int i; |
138 | 138 | ||
139 | DRM_DEBUG("\n"); | 139 | DRM_DEBUG("\n"); |
@@ -178,19 +178,17 @@ int drm_lastclose(drm_device_t * dev) | |||
178 | 178 | ||
179 | /* Clear AGP information */ | 179 | /* Clear AGP information */ |
180 | if (drm_core_has_AGP(dev) && dev->agp) { | 180 | if (drm_core_has_AGP(dev) && dev->agp) { |
181 | drm_agp_mem_t *entry; | 181 | drm_agp_mem_t *entry, *tempe; |
182 | drm_agp_mem_t *nexte; | ||
183 | 182 | ||
184 | /* Remove AGP resources, but leave dev->agp | 183 | /* Remove AGP resources, but leave dev->agp |
185 | intact until drv_cleanup is called. */ | 184 | intact until drv_cleanup is called. */ |
186 | for (entry = dev->agp->memory; entry; entry = nexte) { | 185 | list_for_each_entry_safe(entry, tempe, &dev->agp->memory, head) { |
187 | nexte = entry->next; | ||
188 | if (entry->bound) | 186 | if (entry->bound) |
189 | drm_unbind_agp(entry->memory); | 187 | drm_unbind_agp(entry->memory); |
190 | drm_free_agp(entry->memory, entry->pages); | 188 | drm_free_agp(entry->memory, entry->pages); |
191 | drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS); | 189 | drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS); |
192 | } | 190 | } |
193 | dev->agp->memory = NULL; | 191 | INIT_LIST_HEAD(&dev->agp->memory); |
194 | 192 | ||
195 | if (dev->agp->acquired) | 193 | if (dev->agp->acquired) |
196 | drm_agp_release(dev); | 194 | drm_agp_release(dev); |
@@ -204,20 +202,14 @@ int drm_lastclose(drm_device_t * dev) | |||
204 | } | 202 | } |
205 | 203 | ||
206 | /* Clear vma list (only built for debugging) */ | 204 | /* Clear vma list (only built for debugging) */ |
207 | if (dev->vmalist) { | 205 | list_for_each_entry_safe(vma, vma_temp, &dev->vmalist, head) { |
208 | for (vma = dev->vmalist; vma; vma = vma_next) { | 206 | list_del(&vma->head); |
209 | vma_next = vma->next; | 207 | drm_free(vma, sizeof(*vma), DRM_MEM_VMAS); |
210 | drm_free(vma, sizeof(*vma), DRM_MEM_VMAS); | ||
211 | } | ||
212 | dev->vmalist = NULL; | ||
213 | } | 208 | } |
214 | 209 | ||
215 | if (dev->maplist) { | 210 | list_for_each_entry_safe(r_list, list_t, &dev->maplist, head) { |
216 | while (!list_empty(&dev->maplist->head)) { | 211 | drm_rmmap_locked(dev, r_list->map); |
217 | struct list_head *list = dev->maplist->head.next; | 212 | r_list = NULL; |
218 | r_list = list_entry(list, drm_map_list_t, head); | ||
219 | drm_rmmap_locked(dev, r_list->map); | ||
220 | } | ||
221 | } | 213 | } |
222 | 214 | ||
223 | if (drm_core_check_feature(dev, DRIVER_DMA_QUEUE) && dev->queuelist) { | 215 | if (drm_core_check_feature(dev, DRIVER_DMA_QUEUE) && dev->queuelist) { |
@@ -309,11 +301,7 @@ static void drm_cleanup(drm_device_t * dev) | |||
309 | 301 | ||
310 | drm_lastclose(dev); | 302 | drm_lastclose(dev); |
311 | 303 | ||
312 | if (dev->maplist) { | 304 | drm_ht_remove(&dev->map_hash); |
313 | drm_free(dev->maplist, sizeof(*dev->maplist), DRM_MEM_MAPS); | ||
314 | dev->maplist = NULL; | ||
315 | drm_ht_remove(&dev->map_hash); | ||
316 | } | ||
317 | 305 | ||
318 | drm_ctxbitmap_cleanup(dev); | 306 | drm_ctxbitmap_cleanup(dev); |
319 | 307 | ||
diff --git a/drivers/char/drm/drm_fops.c b/drivers/char/drm/drm_fops.c index 3b159cab3bc8..e82e78fa42b0 100644 --- a/drivers/char/drm/drm_fops.c +++ b/drivers/char/drm/drm_fops.c | |||
@@ -79,13 +79,9 @@ static int drm_setup(drm_device_t * dev) | |||
79 | drm_ht_create(&dev->magiclist, DRM_MAGIC_HASH_ORDER); | 79 | drm_ht_create(&dev->magiclist, DRM_MAGIC_HASH_ORDER); |
80 | INIT_LIST_HEAD(&dev->magicfree); | 80 | INIT_LIST_HEAD(&dev->magicfree); |
81 | 81 | ||
82 | dev->ctxlist = drm_alloc(sizeof(*dev->ctxlist), DRM_MEM_CTXLIST); | 82 | INIT_LIST_HEAD(&dev->ctxlist); |
83 | if (dev->ctxlist == NULL) | 83 | INIT_LIST_HEAD(&dev->vmalist); |
84 | return -ENOMEM; | ||
85 | memset(dev->ctxlist, 0, sizeof(*dev->ctxlist)); | ||
86 | INIT_LIST_HEAD(&dev->ctxlist->head); | ||
87 | 84 | ||
88 | dev->vmalist = NULL; | ||
89 | dev->sigdata.lock = NULL; | 85 | dev->sigdata.lock = NULL; |
90 | init_waitqueue_head(&dev->lock.lock_queue); | 86 | init_waitqueue_head(&dev->lock.lock_queue); |
91 | dev->queue_count = 0; | 87 | dev->queue_count = 0; |
@@ -258,6 +254,8 @@ static int drm_open_helper(struct inode *inode, struct file *filp, | |||
258 | priv->authenticated = capable(CAP_SYS_ADMIN); | 254 | priv->authenticated = capable(CAP_SYS_ADMIN); |
259 | priv->lock_count = 0; | 255 | priv->lock_count = 0; |
260 | 256 | ||
257 | INIT_LIST_HEAD(&priv->lhead); | ||
258 | |||
261 | if (dev->driver->open) { | 259 | if (dev->driver->open) { |
262 | ret = dev->driver->open(dev, priv); | 260 | ret = dev->driver->open(dev, priv); |
263 | if (ret < 0) | 261 | if (ret < 0) |
@@ -265,19 +263,10 @@ static int drm_open_helper(struct inode *inode, struct file *filp, | |||
265 | } | 263 | } |
266 | 264 | ||
267 | mutex_lock(&dev->struct_mutex); | 265 | mutex_lock(&dev->struct_mutex); |
268 | if (!dev->file_last) { | 266 | if (list_empty(&dev->filelist)) |
269 | priv->next = NULL; | ||
270 | priv->prev = NULL; | ||
271 | dev->file_first = priv; | ||
272 | dev->file_last = priv; | ||
273 | /* first opener automatically becomes master */ | ||
274 | priv->master = 1; | 267 | priv->master = 1; |
275 | } else { | 268 | |
276 | priv->next = NULL; | 269 | list_add(&priv->lhead, &dev->filelist); |
277 | priv->prev = dev->file_last; | ||
278 | dev->file_last->next = priv; | ||
279 | dev->file_last = priv; | ||
280 | } | ||
281 | mutex_unlock(&dev->struct_mutex); | 270 | mutex_unlock(&dev->struct_mutex); |
282 | 271 | ||
283 | #ifdef __alpha__ | 272 | #ifdef __alpha__ |
@@ -414,10 +403,10 @@ int drm_release(struct inode *inode, struct file *filp) | |||
414 | drm_fasync(-1, filp, 0); | 403 | drm_fasync(-1, filp, 0); |
415 | 404 | ||
416 | mutex_lock(&dev->ctxlist_mutex); | 405 | mutex_lock(&dev->ctxlist_mutex); |
417 | if (dev->ctxlist && (!list_empty(&dev->ctxlist->head))) { | 406 | if (!list_empty(&dev->ctxlist)) { |
418 | drm_ctx_list_t *pos, *n; | 407 | drm_ctx_list_t *pos, *n; |
419 | 408 | ||
420 | list_for_each_entry_safe(pos, n, &dev->ctxlist->head, head) { | 409 | list_for_each_entry_safe(pos, n, &dev->ctxlist, head) { |
421 | if (pos->tag == priv && | 410 | if (pos->tag == priv && |
422 | pos->handle != DRM_KERNEL_CONTEXT) { | 411 | pos->handle != DRM_KERNEL_CONTEXT) { |
423 | if (dev->driver->context_dtor) | 412 | if (dev->driver->context_dtor) |
@@ -436,22 +425,12 @@ int drm_release(struct inode *inode, struct file *filp) | |||
436 | 425 | ||
437 | mutex_lock(&dev->struct_mutex); | 426 | mutex_lock(&dev->struct_mutex); |
438 | if (priv->remove_auth_on_close == 1) { | 427 | if (priv->remove_auth_on_close == 1) { |
439 | drm_file_t *temp = dev->file_first; | 428 | drm_file_t *temp; |
440 | while (temp) { | 429 | |
430 | list_for_each_entry(temp, &dev->filelist, lhead) | ||
441 | temp->authenticated = 0; | 431 | temp->authenticated = 0; |
442 | temp = temp->next; | ||
443 | } | ||
444 | } | ||
445 | if (priv->prev) { | ||
446 | priv->prev->next = priv->next; | ||
447 | } else { | ||
448 | dev->file_first = priv->next; | ||
449 | } | ||
450 | if (priv->next) { | ||
451 | priv->next->prev = priv->prev; | ||
452 | } else { | ||
453 | dev->file_last = priv->prev; | ||
454 | } | 432 | } |
433 | list_del(&priv->lhead); | ||
455 | mutex_unlock(&dev->struct_mutex); | 434 | mutex_unlock(&dev->struct_mutex); |
456 | 435 | ||
457 | if (dev->driver->postclose) | 436 | if (dev->driver->postclose) |
diff --git a/drivers/char/drm/drm_ioctl.c b/drivers/char/drm/drm_ioctl.c index 565895547d75..96b982f1f4a4 100644 --- a/drivers/char/drm/drm_ioctl.c +++ b/drivers/char/drm/drm_ioctl.c | |||
@@ -204,7 +204,7 @@ int drm_getmap(struct inode *inode, struct file *filp, | |||
204 | } | 204 | } |
205 | 205 | ||
206 | i = 0; | 206 | i = 0; |
207 | list_for_each(list, &dev->maplist->head) { | 207 | list_for_each(list, &dev->maplist) { |
208 | if (i == idx) { | 208 | if (i == idx) { |
209 | r_list = list_entry(list, drm_map_list_t, head); | 209 | r_list = list_entry(list, drm_map_list_t, head); |
210 | break; | 210 | break; |
@@ -257,12 +257,18 @@ int drm_getclient(struct inode *inode, struct file *filp, | |||
257 | return -EFAULT; | 257 | return -EFAULT; |
258 | idx = client.idx; | 258 | idx = client.idx; |
259 | mutex_lock(&dev->struct_mutex); | 259 | mutex_lock(&dev->struct_mutex); |
260 | for (i = 0, pt = dev->file_first; i < idx && pt; i++, pt = pt->next) ; | 260 | |
261 | 261 | if (list_empty(&dev->filelist)) { | |
262 | if (!pt) { | ||
263 | mutex_unlock(&dev->struct_mutex); | 262 | mutex_unlock(&dev->struct_mutex); |
264 | return -EINVAL; | 263 | return -EINVAL; |
265 | } | 264 | } |
265 | |||
266 | i = 0; | ||
267 | list_for_each_entry(pt, &dev->filelist, lhead) { | ||
268 | if (i++ >= idx) | ||
269 | break; | ||
270 | } | ||
271 | |||
266 | client.auth = pt->authenticated; | 272 | client.auth = pt->authenticated; |
267 | client.pid = pt->pid; | 273 | client.pid = pt->pid; |
268 | client.uid = pt->uid; | 274 | client.uid = pt->uid; |
diff --git a/drivers/char/drm/drm_irq.c b/drivers/char/drm/drm_irq.c index 2e75331fd83e..ae3053ce7b2c 100644 --- a/drivers/char/drm/drm_irq.c +++ b/drivers/char/drm/drm_irq.c | |||
@@ -120,8 +120,8 @@ static int drm_irq_install(drm_device_t * dev) | |||
120 | 120 | ||
121 | spin_lock_init(&dev->vbl_lock); | 121 | spin_lock_init(&dev->vbl_lock); |
122 | 122 | ||
123 | INIT_LIST_HEAD(&dev->vbl_sigs.head); | 123 | INIT_LIST_HEAD(&dev->vbl_sigs); |
124 | INIT_LIST_HEAD(&dev->vbl_sigs2.head); | 124 | INIT_LIST_HEAD(&dev->vbl_sigs2); |
125 | 125 | ||
126 | dev->vbl_pending = 0; | 126 | dev->vbl_pending = 0; |
127 | } | 127 | } |
@@ -292,7 +292,7 @@ int drm_wait_vblank(DRM_IOCTL_ARGS) | |||
292 | 292 | ||
293 | if (flags & _DRM_VBLANK_SIGNAL) { | 293 | if (flags & _DRM_VBLANK_SIGNAL) { |
294 | unsigned long irqflags; | 294 | unsigned long irqflags; |
295 | drm_vbl_sig_t *vbl_sigs = (flags & _DRM_VBLANK_SECONDARY) | 295 | struct list_head *vbl_sigs = (flags & _DRM_VBLANK_SECONDARY) |
296 | ? &dev->vbl_sigs2 : &dev->vbl_sigs; | 296 | ? &dev->vbl_sigs2 : &dev->vbl_sigs; |
297 | drm_vbl_sig_t *vbl_sig; | 297 | drm_vbl_sig_t *vbl_sig; |
298 | 298 | ||
@@ -302,7 +302,7 @@ int drm_wait_vblank(DRM_IOCTL_ARGS) | |||
302 | * for the same vblank sequence number; nothing to be done in | 302 | * for the same vblank sequence number; nothing to be done in |
303 | * that case | 303 | * that case |
304 | */ | 304 | */ |
305 | list_for_each_entry(vbl_sig, &vbl_sigs->head, head) { | 305 | list_for_each_entry(vbl_sig, vbl_sigs, head) { |
306 | if (vbl_sig->sequence == vblwait.request.sequence | 306 | if (vbl_sig->sequence == vblwait.request.sequence |
307 | && vbl_sig->info.si_signo == vblwait.request.signal | 307 | && vbl_sig->info.si_signo == vblwait.request.signal |
308 | && vbl_sig->task == current) { | 308 | && vbl_sig->task == current) { |
@@ -336,7 +336,7 @@ int drm_wait_vblank(DRM_IOCTL_ARGS) | |||
336 | 336 | ||
337 | spin_lock_irqsave(&dev->vbl_lock, irqflags); | 337 | spin_lock_irqsave(&dev->vbl_lock, irqflags); |
338 | 338 | ||
339 | list_add_tail((struct list_head *)vbl_sig, &vbl_sigs->head); | 339 | list_add_tail(&vbl_sig->head, vbl_sigs); |
340 | 340 | ||
341 | spin_unlock_irqrestore(&dev->vbl_lock, irqflags); | 341 | spin_unlock_irqrestore(&dev->vbl_lock, irqflags); |
342 | 342 | ||
@@ -379,20 +379,18 @@ void drm_vbl_send_signals(drm_device_t * dev) | |||
379 | spin_lock_irqsave(&dev->vbl_lock, flags); | 379 | spin_lock_irqsave(&dev->vbl_lock, flags); |
380 | 380 | ||
381 | for (i = 0; i < 2; i++) { | 381 | for (i = 0; i < 2; i++) { |
382 | struct list_head *list, *tmp; | 382 | drm_vbl_sig_t *vbl_sig, *tmp; |
383 | drm_vbl_sig_t *vbl_sig; | 383 | struct list_head *vbl_sigs = i ? &dev->vbl_sigs2 : &dev->vbl_sigs; |
384 | drm_vbl_sig_t *vbl_sigs = i ? &dev->vbl_sigs2 : &dev->vbl_sigs; | ||
385 | unsigned int vbl_seq = atomic_read(i ? &dev->vbl_received2 : | 384 | unsigned int vbl_seq = atomic_read(i ? &dev->vbl_received2 : |
386 | &dev->vbl_received); | 385 | &dev->vbl_received); |
387 | 386 | ||
388 | list_for_each_safe(list, tmp, &vbl_sigs->head) { | 387 | list_for_each_entry_safe(vbl_sig, tmp, vbl_sigs, head) { |
389 | vbl_sig = list_entry(list, drm_vbl_sig_t, head); | ||
390 | if ((vbl_seq - vbl_sig->sequence) <= (1 << 23)) { | 388 | if ((vbl_seq - vbl_sig->sequence) <= (1 << 23)) { |
391 | vbl_sig->info.si_code = vbl_seq; | 389 | vbl_sig->info.si_code = vbl_seq; |
392 | send_sig_info(vbl_sig->info.si_signo, | 390 | send_sig_info(vbl_sig->info.si_signo, |
393 | &vbl_sig->info, vbl_sig->task); | 391 | &vbl_sig->info, vbl_sig->task); |
394 | 392 | ||
395 | list_del(list); | 393 | list_del(&vbl_sig->head); |
396 | 394 | ||
397 | drm_free(vbl_sig, sizeof(*vbl_sig), | 395 | drm_free(vbl_sig, sizeof(*vbl_sig), |
398 | DRM_MEM_DRIVER); | 396 | DRM_MEM_DRIVER); |
diff --git a/drivers/char/drm/drm_memory.c b/drivers/char/drm/drm_memory.c index 92a867082376..0683334f16c9 100644 --- a/drivers/char/drm/drm_memory.c +++ b/drivers/char/drm/drm_memory.c | |||
@@ -94,7 +94,7 @@ static void *agp_remap(unsigned long offset, unsigned long size, | |||
94 | offset -= dev->hose->mem_space->start; | 94 | offset -= dev->hose->mem_space->start; |
95 | #endif | 95 | #endif |
96 | 96 | ||
97 | for (agpmem = dev->agp->memory; agpmem; agpmem = agpmem->next) | 97 | list_for_each_entry(agpmem, &dev->agp->memory, head) |
98 | if (agpmem->bound <= offset | 98 | if (agpmem->bound <= offset |
99 | && (agpmem->bound + (agpmem->pages << PAGE_SHIFT)) >= | 99 | && (agpmem->bound + (agpmem->pages << PAGE_SHIFT)) >= |
100 | (offset + size)) | 100 | (offset + size)) |
diff --git a/drivers/char/drm/drm_os_linux.h b/drivers/char/drm/drm_os_linux.h index 0fe7b4497927..e6e5ae89e100 100644 --- a/drivers/char/drm/drm_os_linux.h +++ b/drivers/char/drm/drm_os_linux.h | |||
@@ -104,7 +104,7 @@ static __inline__ int mtrr_del(int reg, unsigned long base, unsigned long size) | |||
104 | #define DRM_GETSAREA() \ | 104 | #define DRM_GETSAREA() \ |
105 | do { \ | 105 | do { \ |
106 | drm_map_list_t *entry; \ | 106 | drm_map_list_t *entry; \ |
107 | list_for_each_entry( entry, &dev->maplist->head, head ) { \ | 107 | list_for_each_entry( entry, &dev->maplist, head ) { \ |
108 | if ( entry->map && \ | 108 | if ( entry->map && \ |
109 | entry->map->type == _DRM_SHM && \ | 109 | entry->map->type == _DRM_SHM && \ |
110 | (entry->map->flags & _DRM_CONTAINS_LOCK) ) { \ | 110 | (entry->map->flags & _DRM_CONTAINS_LOCK) ) { \ |
diff --git a/drivers/char/drm/drm_proc.c b/drivers/char/drm/drm_proc.c index b204498d1a28..1b1735ab3fbf 100644 --- a/drivers/char/drm/drm_proc.c +++ b/drivers/char/drm/drm_proc.c | |||
@@ -209,7 +209,6 @@ static int drm__vm_info(char *buf, char **start, off_t offset, int request, | |||
209 | int len = 0; | 209 | int len = 0; |
210 | drm_map_t *map; | 210 | drm_map_t *map; |
211 | drm_map_list_t *r_list; | 211 | drm_map_list_t *r_list; |
212 | struct list_head *list; | ||
213 | 212 | ||
214 | /* Hardcoded from _DRM_FRAME_BUFFER, | 213 | /* Hardcoded from _DRM_FRAME_BUFFER, |
215 | _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and | 214 | _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and |
@@ -229,9 +228,7 @@ static int drm__vm_info(char *buf, char **start, off_t offset, int request, | |||
229 | DRM_PROC_PRINT("slot offset size type flags " | 228 | DRM_PROC_PRINT("slot offset size type flags " |
230 | "address mtrr\n\n"); | 229 | "address mtrr\n\n"); |
231 | i = 0; | 230 | i = 0; |
232 | if (dev->maplist != NULL) | 231 | list_for_each_entry(r_list, &dev->maplist, head) { |
233 | list_for_each(list, &dev->maplist->head) { | ||
234 | r_list = list_entry(list, drm_map_list_t, head); | ||
235 | map = r_list->map; | 232 | map = r_list->map; |
236 | if (!map) | 233 | if (!map) |
237 | continue; | 234 | continue; |
@@ -242,14 +239,15 @@ static int drm__vm_info(char *buf, char **start, off_t offset, int request, | |||
242 | DRM_PROC_PRINT("%4d 0x%08lx 0x%08lx %4.4s 0x%02x 0x%08x ", | 239 | DRM_PROC_PRINT("%4d 0x%08lx 0x%08lx %4.4s 0x%02x 0x%08x ", |
243 | i, | 240 | i, |
244 | map->offset, | 241 | map->offset, |
245 | map->size, type, map->flags, r_list->user_token); | 242 | map->size, type, map->flags, |
243 | r_list->user_token); | ||
246 | if (map->mtrr < 0) { | 244 | if (map->mtrr < 0) { |
247 | DRM_PROC_PRINT("none\n"); | 245 | DRM_PROC_PRINT("none\n"); |
248 | } else { | 246 | } else { |
249 | DRM_PROC_PRINT("%4d\n", map->mtrr); | 247 | DRM_PROC_PRINT("%4d\n", map->mtrr); |
250 | } | 248 | } |
251 | i++; | 249 | i++; |
252 | } | 250 | } |
253 | 251 | ||
254 | if (len > request + offset) | 252 | if (len > request + offset) |
255 | return request; | 253 | return request; |
@@ -444,7 +442,7 @@ static int drm__clients_info(char *buf, char **start, off_t offset, | |||
444 | *eof = 0; | 442 | *eof = 0; |
445 | 443 | ||
446 | DRM_PROC_PRINT("a dev pid uid magic ioctls\n\n"); | 444 | DRM_PROC_PRINT("a dev pid uid magic ioctls\n\n"); |
447 | for (priv = dev->file_first; priv; priv = priv->next) { | 445 | list_for_each_entry(priv, &dev->filelist, lhead) { |
448 | DRM_PROC_PRINT("%c %3d %5d %5d %10u %10lu\n", | 446 | DRM_PROC_PRINT("%c %3d %5d %5d %10u %10lu\n", |
449 | priv->authenticated ? 'y' : 'n', | 447 | priv->authenticated ? 'y' : 'n', |
450 | priv->minor, | 448 | priv->minor, |
@@ -497,7 +495,7 @@ static int drm__vma_info(char *buf, char **start, off_t offset, int request, | |||
497 | DRM_PROC_PRINT("vma use count: %d, high_memory = %p, 0x%08lx\n", | 495 | DRM_PROC_PRINT("vma use count: %d, high_memory = %p, 0x%08lx\n", |
498 | atomic_read(&dev->vma_count), | 496 | atomic_read(&dev->vma_count), |
499 | high_memory, virt_to_phys(high_memory)); | 497 | high_memory, virt_to_phys(high_memory)); |
500 | for (pt = dev->vmalist; pt; pt = pt->next) { | 498 | list_for_each_entry(pt, &dev->vmalist, head) { |
501 | if (!(vma = pt->vma)) | 499 | if (!(vma = pt->vma)) |
502 | continue; | 500 | continue; |
503 | DRM_PROC_PRINT("\n%5d 0x%08lx-0x%08lx %c%c%c%c%c%c 0x%08lx000", | 501 | DRM_PROC_PRINT("\n%5d 0x%08lx-0x%08lx %c%c%c%c%c%c 0x%08lx000", |
diff --git a/drivers/char/drm/drm_stub.c b/drivers/char/drm/drm_stub.c index 19408adcc775..59a9e7e5f128 100644 --- a/drivers/char/drm/drm_stub.c +++ b/drivers/char/drm/drm_stub.c | |||
@@ -59,6 +59,7 @@ static int drm_fill_in_dev(drm_device_t * dev, struct pci_dev *pdev, | |||
59 | { | 59 | { |
60 | int retcode; | 60 | int retcode; |
61 | 61 | ||
62 | INIT_LIST_HEAD(&dev->filelist); | ||
62 | spin_lock_init(&dev->count_lock); | 63 | spin_lock_init(&dev->count_lock); |
63 | spin_lock_init(&dev->drw_lock); | 64 | spin_lock_init(&dev->drw_lock); |
64 | spin_lock_init(&dev->tasklet_lock); | 65 | spin_lock_init(&dev->tasklet_lock); |
@@ -76,15 +77,12 @@ static int drm_fill_in_dev(drm_device_t * dev, struct pci_dev *pdev, | |||
76 | #endif | 77 | #endif |
77 | dev->irq = pdev->irq; | 78 | dev->irq = pdev->irq; |
78 | 79 | ||
79 | dev->maplist = drm_calloc(1, sizeof(*dev->maplist), DRM_MEM_MAPS); | ||
80 | if (dev->maplist == NULL) | ||
81 | return -ENOMEM; | ||
82 | INIT_LIST_HEAD(&dev->maplist->head); | ||
83 | if (drm_ht_create(&dev->map_hash, 12)) { | 80 | if (drm_ht_create(&dev->map_hash, 12)) { |
84 | drm_free(dev->maplist, sizeof(*dev->maplist), DRM_MEM_MAPS); | ||
85 | return -ENOMEM; | 81 | return -ENOMEM; |
86 | } | 82 | } |
87 | 83 | ||
84 | INIT_LIST_HEAD(&dev->maplist); | ||
85 | |||
88 | /* the DRM has 6 basic counters */ | 86 | /* the DRM has 6 basic counters */ |
89 | dev->counters = 6; | 87 | dev->counters = 6; |
90 | dev->types[0] = _DRM_STAT_LOCK; | 88 | dev->types[0] = _DRM_STAT_LOCK; |
diff --git a/drivers/char/drm/drm_vm.c b/drivers/char/drm/drm_vm.c index b5c5b9fa84c3..948e60d272df 100644 --- a/drivers/char/drm/drm_vm.c +++ b/drivers/char/drm/drm_vm.c | |||
@@ -116,7 +116,7 @@ static __inline__ struct page *drm_do_vm_nopage(struct vm_area_struct *vma, | |||
116 | /* | 116 | /* |
117 | * It's AGP memory - find the real physical page to map | 117 | * It's AGP memory - find the real physical page to map |
118 | */ | 118 | */ |
119 | for (agpmem = dev->agp->memory; agpmem; agpmem = agpmem->next) { | 119 | list_for_each_entry(agpmem, &dev->agp->memory, head) { |
120 | if (agpmem->bound <= baddr && | 120 | if (agpmem->bound <= baddr && |
121 | agpmem->bound + agpmem->pages * PAGE_SIZE > baddr) | 121 | agpmem->bound + agpmem->pages * PAGE_SIZE > baddr) |
122 | break; | 122 | break; |
@@ -196,10 +196,9 @@ static void drm_vm_shm_close(struct vm_area_struct *vma) | |||
196 | { | 196 | { |
197 | drm_file_t *priv = vma->vm_file->private_data; | 197 | drm_file_t *priv = vma->vm_file->private_data; |
198 | drm_device_t *dev = priv->head->dev; | 198 | drm_device_t *dev = priv->head->dev; |
199 | drm_vma_entry_t *pt, *prev, *next; | 199 | drm_vma_entry_t *pt, *temp; |
200 | drm_map_t *map; | 200 | drm_map_t *map; |
201 | drm_map_list_t *r_list; | 201 | drm_map_list_t *r_list; |
202 | struct list_head *list; | ||
203 | int found_maps = 0; | 202 | int found_maps = 0; |
204 | 203 | ||
205 | DRM_DEBUG("0x%08lx,0x%08lx\n", | 204 | DRM_DEBUG("0x%08lx,0x%08lx\n", |
@@ -209,30 +208,22 @@ static void drm_vm_shm_close(struct vm_area_struct *vma) | |||
209 | map = vma->vm_private_data; | 208 | map = vma->vm_private_data; |
210 | 209 | ||
211 | mutex_lock(&dev->struct_mutex); | 210 | mutex_lock(&dev->struct_mutex); |
212 | for (pt = dev->vmalist, prev = NULL; pt; pt = next) { | 211 | list_for_each_entry_safe(pt, temp, &dev->vmalist, head) { |
213 | next = pt->next; | ||
214 | if (pt->vma->vm_private_data == map) | 212 | if (pt->vma->vm_private_data == map) |
215 | found_maps++; | 213 | found_maps++; |
216 | if (pt->vma == vma) { | 214 | if (pt->vma == vma) { |
217 | if (prev) { | 215 | list_del(&pt->head); |
218 | prev->next = pt->next; | ||
219 | } else { | ||
220 | dev->vmalist = pt->next; | ||
221 | } | ||
222 | drm_free(pt, sizeof(*pt), DRM_MEM_VMAS); | 216 | drm_free(pt, sizeof(*pt), DRM_MEM_VMAS); |
223 | } else { | ||
224 | prev = pt; | ||
225 | } | 217 | } |
226 | } | 218 | } |
219 | |||
227 | /* We were the only map that was found */ | 220 | /* We were the only map that was found */ |
228 | if (found_maps == 1 && map->flags & _DRM_REMOVABLE) { | 221 | if (found_maps == 1 && map->flags & _DRM_REMOVABLE) { |
229 | /* Check to see if we are in the maplist, if we are not, then | 222 | /* Check to see if we are in the maplist, if we are not, then |
230 | * we delete this mappings information. | 223 | * we delete this mappings information. |
231 | */ | 224 | */ |
232 | found_maps = 0; | 225 | found_maps = 0; |
233 | list = &dev->maplist->head; | 226 | list_for_each_entry(r_list, &dev->maplist, head) { |
234 | list_for_each(list, &dev->maplist->head) { | ||
235 | r_list = list_entry(list, drm_map_list_t, head); | ||
236 | if (r_list->map == map) | 227 | if (r_list->map == map) |
237 | found_maps++; | 228 | found_maps++; |
238 | } | 229 | } |
@@ -425,9 +416,8 @@ static void drm_vm_open_locked(struct vm_area_struct *vma) | |||
425 | vma_entry = drm_alloc(sizeof(*vma_entry), DRM_MEM_VMAS); | 416 | vma_entry = drm_alloc(sizeof(*vma_entry), DRM_MEM_VMAS); |
426 | if (vma_entry) { | 417 | if (vma_entry) { |
427 | vma_entry->vma = vma; | 418 | vma_entry->vma = vma; |
428 | vma_entry->next = dev->vmalist; | ||
429 | vma_entry->pid = current->pid; | 419 | vma_entry->pid = current->pid; |
430 | dev->vmalist = vma_entry; | 420 | list_add(&vma_entry->head, &dev->vmalist); |
431 | } | 421 | } |
432 | } | 422 | } |
433 | 423 | ||
@@ -453,20 +443,16 @@ static void drm_vm_close(struct vm_area_struct *vma) | |||
453 | { | 443 | { |
454 | drm_file_t *priv = vma->vm_file->private_data; | 444 | drm_file_t *priv = vma->vm_file->private_data; |
455 | drm_device_t *dev = priv->head->dev; | 445 | drm_device_t *dev = priv->head->dev; |
456 | drm_vma_entry_t *pt, *prev; | 446 | drm_vma_entry_t *pt, *temp; |
457 | 447 | ||
458 | DRM_DEBUG("0x%08lx,0x%08lx\n", | 448 | DRM_DEBUG("0x%08lx,0x%08lx\n", |
459 | vma->vm_start, vma->vm_end - vma->vm_start); | 449 | vma->vm_start, vma->vm_end - vma->vm_start); |
460 | atomic_dec(&dev->vma_count); | 450 | atomic_dec(&dev->vma_count); |
461 | 451 | ||
462 | mutex_lock(&dev->struct_mutex); | 452 | mutex_lock(&dev->struct_mutex); |
463 | for (pt = dev->vmalist, prev = NULL; pt; prev = pt, pt = pt->next) { | 453 | list_for_each_entry_safe(pt, temp, &dev->vmalist, head) { |
464 | if (pt->vma == vma) { | 454 | if (pt->vma == vma) { |
465 | if (prev) { | 455 | list_del(&pt->head); |
466 | prev->next = pt->next; | ||
467 | } else { | ||
468 | dev->vmalist = pt->next; | ||
469 | } | ||
470 | drm_free(pt, sizeof(*pt), DRM_MEM_VMAS); | 456 | drm_free(pt, sizeof(*pt), DRM_MEM_VMAS); |
471 | break; | 457 | break; |
472 | } | 458 | } |
diff --git a/drivers/char/drm/i810_dma.c b/drivers/char/drm/i810_dma.c index 603d17fd2d69..53b8a7931955 100644 --- a/drivers/char/drm/i810_dma.c +++ b/drivers/char/drm/i810_dma.c | |||
@@ -327,12 +327,10 @@ static int i810_dma_initialize(drm_device_t * dev, | |||
327 | drm_i810_private_t * dev_priv, | 327 | drm_i810_private_t * dev_priv, |
328 | drm_i810_init_t * init) | 328 | drm_i810_init_t * init) |
329 | { | 329 | { |
330 | struct list_head *list; | 330 | drm_map_list_t *r_list; |
331 | |||
332 | memset(dev_priv, 0, sizeof(drm_i810_private_t)); | 331 | memset(dev_priv, 0, sizeof(drm_i810_private_t)); |
333 | 332 | ||
334 | list_for_each(list, &dev->maplist->head) { | 333 | list_for_each_entry(r_list, &dev->maplist, head) { |
335 | drm_map_list_t *r_list = list_entry(list, drm_map_list_t, head); | ||
336 | if (r_list->map && | 334 | if (r_list->map && |
337 | r_list->map->type == _DRM_SHM && | 335 | r_list->map->type == _DRM_SHM && |
338 | r_list->map->flags & _DRM_CONTAINS_LOCK) { | 336 | r_list->map->flags & _DRM_CONTAINS_LOCK) { |
diff --git a/drivers/char/drm/i830_dma.c b/drivers/char/drm/i830_dma.c index 3314a9fea9e5..3103258df61e 100644 --- a/drivers/char/drm/i830_dma.c +++ b/drivers/char/drm/i830_dma.c | |||
@@ -334,12 +334,11 @@ static int i830_dma_initialize(drm_device_t * dev, | |||
334 | drm_i830_private_t * dev_priv, | 334 | drm_i830_private_t * dev_priv, |
335 | drm_i830_init_t * init) | 335 | drm_i830_init_t * init) |
336 | { | 336 | { |
337 | struct list_head *list; | 337 | drm_map_list_t *r_list; |
338 | 338 | ||
339 | memset(dev_priv, 0, sizeof(drm_i830_private_t)); | 339 | memset(dev_priv, 0, sizeof(drm_i830_private_t)); |
340 | 340 | ||
341 | list_for_each(list, &dev->maplist->head) { | 341 | list_for_each_entry(r_list, &dev->maplist, head) { |
342 | drm_map_list_t *r_list = list_entry(list, drm_map_list_t, head); | ||
343 | if (r_list->map && | 342 | if (r_list->map && |
344 | r_list->map->type == _DRM_SHM && | 343 | r_list->map->type == _DRM_SHM && |
345 | r_list->map->flags & _DRM_CONTAINS_LOCK) { | 344 | r_list->map->flags & _DRM_CONTAINS_LOCK) { |
diff --git a/drivers/char/drm/mga_dma.c b/drivers/char/drm/mga_dma.c index c2a4bac14521..5781a8d934f8 100644 --- a/drivers/char/drm/mga_dma.c +++ b/drivers/char/drm/mga_dma.c | |||
@@ -551,7 +551,7 @@ static int mga_do_agp_dma_bootstrap(drm_device_t * dev, | |||
551 | drm_map_list_t *_entry; | 551 | drm_map_list_t *_entry; |
552 | unsigned long agp_token = 0; | 552 | unsigned long agp_token = 0; |
553 | 553 | ||
554 | list_for_each_entry(_entry, &dev->maplist->head, head) { | 554 | list_for_each_entry(_entry, &dev->maplist, head) { |
555 | if (_entry->map == dev->agp_buffer_map) | 555 | if (_entry->map == dev->agp_buffer_map) |
556 | agp_token = _entry->user_token; | 556 | agp_token = _entry->user_token; |
557 | } | 557 | } |
diff --git a/drivers/char/drm/sis_mm.c b/drivers/char/drm/sis_mm.c index d26f5dbb7853..6875a2eda09d 100644 --- a/drivers/char/drm/sis_mm.c +++ b/drivers/char/drm/sis_mm.c | |||
@@ -234,7 +234,7 @@ static drm_local_map_t *sis_reg_init(drm_device_t *dev) | |||
234 | drm_map_list_t *entry; | 234 | drm_map_list_t *entry; |
235 | drm_local_map_t *map; | 235 | drm_local_map_t *map; |
236 | 236 | ||
237 | list_for_each_entry(entry, &dev->maplist->head, head) { | 237 | list_for_each_entry(entry, &dev->maplist, head) { |
238 | map = entry->map; | 238 | map = entry->map; |
239 | if (!map) | 239 | if (!map) |
240 | continue; | 240 | continue; |
diff --git a/drivers/char/drm/via_verifier.c b/drivers/char/drm/via_verifier.c index 2e7e08078287..8b4ea3027b2c 100644 --- a/drivers/char/drm/via_verifier.c +++ b/drivers/char/drm/via_verifier.c | |||
@@ -254,7 +254,6 @@ static __inline__ drm_local_map_t *via_drm_lookup_agp_map(drm_via_state_t *seq, | |||
254 | unsigned long size, | 254 | unsigned long size, |
255 | drm_device_t * dev) | 255 | drm_device_t * dev) |
256 | { | 256 | { |
257 | struct list_head *list; | ||
258 | drm_map_list_t *r_list; | 257 | drm_map_list_t *r_list; |
259 | drm_local_map_t *map = seq->map_cache; | 258 | drm_local_map_t *map = seq->map_cache; |
260 | 259 | ||
@@ -263,8 +262,7 @@ static __inline__ drm_local_map_t *via_drm_lookup_agp_map(drm_via_state_t *seq, | |||
263 | return map; | 262 | return map; |
264 | } | 263 | } |
265 | 264 | ||
266 | list_for_each(list, &dev->maplist->head) { | 265 | list_for_each_entry(r_list, &dev->maplist, head) { |
267 | r_list = (drm_map_list_t *) list; | ||
268 | map = r_list->map; | 266 | map = r_list->map; |
269 | if (!map) | 267 | if (!map) |
270 | continue; | 268 | continue; |