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.main
parent
ea98d7e796
commit
7b48f0022a
|
@ -300,19 +300,14 @@ typedef struct drm_devstate {
|
||||||
} drm_devstate_t;
|
} drm_devstate_t;
|
||||||
|
|
||||||
typedef struct drm_magic_entry {
|
typedef struct drm_magic_entry {
|
||||||
drm_hash_item_t hash_item;
|
|
||||||
struct list_head head;
|
struct list_head head;
|
||||||
|
drm_hash_item_t hash_item;
|
||||||
struct drm_file *priv;
|
struct drm_file *priv;
|
||||||
} drm_magic_entry_t;
|
} drm_magic_entry_t;
|
||||||
|
|
||||||
typedef struct drm_magic_head {
|
|
||||||
struct drm_magic_entry *head;
|
|
||||||
struct drm_magic_entry *tail;
|
|
||||||
} drm_magic_head_t;
|
|
||||||
|
|
||||||
typedef struct drm_vma_entry {
|
typedef struct drm_vma_entry {
|
||||||
|
struct list_head head;
|
||||||
struct vm_area_struct *vma;
|
struct vm_area_struct *vma;
|
||||||
struct drm_vma_entry *next;
|
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
} drm_vma_entry_t;
|
} drm_vma_entry_t;
|
||||||
|
|
||||||
|
@ -411,8 +406,7 @@ typedef struct drm_file {
|
||||||
uid_t uid;
|
uid_t uid;
|
||||||
drm_magic_t magic;
|
drm_magic_t magic;
|
||||||
unsigned long ioctl_count;
|
unsigned long ioctl_count;
|
||||||
struct drm_file *next;
|
struct list_head lhead;
|
||||||
struct drm_file *prev;
|
|
||||||
struct drm_head *head;
|
struct drm_head *head;
|
||||||
int remove_auth_on_close;
|
int remove_auth_on_close;
|
||||||
unsigned long lock_count;
|
unsigned long lock_count;
|
||||||
|
@ -493,8 +487,7 @@ typedef struct drm_agp_mem {
|
||||||
DRM_AGP_MEM *memory;
|
DRM_AGP_MEM *memory;
|
||||||
unsigned long bound; /**< address */
|
unsigned long bound; /**< address */
|
||||||
int pages;
|
int pages;
|
||||||
struct drm_agp_mem *prev; /**< previous entry */
|
struct list_head head;
|
||||||
struct drm_agp_mem *next; /**< next entry */
|
|
||||||
} drm_agp_mem_t;
|
} drm_agp_mem_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -504,7 +497,7 @@ typedef struct drm_agp_mem {
|
||||||
*/
|
*/
|
||||||
typedef struct drm_agp_head {
|
typedef struct drm_agp_head {
|
||||||
DRM_AGP_KERN agp_info; /**< AGP device information */
|
DRM_AGP_KERN agp_info; /**< AGP device information */
|
||||||
drm_agp_mem_t *memory; /**< memory entries */
|
struct list_head memory;
|
||||||
unsigned long mode; /**< AGP mode */
|
unsigned long mode; /**< AGP mode */
|
||||||
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,11)
|
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,11)
|
||||||
struct agp_bridge_data *bridge;
|
struct agp_bridge_data *bridge;
|
||||||
|
@ -726,15 +719,14 @@ typedef struct drm_device {
|
||||||
|
|
||||||
/** \name Authentication */
|
/** \name Authentication */
|
||||||
/*@{ */
|
/*@{ */
|
||||||
drm_file_t *file_first; /**< file list head */
|
struct list_head filelist;
|
||||||
drm_file_t *file_last; /**< file list tail */
|
|
||||||
drm_open_hash_t magiclist;
|
drm_open_hash_t magiclist;
|
||||||
struct list_head magicfree;
|
struct list_head magicfree;
|
||||||
/*@} */
|
/*@} */
|
||||||
|
|
||||||
/** \name Memory management */
|
/** \name Memory management */
|
||||||
/*@{ */
|
/*@{ */
|
||||||
drm_map_list_t *maplist; /**< Linked list of regions */
|
struct list_head maplist; /**< Linked list of regions */
|
||||||
int map_count; /**< Number of mappable regions */
|
int map_count; /**< Number of mappable regions */
|
||||||
drm_open_hash_t map_hash; /**< User token hash table for maps */
|
drm_open_hash_t map_hash; /**< User token hash table for maps */
|
||||||
drm_mm_t offset_manager; /**< User token manager */
|
drm_mm_t offset_manager; /**< User token manager */
|
||||||
|
@ -744,14 +736,14 @@ typedef struct drm_device {
|
||||||
|
|
||||||
/** \name Context handle management */
|
/** \name Context handle management */
|
||||||
/*@{ */
|
/*@{ */
|
||||||
drm_ctx_list_t *ctxlist; /**< Linked list of context handles */
|
struct list_head ctxlist; /**< Linked list of context handles */
|
||||||
int ctx_count; /**< Number of context handles */
|
int ctx_count; /**< Number of context handles */
|
||||||
struct mutex ctxlist_mutex; /**< For ctxlist */
|
struct mutex ctxlist_mutex; /**< For ctxlist */
|
||||||
|
|
||||||
drm_map_t **context_sareas; /**< per-context SAREA's */
|
drm_map_t **context_sareas; /**< per-context SAREA's */
|
||||||
int max_context;
|
int max_context;
|
||||||
|
|
||||||
drm_vma_entry_t *vmalist; /**< List of vmas (for debugging) */
|
struct list_head vmalist; /**< List of vmas (for debugging) */
|
||||||
drm_lock_data_t lock; /**< Information on hardware lock */
|
drm_lock_data_t lock; /**< Information on hardware lock */
|
||||||
/*@} */
|
/*@} */
|
||||||
|
|
||||||
|
@ -787,8 +779,8 @@ typedef struct drm_device {
|
||||||
atomic_t vbl_received;
|
atomic_t vbl_received;
|
||||||
atomic_t vbl_received2; /**< number of secondary VBLANK interrupts */
|
atomic_t vbl_received2; /**< number of secondary VBLANK interrupts */
|
||||||
spinlock_t vbl_lock;
|
spinlock_t vbl_lock;
|
||||||
drm_vbl_sig_t vbl_sigs; /**< signal list to send on VBLANK */
|
struct list_head vbl_sigs; /**< signal list to send on VBLANK */
|
||||||
drm_vbl_sig_t vbl_sigs2; /**< signals to send on secondary VBLANK */
|
struct list_head vbl_sigs2; /**< signals to send on secondary VBLANK */
|
||||||
unsigned int vbl_pending;
|
unsigned int vbl_pending;
|
||||||
spinlock_t tasklet_lock; /**< For drm_locked_tasklet */
|
spinlock_t tasklet_lock; /**< For drm_locked_tasklet */
|
||||||
void (*locked_tasklet_func)(struct drm_device *dev);
|
void (*locked_tasklet_func)(struct drm_device *dev);
|
||||||
|
@ -1194,7 +1186,7 @@ static __inline__ struct drm_map *drm_core_findmap(struct drm_device *dev,
|
||||||
unsigned int token)
|
unsigned int token)
|
||||||
{
|
{
|
||||||
drm_map_list_t *_entry;
|
drm_map_list_t *_entry;
|
||||||
list_for_each_entry(_entry, &dev->maplist->head, head)
|
list_for_each_entry(_entry, &dev->maplist, head)
|
||||||
if (_entry->user_token == token)
|
if (_entry->user_token == token)
|
||||||
return _entry->map;
|
return _entry->map;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -249,11 +249,7 @@ int drm_agp_alloc(drm_device_t *dev, drm_agp_buffer_t *request)
|
||||||
entry->memory = memory;
|
entry->memory = memory;
|
||||||
entry->bound = 0;
|
entry->bound = 0;
|
||||||
entry->pages = pages;
|
entry->pages = pages;
|
||||||
entry->prev = NULL;
|
list_add(&entry->head, &dev->agp->memory);
|
||||||
entry->next = dev->agp->memory;
|
|
||||||
if (dev->agp->memory)
|
|
||||||
dev->agp->memory->prev = entry;
|
|
||||||
dev->agp->memory = entry;
|
|
||||||
|
|
||||||
request->handle = entry->handle;
|
request->handle = entry->handle;
|
||||||
request->physical = memory->physical;
|
request->physical = memory->physical;
|
||||||
|
@ -280,10 +276,12 @@ int drm_agp_alloc_ioctl(struct inode *inode, struct file *filp,
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
if (copy_to_user(argp, &request, sizeof(request))) {
|
if (copy_to_user(argp, &request, sizeof(request))) {
|
||||||
drm_agp_mem_t *entry = dev->agp->memory;
|
drm_agp_mem_t *entry;
|
||||||
|
list_for_each_entry(entry, &dev->agp->memory, head) {
|
||||||
dev->agp->memory = entry->next;
|
if (entry->handle == request.handle)
|
||||||
dev->agp->memory->prev = NULL;
|
break;
|
||||||
|
}
|
||||||
|
list_del(&entry->head);
|
||||||
drm_free_agp(entry->memory, entry->pages);
|
drm_free_agp(entry->memory, entry->pages);
|
||||||
drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS);
|
drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS);
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
@ -306,7 +304,7 @@ static drm_agp_mem_t *drm_agp_lookup_entry(drm_device_t * dev,
|
||||||
{
|
{
|
||||||
drm_agp_mem_t *entry;
|
drm_agp_mem_t *entry;
|
||||||
|
|
||||||
for (entry = dev->agp->memory; entry; entry = entry->next) {
|
list_for_each_entry(entry, &dev->agp->memory, head) {
|
||||||
if (entry->handle == handle)
|
if (entry->handle == handle)
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
@ -435,13 +433,7 @@ int drm_agp_free(drm_device_t *dev, drm_agp_buffer_t *request)
|
||||||
if (entry->bound)
|
if (entry->bound)
|
||||||
drm_unbind_agp(entry->memory);
|
drm_unbind_agp(entry->memory);
|
||||||
|
|
||||||
if (entry->prev)
|
list_del(&entry->head);
|
||||||
entry->prev->next = entry->next;
|
|
||||||
else
|
|
||||||
dev->agp->memory = entry->next;
|
|
||||||
|
|
||||||
if (entry->next)
|
|
||||||
entry->next->prev = entry->prev;
|
|
||||||
|
|
||||||
drm_free_agp(entry->memory, entry->pages);
|
drm_free_agp(entry->memory, entry->pages);
|
||||||
drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS);
|
drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS);
|
||||||
|
@ -502,7 +494,7 @@ drm_agp_head_t *drm_agp_init(drm_device_t *dev)
|
||||||
drm_free(head, sizeof(*head), DRM_MEM_AGPLISTS);
|
drm_free(head, sizeof(*head), DRM_MEM_AGPLISTS);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
head->memory = NULL;
|
INIT_LIST_HEAD(&head->memory);
|
||||||
head->cant_use_aperture = head->agp_info.cant_use_aperture;
|
head->cant_use_aperture = head->agp_info.cant_use_aperture;
|
||||||
head->page_mask = head->agp_info.page_mask;
|
head->page_mask = head->agp_info.page_mask;
|
||||||
return head;
|
return head;
|
||||||
|
|
|
@ -51,10 +51,8 @@ EXPORT_SYMBOL(drm_get_resource_len);
|
||||||
static drm_map_list_t *drm_find_matching_map(drm_device_t *dev,
|
static drm_map_list_t *drm_find_matching_map(drm_device_t *dev,
|
||||||
drm_local_map_t *map)
|
drm_local_map_t *map)
|
||||||
{
|
{
|
||||||
struct list_head *list;
|
drm_map_list_t *entry;
|
||||||
|
list_for_each_entry(entry, &dev->maplist, head) {
|
||||||
list_for_each(list, &dev->maplist->head) {
|
|
||||||
drm_map_list_t *entry = list_entry(list, drm_map_list_t, head);
|
|
||||||
if (entry->map && map->type == entry->map->type &&
|
if (entry->map && map->type == entry->map->type &&
|
||||||
((entry->map->offset == map->offset) ||
|
((entry->map->offset == map->offset) ||
|
||||||
(map->type == _DRM_SHM && map->flags==_DRM_CONTAINS_LOCK))) {
|
(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,
|
||||||
* skipped and we double check that dev->agp->memory is
|
* skipped and we double check that dev->agp->memory is
|
||||||
* actually set as well as being invalid before EPERM'ing
|
* actually set as well as being invalid before EPERM'ing
|
||||||
*/
|
*/
|
||||||
for (entry = dev->agp->memory; entry; entry = entry->next) {
|
list_for_each_entry(entry, &dev->agp->memory, head) {
|
||||||
if ((map->offset >= entry->bound) &&
|
if ((map->offset >= entry->bound) &&
|
||||||
(map->offset + map->size <= entry->bound + entry->pages * PAGE_SIZE)) {
|
(map->offset + map->size <= entry->bound + entry->pages * PAGE_SIZE)) {
|
||||||
valid = 1;
|
valid = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (dev->agp->memory && !valid) {
|
if (!list_empty(&dev->agp->memory) && !valid) {
|
||||||
drm_free(map, sizeof(*map), DRM_MEM_MAPS);
|
drm_free(map, sizeof(*map), DRM_MEM_MAPS);
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
}
|
}
|
||||||
|
@ -288,7 +286,7 @@ static int drm_addmap_core(drm_device_t * dev, unsigned int offset,
|
||||||
list->map = map;
|
list->map = map;
|
||||||
|
|
||||||
mutex_lock(&dev->struct_mutex);
|
mutex_lock(&dev->struct_mutex);
|
||||||
list_add(&list->head, &dev->maplist->head);
|
list_add(&list->head, &dev->maplist);
|
||||||
|
|
||||||
/* Assign a 32-bit handle */
|
/* Assign a 32-bit handle */
|
||||||
|
|
||||||
|
@ -380,29 +378,28 @@ int drm_addmap_ioctl(struct inode *inode, struct file *filp,
|
||||||
*/
|
*/
|
||||||
int drm_rmmap_locked(drm_device_t *dev, drm_local_map_t *map)
|
int drm_rmmap_locked(drm_device_t *dev, drm_local_map_t *map)
|
||||||
{
|
{
|
||||||
struct list_head *list;
|
drm_map_list_t *r_list = NULL, *list_t;
|
||||||
drm_map_list_t *r_list = NULL;
|
|
||||||
drm_dma_handle_t dmah;
|
drm_dma_handle_t dmah;
|
||||||
|
int found = 0;
|
||||||
|
|
||||||
/* Find the list entry for the map and remove it */
|
/* Find the list entry for the map and remove it */
|
||||||
list_for_each(list, &dev->maplist->head) {
|
list_for_each_entry_safe(r_list, list_t, &dev->maplist, head) {
|
||||||
r_list = list_entry(list, drm_map_list_t, head);
|
|
||||||
|
|
||||||
if (r_list->map == map) {
|
if (r_list->map == map) {
|
||||||
list_del(list);
|
list_del(&r_list->head);
|
||||||
drm_ht_remove_key(&dev->map_hash,
|
drm_ht_remove_key(&dev->map_hash,
|
||||||
r_list->user_token >> PAGE_SHIFT);
|
r_list->user_token >> PAGE_SHIFT);
|
||||||
drm_free(list, sizeof(*list), DRM_MEM_MAPS);
|
drm_free(r_list, sizeof(*r_list), DRM_MEM_MAPS);
|
||||||
|
found = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!found) {
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
/* List has wrapped around to the head pointer, or it's empty and we
|
/* List has wrapped around to the head pointer, or it's empty and we
|
||||||
* didn't find anything.
|
* didn't find anything.
|
||||||
*/
|
*/
|
||||||
if (list == (&dev->maplist->head)) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (map->type) {
|
switch (map->type) {
|
||||||
case _DRM_REGISTERS:
|
case _DRM_REGISTERS:
|
||||||
|
@ -464,7 +461,7 @@ int drm_rmmap_ioctl(struct inode *inode, struct file *filp,
|
||||||
drm_device_t *dev = priv->head->dev;
|
drm_device_t *dev = priv->head->dev;
|
||||||
drm_map_t request;
|
drm_map_t request;
|
||||||
drm_local_map_t *map = NULL;
|
drm_local_map_t *map = NULL;
|
||||||
struct list_head *list;
|
drm_map_list_t *r_list;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (copy_from_user(&request, (drm_map_t __user *) arg, sizeof(request))) {
|
if (copy_from_user(&request, (drm_map_t __user *) arg, sizeof(request))) {
|
||||||
|
@ -472,9 +469,7 @@ int drm_rmmap_ioctl(struct inode *inode, struct file *filp,
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_lock(&dev->struct_mutex);
|
mutex_lock(&dev->struct_mutex);
|
||||||
list_for_each(list, &dev->maplist->head) {
|
list_for_each_entry(r_list, &dev->maplist, head) {
|
||||||
drm_map_list_t *r_list = list_entry(list, drm_map_list_t, head);
|
|
||||||
|
|
||||||
if (r_list->map &&
|
if (r_list->map &&
|
||||||
r_list->user_token == (unsigned long)request.handle &&
|
r_list->user_token == (unsigned long)request.handle &&
|
||||||
r_list->map->flags & _DRM_REMOVABLE) {
|
r_list->map->flags & _DRM_REMOVABLE) {
|
||||||
|
@ -486,7 +481,7 @@ int drm_rmmap_ioctl(struct inode *inode, struct file *filp,
|
||||||
/* List has wrapped around to the head pointer, or its empty we didn't
|
/* List has wrapped around to the head pointer, or its empty we didn't
|
||||||
* find anything.
|
* find anything.
|
||||||
*/
|
*/
|
||||||
if (list == (&dev->maplist->head)) {
|
if (list_empty(&dev->maplist) || !map) {
|
||||||
mutex_unlock(&dev->struct_mutex);
|
mutex_unlock(&dev->struct_mutex);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
@ -610,14 +605,14 @@ int drm_addbufs_agp(drm_device_t * dev, drm_buf_desc_t * request)
|
||||||
|
|
||||||
/* Make sure buffers are located in AGP memory that we own */
|
/* Make sure buffers are located in AGP memory that we own */
|
||||||
valid = 0;
|
valid = 0;
|
||||||
for (agp_entry = dev->agp->memory; agp_entry; agp_entry = agp_entry->next) {
|
list_for_each_entry(agp_entry, &dev->agp->memory, head) {
|
||||||
if ((agp_offset >= agp_entry->bound) &&
|
if ((agp_offset >= agp_entry->bound) &&
|
||||||
(agp_offset + total * count <= agp_entry->bound + agp_entry->pages * PAGE_SIZE)) {
|
(agp_offset + total * count <= agp_entry->bound + agp_entry->pages * PAGE_SIZE)) {
|
||||||
valid = 1;
|
valid = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (dev->agp->memory && !valid) {
|
if (!list_empty(&dev->agp->memory) && !valid) {
|
||||||
DRM_DEBUG("zone invalid\n");
|
DRM_DEBUG("zone invalid\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -233,7 +233,7 @@ int drm_getsareactx(struct inode *inode, struct file *filp,
|
||||||
mutex_unlock(&dev->struct_mutex);
|
mutex_unlock(&dev->struct_mutex);
|
||||||
|
|
||||||
request.handle = NULL;
|
request.handle = NULL;
|
||||||
list_for_each_entry(_entry, &dev->maplist->head,head) {
|
list_for_each_entry(_entry, &dev->maplist, head) {
|
||||||
if (_entry->map == map) {
|
if (_entry->map == map) {
|
||||||
request.handle =
|
request.handle =
|
||||||
(void *)(unsigned long)_entry->user_token;
|
(void *)(unsigned long)_entry->user_token;
|
||||||
|
@ -268,15 +268,13 @@ int drm_setsareactx(struct inode *inode, struct file *filp,
|
||||||
drm_ctx_priv_map_t request;
|
drm_ctx_priv_map_t request;
|
||||||
drm_map_t *map = NULL;
|
drm_map_t *map = NULL;
|
||||||
drm_map_list_t *r_list = NULL;
|
drm_map_list_t *r_list = NULL;
|
||||||
struct list_head *list;
|
|
||||||
|
|
||||||
if (copy_from_user(&request,
|
if (copy_from_user(&request,
|
||||||
(drm_ctx_priv_map_t __user *) arg, sizeof(request)))
|
(drm_ctx_priv_map_t __user *) arg, sizeof(request)))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
mutex_lock(&dev->struct_mutex);
|
mutex_lock(&dev->struct_mutex);
|
||||||
list_for_each(list, &dev->maplist->head) {
|
list_for_each_entry(r_list, &dev->maplist, head) {
|
||||||
r_list = list_entry(list, drm_map_list_t, head);
|
|
||||||
if (r_list->map
|
if (r_list->map
|
||||||
&& r_list->user_token == (unsigned long) request.handle)
|
&& r_list->user_token == (unsigned long) request.handle)
|
||||||
goto found;
|
goto found;
|
||||||
|
@ -449,7 +447,7 @@ int drm_addctx(struct inode *inode, struct file *filp,
|
||||||
ctx_entry->tag = priv;
|
ctx_entry->tag = priv;
|
||||||
|
|
||||||
mutex_lock(&dev->ctxlist_mutex);
|
mutex_lock(&dev->ctxlist_mutex);
|
||||||
list_add(&ctx_entry->head, &dev->ctxlist->head);
|
list_add(&ctx_entry->head, &dev->ctxlist);
|
||||||
++dev->ctx_count;
|
++dev->ctx_count;
|
||||||
mutex_unlock(&dev->ctxlist_mutex);
|
mutex_unlock(&dev->ctxlist_mutex);
|
||||||
|
|
||||||
|
@ -575,10 +573,10 @@ int drm_rmctx(struct inode *inode, struct file *filp,
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_lock(&dev->ctxlist_mutex);
|
mutex_lock(&dev->ctxlist_mutex);
|
||||||
if (!list_empty(&dev->ctxlist->head)) {
|
if (!list_empty(&dev->ctxlist)) {
|
||||||
drm_ctx_list_t *pos, *n;
|
drm_ctx_list_t *pos, *n;
|
||||||
|
|
||||||
list_for_each_entry_safe(pos, n, &dev->ctxlist->head, head) {
|
list_for_each_entry_safe(pos, n, &dev->ctxlist, head) {
|
||||||
if (pos->handle == ctx.handle) {
|
if (pos->handle == ctx.handle) {
|
||||||
list_del(&pos->head);
|
list_del(&pos->head);
|
||||||
drm_free(pos, sizeof(*pos), DRM_MEM_CTXLIST);
|
drm_free(pos, sizeof(*pos), DRM_MEM_CTXLIST);
|
||||||
|
|
|
@ -140,8 +140,8 @@ static drm_ioctl_desc_t drm_ioctls[] = {
|
||||||
int drm_lastclose(drm_device_t * dev)
|
int drm_lastclose(drm_device_t * dev)
|
||||||
{
|
{
|
||||||
drm_magic_entry_t *pt, *next;
|
drm_magic_entry_t *pt, *next;
|
||||||
drm_map_list_t *r_list;
|
drm_map_list_t *r_list, *list_t;
|
||||||
drm_vma_entry_t *vma, *vma_next;
|
drm_vma_entry_t *vma, *vma_temp;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
DRM_DEBUG("\n");
|
DRM_DEBUG("\n");
|
||||||
|
@ -198,19 +198,17 @@ int drm_lastclose(drm_device_t * dev)
|
||||||
|
|
||||||
/* Clear AGP information */
|
/* Clear AGP information */
|
||||||
if (drm_core_has_AGP(dev) && dev->agp) {
|
if (drm_core_has_AGP(dev) && dev->agp) {
|
||||||
drm_agp_mem_t *entry;
|
drm_agp_mem_t *entry, *tempe;
|
||||||
drm_agp_mem_t *nexte;
|
|
||||||
|
|
||||||
/* Remove AGP resources, but leave dev->agp
|
/* Remove AGP resources, but leave dev->agp
|
||||||
intact until drv_cleanup is called. */
|
intact until drv_cleanup is called. */
|
||||||
for (entry = dev->agp->memory; entry; entry = nexte) {
|
list_for_each_entry_safe(entry, tempe, &dev->agp->memory, head) {
|
||||||
nexte = entry->next;
|
|
||||||
if (entry->bound)
|
if (entry->bound)
|
||||||
drm_unbind_agp(entry->memory);
|
drm_unbind_agp(entry->memory);
|
||||||
drm_free_agp(entry->memory, entry->pages);
|
drm_free_agp(entry->memory, entry->pages);
|
||||||
drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS);
|
drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS);
|
||||||
}
|
}
|
||||||
dev->agp->memory = NULL;
|
INIT_LIST_HEAD(&dev->agp->memory);
|
||||||
|
|
||||||
if (dev->agp->acquired)
|
if (dev->agp->acquired)
|
||||||
drm_agp_release(dev);
|
drm_agp_release(dev);
|
||||||
|
@ -224,20 +222,14 @@ int drm_lastclose(drm_device_t * dev)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clear vma list (only built for debugging) */
|
/* Clear vma list (only built for debugging) */
|
||||||
if (dev->vmalist) {
|
list_for_each_entry_safe(vma, vma_temp, &dev->vmalist, head) {
|
||||||
for (vma = dev->vmalist; vma; vma = vma_next) {
|
list_del(&vma->head);
|
||||||
vma_next = vma->next;
|
|
||||||
drm_ctl_free(vma, sizeof(*vma), DRM_MEM_VMAS);
|
drm_ctl_free(vma, sizeof(*vma), DRM_MEM_VMAS);
|
||||||
}
|
}
|
||||||
dev->vmalist = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dev->maplist) {
|
list_for_each_entry_safe(r_list, list_t, &dev->maplist, head) {
|
||||||
while (!list_empty(&dev->maplist->head)) {
|
|
||||||
struct list_head *list = dev->maplist->head.next;
|
|
||||||
r_list = list_entry(list, drm_map_list_t, head);
|
|
||||||
drm_rmmap_locked(dev, r_list->map);
|
drm_rmmap_locked(dev, r_list->map);
|
||||||
}
|
r_list = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (drm_core_check_feature(dev, DRIVER_DMA_QUEUE) && dev->queuelist) {
|
if (drm_core_check_feature(dev, DRIVER_DMA_QUEUE) && dev->queuelist) {
|
||||||
|
@ -372,13 +364,9 @@ static void drm_cleanup(drm_device_t * dev)
|
||||||
drm_lastclose(dev);
|
drm_lastclose(dev);
|
||||||
drm_fence_manager_takedown(dev);
|
drm_fence_manager_takedown(dev);
|
||||||
|
|
||||||
if (dev->maplist) {
|
|
||||||
drm_free(dev->maplist, sizeof(*dev->maplist), DRM_MEM_MAPS);
|
|
||||||
dev->maplist = NULL;
|
|
||||||
drm_ht_remove(&dev->map_hash);
|
drm_ht_remove(&dev->map_hash);
|
||||||
drm_mm_takedown(&dev->offset_manager);
|
drm_mm_takedown(&dev->offset_manager);
|
||||||
drm_ht_remove(&dev->object_hash);
|
drm_ht_remove(&dev->object_hash);
|
||||||
}
|
|
||||||
|
|
||||||
if (!drm_fb_loaded)
|
if (!drm_fb_loaded)
|
||||||
pci_disable_device(dev->pdev);
|
pci_disable_device(dev->pdev);
|
||||||
|
@ -655,7 +643,7 @@ drm_local_map_t *drm_getsarea(struct drm_device *dev)
|
||||||
{
|
{
|
||||||
drm_map_list_t *entry;
|
drm_map_list_t *entry;
|
||||||
|
|
||||||
list_for_each_entry(entry, &dev->maplist->head, head) {
|
list_for_each_entry(entry, &dev->maplist, head) {
|
||||||
if (entry->map && entry->map->type == _DRM_SHM &&
|
if (entry->map && entry->map->type == _DRM_SHM &&
|
||||||
(entry->map->flags & _DRM_CONTAINS_LOCK)) {
|
(entry->map->flags & _DRM_CONTAINS_LOCK)) {
|
||||||
return entry->map;
|
return entry->map;
|
||||||
|
|
|
@ -79,13 +79,9 @@ static int drm_setup(drm_device_t * dev)
|
||||||
drm_ht_create(&dev->magiclist, DRM_MAGIC_HASH_ORDER);
|
drm_ht_create(&dev->magiclist, DRM_MAGIC_HASH_ORDER);
|
||||||
INIT_LIST_HEAD(&dev->magicfree);
|
INIT_LIST_HEAD(&dev->magicfree);
|
||||||
|
|
||||||
dev->ctxlist = drm_alloc(sizeof(*dev->ctxlist), DRM_MEM_CTXLIST);
|
INIT_LIST_HEAD(&dev->ctxlist);
|
||||||
if (dev->ctxlist == NULL)
|
INIT_LIST_HEAD(&dev->vmalist);
|
||||||
return -ENOMEM;
|
|
||||||
memset(dev->ctxlist, 0, sizeof(*dev->ctxlist));
|
|
||||||
INIT_LIST_HEAD(&dev->ctxlist->head);
|
|
||||||
|
|
||||||
dev->vmalist = NULL;
|
|
||||||
dev->sigdata.lock = NULL;
|
dev->sigdata.lock = NULL;
|
||||||
init_waitqueue_head(&dev->lock.lock_queue);
|
init_waitqueue_head(&dev->lock.lock_queue);
|
||||||
dev->queue_count = 0;
|
dev->queue_count = 0;
|
||||||
|
@ -268,6 +264,7 @@ static int drm_open_helper(struct inode *inode, struct file *filp,
|
||||||
priv->authenticated = capable(CAP_SYS_ADMIN);
|
priv->authenticated = capable(CAP_SYS_ADMIN);
|
||||||
priv->lock_count = 0;
|
priv->lock_count = 0;
|
||||||
|
|
||||||
|
INIT_LIST_HEAD(&priv->lhead);
|
||||||
INIT_LIST_HEAD(&priv->user_objects);
|
INIT_LIST_HEAD(&priv->user_objects);
|
||||||
INIT_LIST_HEAD(&priv->refd_objects);
|
INIT_LIST_HEAD(&priv->refd_objects);
|
||||||
|
|
||||||
|
@ -291,19 +288,10 @@ static int drm_open_helper(struct inode *inode, struct file *filp,
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_lock(&dev->struct_mutex);
|
mutex_lock(&dev->struct_mutex);
|
||||||
if (!dev->file_last) {
|
if (list_empty(&dev->filelist))
|
||||||
priv->next = NULL;
|
|
||||||
priv->prev = NULL;
|
|
||||||
dev->file_first = priv;
|
|
||||||
dev->file_last = priv;
|
|
||||||
/* first opener automatically becomes master */
|
|
||||||
priv->master = 1;
|
priv->master = 1;
|
||||||
} else {
|
|
||||||
priv->next = NULL;
|
list_add(&priv->lhead, &dev->filelist);
|
||||||
priv->prev = dev->file_last;
|
|
||||||
dev->file_last->next = priv;
|
|
||||||
dev->file_last = priv;
|
|
||||||
}
|
|
||||||
mutex_unlock(&dev->struct_mutex);
|
mutex_unlock(&dev->struct_mutex);
|
||||||
|
|
||||||
#ifdef __alpha__
|
#ifdef __alpha__
|
||||||
|
@ -480,10 +468,10 @@ int drm_release(struct inode *inode, struct file *filp)
|
||||||
|
|
||||||
mutex_lock(&dev->ctxlist_mutex);
|
mutex_lock(&dev->ctxlist_mutex);
|
||||||
|
|
||||||
if (dev->ctxlist && (!list_empty(&dev->ctxlist->head))) {
|
if (!list_empty(&dev->ctxlist)) {
|
||||||
drm_ctx_list_t *pos, *n;
|
drm_ctx_list_t *pos, *n;
|
||||||
|
|
||||||
list_for_each_entry_safe(pos, n, &dev->ctxlist->head, head) {
|
list_for_each_entry_safe(pos, n, &dev->ctxlist, head) {
|
||||||
if (pos->tag == priv &&
|
if (pos->tag == priv &&
|
||||||
pos->handle != DRM_KERNEL_CONTEXT) {
|
pos->handle != DRM_KERNEL_CONTEXT) {
|
||||||
if (dev->driver->context_dtor)
|
if (dev->driver->context_dtor)
|
||||||
|
@ -503,22 +491,12 @@ int drm_release(struct inode *inode, struct file *filp)
|
||||||
mutex_lock(&dev->struct_mutex);
|
mutex_lock(&dev->struct_mutex);
|
||||||
drm_object_release(filp);
|
drm_object_release(filp);
|
||||||
if (priv->remove_auth_on_close == 1) {
|
if (priv->remove_auth_on_close == 1) {
|
||||||
drm_file_t *temp = dev->file_first;
|
drm_file_t *temp;
|
||||||
while (temp) {
|
|
||||||
|
list_for_each_entry(temp, &dev->filelist, lhead)
|
||||||
temp->authenticated = 0;
|
temp->authenticated = 0;
|
||||||
temp = temp->next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (priv->prev) {
|
|
||||||
priv->prev->next = priv->next;
|
|
||||||
} else {
|
|
||||||
dev->file_first = priv->next;
|
|
||||||
}
|
|
||||||
if (priv->next) {
|
|
||||||
priv->next->prev = priv->prev;
|
|
||||||
} else {
|
|
||||||
dev->file_last = priv->prev;
|
|
||||||
}
|
}
|
||||||
|
list_del(&priv->lhead);
|
||||||
mutex_unlock(&dev->struct_mutex);
|
mutex_unlock(&dev->struct_mutex);
|
||||||
|
|
||||||
if (dev->driver->postclose)
|
if (dev->driver->postclose)
|
||||||
|
|
|
@ -199,7 +199,7 @@ int drm_getmap(struct inode *inode, struct file *filp,
|
||||||
}
|
}
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
list_for_each(list, &dev->maplist->head) {
|
list_for_each(list, &dev->maplist) {
|
||||||
if (i == idx) {
|
if (i == idx) {
|
||||||
r_list = list_entry(list, drm_map_list_t, head);
|
r_list = list_entry(list, drm_map_list_t, head);
|
||||||
break;
|
break;
|
||||||
|
@ -252,12 +252,18 @@ int drm_getclient(struct inode *inode, struct file *filp,
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
idx = client.idx;
|
idx = client.idx;
|
||||||
mutex_lock(&dev->struct_mutex);
|
mutex_lock(&dev->struct_mutex);
|
||||||
for (i = 0, pt = dev->file_first; i < idx && pt; i++, pt = pt->next) ;
|
|
||||||
|
|
||||||
if (!pt) {
|
if (list_empty(&dev->filelist)) {
|
||||||
mutex_unlock(&dev->struct_mutex);
|
mutex_unlock(&dev->struct_mutex);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
list_for_each_entry(pt, &dev->filelist, lhead) {
|
||||||
|
if (i++ >= idx)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
client.auth = pt->authenticated;
|
client.auth = pt->authenticated;
|
||||||
client.pid = pt->pid;
|
client.pid = pt->pid;
|
||||||
client.uid = pt->uid;
|
client.uid = pt->uid;
|
||||||
|
|
|
@ -119,8 +119,8 @@ static int drm_irq_install(drm_device_t * dev)
|
||||||
|
|
||||||
spin_lock_init(&dev->vbl_lock);
|
spin_lock_init(&dev->vbl_lock);
|
||||||
|
|
||||||
INIT_LIST_HEAD(&dev->vbl_sigs.head);
|
INIT_LIST_HEAD(&dev->vbl_sigs);
|
||||||
INIT_LIST_HEAD(&dev->vbl_sigs2.head);
|
INIT_LIST_HEAD(&dev->vbl_sigs2);
|
||||||
|
|
||||||
dev->vbl_pending = 0;
|
dev->vbl_pending = 0;
|
||||||
}
|
}
|
||||||
|
@ -290,7 +290,7 @@ int drm_wait_vblank(DRM_IOCTL_ARGS)
|
||||||
|
|
||||||
if (flags & _DRM_VBLANK_SIGNAL) {
|
if (flags & _DRM_VBLANK_SIGNAL) {
|
||||||
unsigned long irqflags;
|
unsigned long irqflags;
|
||||||
drm_vbl_sig_t *vbl_sigs = (flags & _DRM_VBLANK_SECONDARY)
|
struct list_head *vbl_sigs = (flags & _DRM_VBLANK_SECONDARY)
|
||||||
? &dev->vbl_sigs2 : &dev->vbl_sigs;
|
? &dev->vbl_sigs2 : &dev->vbl_sigs;
|
||||||
drm_vbl_sig_t *vbl_sig;
|
drm_vbl_sig_t *vbl_sig;
|
||||||
|
|
||||||
|
@ -300,7 +300,7 @@ int drm_wait_vblank(DRM_IOCTL_ARGS)
|
||||||
* for the same vblank sequence number; nothing to be done in
|
* for the same vblank sequence number; nothing to be done in
|
||||||
* that case
|
* that case
|
||||||
*/
|
*/
|
||||||
list_for_each_entry(vbl_sig, &vbl_sigs->head, head) {
|
list_for_each_entry(vbl_sig, vbl_sigs, head) {
|
||||||
if (vbl_sig->sequence == vblwait.request.sequence
|
if (vbl_sig->sequence == vblwait.request.sequence
|
||||||
&& vbl_sig->info.si_signo == vblwait.request.signal
|
&& vbl_sig->info.si_signo == vblwait.request.signal
|
||||||
&& vbl_sig->task == current) {
|
&& vbl_sig->task == current) {
|
||||||
|
@ -334,7 +334,7 @@ int drm_wait_vblank(DRM_IOCTL_ARGS)
|
||||||
|
|
||||||
spin_lock_irqsave(&dev->vbl_lock, irqflags);
|
spin_lock_irqsave(&dev->vbl_lock, irqflags);
|
||||||
|
|
||||||
list_add_tail((struct list_head *)vbl_sig, &vbl_sigs->head);
|
list_add_tail(&vbl_sig->head, vbl_sigs);
|
||||||
|
|
||||||
spin_unlock_irqrestore(&dev->vbl_lock, irqflags);
|
spin_unlock_irqrestore(&dev->vbl_lock, irqflags);
|
||||||
|
|
||||||
|
@ -377,20 +377,18 @@ void drm_vbl_send_signals(drm_device_t * dev)
|
||||||
spin_lock_irqsave(&dev->vbl_lock, flags);
|
spin_lock_irqsave(&dev->vbl_lock, flags);
|
||||||
|
|
||||||
for (i = 0; i < 2; i++) {
|
for (i = 0; i < 2; i++) {
|
||||||
struct list_head *list, *tmp;
|
drm_vbl_sig_t *vbl_sig, *tmp;
|
||||||
drm_vbl_sig_t *vbl_sig;
|
struct list_head *vbl_sigs = i ? &dev->vbl_sigs2 : &dev->vbl_sigs;
|
||||||
drm_vbl_sig_t *vbl_sigs = i ? &dev->vbl_sigs2 : &dev->vbl_sigs;
|
|
||||||
unsigned int vbl_seq = atomic_read(i ? &dev->vbl_received2 :
|
unsigned int vbl_seq = atomic_read(i ? &dev->vbl_received2 :
|
||||||
&dev->vbl_received);
|
&dev->vbl_received);
|
||||||
|
|
||||||
list_for_each_safe(list, tmp, &vbl_sigs->head) {
|
list_for_each_entry_safe(vbl_sig, tmp, vbl_sigs, head) {
|
||||||
vbl_sig = list_entry(list, drm_vbl_sig_t, head);
|
|
||||||
if ((vbl_seq - vbl_sig->sequence) <= (1 << 23)) {
|
if ((vbl_seq - vbl_sig->sequence) <= (1 << 23)) {
|
||||||
vbl_sig->info.si_code = vbl_seq;
|
vbl_sig->info.si_code = vbl_seq;
|
||||||
send_sig_info(vbl_sig->info.si_signo,
|
send_sig_info(vbl_sig->info.si_signo,
|
||||||
&vbl_sig->info, vbl_sig->task);
|
&vbl_sig->info, vbl_sig->task);
|
||||||
|
|
||||||
list_del(list);
|
list_del(&vbl_sig->head);
|
||||||
|
|
||||||
drm_free(vbl_sig, sizeof(*vbl_sig),
|
drm_free(vbl_sig, sizeof(*vbl_sig),
|
||||||
DRM_MEM_DRIVER);
|
DRM_MEM_DRIVER);
|
||||||
|
|
|
@ -228,7 +228,7 @@ static void *agp_remap(unsigned long offset, unsigned long size,
|
||||||
offset -= dev->hose->mem_space->start;
|
offset -= dev->hose->mem_space->start;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (agpmem = dev->agp->memory; agpmem; agpmem = agpmem->next)
|
list_for_each_entry(agpmem, &dev->agp->memory, head)
|
||||||
if (agpmem->bound <= offset
|
if (agpmem->bound <= offset
|
||||||
&& (agpmem->bound + (agpmem->pages << PAGE_SHIFT)) >=
|
&& (agpmem->bound + (agpmem->pages << PAGE_SHIFT)) >=
|
||||||
(offset + size))
|
(offset + size))
|
||||||
|
|
|
@ -211,7 +211,6 @@ static int drm__vm_info(char *buf, char **start, off_t offset, int request,
|
||||||
int len = 0;
|
int len = 0;
|
||||||
drm_map_t *map;
|
drm_map_t *map;
|
||||||
drm_map_list_t *r_list;
|
drm_map_list_t *r_list;
|
||||||
struct list_head *list;
|
|
||||||
|
|
||||||
/* Hardcoded from _DRM_FRAME_BUFFER,
|
/* Hardcoded from _DRM_FRAME_BUFFER,
|
||||||
_DRM_REGISTERS, _DRM_SHM, _DRM_AGP,
|
_DRM_REGISTERS, _DRM_SHM, _DRM_AGP,
|
||||||
|
@ -231,9 +230,7 @@ static int drm__vm_info(char *buf, char **start, off_t offset, int request,
|
||||||
DRM_PROC_PRINT("slot offset size type flags "
|
DRM_PROC_PRINT("slot offset size type flags "
|
||||||
"address mtrr\n\n");
|
"address mtrr\n\n");
|
||||||
i = 0;
|
i = 0;
|
||||||
if (dev->maplist != NULL)
|
list_for_each_entry(r_list, &dev->maplist, head) {
|
||||||
list_for_each(list, &dev->maplist->head) {
|
|
||||||
r_list = list_entry(list, drm_map_list_t, head);
|
|
||||||
map = r_list->map;
|
map = r_list->map;
|
||||||
if (!map)
|
if (!map)
|
||||||
continue;
|
continue;
|
||||||
|
@ -535,7 +532,7 @@ static int drm__clients_info(char *buf, char **start, off_t offset,
|
||||||
*eof = 0;
|
*eof = 0;
|
||||||
|
|
||||||
DRM_PROC_PRINT("a dev pid uid magic ioctls\n\n");
|
DRM_PROC_PRINT("a dev pid uid magic ioctls\n\n");
|
||||||
for (priv = dev->file_first; priv; priv = priv->next) {
|
list_for_each_entry(priv, &dev->filelist, lhead) {
|
||||||
DRM_PROC_PRINT("%c %3d %5d %5d %10u %10lu\n",
|
DRM_PROC_PRINT("%c %3d %5d %5d %10u %10lu\n",
|
||||||
priv->authenticated ? 'y' : 'n',
|
priv->authenticated ? 'y' : 'n',
|
||||||
priv->minor,
|
priv->minor,
|
||||||
|
@ -588,7 +585,7 @@ static int drm__vma_info(char *buf, char **start, off_t offset, int request,
|
||||||
DRM_PROC_PRINT("vma use count: %d, high_memory = %p, 0x%08lx\n",
|
DRM_PROC_PRINT("vma use count: %d, high_memory = %p, 0x%08lx\n",
|
||||||
atomic_read(&dev->vma_count),
|
atomic_read(&dev->vma_count),
|
||||||
high_memory, virt_to_phys(high_memory));
|
high_memory, virt_to_phys(high_memory));
|
||||||
for (pt = dev->vmalist; pt; pt = pt->next) {
|
list_for_each_entry(pt, &dev->vmalist, head) {
|
||||||
if (!(vma = pt->vma))
|
if (!(vma = pt->vma))
|
||||||
continue;
|
continue;
|
||||||
DRM_PROC_PRINT("\n%5d 0x%08lx-0x%08lx %c%c%c%c%c%c 0x%08lx000",
|
DRM_PROC_PRINT("\n%5d 0x%08lx-0x%08lx %c%c%c%c%c%c 0x%08lx000",
|
||||||
|
|
|
@ -60,6 +60,7 @@ static int drm_fill_in_dev(drm_device_t * dev, struct pci_dev *pdev,
|
||||||
{
|
{
|
||||||
int retcode;
|
int retcode;
|
||||||
|
|
||||||
|
INIT_LIST_HEAD(&dev->filelist);
|
||||||
spin_lock_init(&dev->count_lock);
|
spin_lock_init(&dev->count_lock);
|
||||||
spin_lock_init(&dev->drw_lock);
|
spin_lock_init(&dev->drw_lock);
|
||||||
spin_lock_init(&dev->tasklet_lock);
|
spin_lock_init(&dev->tasklet_lock);
|
||||||
|
@ -80,27 +81,21 @@ static int drm_fill_in_dev(drm_device_t * dev, struct pci_dev *pdev,
|
||||||
dev->irq = pdev->irq;
|
dev->irq = pdev->irq;
|
||||||
|
|
||||||
if (drm_ht_create(&dev->map_hash, DRM_MAP_HASH_ORDER)) {
|
if (drm_ht_create(&dev->map_hash, DRM_MAP_HASH_ORDER)) {
|
||||||
drm_free(dev->maplist, sizeof(*dev->maplist), DRM_MEM_MAPS);
|
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
if (drm_mm_init(&dev->offset_manager, DRM_FILE_PAGE_OFFSET_START,
|
if (drm_mm_init(&dev->offset_manager, DRM_FILE_PAGE_OFFSET_START,
|
||||||
DRM_FILE_PAGE_OFFSET_SIZE)) {
|
DRM_FILE_PAGE_OFFSET_SIZE)) {
|
||||||
drm_free(dev->maplist, sizeof(*dev->maplist), DRM_MEM_MAPS);
|
|
||||||
drm_ht_remove(&dev->map_hash);
|
drm_ht_remove(&dev->map_hash);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (drm_ht_create(&dev->object_hash, DRM_OBJECT_HASH_ORDER)) {
|
if (drm_ht_create(&dev->object_hash, DRM_OBJECT_HASH_ORDER)) {
|
||||||
drm_free(dev->maplist, sizeof(*dev->maplist), DRM_MEM_MAPS);
|
|
||||||
drm_ht_remove(&dev->map_hash);
|
drm_ht_remove(&dev->map_hash);
|
||||||
drm_mm_takedown(&dev->offset_manager);
|
drm_mm_takedown(&dev->offset_manager);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
dev->maplist = drm_calloc(1, sizeof(*dev->maplist), DRM_MEM_MAPS);
|
INIT_LIST_HEAD(&dev->maplist);
|
||||||
if (dev->maplist == NULL)
|
|
||||||
return -ENOMEM;
|
|
||||||
INIT_LIST_HEAD(&dev->maplist->head);
|
|
||||||
|
|
||||||
/* the DRM has 6 counters */
|
/* the DRM has 6 counters */
|
||||||
dev->counters = 6;
|
dev->counters = 6;
|
||||||
|
|
|
@ -122,7 +122,7 @@ static __inline__ struct page *drm_do_vm_nopage(struct vm_area_struct *vma,
|
||||||
/*
|
/*
|
||||||
* It's AGP memory - find the real physical page to map
|
* It's AGP memory - find the real physical page to map
|
||||||
*/
|
*/
|
||||||
for (agpmem = dev->agp->memory; agpmem; agpmem = agpmem->next) {
|
list_for_each_entry(agpmem, &dev->agp->memory, head) {
|
||||||
if (agpmem->bound <= baddr &&
|
if (agpmem->bound <= baddr &&
|
||||||
agpmem->bound + agpmem->pages * PAGE_SIZE > baddr)
|
agpmem->bound + agpmem->pages * PAGE_SIZE > baddr)
|
||||||
break;
|
break;
|
||||||
|
@ -205,10 +205,9 @@ static void drm_vm_shm_close(struct vm_area_struct *vma)
|
||||||
{
|
{
|
||||||
drm_file_t *priv = vma->vm_file->private_data;
|
drm_file_t *priv = vma->vm_file->private_data;
|
||||||
drm_device_t *dev = priv->head->dev;
|
drm_device_t *dev = priv->head->dev;
|
||||||
drm_vma_entry_t *pt, *prev, *next;
|
drm_vma_entry_t *pt, *temp;
|
||||||
drm_map_t *map;
|
drm_map_t *map;
|
||||||
drm_map_list_t *r_list;
|
drm_map_list_t *r_list;
|
||||||
struct list_head *list;
|
|
||||||
int found_maps = 0;
|
int found_maps = 0;
|
||||||
|
|
||||||
DRM_DEBUG("0x%08lx,0x%08lx\n",
|
DRM_DEBUG("0x%08lx,0x%08lx\n",
|
||||||
|
@ -218,19 +217,12 @@ static void drm_vm_shm_close(struct vm_area_struct *vma)
|
||||||
map = vma->vm_private_data;
|
map = vma->vm_private_data;
|
||||||
|
|
||||||
mutex_lock(&dev->struct_mutex);
|
mutex_lock(&dev->struct_mutex);
|
||||||
for (pt = dev->vmalist, prev = NULL; pt; pt = next) {
|
list_for_each_entry_safe(pt, temp, &dev->vmalist, head) {
|
||||||
next = pt->next;
|
|
||||||
if (pt->vma->vm_private_data == map)
|
if (pt->vma->vm_private_data == map)
|
||||||
found_maps++;
|
found_maps++;
|
||||||
if (pt->vma == vma) {
|
if (pt->vma == vma) {
|
||||||
if (prev) {
|
list_del(&pt->head);
|
||||||
prev->next = pt->next;
|
|
||||||
} else {
|
|
||||||
dev->vmalist = pt->next;
|
|
||||||
}
|
|
||||||
drm_ctl_free(pt, sizeof(*pt), DRM_MEM_VMAS);
|
drm_ctl_free(pt, sizeof(*pt), DRM_MEM_VMAS);
|
||||||
} else {
|
|
||||||
prev = pt;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* We were the only map that was found */
|
/* We were the only map that was found */
|
||||||
|
@ -239,9 +231,7 @@ static void drm_vm_shm_close(struct vm_area_struct *vma)
|
||||||
* we delete this mappings information.
|
* we delete this mappings information.
|
||||||
*/
|
*/
|
||||||
found_maps = 0;
|
found_maps = 0;
|
||||||
list = &dev->maplist->head;
|
list_for_each_entry(r_list, &dev->maplist, head) {
|
||||||
list_for_each(list, &dev->maplist->head) {
|
|
||||||
r_list = list_entry(list, drm_map_list_t, head);
|
|
||||||
if (r_list->map == map)
|
if (r_list->map == map)
|
||||||
found_maps++;
|
found_maps++;
|
||||||
}
|
}
|
||||||
|
@ -439,9 +429,8 @@ static void drm_vm_open_locked(struct vm_area_struct *vma)
|
||||||
vma_entry = drm_ctl_alloc(sizeof(*vma_entry), DRM_MEM_VMAS);
|
vma_entry = drm_ctl_alloc(sizeof(*vma_entry), DRM_MEM_VMAS);
|
||||||
if (vma_entry) {
|
if (vma_entry) {
|
||||||
vma_entry->vma = vma;
|
vma_entry->vma = vma;
|
||||||
vma_entry->next = dev->vmalist;
|
|
||||||
vma_entry->pid = current->pid;
|
vma_entry->pid = current->pid;
|
||||||
dev->vmalist = vma_entry;
|
list_add(&vma_entry->head, &dev->vmalist);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -467,20 +456,16 @@ static void drm_vm_close(struct vm_area_struct *vma)
|
||||||
{
|
{
|
||||||
drm_file_t *priv = vma->vm_file->private_data;
|
drm_file_t *priv = vma->vm_file->private_data;
|
||||||
drm_device_t *dev = priv->head->dev;
|
drm_device_t *dev = priv->head->dev;
|
||||||
drm_vma_entry_t *pt, *prev;
|
drm_vma_entry_t *pt, *temp;
|
||||||
|
|
||||||
DRM_DEBUG("0x%08lx,0x%08lx\n",
|
DRM_DEBUG("0x%08lx,0x%08lx\n",
|
||||||
vma->vm_start, vma->vm_end - vma->vm_start);
|
vma->vm_start, vma->vm_end - vma->vm_start);
|
||||||
atomic_dec(&dev->vma_count);
|
atomic_dec(&dev->vma_count);
|
||||||
|
|
||||||
mutex_lock(&dev->struct_mutex);
|
mutex_lock(&dev->struct_mutex);
|
||||||
for (pt = dev->vmalist, prev = NULL; pt; prev = pt, pt = pt->next) {
|
list_for_each_entry_safe(pt, temp, &dev->vmalist, head) {
|
||||||
if (pt->vma == vma) {
|
if (pt->vma == vma) {
|
||||||
if (prev) {
|
list_del(&pt->head);
|
||||||
prev->next = pt->next;
|
|
||||||
} else {
|
|
||||||
dev->vmalist = pt->next;
|
|
||||||
}
|
|
||||||
drm_ctl_free(pt, sizeof(*pt), DRM_MEM_VMAS);
|
drm_ctl_free(pt, sizeof(*pt), DRM_MEM_VMAS);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -346,12 +346,10 @@ static int i810_dma_initialize(drm_device_t * dev,
|
||||||
drm_i810_private_t * dev_priv,
|
drm_i810_private_t * dev_priv,
|
||||||
drm_i810_init_t * init)
|
drm_i810_init_t * init)
|
||||||
{
|
{
|
||||||
struct list_head *list;
|
drm_map_list_t *r_list;
|
||||||
|
|
||||||
memset(dev_priv, 0, sizeof(drm_i810_private_t));
|
memset(dev_priv, 0, sizeof(drm_i810_private_t));
|
||||||
|
|
||||||
list_for_each(list, &dev->maplist->head) {
|
list_for_each_entry(r_list, &dev->maplist, head) {
|
||||||
drm_map_list_t *r_list = list_entry(list, drm_map_list_t, head);
|
|
||||||
if (r_list->map &&
|
if (r_list->map &&
|
||||||
r_list->map->type == _DRM_SHM &&
|
r_list->map->type == _DRM_SHM &&
|
||||||
r_list->map->flags & _DRM_CONTAINS_LOCK) {
|
r_list->map->flags & _DRM_CONTAINS_LOCK) {
|
||||||
|
|
|
@ -233,7 +233,7 @@ static drm_local_map_t *sis_reg_init(drm_device_t *dev)
|
||||||
drm_map_list_t *entry;
|
drm_map_list_t *entry;
|
||||||
drm_local_map_t *map;
|
drm_local_map_t *map;
|
||||||
|
|
||||||
list_for_each_entry(entry, &dev->maplist->head, head) {
|
list_for_each_entry(entry, &dev->maplist, head) {
|
||||||
map = entry->map;
|
map = entry->map;
|
||||||
if (!map)
|
if (!map)
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -551,7 +551,7 @@ static int mga_do_agp_dma_bootstrap(drm_device_t * dev,
|
||||||
drm_map_list_t *_entry;
|
drm_map_list_t *_entry;
|
||||||
unsigned long agp_token = 0;
|
unsigned long agp_token = 0;
|
||||||
|
|
||||||
list_for_each_entry(_entry, &dev->maplist->head, head) {
|
list_for_each_entry(_entry, &dev->maplist, head) {
|
||||||
if (_entry->map == dev->agp_buffer_map)
|
if (_entry->map == dev->agp_buffer_map)
|
||||||
agp_token = _entry->user_token;
|
agp_token = _entry->user_token;
|
||||||
}
|
}
|
||||||
|
|
|
@ -255,7 +255,6 @@ static __inline__ drm_local_map_t *via_drm_lookup_agp_map(drm_via_state_t * seq,
|
||||||
drm_device_t * dev)
|
drm_device_t * dev)
|
||||||
{
|
{
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
struct list_head *list;
|
|
||||||
drm_map_list_t *r_list;
|
drm_map_list_t *r_list;
|
||||||
#endif
|
#endif
|
||||||
drm_local_map_t *map = seq->map_cache;
|
drm_local_map_t *map = seq->map_cache;
|
||||||
|
@ -265,8 +264,7 @@ static __inline__ drm_local_map_t *via_drm_lookup_agp_map(drm_via_state_t * seq,
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
list_for_each(list, &dev->maplist->head) {
|
list_for_each_entry(r_list, &dev->maplist, head) {
|
||||||
r_list = (drm_map_list_t *) list;
|
|
||||||
map = r_list->map;
|
map = r_list->map;
|
||||||
if (!map)
|
if (!map)
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Reference in New Issue