summaryrefslogtreecommitdiff
path: root/linux-core
diff options
context:
space:
mode:
authorDave Airlie <airlied@linux.ie>2006-07-24 10:51:27 +1000
committerDave Airlie <airlied@linux.ie>2006-07-24 10:51:27 +1000
commit5cfbd5dbab4fe9668771377cb22da04c6103459e (patch)
tree375d460ab42628fbe57bb669d6e0710bf2fc3078 /linux-core
parent6677e2a10b820a5ccfd375cc627b8e41453a71da (diff)
switch drm to use Linux mutexes instead of semaphore.
I hope the fallback compat code works if not shout at me.
Diffstat (limited to 'linux-core')
-rw-r--r--linux-core/drmP.h7
-rw-r--r--linux-core/drm_auth.c14
-rw-r--r--linux-core/drm_bufs.c82
-rw-r--r--linux-core/drm_compat.h10
-rw-r--r--linux-core/drm_context.c44
-rw-r--r--linux-core/drm_drv.c4
-rw-r--r--linux-core/drm_fops.c12
-rw-r--r--linux-core/drm_ioctl.c18
-rw-r--r--linux-core/drm_irq.c16
-rw-r--r--linux-core/drm_proc.c20
-rw-r--r--linux-core/drm_stub.c4
-rw-r--r--linux-core/drm_vm.c12
-rw-r--r--linux-core/sis_mm.c30
-rw-r--r--linux-core/via_mm.c32
14 files changed, 159 insertions, 146 deletions
diff --git a/linux-core/drmP.h b/linux-core/drmP.h
index fb0ba482..6cbb810f 100644
--- a/linux-core/drmP.h
+++ b/linux-core/drmP.h
@@ -55,6 +55,9 @@
#include <linux/smp_lock.h> /* For (un)lock_kernel */
#include <linux/mm.h>
#include <linux/pagemap.h>
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+#include <linux/mutex.h>
+#endif
#if defined(__alpha__) || defined(__powerpc__)
#include <asm/pgtable.h> /* For pte_wrprotect */
#endif
@@ -650,7 +653,7 @@ typedef struct drm_device {
/** \name Locks */
/*@{ */
spinlock_t count_lock; /**< For inuse, drm_device::open_count, drm_device::buf_use */
- struct semaphore struct_sem; /**< For others */
+ struct mutex struct_mutex; /**< For others */
/*@} */
/** \name Usage Counters */
@@ -687,7 +690,7 @@ typedef struct drm_device {
/*@{ */
drm_ctx_list_t *ctxlist; /**< Linked list of context handles */
int ctx_count; /**< Number of context handles */
- struct semaphore ctxlist_sem; /**< For ctxlist */
+ struct mutex ctxlist_mutex; /**< For ctxlist */
drm_map_t **context_sareas; /**< per-context SAREA's */
int max_context;
diff --git a/linux-core/drm_auth.c b/linux-core/drm_auth.c
index a6f74209..9c8db644 100644
--- a/linux-core/drm_auth.c
+++ b/linux-core/drm_auth.c
@@ -51,12 +51,12 @@ static drm_file_t *drm_find_file(drm_device_t * dev, drm_magic_t magic)
drm_magic_entry_t *pt;
drm_hash_item_t *hash;
- down(&dev->struct_sem);
+ mutex_lock(&dev->struct_mutex);
if (!drm_ht_find_item(&dev->magiclist, (unsigned long) magic, &hash)) {
pt = drm_hash_entry(hash, drm_magic_entry_t, hash_item);
retval = pt->priv;
}
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
return retval;
}
@@ -84,10 +84,10 @@ static int drm_add_magic(drm_device_t *dev, drm_file_t *priv,
memset(entry, 0, sizeof(*entry));
entry->priv = priv;
entry->hash_item.key = (unsigned long) magic;
- down(&dev->struct_sem);
+ mutex_lock(&dev->struct_mutex);
drm_ht_insert_item(&dev->magiclist, &entry->hash_item);
list_add_tail(&entry->head, &dev->magicfree);
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
return 0;
}
@@ -108,15 +108,15 @@ static int drm_remove_magic(drm_device_t * dev, drm_magic_t magic)
DRM_DEBUG("%d\n", magic);
- down(&dev->struct_sem);
+ mutex_lock(&dev->struct_mutex);
if (drm_ht_find_item(&dev->magiclist, (unsigned long) magic, &hash)) {
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
return -EINVAL;
}
pt = drm_hash_entry(hash, drm_magic_entry_t, hash_item);
drm_ht_remove_item(&dev->magiclist, hash);
list_del(&pt->head);
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
drm_free(pt, sizeof(*pt), DRM_MEM_MAGIC);
diff --git a/linux-core/drm_bufs.c b/linux-core/drm_bufs.c
index 7dd46b69..a977b5bc 100644
--- a/linux-core/drm_bufs.c
+++ b/linux-core/drm_bufs.c
@@ -283,7 +283,7 @@ static int drm_addmap_core(drm_device_t * dev, unsigned int offset,
memset(list, 0, sizeof(*list));
list->map = map;
- down(&dev->struct_sem);
+ mutex_lock(&dev->struct_mutex);
list_add(&list->head, &dev->maplist->head);
/* Assign a 32-bit handle */
@@ -295,12 +295,12 @@ static int drm_addmap_core(drm_device_t * dev, unsigned int offset,
if (ret) {
drm_free(map, sizeof(*map), DRM_MEM_MAPS);
drm_free(list, sizeof(*list), DRM_MEM_MAPS);
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
return ret;
}
list->user_token = list->hash.key;
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
*maplist = list;
return 0;
@@ -431,9 +431,9 @@ int drm_rmmap(drm_device_t *dev, drm_local_map_t *map)
{
int ret;
- down(&dev->struct_sem);
+ mutex_lock(&dev->struct_mutex);
ret = drm_rmmap_locked(dev, map);
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
return ret;
}
@@ -462,7 +462,7 @@ int drm_rmmap_ioctl(struct inode *inode, struct file *filp,
return -EFAULT;
}
- down(&dev->struct_sem);
+ mutex_lock(&dev->struct_mutex);
list_for_each(list, &dev->maplist->head) {
drm_map_list_t *r_list = list_entry(list, drm_map_list_t, head);
@@ -478,24 +478,24 @@ int drm_rmmap_ioctl(struct inode *inode, struct file *filp,
* find anything.
*/
if (list == (&dev->maplist->head)) {
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
return -EINVAL;
}
if (!map) {
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
return -EINVAL;
}
/* Register and framebuffer maps are permanent */
if ((map->type == _DRM_REGISTERS) || (map->type == _DRM_FRAME_BUFFER)) {
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
return 0;
}
ret = drm_rmmap_locked(dev, map);
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
return ret;
}
@@ -620,16 +620,16 @@ int drm_addbufs_agp(drm_device_t * dev, drm_buf_desc_t * request)
atomic_inc(&dev->buf_alloc);
spin_unlock(&dev->count_lock);
- down(&dev->struct_sem);
+ mutex_lock(&dev->struct_mutex);
entry = &dma->bufs[order];
if (entry->buf_count) {
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
atomic_dec(&dev->buf_alloc);
return -ENOMEM; /* May only call once for each order */
}
if (count < 0 || count > 4096) {
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
atomic_dec(&dev->buf_alloc);
return -EINVAL;
}
@@ -637,7 +637,7 @@ int drm_addbufs_agp(drm_device_t * dev, drm_buf_desc_t * request)
entry->buflist = drm_alloc(count * sizeof(*entry->buflist),
DRM_MEM_BUFS);
if (!entry->buflist) {
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
atomic_dec(&dev->buf_alloc);
return -ENOMEM;
}
@@ -670,7 +670,7 @@ int drm_addbufs_agp(drm_device_t * dev, drm_buf_desc_t * request)
/* Set count correctly so we free the proper amount. */
entry->buf_count = count;
drm_cleanup_buf_error(dev, entry);
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
atomic_dec(&dev->buf_alloc);
return -ENOMEM;
}
@@ -692,7 +692,7 @@ int drm_addbufs_agp(drm_device_t * dev, drm_buf_desc_t * request)
if (!temp_buflist) {
/* Free the entry because it isn't valid */
drm_cleanup_buf_error(dev, entry);
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
atomic_dec(&dev->buf_alloc);
return -ENOMEM;
}
@@ -710,7 +710,7 @@ int drm_addbufs_agp(drm_device_t * dev, drm_buf_desc_t * request)
DRM_DEBUG("dma->buf_count : %d\n", dma->buf_count);
DRM_DEBUG("entry->buf_count : %d\n", entry->buf_count);
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
request->count = entry->buf_count;
request->size = size;
@@ -776,16 +776,16 @@ int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request)
atomic_inc(&dev->buf_alloc);
spin_unlock(&dev->count_lock);
- down(&dev->struct_sem);
+ mutex_lock(&dev->struct_mutex);
entry = &dma->bufs[order];
if (entry->buf_count) {
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
atomic_dec(&dev->buf_alloc);
return -ENOMEM; /* May only call once for each order */
}
if (count < 0 || count > 4096) {
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
atomic_dec(&dev->buf_alloc);
return -EINVAL;
}
@@ -793,7 +793,7 @@ int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request)
entry->buflist = drm_alloc(count * sizeof(*entry->buflist),
DRM_MEM_BUFS);
if (!entry->buflist) {
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
atomic_dec(&dev->buf_alloc);
return -ENOMEM;
}
@@ -804,7 +804,7 @@ int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request)
if (!entry->seglist) {
drm_free(entry->buflist,
count * sizeof(*entry->buflist), DRM_MEM_BUFS);
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
atomic_dec(&dev->buf_alloc);
return -ENOMEM;
}
@@ -820,7 +820,7 @@ int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request)
count * sizeof(*entry->buflist), DRM_MEM_BUFS);
drm_free(entry->seglist,
count * sizeof(*entry->seglist), DRM_MEM_SEGS);
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
atomic_dec(&dev->buf_alloc);
return -ENOMEM;
}
@@ -846,7 +846,7 @@ int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request)
drm_free(temp_pagelist,
(dma->page_count + (count << page_order))
* sizeof(*dma->pagelist), DRM_MEM_PAGES);
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
atomic_dec(&dev->buf_alloc);
return -ENOMEM;
}
@@ -888,7 +888,7 @@ int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request)
(count << page_order))
* sizeof(*dma->pagelist),
DRM_MEM_PAGES);
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
atomic_dec(&dev->buf_alloc);
return -ENOMEM;
}
@@ -910,7 +910,7 @@ int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request)
drm_free(temp_pagelist,
(dma->page_count + (count << page_order))
* sizeof(*dma->pagelist), DRM_MEM_PAGES);
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
atomic_dec(&dev->buf_alloc);
return -ENOMEM;
}
@@ -935,7 +935,7 @@ int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request)
dma->page_count += entry->seg_count << page_order;
dma->byte_count += PAGE_SIZE * (entry->seg_count << page_order);
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
request->count = entry->buf_count;
request->size = size;
@@ -1005,16 +1005,16 @@ static int drm_addbufs_sg(drm_device_t * dev, drm_buf_desc_t * request)
atomic_inc(&dev->buf_alloc);
spin_unlock(&dev->count_lock);
- down(&dev->struct_sem);
+ mutex_lock(&dev->struct_mutex);
entry = &dma->bufs[order];
if (entry->buf_count) {
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
atomic_dec(&dev->buf_alloc);
return -ENOMEM; /* May only call once for each order */
}
if (count < 0 || count > 4096) {
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
atomic_dec(&dev->buf_alloc);
return -EINVAL;
}
@@ -1022,7 +1022,7 @@ static int drm_addbufs_sg(drm_device_t * dev, drm_buf_desc_t * request)
entry->buflist = drm_alloc(count * sizeof(*entry->buflist),
DRM_MEM_BUFS);
if (!entry->buflist) {
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
atomic_dec(&dev->buf_alloc);
return -ENOMEM;
}
@@ -1056,7 +1056,7 @@ static int drm_addbufs_sg(drm_device_t * dev, drm_buf_desc_t * request)
/* Set count correctly so we free the proper amount. */
entry->buf_count = count;
drm_cleanup_buf_error(dev, entry);
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
atomic_dec(&dev->buf_alloc);
return -ENOMEM;
}
@@ -1079,7 +1079,7 @@ static int drm_addbufs_sg(drm_device_t * dev, drm_buf_desc_t * request)
if (!temp_buflist) {
/* Free the entry because it isn't valid */
drm_cleanup_buf_error(dev, entry);
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
atomic_dec(&dev->buf_alloc);
return -ENOMEM;
}
@@ -1097,7 +1097,7 @@ static int drm_addbufs_sg(drm_device_t * dev, drm_buf_desc_t * request)
DRM_DEBUG("dma->buf_count : %d\n", dma->buf_count);
DRM_DEBUG("entry->buf_count : %d\n", entry->buf_count);
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
request->count = entry->buf_count;
request->size = size;
@@ -1167,16 +1167,16 @@ int drm_addbufs_fb(drm_device_t * dev, drm_buf_desc_t * request)
atomic_inc(&dev->buf_alloc);
spin_unlock(&dev->count_lock);
- down(&dev->struct_sem);
+ mutex_lock(&dev->struct_mutex);
entry = &dma->bufs[order];
if (entry->buf_count) {
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
atomic_dec(&dev->buf_alloc);
return -ENOMEM; /* May only call once for each order */
}
if (count < 0 || count > 4096) {
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
atomic_dec(&dev->buf_alloc);
return -EINVAL;
}
@@ -1184,7 +1184,7 @@ int drm_addbufs_fb(drm_device_t * dev, drm_buf_desc_t * request)
entry->buflist = drm_alloc(count * sizeof(*entry->buflist),
DRM_MEM_BUFS);
if (!entry->buflist) {
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
atomic_dec(&dev->buf_alloc);
return -ENOMEM;
}
@@ -1217,7 +1217,7 @@ int drm_addbufs_fb(drm_device_t * dev, drm_buf_desc_t * request)
/* Set count correctly so we free the proper amount. */
entry->buf_count = count;
drm_cleanup_buf_error(dev, entry);
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
atomic_dec(&dev->buf_alloc);
return -ENOMEM;
}
@@ -1239,7 +1239,7 @@ int drm_addbufs_fb(drm_device_t * dev, drm_buf_desc_t * request)
if (!temp_buflist) {
/* Free the entry because it isn't valid */
drm_cleanup_buf_error(dev, entry);
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
atomic_dec(&dev->buf_alloc);
return -ENOMEM;
}
@@ -1257,7 +1257,7 @@ int drm_addbufs_fb(drm_device_t * dev, drm_buf_desc_t * request)
DRM_DEBUG("dma->buf_count : %d\n", dma->buf_count);
DRM_DEBUG("entry->buf_count : %d\n", entry->buf_count);
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
request->count = entry->buf_count;
request->size = size;
diff --git a/linux-core/drm_compat.h b/linux-core/drm_compat.h
index 03749d14..4f3a6688 100644
--- a/linux-core/drm_compat.h
+++ b/linux-core/drm_compat.h
@@ -195,6 +195,16 @@ static inline int remap_pfn_range(struct vm_area_struct *vma, unsigned long from
}
#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16)
+#define mutex_lock down
+#define mutex_unlock up
+
+#define mutex semaphore
+
+#define mutex_init(a) sema_init((a), 1)
+
+#endif
+
/* old architectures */
#ifdef __AMD64__
#define __x86_64__
diff --git a/linux-core/drm_context.c b/linux-core/drm_context.c
index 748a2a61..95581b53 100644
--- a/linux-core/drm_context.c
+++ b/linux-core/drm_context.c
@@ -64,10 +64,10 @@ void drm_ctxbitmap_free(drm_device_t * dev, int ctx_handle)
goto failed;
if (ctx_handle < DRM_MAX_CTXBITMAP) {
- down(&dev->struct_sem);
+ mutex_lock(&dev->struct_mutex);
clear_bit(ctx_handle, dev->ctx_bitmap);
dev->context_sareas[ctx_handle] = NULL;
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
return;
}
failed:
@@ -92,7 +92,7 @@ static int drm_ctxbitmap_next(drm_device_t * dev)
if (!dev->ctx_bitmap)
return -1;
- down(&dev->struct_sem);
+ mutex_lock(&dev->struct_mutex);
bit = find_first_zero_bit(dev->ctx_bitmap, DRM_MAX_CTXBITMAP);
if (bit < DRM_MAX_CTXBITMAP) {
set_bit(bit, dev->ctx_bitmap);
@@ -113,7 +113,7 @@ static int drm_ctxbitmap_next(drm_device_t * dev)
DRM_MEM_MAPS);
if (!ctx_sareas) {
clear_bit(bit, dev->ctx_bitmap);
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
return -1;
}
dev->context_sareas = ctx_sareas;
@@ -126,16 +126,16 @@ static int drm_ctxbitmap_next(drm_device_t * dev)
DRM_MEM_MAPS);
if (!dev->context_sareas) {
clear_bit(bit, dev->ctx_bitmap);
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
return -1;
}
dev->context_sareas[bit] = NULL;
}
}
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
return bit;
}
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
return -1;
}
@@ -152,17 +152,17 @@ int drm_ctxbitmap_init(drm_device_t * dev)
int i;
int temp;
- down(&dev->struct_sem);
+ mutex_lock(&dev->struct_mutex);
dev->ctx_bitmap = (unsigned long *)drm_alloc(PAGE_SIZE,
DRM_MEM_CTXBITMAP);
if (dev->ctx_bitmap == NULL) {
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
return -ENOMEM;
}
memset((void *)dev->ctx_bitmap, 0, PAGE_SIZE);
dev->context_sareas = NULL;
dev->max_context = -1;
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) {
temp = drm_ctxbitmap_next(dev);
@@ -182,13 +182,13 @@ int drm_ctxbitmap_init(drm_device_t * dev)
*/
void drm_ctxbitmap_cleanup(drm_device_t * dev)
{
- down(&dev->struct_sem);
+ mutex_lock(&dev->struct_mutex);
if (dev->context_sareas)
drm_free(dev->context_sareas,
sizeof(*dev->context_sareas) *
dev->max_context, DRM_MEM_MAPS);
drm_free((void *)dev->ctx_bitmap, PAGE_SIZE, DRM_MEM_CTXBITMAP);
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
}
/*@}*/
@@ -222,15 +222,15 @@ int drm_getsareactx(struct inode *inode, struct file *filp,
if (copy_from_user(&request, argp, sizeof(request)))
return -EFAULT;
- down(&dev->struct_sem);
+ mutex_lock(&dev->struct_mutex);
if (dev->max_context < 0
|| request.ctx_id >= (unsigned)dev->max_context) {
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
return -EINVAL;
}
map = dev->context_sareas[request.ctx_id];
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
request.handle = NULL;
list_for_each_entry(_entry, &dev->maplist->head,head) {
@@ -274,7 +274,7 @@ int drm_setsareactx(struct inode *inode, struct file *filp,
(drm_ctx_priv_map_t __user *) arg, sizeof(request)))
return -EFAULT;
- down(&dev->struct_sem);
+ mutex_lock(&dev->struct_mutex);
list_for_each(list, &dev->maplist->head) {
r_list = list_entry(list, drm_map_list_t, head);
if (r_list->map
@@ -282,7 +282,7 @@ int drm_setsareactx(struct inode *inode, struct file *filp,
goto found;
}
bad:
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
return -EINVAL;
found:
@@ -294,7 +294,7 @@ int drm_setsareactx(struct inode *inode, struct file *filp,
if (request.ctx_id >= (unsigned)dev->max_context)
goto bad;
dev->context_sareas[request.ctx_id] = map;
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
return 0;
}
@@ -448,10 +448,10 @@ int drm_addctx(struct inode *inode, struct file *filp,
ctx_entry->handle = ctx.handle;
ctx_entry->tag = priv;
- down(&dev->ctxlist_sem);
+ mutex_lock(&dev->ctxlist_mutex);
list_add(&ctx_entry->head, &dev->ctxlist->head);
++dev->ctx_count;
- up(&dev->ctxlist_sem);
+ mutex_unlock(&dev->ctxlist_mutex);
if (copy_to_user(argp, &ctx, sizeof(ctx)))
return -EFAULT;
@@ -574,7 +574,7 @@ int drm_rmctx(struct inode *inode, struct file *filp,
drm_ctxbitmap_free(dev, ctx.handle);
}
- down(&dev->ctxlist_sem);
+ mutex_lock(&dev->ctxlist_mutex);
if (!list_empty(&dev->ctxlist->head)) {
drm_ctx_list_t *pos, *n;
@@ -586,7 +586,7 @@ int drm_rmctx(struct inode *inode, struct file *filp,
}
}
}
- up(&dev->ctxlist_sem);
+ mutex_unlock(&dev->ctxlist_mutex);
return 0;
}
diff --git a/linux-core/drm_drv.c b/linux-core/drm_drv.c
index 07f9952c..c3ea9b53 100644
--- a/linux-core/drm_drv.c
+++ b/linux-core/drm_drv.c
@@ -154,7 +154,7 @@ int drm_lastclose(drm_device_t * dev)
if (dev->irq_enabled)
drm_irq_uninstall(dev);
- down(&dev->struct_sem);
+ mutex_lock(&dev->struct_mutex);
del_timer(&dev->timer);
if (dev->unique) {
@@ -239,7 +239,7 @@ int drm_lastclose(drm_device_t * dev)
dev->lock.filp = NULL;
wake_up_interruptible(&dev->lock.lock_queue);
}
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
DRM_DEBUG("lastclose completed\n");
return 0;
diff --git a/linux-core/drm_fops.c b/linux-core/drm_fops.c
index 632108db..a58f3ae8 100644
--- a/linux-core/drm_fops.c
+++ b/linux-core/drm_fops.c
@@ -260,7 +260,7 @@ static int drm_open_helper(struct inode *inode, struct file *filp,
goto out_free;
}
- down(&dev->struct_sem);
+ mutex_lock(&dev->struct_mutex);
if (!dev->file_last) {
priv->next = NULL;
priv->prev = NULL;
@@ -274,7 +274,7 @@ static int drm_open_helper(struct inode *inode, struct file *filp,
dev->file_last->next = priv;
dev->file_last = priv;
}
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
#ifdef __alpha__
/*
@@ -411,7 +411,7 @@ int drm_release(struct inode *inode, struct file *filp)
drm_fasync(-1, filp, 0);
- down(&dev->ctxlist_sem);
+ mutex_lock(&dev->ctxlist_mutex);
if (dev->ctxlist && (!list_empty(&dev->ctxlist->head))) {
drm_ctx_list_t *pos, *n;
@@ -430,9 +430,9 @@ int drm_release(struct inode *inode, struct file *filp)
}
}
}
- up(&dev->ctxlist_sem);
+ mutex_unlock(&dev->ctxlist_mutex);
- down(&dev->struct_sem);
+ mutex_lock(&dev->struct_mutex);
if (priv->remove_auth_on_close == 1) {
drm_file_t *temp = dev->file_first;
while (temp) {
@@ -450,7 +450,7 @@ int drm_release(struct inode *inode, struct file *filp)
} else {
dev->file_last = priv->prev;
}
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
if (dev->driver->postclose)
dev->driver->postclose(dev, priv);
diff --git a/linux-core/drm_ioctl.c b/linux-core/drm_ioctl.c
index e0998d53..54024e1b 100644
--- a/linux-core/drm_ioctl.c
+++ b/linux-core/drm_ioctl.c
@@ -188,9 +188,9 @@ int drm_getmap(struct inode *inode, struct file *filp,
return -EFAULT;
idx = map.offset;
- down(&dev->struct_sem);
+ mutex_lock(&dev->struct_mutex);
if (idx < 0) {
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
return -EINVAL;
}
@@ -203,7 +203,7 @@ int drm_getmap(struct inode *inode, struct file *filp,
i++;
}
if (!r_list || !r_list->map) {
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
return -EINVAL;
}
@@ -213,7 +213,7 @@ int drm_getmap(struct inode *inode, struct file *filp,
map.flags = r_list->map->flags;
map.handle = (void *)(unsigned long) r_list->user_token;
map.mtrr = r_list->map->mtrr;
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
if (copy_to_user(argp, &map, sizeof(map)))
return -EFAULT;
@@ -247,11 +247,11 @@ int drm_getclient(struct inode *inode, struct file *filp,
if (copy_from_user(&client, argp, sizeof(client)))
return -EFAULT;
idx = client.idx;
- down(&dev->struct_sem);
+ mutex_lock(&dev->struct_mutex);
for (i = 0, pt = dev->file_first; i < idx && pt; i++, pt = pt->next) ;
if (!pt) {
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
return -EINVAL;
}
client.auth = pt->authenticated;
@@ -259,7 +259,7 @@ int drm_getclient(struct inode *inode, struct file *filp,
client.uid = pt->uid;
client.magic = pt->magic;
client.iocs = pt->ioctl_count;
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
if (copy_to_user(argp, &client, sizeof(client)))
return -EFAULT;
@@ -286,7 +286,7 @@ int drm_getstats(struct inode *inode, struct file *filp,
memset(&stats, 0, sizeof(stats));
- down(&dev->struct_sem);
+ mutex_lock(&dev->struct_mutex);
for (i = 0; i < dev->counters; i++) {
if (dev->types[i] == _DRM_STAT_LOCK)
@@ -299,7 +299,7 @@ int drm_getstats(struct inode *inode, struct file *filp,
stats.count = dev->counters;
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
if (copy_to_user((drm_stats_t __user *) arg, &stats, sizeof(stats)))
return -EFAULT;
diff --git a/linux-core/drm_irq.c b/linux-core/drm_irq.c
index 7f21205d..d76fd51d 100644
--- a/linux-core/drm_irq.c
+++ b/linux-core/drm_irq.c
@@ -97,20 +97,20 @@ static int drm_irq_install(drm_device_t * dev)
if (dev->irq == 0)
return -EINVAL;
- down(&dev->struct_sem);
+ mutex_lock(&dev->struct_mutex);
/* Driver must have been initialized */
if (!dev->dev_private) {
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
return -EINVAL;
}
if (dev->irq_enabled) {
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
return -EBUSY;
}
dev->irq_enabled = 1;
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
DRM_DEBUG("%s: irq=%d\n", __FUNCTION__, dev->irq);
@@ -134,9 +134,9 @@ static int drm_irq_install(drm_device_t * dev)
ret = request_irq(dev->irq, dev->driver->irq_handler,
sh_flags, dev->devname, dev);
if (ret < 0) {
- down(&dev->struct_sem);
+ mutex_lock(&dev->struct_mutex);
dev->irq_enabled = 0;
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
return ret;
}
@@ -160,10 +160,10 @@ int drm_irq_uninstall(drm_device_t * dev)
if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
return -EINVAL;
- down(&dev->struct_sem);
+ mutex_lock(&dev->struct_mutex);
irq_enabled = dev->irq_enabled;
dev->irq_enabled = 0;
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
if (!irq_enabled)
return -EINVAL;
diff --git a/linux-core/drm_proc.c b/linux-core/drm_proc.c
index 52241bd4..014486c1 100644
--- a/linux-core/drm_proc.c
+++ b/linux-core/drm_proc.c
@@ -266,9 +266,9 @@ static int drm_vm_info(char *buf, char **start, off_t offset, int request,
drm_device_t *dev = (drm_device_t *) data;
int ret;
- down(&dev->struct_sem);
+ mutex_lock(&dev->struct_mutex);
ret = drm__vm_info(buf, start, offset, request, eof, data);
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
return ret;
}
@@ -339,9 +339,9 @@ static int drm_queues_info(char *buf, char **start, off_t offset, int request,
drm_device_t *dev = (drm_device_t *) data;
int ret;
- down(&dev->struct_sem);
+ mutex_lock(&dev->struct_mutex);
ret = drm__queues_info(buf, start, offset, request, eof, data);
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
return ret;
}
@@ -411,9 +411,9 @@ static int drm_bufs_info(char *buf, char **start, off_t offset, int request,
drm_device_t *dev = (drm_device_t *) data;
int ret;
- down(&dev->struct_sem);
+ mutex_lock(&dev->struct_mutex);
ret = drm__bufs_info(buf, start, offset, request, eof, data);
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
return ret;
}
@@ -467,9 +467,9 @@ static int drm_clients_info(char *buf, char **start, off_t offset,
drm_device_t *dev = (drm_device_t *) data;
int ret;
- down(&dev->struct_sem);
+ mutex_lock(&dev->struct_mutex);
ret = drm__clients_info(buf, start, offset, request, eof, data);
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
return ret;
}
@@ -540,9 +540,9 @@ static int drm_vma_info(char *buf, char **start, off_t offset, int request,
drm_device_t *dev = (drm_device_t *) data;
int ret;
- down(&dev->struct_sem);
+ mutex_lock(&dev->struct_mutex);
ret = drm__vma_info(buf, start, offset, request, eof, data);
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
return ret;
}
#endif
diff --git a/linux-core/drm_stub.c b/linux-core/drm_stub.c
index 24955634..25bb5f33 100644
--- a/linux-core/drm_stub.c
+++ b/linux-core/drm_stub.c
@@ -62,8 +62,8 @@ static int drm_fill_in_dev(drm_device_t * dev, struct pci_dev *pdev,
spin_lock_init(&dev->count_lock);
init_timer(&dev->timer);
- sema_init(&dev->struct_sem, 1);
- sema_init(&dev->ctxlist_sem, 1);
+ mutex_init(&dev->struct_mutex);
+ mutex_init(&dev->ctxlist_mutex);
dev->pdev = pdev;
diff --git a/linux-core/drm_vm.c b/linux-core/drm_vm.c
index 19866dca..cf3bc3cf 100644
--- a/linux-core/drm_vm.c
+++ b/linux-core/drm_vm.c
@@ -187,7 +187,7 @@ static void drm_vm_shm_close(struct vm_area_struct *vma)
map = vma->vm_private_data;
- down(&dev->struct_sem);
+ mutex_lock(&dev->struct_mutex);
for (pt = dev->vmalist, prev = NULL; pt; pt = next) {
next = pt->next;
if (pt->vma->vm_private_data == map)
@@ -247,7 +247,7 @@ static void drm_vm_shm_close(struct vm_area_struct *vma)
drm_free(map, sizeof(*map), DRM_MEM_MAPS);
}
}
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
}
/**
@@ -434,12 +434,12 @@ static void drm_vm_open(struct vm_area_struct *vma)
vma_entry = drm_alloc(sizeof(*vma_entry), DRM_MEM_VMAS);
if (vma_entry) {
- down(&dev->struct_sem);
+ mutex_lock(&dev->struct_mutex);
vma_entry->vma = vma;
vma_entry->next = dev->vmalist;
vma_entry->pid = current->pid;
dev->vmalist = vma_entry;
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
}
}
@@ -461,7 +461,7 @@ static void drm_vm_close(struct vm_area_struct *vma)
vma->vm_start, vma->vm_end - vma->vm_start);
atomic_dec(&dev->vma_count);
- down(&dev->struct_sem);
+ mutex_lock(&dev->struct_mutex);
for (pt = dev->vmalist, prev = NULL; pt; prev = pt, pt = pt->next) {
if (pt->vma == vma) {
if (prev) {
@@ -473,7 +473,7 @@ static void drm_vm_close(struct vm_area_struct *vma)
break;
}
}
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
}
/**
diff --git a/linux-core/sis_mm.c b/linux-core/sis_mm.c
index 70e2fac4..b7ce18ce 100644
--- a/linux-core/sis_mm.c
+++ b/linux-core/sis_mm.c
@@ -94,7 +94,7 @@ static int sis_fb_init(DRM_IOCTL_ARGS)
DRM_COPY_FROM_USER_IOCTL(fb, (drm_sis_fb_t __user *) data, sizeof(fb));
- down(&dev->struct_sem);
+ mutex_lock(&dev->struct_mutex);
#if defined(__linux__) && defined(CONFIG_FB_SIS)
{
drm_sman_mm_t sman_mm;
@@ -113,14 +113,14 @@ static int sis_fb_init(DRM_IOCTL_ARGS)
if (ret) {
DRM_ERROR("VRAM memory manager initialisation error\n");
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
return ret;
}
dev_priv->vram_initialized = TRUE;
dev_priv->vram_offset = fb.offset;
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
DRM_DEBUG("offset = %u, size = %u", fb.offset, fb.size);
return 0;
@@ -137,7 +137,7 @@ static int sis_drm_alloc(drm_device_t * dev, drm_file_t * priv,
DRM_COPY_FROM_USER_IOCTL(mem, argp, sizeof(mem));
- down(&dev->struct_sem);
+ mutex_lock(&dev->struct_mutex);
if (FALSE == ((pool == 0) ? dev_priv->vram_initialized :
dev_priv->agp_initialized)) {
@@ -150,7 +150,7 @@ static int sis_drm_alloc(drm_device_t * dev, drm_file_t * priv,
item = drm_sman_alloc(&dev_priv->sman, pool, mem.size, 0,
(unsigned long)priv);
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
if (item) {
mem.offset = ((pool == 0) ?
dev_priv->vram_offset : dev_priv->agp_offset) +
@@ -183,9 +183,9 @@ static int sis_drm_free(DRM_IOCTL_ARGS)
DRM_COPY_FROM_USER_IOCTL(mem, (drm_sis_mem_t __user *) data,
sizeof(mem));
- down(&dev->struct_sem);
+ mutex_lock(&dev->struct_mutex);
ret = drm_sman_free_key(&dev_priv->sman, mem.free);
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
DRM_DEBUG("free = 0x%lx\n", mem.free);
return ret;
@@ -207,19 +207,19 @@ static int sis_ioctl_agp_init(DRM_IOCTL_ARGS)
DRM_COPY_FROM_USER_IOCTL(agp, (drm_sis_agp_t __user *) data,
sizeof(agp));
- down(&dev->struct_sem);
+ mutex_lock(&dev->struct_mutex);
ret = drm_sman_set_range(&dev_priv->sman, AGP_TYPE, 0,
agp.size >> SIS_MM_ALIGN_SHIFT);
if (ret) {
DRM_ERROR("AGP memory manager initialisation error\n");
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
return ret;
}
dev_priv->agp_initialized = TRUE;
dev_priv->agp_offset = agp.offset;
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
DRM_DEBUG("offset = %u, size = %u", agp.offset, agp.size);
return 0;
@@ -310,12 +310,12 @@ void sis_lastclose(struct drm_device *dev)
if (!dev_priv)
return;
- down(&dev->struct_sem);
+ mutex_lock(&dev->struct_mutex);
drm_sman_cleanup(&dev_priv->sman);
dev_priv->vram_initialized = FALSE;
dev_priv->agp_initialized = FALSE;
dev_priv->mmio = NULL;
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
}
void sis_reclaim_buffers_locked(drm_device_t * dev, struct file *filp)
@@ -323,9 +323,9 @@ void sis_reclaim_buffers_locked(drm_device_t * dev, struct file *filp)
drm_sis_private_t *dev_priv = dev->dev_private;
drm_file_t *priv = filp->private_data;
- down(&dev->struct_sem);
+ mutex_lock(&dev->struct_mutex);
if (drm_sman_owner_clean(&dev_priv->sman, (unsigned long)priv)) {
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
return;
}
@@ -334,7 +334,7 @@ void sis_reclaim_buffers_locked(drm_device_t * dev, struct file *filp)
}
drm_sman_owner_cleanup(&dev_priv->sman, (unsigned long)priv);
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
return;
}
diff --git a/linux-core/via_mm.c b/linux-core/via_mm.c
index 71762b74..366a0187 100644
--- a/linux-core/via_mm.c
+++ b/linux-core/via_mm.c
@@ -42,19 +42,19 @@ int via_agp_init(DRM_IOCTL_ARGS)
DRM_COPY_FROM_USER_IOCTL(agp, (drm_via_agp_t __user *) data,
sizeof(agp));
- down(&dev->struct_sem);
+ mutex_lock(&dev->struct_mutex);
ret = drm_sman_set_range(&dev_priv->sman, VIA_MEM_AGP, 0,
agp.size >> VIA_MM_ALIGN_SHIFT);
if (ret) {
DRM_ERROR("AGP memory manager initialisation error\n");
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
return ret;
}
dev_priv->agp_initialized = TRUE;
dev_priv->agp_offset = agp.offset;
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
DRM_DEBUG("offset = %u, size = %u", agp.offset, agp.size);
return 0;
@@ -69,20 +69,20 @@ int via_fb_init(DRM_IOCTL_ARGS)
DRM_COPY_FROM_USER_IOCTL(fb, (drm_via_fb_t __user *) data, sizeof(fb));
- down(&dev->struct_sem);
+ mutex_lock(&dev->struct_mutex);
ret = drm_sman_set_range(&dev_priv->sman, VIA_MEM_VIDEO, 0,
fb.size >> VIA_MM_ALIGN_SHIFT);
if (ret) {
DRM_ERROR("VRAM memory manager initialisation error\n");
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
return ret;
}
dev_priv->vram_initialized = TRUE;
dev_priv->vram_offset = fb.offset;
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
DRM_DEBUG("offset = %u, size = %u", fb.offset, fb.size);
return 0;
@@ -116,11 +116,11 @@ void via_lastclose(struct drm_device *dev)
if (!dev_priv)
return;
- down(&dev->struct_sem);
+ mutex_lock(&dev->struct_mutex);
drm_sman_cleanup(&dev_priv->sman);
dev_priv->vram_initialized = FALSE;
dev_priv->agp_initialized = FALSE;
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
}
@@ -141,19 +141,19 @@ int via_mem_alloc(DRM_IOCTL_ARGS)
DRM_ERROR("Unknown memory type allocation\n");
return DRM_ERR(EINVAL);
}
- down(&dev->struct_sem);
+ mutex_lock(&dev->struct_mutex);
if (FALSE == ((mem.type == VIA_MEM_VIDEO) ? dev_priv->vram_initialized :
dev_priv->agp_initialized)) {
DRM_ERROR
("Attempt to allocate from uninitialized memory manager.\n");
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
return DRM_ERR(EINVAL);
}
tmpSize = (mem.size + VIA_MM_ALIGN_MASK) >> VIA_MM_ALIGN_SHIFT;
item = drm_sman_alloc(&dev_priv->sman, mem.type, tmpSize, 0,
(unsigned long)priv);
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
if (item) {
mem.offset = ((mem.type == VIA_MEM_VIDEO) ?
dev_priv->vram_offset : dev_priv->agp_offset) +
@@ -182,9 +182,9 @@ int via_mem_free(DRM_IOCTL_ARGS)
DRM_COPY_FROM_USER_IOCTL(mem, (drm_via_mem_t __user *) data,
sizeof(mem));
- down(&dev->struct_sem);
+ mutex_lock(&dev->struct_mutex);
ret = drm_sman_free_key(&dev_priv->sman, mem.index);
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
DRM_DEBUG("free = 0x%lx\n", mem.index);
return ret;
@@ -198,9 +198,9 @@ void via_reclaim_buffers_locked(drm_device_t * dev, struct file *filp)
drm_via_private_t *dev_priv = dev->dev_private;
drm_file_t *priv = filp->private_data;
- down(&dev->struct_sem);
+ mutex_lock(&dev->struct_mutex);
if (drm_sman_owner_clean(&dev_priv->sman, (unsigned long)priv)) {
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
return;
}
@@ -209,6 +209,6 @@ void via_reclaim_buffers_locked(drm_device_t * dev, struct file *filp)
}
drm_sman_owner_cleanup(&dev_priv->sman, (unsigned long)priv);
- up(&dev->struct_sem);
+ mutex_unlock(&dev->struct_mutex);
return;
}