Commit cf41f8ac authored by Linus Torvalds's avatar Linus Torvalds
parents 0271fc2d 30e2fb18
...@@ -59,17 +59,16 @@ static void *drm_ati_alloc_pcigart_table(void) ...@@ -59,17 +59,16 @@ static void *drm_ati_alloc_pcigart_table(void)
int i; int i;
DRM_DEBUG("%s\n", __FUNCTION__); DRM_DEBUG("%s\n", __FUNCTION__);
address = __get_free_pages(GFP_KERNEL, ATI_PCIGART_TABLE_ORDER); address = __get_free_pages(GFP_KERNEL | __GFP_COMP,
ATI_PCIGART_TABLE_ORDER);
if (address == 0UL) { if (address == 0UL) {
return 0; return NULL;
} }
page = virt_to_page(address); page = virt_to_page(address);
for (i = 0; i < ATI_PCIGART_TABLE_PAGES; i++, page++) { for (i = 0; i < ATI_PCIGART_TABLE_PAGES; i++, page++)
get_page(page);
SetPageReserved(page); SetPageReserved(page);
}
DRM_DEBUG("%s: returning 0x%08lx\n", __FUNCTION__, address); DRM_DEBUG("%s: returning 0x%08lx\n", __FUNCTION__, address);
return (void *)address; return (void *)address;
...@@ -83,10 +82,8 @@ static void drm_ati_free_pcigart_table(void *address) ...@@ -83,10 +82,8 @@ static void drm_ati_free_pcigart_table(void *address)
page = virt_to_page((unsigned long)address); page = virt_to_page((unsigned long)address);
for (i = 0; i < ATI_PCIGART_TABLE_PAGES; i++, page++) { for (i = 0; i < ATI_PCIGART_TABLE_PAGES; i++, page++)
__put_page(page);
ClearPageReserved(page); ClearPageReserved(page);
}
free_pages((unsigned long)address, ATI_PCIGART_TABLE_ORDER); free_pages((unsigned long)address, ATI_PCIGART_TABLE_ORDER);
} }
...@@ -127,7 +124,7 @@ int drm_ati_pcigart_cleanup(drm_device_t *dev, drm_ati_pcigart_info *gart_info) ...@@ -127,7 +124,7 @@ int drm_ati_pcigart_cleanup(drm_device_t *dev, drm_ati_pcigart_info *gart_info)
if (gart_info->gart_table_location == DRM_ATI_GART_MAIN if (gart_info->gart_table_location == DRM_ATI_GART_MAIN
&& gart_info->addr) { && gart_info->addr) {
drm_ati_free_pcigart_table(gart_info->addr); drm_ati_free_pcigart_table(gart_info->addr);
gart_info->addr = 0; gart_info->addr = NULL;
} }
return 1; return 1;
...@@ -168,7 +165,7 @@ int drm_ati_pcigart_init(drm_device_t *dev, drm_ati_pcigart_info *gart_info) ...@@ -168,7 +165,7 @@ int drm_ati_pcigart_init(drm_device_t *dev, drm_ati_pcigart_info *gart_info)
if (bus_address == 0) { if (bus_address == 0) {
DRM_ERROR("unable to map PCIGART pages!\n"); DRM_ERROR("unable to map PCIGART pages!\n");
drm_ati_free_pcigart_table(address); drm_ati_free_pcigart_table(address);
address = 0; address = NULL;
goto done; goto done;
} }
} else { } else {
......
...@@ -57,6 +57,7 @@ ...@@ -57,6 +57,7 @@
#include <linux/smp_lock.h> /* For (un)lock_kernel */ #include <linux/smp_lock.h> /* For (un)lock_kernel */
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/cdev.h> #include <linux/cdev.h>
#include <linux/mutex.h>
#if defined(__alpha__) || defined(__powerpc__) #if defined(__alpha__) || defined(__powerpc__)
#include <asm/pgtable.h> /* For pte_wrprotect */ #include <asm/pgtable.h> /* For pte_wrprotect */
#endif #endif
...@@ -623,7 +624,7 @@ typedef struct drm_device { ...@@ -623,7 +624,7 @@ typedef struct drm_device {
/** \name Locks */ /** \name Locks */
/*@{ */ /*@{ */
spinlock_t count_lock; /**< For inuse, drm_device::open_count, drm_device::buf_use */ 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 */ /** \name Usage Counters */
...@@ -658,7 +659,7 @@ typedef struct drm_device { ...@@ -658,7 +659,7 @@ typedef struct drm_device {
/*@{ */ /*@{ */
drm_ctx_list_t *ctxlist; /**< Linked list of context handles */ drm_ctx_list_t *ctxlist; /**< Linked list of context handles */
int ctx_count; /**< Number 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 */ drm_map_t **context_sareas; /**< per-context SAREA's */
int max_context; int max_context;
......
...@@ -56,7 +56,7 @@ static int drm_hash_magic(drm_magic_t magic) ...@@ -56,7 +56,7 @@ static int drm_hash_magic(drm_magic_t magic)
* \param magic magic number. * \param magic magic number.
* *
* Searches in drm_device::magiclist within all files with the same hash key * Searches in drm_device::magiclist within all files with the same hash key
* the one with matching magic number, while holding the drm_device::struct_sem * the one with matching magic number, while holding the drm_device::struct_mutex
* lock. * lock.
*/ */
static drm_file_t *drm_find_file(drm_device_t * dev, drm_magic_t magic) static drm_file_t *drm_find_file(drm_device_t * dev, drm_magic_t magic)
...@@ -65,14 +65,14 @@ static drm_file_t *drm_find_file(drm_device_t * dev, drm_magic_t magic) ...@@ -65,14 +65,14 @@ static drm_file_t *drm_find_file(drm_device_t * dev, drm_magic_t magic)
drm_magic_entry_t *pt; drm_magic_entry_t *pt;
int hash = drm_hash_magic(magic); int hash = drm_hash_magic(magic);
down(&dev->struct_sem); mutex_lock(&dev->struct_mutex);
for (pt = dev->magiclist[hash].head; pt; pt = pt->next) { for (pt = dev->magiclist[hash].head; pt; pt = pt->next) {
if (pt->magic == magic) { if (pt->magic == magic) {
retval = pt->priv; retval = pt->priv;
break; break;
} }
} }
up(&dev->struct_sem); mutex_unlock(&dev->struct_mutex);
return retval; return retval;
} }
...@@ -85,7 +85,7 @@ static drm_file_t *drm_find_file(drm_device_t * dev, drm_magic_t magic) ...@@ -85,7 +85,7 @@ static drm_file_t *drm_find_file(drm_device_t * dev, drm_magic_t magic)
* *
* Creates a drm_magic_entry structure and appends to the linked list * Creates a drm_magic_entry structure and appends to the linked list
* associated the magic number hash key in drm_device::magiclist, while holding * associated the magic number hash key in drm_device::magiclist, while holding
* the drm_device::struct_sem lock. * the drm_device::struct_mutex lock.
*/ */
static int drm_add_magic(drm_device_t * dev, drm_file_t * priv, static int drm_add_magic(drm_device_t * dev, drm_file_t * priv,
drm_magic_t magic) drm_magic_t magic)
...@@ -104,7 +104,7 @@ static int drm_add_magic(drm_device_t * dev, drm_file_t * priv, ...@@ -104,7 +104,7 @@ static int drm_add_magic(drm_device_t * dev, drm_file_t * priv,
entry->priv = priv; entry->priv = priv;
entry->next = NULL; entry->next = NULL;
down(&dev->struct_sem); mutex_lock(&dev->struct_mutex);
if (dev->magiclist[hash].tail) { if (dev->magiclist[hash].tail) {
dev->magiclist[hash].tail->next = entry; dev->magiclist[hash].tail->next = entry;
dev->magiclist[hash].tail = entry; dev->magiclist[hash].tail = entry;
...@@ -112,7 +112,7 @@ static int drm_add_magic(drm_device_t * dev, drm_file_t * priv, ...@@ -112,7 +112,7 @@ static int drm_add_magic(drm_device_t * dev, drm_file_t * priv,
dev->magiclist[hash].head = entry; dev->magiclist[hash].head = entry;
dev->magiclist[hash].tail = entry; dev->magiclist[hash].tail = entry;
} }
up(&dev->struct_sem); mutex_unlock(&dev->struct_mutex);
return 0; return 0;
} }
...@@ -124,7 +124,7 @@ static int drm_add_magic(drm_device_t * dev, drm_file_t * priv, ...@@ -124,7 +124,7 @@ static int drm_add_magic(drm_device_t * dev, drm_file_t * priv,
* \param magic magic number. * \param magic magic number.
* *
* Searches and unlinks the entry in drm_device::magiclist with the magic * Searches and unlinks the entry in drm_device::magiclist with the magic
* number hash key, while holding the drm_device::struct_sem lock. * number hash key, while holding the drm_device::struct_mutex lock.
*/ */
static int drm_remove_magic(drm_device_t * dev, drm_magic_t magic) static int drm_remove_magic(drm_device_t * dev, drm_magic_t magic)
{ {
...@@ -135,7 +135,7 @@ static int drm_remove_magic(drm_device_t * dev, drm_magic_t magic) ...@@ -135,7 +135,7 @@ static int drm_remove_magic(drm_device_t * dev, drm_magic_t magic)
DRM_DEBUG("%d\n", magic); DRM_DEBUG("%d\n", magic);
hash = drm_hash_magic(magic); hash = drm_hash_magic(magic);
down(&dev->struct_sem); mutex_lock(&dev->struct_mutex);
for (pt = dev->magiclist[hash].head; pt; prev = pt, pt = pt->next) { for (pt = dev->magiclist[hash].head; pt; prev = pt, pt = pt->next) {
if (pt->magic == magic) { if (pt->magic == magic) {
if (dev->magiclist[hash].head == pt) { if (dev->magiclist[hash].head == pt) {
...@@ -147,11 +147,11 @@ static int drm_remove_magic(drm_device_t * dev, drm_magic_t magic) ...@@ -147,11 +147,11 @@ static int drm_remove_magic(drm_device_t * dev, drm_magic_t magic)
if (prev) { if (prev) {
prev->next = pt->next; prev->next = pt->next;
} }
up(&dev->struct_sem); mutex_unlock(&dev->struct_mutex);
return 0; return 0;
} }
} }
up(&dev->struct_sem); mutex_unlock(&dev->struct_mutex);
drm_free(pt, sizeof(*pt), DRM_MEM_MAGIC); drm_free(pt, sizeof(*pt), DRM_MEM_MAGIC);
......
This diff is collapsed.
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
* \param ctx_handle context handle. * \param ctx_handle context handle.
* *
* Clears the bit specified by \p ctx_handle in drm_device::ctx_bitmap and the entry * Clears the bit specified by \p ctx_handle in drm_device::ctx_bitmap and the entry
* in drm_device::context_sareas, while holding the drm_device::struct_sem * in drm_device::context_sareas, while holding the drm_device::struct_mutex
* lock. * lock.
*/ */
void drm_ctxbitmap_free(drm_device_t * dev, int ctx_handle) void drm_ctxbitmap_free(drm_device_t * dev, int ctx_handle)
...@@ -64,10 +64,10 @@ void drm_ctxbitmap_free(drm_device_t * dev, int ctx_handle) ...@@ -64,10 +64,10 @@ void drm_ctxbitmap_free(drm_device_t * dev, int ctx_handle)
goto failed; goto failed;
if (ctx_handle < DRM_MAX_CTXBITMAP) { if (ctx_handle < DRM_MAX_CTXBITMAP) {
down(&dev->struct_sem); mutex_lock(&dev->struct_mutex);
clear_bit(ctx_handle, dev->ctx_bitmap); clear_bit(ctx_handle, dev->ctx_bitmap);
dev->context_sareas[ctx_handle] = NULL; dev->context_sareas[ctx_handle] = NULL;
up(&dev->struct_sem); mutex_unlock(&dev->struct_mutex);
return; return;
} }
failed: failed:
...@@ -83,7 +83,7 @@ void drm_ctxbitmap_free(drm_device_t * dev, int ctx_handle) ...@@ -83,7 +83,7 @@ void drm_ctxbitmap_free(drm_device_t * dev, int ctx_handle)
* *
* Find the first zero bit in drm_device::ctx_bitmap and (re)allocates * Find the first zero bit in drm_device::ctx_bitmap and (re)allocates
* drm_device::context_sareas to accommodate the new entry while holding the * drm_device::context_sareas to accommodate the new entry while holding the
* drm_device::struct_sem lock. * drm_device::struct_mutex lock.
*/ */
static int drm_ctxbitmap_next(drm_device_t * dev) static int drm_ctxbitmap_next(drm_device_t * dev)
{ {
...@@ -92,7 +92,7 @@ static int drm_ctxbitmap_next(drm_device_t * dev) ...@@ -92,7 +92,7 @@ static int drm_ctxbitmap_next(drm_device_t * dev)
if (!dev->ctx_bitmap) if (!dev->ctx_bitmap)
return -1; return -1;
down(&dev->struct_sem); mutex_lock(&dev->struct_mutex);
bit = find_first_zero_bit(dev->ctx_bitmap, DRM_MAX_CTXBITMAP); bit = find_first_zero_bit(dev->ctx_bitmap, DRM_MAX_CTXBITMAP);
if (bit < DRM_MAX_CTXBITMAP) { if (bit < DRM_MAX_CTXBITMAP) {
set_bit(bit, dev->ctx_bitmap); set_bit(bit, dev->ctx_bitmap);
...@@ -113,7 +113,7 @@ static int drm_ctxbitmap_next(drm_device_t * dev) ...@@ -113,7 +113,7 @@ static int drm_ctxbitmap_next(drm_device_t * dev)
DRM_MEM_MAPS); DRM_MEM_MAPS);
if (!ctx_sareas) { if (!ctx_sareas) {
clear_bit(bit, dev->ctx_bitmap); clear_bit(bit, dev->ctx_bitmap);
up(&dev->struct_sem); mutex_unlock(&dev->struct_mutex);
return -1; return -1;
} }
dev->context_sareas = ctx_sareas; dev->context_sareas = ctx_sareas;
...@@ -126,16 +126,16 @@ static int drm_ctxbitmap_next(drm_device_t * dev) ...@@ -126,16 +126,16 @@ static int drm_ctxbitmap_next(drm_device_t * dev)
DRM_MEM_MAPS); DRM_MEM_MAPS);
if (!dev->context_sareas) { if (!dev->context_sareas) {
clear_bit(bit, dev->ctx_bitmap); clear_bit(bit, dev->ctx_bitmap);
up(&dev->struct_sem); mutex_unlock(&dev->struct_mutex);
return -1; return -1;
} }
dev->context_sareas[bit] = NULL; dev->context_sareas[bit] = NULL;
} }
} }
up(&dev->struct_sem); mutex_unlock(&dev->struct_mutex);
return bit; return bit;
} }
up(&dev->struct_sem); mutex_unlock(&dev->struct_mutex);
return -1; return -1;
} }
...@@ -145,24 +145,24 @@ static int drm_ctxbitmap_next(drm_device_t * dev) ...@@ -145,24 +145,24 @@ static int drm_ctxbitmap_next(drm_device_t * dev)
* \param dev DRM device. * \param dev DRM device.
* *
* Allocates and initialize drm_device::ctx_bitmap and drm_device::context_sareas, while holding * Allocates and initialize drm_device::ctx_bitmap and drm_device::context_sareas, while holding
* the drm_device::struct_sem lock. * the drm_device::struct_mutex lock.
*/ */
int drm_ctxbitmap_init(drm_device_t * dev) int drm_ctxbitmap_init(drm_device_t * dev)
{ {
int i; int i;
int temp; int temp;
down(&dev->struct_sem); mutex_lock(&dev->struct_mutex);
dev->ctx_bitmap = (unsigned long *)drm_alloc(PAGE_SIZE, dev->ctx_bitmap = (unsigned long *)drm_alloc(PAGE_SIZE,
DRM_MEM_CTXBITMAP); DRM_MEM_CTXBITMAP);
if (dev->ctx_bitmap == NULL) { if (dev->ctx_bitmap == NULL) {
up(&dev->struct_sem); mutex_unlock(&dev->struct_mutex);
return -ENOMEM; return -ENOMEM;
} }
memset((void *)dev->ctx_bitmap, 0, PAGE_SIZE); memset((void *)dev->ctx_bitmap, 0, PAGE_SIZE);
dev->context_sareas = NULL; dev->context_sareas = NULL;
dev->max_context = -1; dev->max_context = -1;
up(&dev->struct_sem); mutex_unlock(&dev->struct_mutex);
for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) { for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) {
temp = drm_ctxbitmap_next(dev); temp = drm_ctxbitmap_next(dev);
...@@ -178,17 +178,17 @@ int drm_ctxbitmap_init(drm_device_t * dev) ...@@ -178,17 +178,17 @@ int drm_ctxbitmap_init(drm_device_t * dev)
* \param dev DRM device. * \param dev DRM device.
* *
* Frees drm_device::ctx_bitmap and drm_device::context_sareas, while holding * Frees drm_device::ctx_bitmap and drm_device::context_sareas, while holding
* the drm_device::struct_sem lock. * the drm_device::struct_mutex lock.
*/ */
void drm_ctxbitmap_cleanup(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) if (dev->context_sareas)
drm_free(dev->context_sareas, drm_free(dev->context_sareas,
sizeof(*dev->context_sareas) * sizeof(*dev->context_sareas) *
dev->max_context, DRM_MEM_MAPS); dev->max_context, DRM_MEM_MAPS);
drm_free((void *)dev->ctx_bitmap, PAGE_SIZE, DRM_MEM_CTXBITMAP); 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, ...@@ -222,15 +222,15 @@ int drm_getsareactx(struct inode *inode, struct file *filp,
if (copy_from_user(&request, argp, sizeof(request))) if (copy_from_user(&request, argp, sizeof(request)))
return -EFAULT; return -EFAULT;
down(&dev->struct_sem); mutex_lock(&dev->struct_mutex);
if (dev->max_context < 0 if (dev->max_context < 0
|| request.ctx_id >= (unsigned)dev->max_context) { || request.ctx_id >= (unsigned)dev->max_context) {
up(&dev->struct_sem); mutex_unlock(&dev->struct_mutex);
return -EINVAL; return -EINVAL;
} }
map = dev->context_sareas[request.ctx_id]; map = dev->context_sareas[request.ctx_id];
up(&dev->struct_sem); 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, head) {
...@@ -274,7 +274,7 @@ int drm_setsareactx(struct inode *inode, struct file *filp, ...@@ -274,7 +274,7 @@ int drm_setsareactx(struct inode *inode, struct file *filp,
(drm_ctx_priv_map_t __user *) arg, sizeof(request))) (drm_ctx_priv_map_t __user *) arg, sizeof(request)))
return -EFAULT; return -EFAULT;
down(&dev->struct_sem); mutex_lock(&dev->struct_mutex);
list_for_each(list, &dev->maplist->head) { list_for_each(list, &dev->maplist->head) {
r_list = list_entry(list, drm_map_list_t, head); r_list = list_entry(list, drm_map_list_t, head);
if (r_list->map if (r_list->map
...@@ -282,7 +282,7 @@ int drm_setsareactx(struct inode *inode, struct file *filp, ...@@ -282,7 +282,7 @@ int drm_setsareactx(struct inode *inode, struct file *filp,
goto found; goto found;
} }
bad: bad:
up(&dev->struct_sem); mutex_unlock(&dev->struct_mutex);
return -EINVAL; return -EINVAL;
found: found:
...@@ -294,7 +294,7 @@ int drm_setsareactx(struct inode *inode, struct file *filp, ...@@ -294,7 +294,7 @@ int drm_setsareactx(struct inode *inode, struct file *filp,
if (request.ctx_id >= (unsigned)dev->max_context) if (request.ctx_id >= (unsigned)dev->max_context)
goto bad; goto bad;
dev->context_sareas[request.ctx_id] = map; dev->context_sareas[request.ctx_id] = map;
up(&dev->struct_sem); mutex_unlock(&dev->struct_mutex);
return 0; return 0;
} }
...@@ -448,10 +448,10 @@ int drm_addctx(struct inode *inode, struct file *filp, ...@@ -448,10 +448,10 @@ int drm_addctx(struct inode *inode, struct file *filp,
ctx_entry->handle = ctx.handle; ctx_entry->handle = ctx.handle;
ctx_entry->tag = priv; ctx_entry->tag = priv;
down(&dev->ctxlist_sem); mutex_lock(&dev->ctxlist_mutex);
list_add(&ctx_entry->head, &dev->ctxlist->head); list_add(&ctx_entry->head, &dev->ctxlist->head);
++dev->ctx_count; ++dev->ctx_count;
up(&dev->ctxlist_sem); mutex_unlock(&dev->ctxlist_mutex);
if (copy_to_user(argp, &ctx, sizeof(ctx))) if (copy_to_user(argp, &ctx, sizeof(ctx)))
return -EFAULT; return -EFAULT;
...@@ -574,7 +574,7 @@ int drm_rmctx(struct inode *inode, struct file *filp, ...@@ -574,7 +574,7 @@ int drm_rmctx(struct inode *inode, struct file *filp,
drm_ctxbitmap_free(dev, ctx.handle); drm_ctxbitmap_free(dev, ctx.handle);
} }
down(&dev->ctxlist_sem); mutex_lock(&dev->ctxlist_mutex);
if (!list_empty(&dev->ctxlist->head)) { if (!list_empty(&dev->ctxlist->head)) {
drm_ctx_list_t *pos, *n; drm_ctx_list_t *pos, *n;
...@@ -586,7 +586,7 @@ int drm_rmctx(struct inode *inode, struct file *filp, ...@@ -586,7 +586,7 @@ int drm_rmctx(struct inode *inode, struct file *filp,
} }
} }
} }
up(&dev->ctxlist_sem); mutex_unlock(&dev->ctxlist_mutex);
return 0; return 0;
} }
......
...@@ -151,7 +151,7 @@ int drm_lastclose(drm_device_t * dev) ...@@ -151,7 +151,7 @@ int drm_lastclose(drm_device_t * dev)
if (dev->irq_enabled) if (dev->irq_enabled)
drm_irq_uninstall(dev); drm_irq_uninstall(dev);
down(&dev->struct_sem); mutex_lock(&dev->struct_mutex);
del_timer(&dev->timer); del_timer(&dev->timer);
/* Clear pid list */ /* Clear pid list */
...@@ -231,7 +231,7 @@ int drm_lastclose(drm_device_t * dev) ...@@ -231,7 +231,7 @@ int drm_lastclose(drm_device_t * dev)
dev->lock.filp = NULL; dev->lock.filp = NULL;
wake_up_interruptible(&dev->lock.lock_queue); wake_up_interruptible(&dev->lock.lock_queue);
} }
up(&dev->struct_sem); mutex_unlock(&dev->struct_mutex);
DRM_DEBUG("lastclose completed\n"); DRM_DEBUG("lastclose completed\n");
return 0; return 0;
......
...@@ -262,7 +262,7 @@ static int drm_open_helper(struct inode *inode, struct file *filp, ...@@ -262,7 +262,7 @@ static int drm_open_helper(struct inode *inode, struct file *filp,
goto out_free; goto out_free;
} }
down(&dev->struct_sem); mutex_lock(&dev->struct_mutex);
if (!dev->file_last) { if (!dev->file_last) {
priv->next = NULL; priv->next = NULL;
priv->prev = NULL; priv->prev = NULL;
...@@ -276,7 +276,7 @@ static int drm_open_helper(struct inode *inode, struct file *filp, ...@@ -276,7 +276,7 @@ static int drm_open_helper(struct inode *inode, struct file *filp,
dev->file_last->next = priv; dev->file_last->next = priv;
dev->file_last = priv; dev->file_last = priv;
} }
up(&dev->struct_sem); mutex_unlock(&dev->struct_mutex);
#ifdef __alpha__ #ifdef __alpha__
/* /*
...@@ -413,7 +413,7 @@ int drm_release(struct inode *inode, struct file *filp) ...@@ -413,7 +413,7 @@ int drm_release(struct inode *inode, struct file *filp)
drm_fasync(-1, filp, 0); drm_fasync(-1, filp, 0);
down(&dev->ctxlist_sem); mutex_lock(&dev->ctxlist_mutex);
if (dev->ctxlist && (!list_empty(&dev->ctxlist->head))) { if (dev->ctxlist && (!list_empty(&dev->ctxlist->head))) {
drm_ctx_list_t *pos, *n; drm_ctx_list_t *pos, *n;
...@@ -432,9 +432,9 @@ int drm_release(struct inode *inode, struct file *filp) ...@@ -432,9 +432,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) { if (priv->remove_auth_on_close == 1) {
drm_file_t *temp = dev->file_first; drm_file_t *temp = dev->file_first;
while (temp) { while (temp) {
...@@ -452,7 +452,7 @@ int drm_release(struct inode *inode, struct file *filp) ...@@ -452,7 +452,7 @@ int drm_release(struct inode *inode, struct file *filp)
} else { } else {
dev->file_last = priv->prev; dev->file_last = priv->prev;
} }
up(&dev->struct_sem); mutex_unlock(&dev->struct_mutex);
if (dev->driver->postclose) if (dev->driver->postclose)
dev->driver->postclose(dev, priv); dev->driver->postclose(dev, priv);
......
...@@ -194,9 +194,9 @@ int drm_getmap(struct inode *inode, struct file *filp, ...@@ -194,9 +194,9 @@ int drm_getmap(struct inode *inode, struct file *filp,
return -EFAULT; return -EFAULT;
idx = map.offset; idx = map.offset;
down(&dev->struct_sem); mutex_lock(&dev->struct_mutex);
if (idx < 0) { if (idx < 0) {
up(&dev->struct_sem); mutex_unlock(&dev->struct_mutex);
return -EINVAL; return -EINVAL;
} }
...@@ -209,7 +209,7 @@ int drm_getmap(struct inode *inode, struct file *filp, ...@@ -209,7 +209,7 @@ int drm_getmap(struct inode *inode, struct file *filp,
i++; i++;
} }
if (!r_list || !r_list->map) { if (!r_list || !r_list->map) {
up(&dev->struct_sem); mutex_unlock(&dev->struct_mutex);
return -EINVAL; return -EINVAL;
} }
...@@ -219,7 +219,7 @@ int drm_getmap(struct inode *inode, struct file *filp, ...@@ -219,7 +219,7 @@ int drm_getmap(struct inode *inode, struct file *filp,
map.flags = r_list->map->flags; map.flags = r_list->map->flags;
map.handle = (void *)(unsigned long)r_list->user_token; map.handle = (void *)(unsigned long)r_list->user_token;
map.mtrr = r_list->map->mtrr; map.mtrr = r_list->map->mtrr;
up(&dev->struct_sem); mutex_unlock(&dev->struct_mutex);
if (copy_to_user(argp, &map, sizeof(map))) if (copy_to_user(argp, &map, sizeof(map)))
return -EFAULT; return -EFAULT;
...@@ -253,11 +253,11 @@ int drm_getclient(struct inode *inode, struct file *filp, ...@@ -253,11 +253,11 @@ int drm_getclient(struct inode *inode, struct file *filp,
if (copy_from_user(&client, argp, sizeof(client))) if (copy_from_user(&client, argp, sizeof(client)))
return -EFAULT; return -EFAULT;
idx = client.idx; 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) ; for (i = 0, pt = dev->file_first; i < idx && pt; i++, pt = pt->next) ;
if (!pt) { if (!pt) {
up(&dev->struct_sem); mutex_unlock(&dev->struct_mutex);
return -EINVAL; return -EINVAL;
} }
client.auth = pt->authenticated; client.auth = pt->authenticated;
...@@ -265,7 +265,7 @@ int drm_getclient(struct inode *inode, struct file *filp, ...@@ -265,7 +265,7 @@ int drm_getclient(struct inode *inode, struct file *filp,
client.uid = pt->uid; client.uid = pt->uid;
client.magic = pt->magic; client.magic = pt->magic;
client.iocs = pt->ioctl_count; client.iocs = pt->ioctl_count;
up(&dev->struct_sem); mutex_unlock(&dev->struct_mutex);
if (copy_to_user(argp, &client, sizeof(client))) if (copy_to_user(argp, &client, sizeof(client)))
return -EFAULT; return -EFAULT;
...@@ -292,7 +292,7 @@ int drm_getstats(struct inode *inode, struct file *filp, ...@@ -292,7 +292,7 @@ int drm_getstats(struct inode *inode, struct file *filp,
memset(&stats, 0, sizeof(stats)); memset(&stats, 0, sizeof(stats));
down(&dev->struct_sem); mutex_lock(&dev->struct_mutex);
for (i = 0; i < dev->counters; i++) { for (i = 0; i < dev->counters; i++) {
if (dev->types[i] == _DRM_STAT_LOCK) if (dev->types[i] == _DRM_STAT_LOCK)
...@@ -305,7 +305,7 @@ int drm_getstats(struct inode *inode, struct file *filp, ...@@ -305,7 +305,7 @@ int drm_getstats(struct inode *inode, struct file *filp,
stats.count = dev->counters; 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))) if (copy_to_user((drm_stats_t __user *) arg, &stats, sizeof(stats)))
return -EFAULT; return -EFAULT;
......
...@@ -98,20 +98,20 @@ static int drm_irq_install(drm_device_t * dev) ...@@ -98,20 +98,20 @@ static int drm_irq_install(drm_device_t * dev)
if (dev->irq == 0) if (dev->irq == 0)
return -EINVAL; return -EINVAL;
down(&dev->struct_sem); mutex_lock(&dev->struct_mutex);
/* Driver must have been initialized */ /* Driver must have been initialized */
if (!dev->dev_private) { if (!dev->dev_private) {
up(&dev->struct_sem); mutex_unlock(&dev->struct_mutex);
return -EINVAL; return -EINVAL;
} }
if (dev->irq_enabled) { if (dev->irq_enabled) {
up(&dev->struct_sem); mutex_unlock(&dev->struct_mutex);
return -EBUSY; return -EBUSY;
} }
dev->irq_enabled = 1; dev->irq_enabled = 1;
up(&dev->struct_sem); mutex_unlock(&dev->struct_mutex);
DRM_DEBUG("%s: irq=%d\n", __FUNCTION__, dev->irq); DRM_DEBUG("%s: irq=%d\n", __FUNCTION__, dev->irq);
...@@ -135,9 +135,9 @@ static int drm_irq_install(drm_device_t * dev) ...@@ -135,9 +135,9 @@ static int drm_irq_install(drm_device_t * dev)
ret = request_irq(dev->irq, dev->driver->irq_handler, ret = request_irq(dev->irq, dev->driver->irq_handler,
sh_flags, dev->devname, dev); sh_flags, dev->devname, dev);
if (ret < 0) { if (ret < 0) {
down(&dev->struct_sem); mutex_lock(&dev->struct_mutex);
dev->irq_enabled = 0; dev->irq_enabled = 0;
up(&dev->struct_sem); mutex_unlock(&dev->struct_mutex);
return ret; return ret;
} }
...@@ -161,10 +161,10 @@ int drm_irq_uninstall(drm_device_t * dev) ...@@ -161,10 +161,10 @@ int drm_irq_uninstall(drm_device_t * dev)
if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ)) if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
return -EINVAL; return -EINVAL;
down(&dev->struct_sem); mutex_lock(&dev->struct_mutex);
irq_enabled = dev->irq_enabled; irq_enabled = dev->irq_enabled;
dev->irq_enabled = 0; dev->irq_enabled = 0;
up(&dev->struct_sem); mutex_unlock(&dev->struct_mutex);
if (!irq_enabled) if (!irq_enabled)
return -EINVAL; return -EINVAL;
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
Please contact dri-devel@lists.sf.net to add new cards to this list Please contact dri-devel@lists.sf.net to add new cards to this list
*/ */
#define radeon_PCI_IDS \ #define radeon_PCI_IDS \
{0x1002, 0x3150, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV350},\
{0x1002, 0x4136, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS100|CHIP_IS_IGP}, \ {0x1002, 0x4136, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS100|CHIP_IS_IGP}, \
{0x1002, 0x4137, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS200|CHIP_IS_IGP}, \ {0x1002, 0x4137, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS200|CHIP_IS_IGP}, \
{0x1002, 0x4144, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R300}, \ {0x1002, 0x4144, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R300}, \
...@@ -242,5 +243,6 @@ ...@@ -242,5 +243,6 @@
{0x8086, 0x2582, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x8086, 0x2582, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x8086, 0x2592, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x8086, 0x2592, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x8086, 0x2772, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x8086, 0x2772, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x8086, 0x27a2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0, 0, 0} {0, 0, 0}
...@@ -258,7 +258,7 @@ static int drm__vm_info(char *buf, char **start, off_t offset, int request, ...@@ -258,7 +258,7 @@ static int drm__vm_info(char *buf, char **start, off_t offset, int request,
} }
/** /**
* Simply calls _vm_info() while holding the drm_device::struct_sem lock. * Simply calls _vm_info() while holding the drm_device::struct_mutex lock.
*/ */
static int drm_vm_info(char *buf, char **start, off_t offset, int request, static int drm_vm_info(char *buf, char **start, off_t offset, int request,
int *eof, void *data) int *eof, void *data)
...@@ -266,9 +266,9 @@ static int drm_vm_info(char *buf, char **start, off_t offset, int request, ...@@ -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; drm_device_t *dev = (drm_device_t *) data;
int ret; int ret;
down(&dev->struct_sem); mutex_lock(&dev->struct_mutex);
ret = drm__vm_info(buf, start, offset, request, eof, data); ret = drm__vm_info(buf, start, offset, request, eof, data);
up(&dev->struct_sem); mutex_unlock(&dev->struct_mutex);
return ret; return ret;
} }
...@@ -331,7 +331,7 @@ static int drm__queues_info(char *buf, char **start, off_t offset, ...@@ -331,7 +331,7 @@ static int drm__queues_info(char *buf, char **start, off_t offset,
} }
/** /**
* Simply calls _queues_info() while holding the drm_device::struct_sem lock. * Simply calls _queues_info() while holding the drm_device::struct_mutex lock.
*/ */
static int drm_queues_info(char *buf, char **start, off_t offset, int request, static int drm_queues_info(char *buf, char **start, off_t offset, int request,
int *eof, void *data) int *eof, void *data)
...@@ -339,9 +339,9 @@ static int drm_queues_info(char *buf, char **start, off_t offset, int request, ...@@ -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; drm_device_t *dev = (drm_device_t *) data;
int ret; int ret;
down(&dev->struct_sem); mutex_lock(&dev->struct_mutex);
ret = drm__queues_info(buf, start, offset, request, eof, data); ret = drm__queues_info(buf, start, offset, request, eof, data);
up(&dev->struct_sem); mutex_unlock(&dev->struct_mutex);
return ret; return ret;
} }
...@@ -403,7 +403,7 @@ static int drm__bufs_info(char *buf, char **start, off_t offset, int request, ...@@ -403,7 +403,7 @@ static int drm__bufs_info(char *buf, char **start, off_t offset, int request,
} }
/** /**
* Simply calls _bufs_info() while holding the drm_device::struct_sem lock. * Simply calls _bufs_info() while holding the drm_device::struct_mutex lock.
*/ */
static int drm_bufs_info(char *buf, char **start, off_t offset, int request, static int drm_bufs_info(char *buf, char **start, off_t offset, int request,
int *eof, void *data) int *eof, void *data)
...@@ -411,9 +411,9 @@ static int drm_bufs_info(char *buf, char **start, off_t offset, int request, ...@@ -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; drm_device_t *dev = (drm_device_t *) data;
int ret; int ret;
down(&dev->struct_sem); mutex_lock(&dev->struct_mutex);
ret = drm__bufs_info(buf, start, offset, request, eof, data); ret = drm__bufs_info(buf, start, offset, request, eof, data);
up(&dev->struct_sem); mutex_unlock(&dev->struct_mutex);
return ret; return ret;
} }
...@@ -459,7 +459,7 @@ static int drm__clients_info(char *buf, char **start, off_t offset, ...@@ -459,7 +459,7 @@ static int drm__clients_info(char *buf, char **start, off_t offset,
} }
/** /**
* Simply calls _clients_info() while holding the drm_device::struct_sem lock. * Simply calls _clients_info() while holding the drm_device::struct_mutex lock.
*/ */
static int drm_clients_info(char *buf, char **start, off_t offset, static int drm_clients_info(char *buf, char **start, off_t offset,
int request, int *eof, void *data) int request, int *eof, void *data)
...@@ -467,9 +467,9 @@ static int drm_clients_info(char *buf, char **start, off_t offset, ...@@ -467,9 +467,9 @@ static int drm_clients_info(char *buf, char **start, off_t offset,
drm_device_t *dev = (drm_device_t *) data; drm_device_t *dev = (drm_device_t *) data;
int ret; int ret;
down(&dev->struct_sem); mutex_lock(&dev->struct_mutex);
ret = drm__clients_info(buf, start, offset, request, eof, data); ret = drm__clients_info(buf, start, offset, request, eof, data);
up(&dev->struct_sem); mutex_unlock(&dev->struct_mutex);
return ret; return ret;
} }
...@@ -540,9 +540,9 @@ static int drm_vma_info(char *buf, char **start, off_t offset, int request, ...@@ -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; drm_device_t *dev = (drm_device_t *) data;
int ret; int ret;
down(&dev->struct_sem); mutex_lock(&dev->struct_mutex);
ret = drm__vma_info(buf, start, offset, request, eof, data); ret = drm__vma_info(buf, start, offset, request, eof, data);
up(&dev->struct_sem); mutex_unlock(&dev->struct_mutex);
return ret; return ret;
} }
#endif #endif
...@@ -61,8 +61,8 @@ static int drm_fill_in_dev(drm_device_t * dev, struct pci_dev *pdev, ...@@ -61,8 +61,8 @@ static int drm_fill_in_dev(drm_device_t * dev, struct pci_dev *pdev,
spin_lock_init(&dev->count_lock); spin_lock_init(&dev->count_lock);
init_timer(&dev->timer); init_timer(&dev->timer);
sema_init(&dev->struct_sem, 1); mutex_init(&dev->struct_mutex);
sema_init(&dev->ctxlist_sem, 1); mutex_init(&dev->ctxlist_mutex);
dev->pdev = pdev; dev->pdev = pdev;
......
...@@ -188,7 +188,7 @@ static void drm_vm_shm_close(struct vm_area_struct *vma) ...@@ -188,7 +188,7 @@ static void drm_vm_shm_close(struct vm_area_struct *vma)
map = vma->vm_private_data; map = vma->vm_private_data;
down(&dev->struct_sem); mutex_lock(&dev->struct_mutex);
for (pt = dev->vmalist, prev = NULL; pt; pt = next) { for (pt = dev->vmalist, prev = NULL; pt; pt = next) {
next = pt->next; next = pt->next;
if (pt->vma->vm_private_data == map) if (pt->vma->vm_private_data == map)
...@@ -248,7 +248,7 @@ static void drm_vm_shm_close(struct vm_area_struct *vma) ...@@ -248,7 +248,7 @@ static void drm_vm_shm_close(struct vm_area_struct *vma)
drm_free(map, sizeof(*map), DRM_MEM_MAPS); drm_free(map, sizeof(*map), DRM_MEM_MAPS);
} }
} }
up(&dev->struct_sem); mutex_unlock(&dev->struct_mutex);
} }
/** /**
...@@ -404,12 +404,12 @@ static void drm_vm_open(struct vm_area_struct *vma) ...@@ -404,12 +404,12 @@ static void drm_vm_open(struct vm_area_struct *vma)
vma_entry = drm_alloc(sizeof(*vma_entry), DRM_MEM_VMAS); vma_entry = drm_alloc(sizeof(*vma_entry), DRM_MEM_VMAS);
if (vma_entry) { if (vma_entry) {
down(&dev->struct_sem); mutex_lock(&dev->struct_mutex);
vma_entry->vma = vma; vma_entry->vma = vma;
vma_entry->next = dev->vmalist; vma_entry->next = dev->vmalist;
vma_entry->pid = current->pid; vma_entry->pid = current->pid;
dev->vmalist = vma_entry; dev->vmalist = vma_entry;
up(&dev->struct_sem); mutex_unlock(&dev->struct_mutex);
} }
} }
...@@ -431,7 +431,7 @@ static void drm_vm_close(struct vm_area_struct *vma) ...@@ -431,7 +431,7 @@ static void drm_vm_close(struct vm_area_struct *vma)
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);
down(&dev->struct_sem); mutex_lock(&dev->struct_mutex);
for (pt = dev->vmalist, prev = NULL; pt; prev = pt, pt = pt->next) { for (pt = dev->vmalist, prev = NULL; pt; prev = pt, pt = pt->next) {
if (pt->vma == vma) { if (pt->vma == vma) {
if (prev) { if (prev) {
...@@ -443,7 +443,7 @@ static void drm_vm_close(struct vm_area_struct *vma) ...@@ -443,7 +443,7 @@ static void drm_vm_close(struct vm_area_struct *vma)
break; break;
} }
} }
up(&dev->struct_sem); mutex_unlock(&dev->struct_mutex);
} }
/** /**
......
...@@ -958,7 +958,7 @@ static int i810_flush_queue(drm_device_t * dev) ...@@ -958,7 +958,7 @@ static int i810_flush_queue(drm_device_t * dev)
} }
/* Must be called with the lock held */ /* Must be called with the lock held */
void i810_reclaim_buffers(drm_device_t * dev, struct file *filp) static void i810_reclaim_buffers(drm_device_t * dev, struct file *filp)
{ {
drm_device_dma_t *dma = dev->dma; drm_device_dma_t *dma = dev->dma;
int i; int i;
......
...@@ -113,8 +113,6 @@ typedef struct drm_i810_private { ...@@ -113,8 +113,6 @@ typedef struct drm_i810_private {
} drm_i810_private_t; } drm_i810_private_t;
/* i810_dma.c */ /* i810_dma.c */
extern void i810_reclaim_buffers(drm_device_t * dev, struct file *filp);
extern int i810_driver_dma_quiescent(drm_device_t * dev); extern int i810_driver_dma_quiescent(drm_device_t * dev);
extern void i810_driver_reclaim_buffers_locked(drm_device_t * dev, extern void i810_driver_reclaim_buffers_locked(drm_device_t * dev,
struct file *filp); struct file *filp);
......
...@@ -1239,7 +1239,7 @@ static int i830_flush_queue(drm_device_t * dev) ...@@ -1239,7 +1239,7 @@ static int i830_flush_queue(drm_device_t * dev)
} }
/* Must be called with the lock held */ /* Must be called with the lock held */
void i830_reclaim_buffers(drm_device_t * dev, struct file *filp) static void i830_reclaim_buffers(drm_device_t * dev, struct file *filp)
{ {
drm_device_dma_t *dma = dev->dma; drm_device_dma_t *dma = dev->dma;
int i; int i;
......
...@@ -123,9 +123,6 @@ typedef struct drm_i830_private { ...@@ -123,9 +123,6 @@ typedef struct drm_i830_private {
extern drm_ioctl_desc_t i830_ioctls[]; extern drm_ioctl_desc_t i830_ioctls[];
extern int i830_max_ioctl; extern int i830_max_ioctl;
/* i830_dma.c */
extern void i830_reclaim_buffers(drm_device_t * dev, struct file *filp);
/* i830_irq.c */ /* i830_irq.c */
extern int i830_irq_emit(struct inode *inode, struct file *filp, extern int i830_irq_emit(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg); unsigned int cmd, unsigned long arg);
......
...@@ -344,18 +344,20 @@ static int i915_emit_cmds(drm_device_t * dev, int __user * buffer, int dwords) ...@@ -344,18 +344,20 @@ static int i915_emit_cmds(drm_device_t * dev, int __user * buffer, int dwords)
int i; int i;
RING_LOCALS; RING_LOCALS;
if ((dwords+1) * sizeof(int) >= dev_priv->ring.Size - 8)
return DRM_ERR(EINVAL);
BEGIN_LP_RING(((dwords+1)&~1));
for (i = 0; i < dwords;) { for (i = 0; i < dwords;) {
int cmd, sz; int cmd, sz;
if (DRM_COPY_FROM_USER_UNCHECKED(&cmd, &buffer[i], sizeof(cmd))) if (DRM_COPY_FROM_USER_UNCHECKED(&cmd, &buffer[i], sizeof(cmd)))
return DRM_ERR(EINVAL); return DRM_ERR(EINVAL);
/* printk("%d/%d ", i, dwords); */
if ((sz = validate_cmd(cmd)) == 0 || i + sz > dwords) if ((sz = validate_cmd(cmd)) == 0 || i + sz > dwords)
return DRM_ERR(EINVAL); return DRM_ERR(EINVAL);
BEGIN_LP_RING(sz);
OUT_RING(cmd); OUT_RING(cmd);
while (++i, --sz) { while (++i, --sz) {
...@@ -365,9 +367,13 @@ static int i915_emit_cmds(drm_device_t * dev, int __user * buffer, int dwords) ...@@ -365,9 +367,13 @@ static int i915_emit_cmds(drm_device_t * dev, int __user * buffer, int dwords)
} }
OUT_RING(cmd); OUT_RING(cmd);
} }
ADVANCE_LP_RING();
} }
if (dwords & 1)
OUT_RING(0);
ADVANCE_LP_RING();
return 0; return 0;
} }
...@@ -401,6 +407,21 @@ static int i915_emit_box(drm_device_t * dev, ...@@ -401,6 +407,21 @@ static int i915_emit_box(drm_device_t * dev,
return 0; return 0;
} }
static void i915_emit_breadcrumb(drm_device_t *dev)
{
drm_i915_private_t *dev_priv = dev->dev_private;
RING_LOCALS;
dev_priv->sarea_priv->last_enqueue = dev_priv->counter++;
BEGIN_LP_RING(4);
OUT_RING(CMD_STORE_DWORD_IDX);
OUT_RING(20);
OUT_RING(dev_priv->counter);
OUT_RING(0);
ADVANCE_LP_RING();
}
static int i915_dispatch_cmdbuffer(drm_device_t * dev, static int i915_dispatch_cmdbuffer(drm_device_t * dev,
drm_i915_cmdbuffer_t * cmd) drm_i915_cmdbuffer_t * cmd)
{ {
...@@ -429,6 +450,7 @@ static int i915_dispatch_cmdbuffer(drm_device_t * dev, ...@@ -429,6 +450,7 @@ static int i915_dispatch_cmdbuffer(drm_device_t * dev,
return ret; return ret;
} }
i915_emit_breadcrumb(dev);
return 0; return 0;
} }
...@@ -475,12 +497,7 @@ static int i915_dispatch_batchbuffer(drm_device_t * dev, ...@@ -475,12 +497,7 @@ static int i915_dispatch_batchbuffer(drm_device_t * dev,
dev_priv->sarea_priv->last_enqueue = dev_priv->counter++; dev_priv->sarea_priv->last_enqueue = dev_priv->counter++;
BEGIN_LP_RING(4); i915_emit_breadcrumb(dev);
OUT_RING(CMD_STORE_DWORD_IDX);
OUT_RING(20);
OUT_RING(dev_priv->counter);
OUT_RING(0);
ADVANCE_LP_RING();
return 0; return 0;
} }
...@@ -657,7 +674,7 @@ static int i915_getparam(DRM_IOCTL_ARGS) ...@@ -657,7 +674,7 @@ static int i915_getparam(DRM_IOCTL_ARGS)
value = READ_BREADCRUMB(dev_priv); value = READ_BREADCRUMB(dev_priv);
break; break;
default: default:
DRM_ERROR("Unkown parameter %d\n", param.param); DRM_ERROR("Unknown parameter %d\n", param.param);
return DRM_ERR(EINVAL); return DRM_ERR(EINVAL);
} }
...@@ -742,7 +759,8 @@ drm_ioctl_desc_t i915_ioctls[] = { ...@@ -742,7 +759,8 @@ drm_ioctl_desc_t i915_ioctls[] = {
[DRM_IOCTL_NR(DRM_I915_ALLOC)] = {i915_mem_alloc, DRM_AUTH}, [DRM_IOCTL_NR(DRM_I915_ALLOC)] = {i915_mem_alloc, DRM_AUTH},
[DRM_IOCTL_NR(DRM_I915_FREE)] = {i915_mem_free, DRM_AUTH}, [DRM_IOCTL_NR(DRM_I915_FREE)] = {i915_mem_free, DRM_AUTH},
[DRM_IOCTL_NR(DRM_I915_INIT_HEAP)] = {i915_mem_init_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, [DRM_IOCTL_NR(DRM_I915_INIT_HEAP)] = {i915_mem_init_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
[DRM_IOCTL_NR(DRM_I915_CMDBUFFER)] = {i915_cmdbuffer, DRM_AUTH} [DRM_IOCTL_NR(DRM_I915_CMDBUFFER)] = {i915_cmdbuffer, DRM_AUTH},
[DRM_IOCTL_NR(DRM_I915_DESTROY_HEAP)] = { i915_mem_destroy_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY }
}; };
int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls); int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls);
......
...@@ -74,6 +74,30 @@ typedef struct _drm_i915_sarea { ...@@ -74,6 +74,30 @@ typedef struct _drm_i915_sarea {
int pf_active; int pf_active;
int pf_current_page; /* which buffer is being displayed? */ int pf_current_page; /* which buffer is being displayed? */
int perf_boxes; /* performance boxes to be displayed */ int perf_boxes; /* performance boxes to be displayed */
int width, height; /* screen size in pixels */
drm_handle_t front_handle;
int front_offset;
int front_size;
drm_handle_t back_handle;
int back_offset;
int back_size;
drm_handle_t depth_handle;
int depth_offset;
int depth_size;
drm_handle_t tex_handle;
int tex_offset;
int tex_size;
int log_tex_granularity;
int pitch;
int rotation; /* 0, 90, 180 or 270 */
int rotated_offset;
int rotated_size;
int rotated_pitch;
int virtualX, virtualY;
} drm_i915_sarea_t; } drm_i915_sarea_t;
/* Flags for perf_boxes /* Flags for perf_boxes
...@@ -99,6 +123,7 @@ typedef struct _drm_i915_sarea { ...@@ -99,6 +123,7 @@ typedef struct _drm_i915_sarea {
#define DRM_I915_FREE 0x09 #define DRM_I915_FREE 0x09
#define DRM_I915_INIT_HEAP 0x0a #define DRM_I915_INIT_HEAP 0x0a
#define DRM_I915_CMDBUFFER 0x0b #define DRM_I915_CMDBUFFER 0x0b
#define DRM_I915_DESTROY_HEAP 0x0c
#define DRM_IOCTL_I915_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT, drm_i915_init_t) #define DRM_IOCTL_I915_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT, drm_i915_init_t)
#define DRM_IOCTL_I915_FLUSH DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLUSH) #define DRM_IOCTL_I915_FLUSH DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLUSH)
...@@ -112,6 +137,7 @@ typedef struct _drm_i915_sarea { ...@@ -112,6 +137,7 @@ typedef struct _drm_i915_sarea {
#define DRM_IOCTL_I915_FREE DRM_IOW( DRM_COMMAND_BASE + DRM_I915_FREE, drm_i915_mem_free_t) #define DRM_IOCTL_I915_FREE DRM_IOW( DRM_COMMAND_BASE + DRM_I915_FREE, drm_i915_mem_free_t)
#define DRM_IOCTL_I915_INIT_HEAP DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT_HEAP, drm_i915_mem_init_heap_t) #define DRM_IOCTL_I915_INIT_HEAP DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT_HEAP, drm_i915_mem_init_heap_t)
#define DRM_IOCTL_I915_CMDBUFFER DRM_IOW( DRM_COMMAND_BASE + DRM_I915_CMDBUFFER, drm_i915_cmdbuffer_t) #define DRM_IOCTL_I915_CMDBUFFER DRM_IOW( DRM_COMMAND_BASE + DRM_I915_CMDBUFFER, drm_i915_cmdbuffer_t)
#define DRM_IOCTL_I915_DESTROY_HEAP DRM_IOW( DRM_COMMAND_BASE + DRM_I915_DESTROY_HEAP, drm_i915_mem_destroy_heap_t)
/* Allow drivers to submit batchbuffers directly to hardware, relying /* Allow drivers to submit batchbuffers directly to hardware, relying
* on the security mechanisms provided by hardware. * on the security mechanisms provided by hardware.
...@@ -191,4 +217,11 @@ typedef struct drm_i915_mem_init_heap { ...@@ -191,4 +217,11 @@ typedef struct drm_i915_mem_init_heap {
int start; int start;
} drm_i915_mem_init_heap_t; } drm_i915_mem_init_heap_t;
/* Allow memory manager to be torn down and re-initialized (eg on
* rotate):
*/
typedef struct drm_i915_mem_destroy_heap {
int region;
} drm_i915_mem_destroy_heap_t;
#endif /* _I915_DRM_H_ */ #endif /* _I915_DRM_H_ */
...@@ -37,16 +37,17 @@ ...@@ -37,16 +37,17 @@
#define DRIVER_NAME "i915" #define DRIVER_NAME "i915"
#define DRIVER_DESC "Intel Graphics" #define DRIVER_DESC "Intel Graphics"
#define DRIVER_DATE "20051209" #define DRIVER_DATE "20060119"
/* Interface history: /* Interface history:
* *
* 1.1: Original. * 1.1: Original.
* 1.2: Add Power Management * 1.2: Add Power Management
* 1.3: Add vblank support * 1.3: Add vblank support
* 1.4: Fix cmdbuffer path, add heap destroy
*/ */
#define DRIVER_MAJOR 1 #define DRIVER_MAJOR 1
#define DRIVER_MINOR 3 #define DRIVER_MINOR 4
#define DRIVER_PATCHLEVEL 0 #define DRIVER_PATCHLEVEL 0
typedef struct _drm_i915_ring_buffer { typedef struct _drm_i915_ring_buffer {
...@@ -123,6 +124,7 @@ extern void i915_driver_irq_uninstall(drm_device_t * dev); ...@@ -123,6 +124,7 @@ extern void i915_driver_irq_uninstall(drm_device_t * dev);
extern int i915_mem_alloc(DRM_IOCTL_ARGS); extern int i915_mem_alloc(DRM_IOCTL_ARGS);
extern int i915_mem_free(DRM_IOCTL_ARGS); extern int i915_mem_free(DRM_IOCTL_ARGS);
extern int i915_mem_init_heap(DRM_IOCTL_ARGS); extern int i915_mem_init_heap(DRM_IOCTL_ARGS);
extern int i915_mem_destroy_heap(DRM_IOCTL_ARGS);
extern void i915_mem_takedown(struct mem_block **heap); extern void i915_mem_takedown(struct mem_block **heap);
extern void i915_mem_release(drm_device_t * dev, extern void i915_mem_release(drm_device_t * dev,
DRMFILE filp, struct mem_block *heap); DRMFILE filp, struct mem_block *heap);
......
...@@ -365,3 +365,34 @@ int i915_mem_init_heap(DRM_IOCTL_ARGS) ...@@ -365,3 +365,34 @@ int i915_mem_init_heap(DRM_IOCTL_ARGS)
return init_heap(heap, initheap.start, initheap.size); return init_heap(heap, initheap.start, initheap.size);
} }
int i915_mem_destroy_heap( DRM_IOCTL_ARGS )
{
DRM_DEVICE;
drm_i915_private_t *dev_priv = dev->dev_private;
drm_i915_mem_destroy_heap_t destroyheap;
struct mem_block **heap;
if ( !dev_priv ) {
DRM_ERROR( "%s called with no initialization\n", __FUNCTION__ );
return DRM_ERR(EINVAL);
}
DRM_COPY_FROM_USER_IOCTL( destroyheap, (drm_i915_mem_destroy_heap_t *)data,
sizeof(destroyheap) );
heap = get_heap( dev_priv, destroyheap.region );
if (!heap) {
DRM_ERROR("get_heap failed");
return DRM_ERR(EFAULT);
}
if (!*heap) {
DRM_ERROR("heap not initialized?");
return DRM_ERR(EFAULT);
}
i915_mem_takedown( heap );
return 0;
}
...@@ -1640,7 +1640,7 @@ static int radeon_do_cleanup_cp(drm_device_t * dev) ...@@ -1640,7 +1640,7 @@ static int radeon_do_cleanup_cp(drm_device_t * dev)
if (dev_priv->gart_info.gart_table_location == DRM_ATI_GART_FB) if (dev_priv->gart_info.gart_table_location == DRM_ATI_GART_FB)
{ {
drm_core_ioremapfree(&dev_priv->gart_info.mapping, dev); drm_core_ioremapfree(&dev_priv->gart_info.mapping, dev);
dev_priv->gart_info.addr = 0; dev_priv->gart_info.addr = NULL;
} }
} }
/* only clear to the start of flags */ /* only clear to the start of flags */
......
...@@ -32,6 +32,8 @@ ...@@ -32,6 +32,8 @@
#define SAVAGE_EVENT_USEC_TIMEOUT 5000000 /* 5s */ #define SAVAGE_EVENT_USEC_TIMEOUT 5000000 /* 5s */
#define SAVAGE_FREELIST_DEBUG 0 #define SAVAGE_FREELIST_DEBUG 0
static int savage_do_cleanup_bci(drm_device_t *dev);
static int static int
savage_bci_wait_fifo_shadow(drm_savage_private_t * dev_priv, unsigned int n) savage_bci_wait_fifo_shadow(drm_savage_private_t * dev_priv, unsigned int n)
{ {
...@@ -895,7 +897,7 @@ static int savage_do_init_bci(drm_device_t * dev, drm_savage_init_t * init) ...@@ -895,7 +897,7 @@ static int savage_do_init_bci(drm_device_t * dev, drm_savage_init_t * init)
return 0; return 0;
} }
int savage_do_cleanup_bci(drm_device_t * dev) static int savage_do_cleanup_bci(drm_device_t * dev)
{ {
drm_savage_private_t *dev_priv = dev->dev_private; drm_savage_private_t *dev_priv = dev->dev_private;
......
...@@ -212,7 +212,6 @@ extern int savage_driver_load(drm_device_t *dev, unsigned long chipset); ...@@ -212,7 +212,6 @@ extern int savage_driver_load(drm_device_t *dev, unsigned long chipset);
extern int savage_driver_firstopen(drm_device_t *dev); extern int savage_driver_firstopen(drm_device_t *dev);
extern void savage_driver_lastclose(drm_device_t *dev); extern void savage_driver_lastclose(drm_device_t *dev);
extern int savage_driver_unload(drm_device_t *dev); extern int savage_driver_unload(drm_device_t *dev);
extern int savage_do_cleanup_bci(drm_device_t * dev);
extern void savage_reclaim_buffers(drm_device_t * dev, DRMFILE filp); extern void savage_reclaim_buffers(drm_device_t * dev, DRMFILE filp);
/* state functions */ /* state functions */
......
...@@ -222,7 +222,7 @@ static int via_initialize(drm_device_t * dev, ...@@ -222,7 +222,7 @@ static int via_initialize(drm_device_t * dev,
return 0; return 0;
} }
int via_dma_init(DRM_IOCTL_ARGS) static int via_dma_init(DRM_IOCTL_ARGS)
{ {
DRM_DEVICE; DRM_DEVICE;
drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
...@@ -321,7 +321,7 @@ int via_driver_dma_quiescent(drm_device_t * dev) ...@@ -321,7 +321,7 @@ int via_driver_dma_quiescent(drm_device_t * dev)
return 0; return 0;
} }
int via_flush_ioctl(DRM_IOCTL_ARGS) static int via_flush_ioctl(DRM_IOCTL_ARGS)
{ {
DRM_DEVICE; DRM_DEVICE;
...@@ -330,7 +330,7 @@ int via_flush_ioctl(DRM_IOCTL_ARGS) ...@@ -330,7 +330,7 @@ int via_flush_ioctl(DRM_IOCTL_ARGS)
return via_driver_dma_quiescent(dev); return via_driver_dma_quiescent(dev);
} }
int via_cmdbuffer(DRM_IOCTL_ARGS) static int via_cmdbuffer(DRM_IOCTL_ARGS)
{ {
DRM_DEVICE; DRM_DEVICE;
drm_via_cmdbuffer_t cmdbuf; drm_via_cmdbuffer_t cmdbuf;
...@@ -375,7 +375,7 @@ static int via_dispatch_pci_cmdbuffer(drm_device_t * dev, ...@@ -375,7 +375,7 @@ static int via_dispatch_pci_cmdbuffer(drm_device_t * dev,
return ret; return ret;
} }
int via_pci_cmdbuffer(DRM_IOCTL_ARGS) static int via_pci_cmdbuffer(DRM_IOCTL_ARGS)
{ {
DRM_DEVICE; DRM_DEVICE;
drm_via_cmdbuffer_t cmdbuf; drm_via_cmdbuffer_t cmdbuf;
...@@ -665,7 +665,7 @@ static void via_cmdbuf_reset(drm_via_private_t * dev_priv) ...@@ -665,7 +665,7 @@ static void via_cmdbuf_reset(drm_via_private_t * dev_priv)
* User interface to the space and lag functions. * User interface to the space and lag functions.
*/ */
int via_cmdbuf_size(DRM_IOCTL_ARGS) static int via_cmdbuf_size(DRM_IOCTL_ARGS)
{ {
DRM_DEVICE; DRM_DEVICE;
drm_via_cmdbuf_size_t d_siz; drm_via_cmdbuf_size_t d_siz;
......
...@@ -108,7 +108,7 @@ via_map_blit_for_device(struct pci_dev *pdev, ...@@ -108,7 +108,7 @@ via_map_blit_for_device(struct pci_dev *pdev,
int num_desc = 0; int num_desc = 0;
int cur_line; int cur_line;
dma_addr_t next = 0 | VIA_DMA_DPR_EC; dma_addr_t next = 0 | VIA_DMA_DPR_EC;
drm_via_descriptor_t *desc_ptr = 0; drm_via_descriptor_t *desc_ptr = NULL;
if (mode == 1) if (mode == 1)
desc_ptr = vsg->desc_pages[cur_descriptor_page]; desc_ptr = vsg->desc_pages[cur_descriptor_page];
...@@ -167,7 +167,7 @@ via_map_blit_for_device(struct pci_dev *pdev, ...@@ -167,7 +167,7 @@ via_map_blit_for_device(struct pci_dev *pdev,
*/ */
void static void
via_free_sg_info(struct pci_dev *pdev, drm_via_sg_info_t *vsg) via_free_sg_info(struct pci_dev *pdev, drm_via_sg_info_t *vsg)
{ {
struct page *page; struct page *page;
...@@ -581,7 +581,7 @@ via_build_sg_info(drm_device_t *dev, drm_via_sg_info_t *vsg, drm_via_dmablit_t * ...@@ -581,7 +581,7 @@ via_build_sg_info(drm_device_t *dev, drm_via_sg_info_t *vsg, drm_via_dmablit_t *
int ret = 0; int ret = 0;
vsg->direction = (draw) ? DMA_TO_DEVICE : DMA_FROM_DEVICE; vsg->direction = (draw) ? DMA_TO_DEVICE : DMA_FROM_DEVICE;
vsg->bounce_buffer = 0; vsg->bounce_buffer = NULL;
vsg->state = dr_via_sg_init; vsg->state = dr_via_sg_init;
......
...@@ -110,11 +110,6 @@ extern int via_mem_free(DRM_IOCTL_ARGS); ...@@ -110,11 +110,6 @@ extern int via_mem_free(DRM_IOCTL_ARGS);
extern int via_agp_init(DRM_IOCTL_ARGS); extern int via_agp_init(DRM_IOCTL_ARGS);
extern int via_map_init(DRM_IOCTL_ARGS); extern int via_map_init(DRM_IOCTL_ARGS);
extern int via_decoder_futex(DRM_IOCTL_ARGS); extern int via_decoder_futex(DRM_IOCTL_ARGS);
extern int via_dma_init(DRM_IOCTL_ARGS);
extern int via_cmdbuffer(DRM_IOCTL_ARGS);
extern int via_flush_ioctl(DRM_IOCTL_ARGS);
extern int via_pci_cmdbuffer(DRM_IOCTL_ARGS);
extern int via_cmdbuf_size(DRM_IOCTL_ARGS);
extern int via_wait_irq(DRM_IOCTL_ARGS); extern int via_wait_irq(DRM_IOCTL_ARGS);
extern int via_dma_blit_sync( DRM_IOCTL_ARGS ); extern int via_dma_blit_sync( DRM_IOCTL_ARGS );
extern int via_dma_blit( DRM_IOCTL_ARGS ); extern int via_dma_blit( DRM_IOCTL_ARGS );
...@@ -139,8 +134,6 @@ extern int via_driver_dma_quiescent(drm_device_t * dev); ...@@ -139,8 +134,6 @@ extern int via_driver_dma_quiescent(drm_device_t * dev);
extern void via_init_futex(drm_via_private_t * dev_priv); extern void via_init_futex(drm_via_private_t * dev_priv);
extern void via_cleanup_futex(drm_via_private_t * dev_priv); extern void via_cleanup_futex(drm_via_private_t * dev_priv);
extern void via_release_futex(drm_via_private_t * dev_priv, int context); extern void via_release_futex(drm_via_private_t * dev_priv, int context);
extern int via_driver_irq_wait(drm_device_t * dev, unsigned int irq,
int force_sequence, unsigned int *sequence);
extern void via_dmablit_handler(drm_device_t *dev, int engine, int from_irq); extern void via_dmablit_handler(drm_device_t *dev, int engine, int from_irq);
extern void via_init_dmablit(drm_device_t *dev); extern void via_init_dmablit(drm_device_t *dev);
......
...@@ -190,7 +190,7 @@ int via_driver_vblank_wait(drm_device_t * dev, unsigned int *sequence) ...@@ -190,7 +190,7 @@ int via_driver_vblank_wait(drm_device_t * dev, unsigned int *sequence)
return ret; return ret;
} }
int static int
via_driver_irq_wait(drm_device_t * dev, unsigned int irq, int force_sequence, via_driver_irq_wait(drm_device_t * dev, unsigned int irq, int force_sequence,
unsigned int *sequence) unsigned int *sequence)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment