summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkeithw <keithw>2003-03-28 14:27:29 +0000
committerkeithw <keithw>2003-03-28 14:27:29 +0000
commitdaa6000e09c03433dc222f6bdc1ec1866bb73691 (patch)
tree680eacea5637e8d065f6f07f4e6ccf276144b33e
parentbd20e4b7616b9b52ec64f1c007c369e41cdd442c (diff)
merged drm-filp-0-1-branchdrm-filp-1-20020328-merge
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drmP.h21
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm_bufs.h12
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm_dma.h36
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm_drv.h24
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm_lists.h4
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm_lock.h10
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm_os_linux.h1
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_dma.c29
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_drv.h10
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810.h2
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_dma.c9
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drv.h2
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i830.h2
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i830_dma.c9
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i830_drv.h2
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/mga_dma.c13
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/mga_drv.h10
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/mga_state.c12
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/r128_cce.c22
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/r128_drv.h9
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/r128_state.c37
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/radeon.h12
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/radeon_cp.c22
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/radeon_drv.h14
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/radeon_irq.c2
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/radeon_mem.c43
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/radeon_state.c56
27 files changed, 203 insertions, 222 deletions
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drmP.h b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drmP.h
index 5c1474dfa..a6b322855 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drmP.h
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drmP.h
@@ -276,6 +276,17 @@ do { \
(_map) = (_dev)->context_sareas[_ctx]; \
} while(0)
+#define LOCK_TEST_WITH_RETURN( dev, filp ) \
+do { \
+ if ( !_DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ) || \
+ dev->lock.filp != filp ) { \
+ DRM_ERROR( "%s called without lock held\n", \
+ __FUNCTION__ ); \
+ return -EINVAL; \
+ } \
+} while (0)
+
+
typedef int drm_ioctl_t( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg );
@@ -324,7 +335,7 @@ typedef struct drm_buf {
__volatile__ int waiting; /* On kernel DMA queue */
__volatile__ int pending; /* On hardware DMA queue */
wait_queue_head_t dma_wait; /* Processes waiting */
- pid_t pid; /* PID of holding process */
+ struct file *filp; /* Pointer to holding file descr */
int context; /* Kernel queue for this buffer */
int while_locked;/* Dispatch this buffer while locked */
enum {
@@ -442,7 +453,7 @@ typedef struct drm_queue {
typedef struct drm_lock_data {
drm_hw_lock_t *hw_lock; /* Hardware lock */
- pid_t pid; /* PID of lock holder (0=kernel) */
+ struct file *filp; /* File descr of lock holder (0=kernel) */
wait_queue_head_t lock_queue; /* Queue of blocked processes */
unsigned long lock_time; /* Time of last lock in jiffies */
} drm_lock_data_t;
@@ -818,15 +829,15 @@ extern int DRM(mapbufs)( struct inode *inode, struct file *filp,
extern int DRM(dma_setup)(drm_device_t *dev);
extern void DRM(dma_takedown)(drm_device_t *dev);
extern void DRM(free_buffer)(drm_device_t *dev, drm_buf_t *buf);
-extern void DRM(reclaim_buffers)(drm_device_t *dev, pid_t pid);
+extern void DRM(reclaim_buffers)( struct file *filp );
#if __HAVE_OLD_DMA
/* GH: This is a dirty hack for now...
*/
extern void DRM(clear_next_buffer)(drm_device_t *dev);
extern int DRM(select_queue)(drm_device_t *dev,
void (*wrapper)(unsigned long));
-extern int DRM(dma_enqueue)(drm_device_t *dev, drm_dma_t *dma);
-extern int DRM(dma_get_buffers)(drm_device_t *dev, drm_dma_t *dma);
+extern int DRM(dma_enqueue)(struct file *filp, drm_dma_t *dma);
+extern int DRM(dma_get_buffers)(struct file *filp, drm_dma_t *dma);
#endif
#if __HAVE_DMA_IRQ
extern int DRM(control)( struct inode *inode, struct file *filp,
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm_bufs.h b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm_bufs.h
index 9ce7cfff7..b4e73699c 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm_bufs.h
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm_bufs.h
@@ -404,7 +404,7 @@ int DRM(addbufs_agp)( struct inode *inode, struct file *filp,
buf->waiting = 0;
buf->pending = 0;
init_waitqueue_head( &buf->dma_wait );
- buf->pid = 0;
+ buf->filp = 0;
buf->dev_priv_size = sizeof(DRIVER_BUF_PRIV_T);
buf->dev_private = DRM(alloc)( sizeof(DRIVER_BUF_PRIV_T),
@@ -617,7 +617,7 @@ int DRM(addbufs_pci)( struct inode *inode, struct file *filp,
buf->waiting = 0;
buf->pending = 0;
init_waitqueue_head( &buf->dma_wait );
- buf->pid = 0;
+ buf->filp = 0;
#if __HAVE_DMA_HISTOGRAM
buf->time_queued = 0;
buf->time_dispatched = 0;
@@ -774,7 +774,7 @@ int DRM(addbufs_sg)( struct inode *inode, struct file *filp,
buf->waiting = 0;
buf->pending = 0;
init_waitqueue_head( &buf->dma_wait );
- buf->pid = 0;
+ buf->filp = 0;
buf->dev_priv_size = sizeof(DRIVER_BUF_PRIV_T);
buf->dev_private = DRM(alloc)( sizeof(DRIVER_BUF_PRIV_T),
@@ -1012,9 +1012,9 @@ int DRM(freebufs)( struct inode *inode, struct file *filp,
return -EINVAL;
}
buf = dma->buflist[idx];
- if ( buf->pid != current->pid ) {
- DRM_ERROR( "Process %d freeing buffer owned by %d\n",
- current->pid, buf->pid );
+ if ( buf->filp != filp ) {
+ DRM_ERROR( "Process %d freeing buffer not owned\n",
+ current->pid );
return -EINVAL;
}
DRM(free_buffer)( dev, buf );
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm_dma.h b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm_dma.h
index 1b0b639e9..d21c8b9dc 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm_dma.h
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm_dma.h
@@ -189,7 +189,7 @@ void DRM(free_buffer)(drm_device_t *dev, drm_buf_t *buf)
buf->waiting = 0;
buf->pending = 0;
- buf->pid = 0;
+ buf->filp = 0;
buf->used = 0;
#if __HAVE_DMA_HISTOGRAM
buf->time_completed = get_cycles();
@@ -211,14 +211,16 @@ void DRM(free_buffer)(drm_device_t *dev, drm_buf_t *buf)
}
#if !__HAVE_DMA_RECLAIM
-void DRM(reclaim_buffers)(drm_device_t *dev, pid_t pid)
+void DRM(reclaim_buffers)( struct file *filp )
{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
drm_device_dma_t *dma = dev->dma;
int i;
if (!dma) return;
for (i = 0; i < dma->buf_count; i++) {
- if (dma->buflist[i]->pid == pid) {
+ if (dma->buflist[i]->filp == filp) {
switch (dma->buflist[i]->list) {
case DRM_LIST_NONE:
DRM(free_buffer)(dev, dma->buflist[i]);
@@ -319,8 +321,10 @@ int DRM(select_queue)(drm_device_t *dev, void (*wrapper)(unsigned long))
}
-int DRM(dma_enqueue)(drm_device_t *dev, drm_dma_t *d)
+int DRM(dma_enqueue)(struct file *filp, drm_dma_t *d)
{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
int i;
drm_queue_t *q;
drm_buf_t *buf;
@@ -382,10 +386,10 @@ int DRM(dma_enqueue)(drm_device_t *dev, drm_dma_t *d)
return -EINVAL;
}
buf = dma->buflist[ idx ];
- if (buf->pid != current->pid) {
+ if (buf->filp != filp) {
atomic_dec(&q->use_count);
- DRM_ERROR("Process %d using buffer owned by %d\n",
- current->pid, buf->pid);
+ DRM_ERROR("Process %d using buffer not owned\n",
+ current->pid);
return -EINVAL;
}
if (buf->list != DRM_LIST_NONE) {
@@ -427,9 +431,11 @@ int DRM(dma_enqueue)(drm_device_t *dev, drm_dma_t *d)
return 0;
}
-static int DRM(dma_get_buffers_of_order)(drm_device_t *dev, drm_dma_t *d,
+static int DRM(dma_get_buffers_of_order)(struct file *filp, drm_dma_t *d,
int order)
{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
int i;
drm_buf_t *buf;
drm_device_dma_t *dma = dev->dma;
@@ -439,13 +445,13 @@ static int DRM(dma_get_buffers_of_order)(drm_device_t *dev, drm_dma_t *d,
d->flags & _DRM_DMA_WAIT);
if (!buf) break;
if (buf->pending || buf->waiting) {
- DRM_ERROR("Free buffer %d in use by %d (w%d, p%d)\n",
+ DRM_ERROR("Free buffer %d in use by %x (w%d, p%d)\n",
buf->idx,
- buf->pid,
+ buf->filp,
buf->waiting,
buf->pending);
}
- buf->pid = current->pid;
+ buf->filp = filp;
if (copy_to_user(&d->request_indices[i],
&buf->idx,
sizeof(buf->idx)))
@@ -462,7 +468,7 @@ static int DRM(dma_get_buffers_of_order)(drm_device_t *dev, drm_dma_t *d,
}
-int DRM(dma_get_buffers)(drm_device_t *dev, drm_dma_t *dma)
+int DRM(dma_get_buffers)(struct file *filp, drm_dma_t *dma)
{
int order;
int retcode = 0;
@@ -471,7 +477,7 @@ int DRM(dma_get_buffers)(drm_device_t *dev, drm_dma_t *dma)
order = DRM(order)(dma->request_size);
dma->granted_count = 0;
- retcode = DRM(dma_get_buffers_of_order)(dev, dma, order);
+ retcode = DRM(dma_get_buffers_of_order)(filp, dma, order);
if (dma->granted_count < dma->request_count
&& (dma->flags & _DRM_DMA_SMALLER_OK)) {
@@ -481,7 +487,7 @@ int DRM(dma_get_buffers)(drm_device_t *dev, drm_dma_t *dma)
&& tmp_order >= DRM_MIN_ORDER;
--tmp_order) {
- retcode = DRM(dma_get_buffers_of_order)(dev, dma,
+ retcode = DRM(dma_get_buffers_of_order)(filp, dma,
tmp_order);
}
}
@@ -494,7 +500,7 @@ int DRM(dma_get_buffers)(drm_device_t *dev, drm_dma_t *dma)
&& tmp_order <= DRM_MAX_ORDER;
++tmp_order) {
- retcode = DRM(dma_get_buffers_of_order)(dev, dma,
+ retcode = DRM(dma_get_buffers_of_order)(filp, dma,
tmp_order);
}
}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm_drv.h b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm_drv.h
index 41349e8c0..0a4f3aeb6 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm_drv.h
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm_drv.h
@@ -496,7 +496,7 @@ static int DRM(takedown)( drm_device_t *dev )
#endif
if ( dev->lock.hw_lock ) {
dev->sigdata.lock = dev->lock.hw_lock = NULL; /* SHM removed */
- dev->lock.pid = 0;
+ dev->lock.filp = 0;
wake_up_interruptible( &dev->lock.lock_queue );
}
up( &dev->struct_sem );
@@ -732,8 +732,6 @@ int DRM(open)( struct inode *inode, struct file *filp )
return -ENODEV;
}
- DRM_DEBUG( "open_count = %d\n", dev->open_count );
-
retcode = DRM(open_helper)( inode, filp, dev );
if ( !retcode ) {
atomic_inc( &dev->counts[_DRM_STAT_OPENS] );
@@ -770,10 +768,10 @@ int DRM(release)( struct inode *inode, struct file *filp )
if ( dev->lock.hw_lock &&
_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) &&
- dev->lock.pid == current->pid ) {
- DRM_DEBUG( "Process %d dead, freeing lock for context %d\n",
- current->pid,
- _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock) );
+ dev->lock.filp == filp ) {
+ DRM_DEBUG( "File %p released, freeing lock for context %d\n",
+ filp,
+ _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock) );
#if __HAVE_RELEASE
DRIVER_RELEASE();
#endif
@@ -789,6 +787,7 @@ int DRM(release)( struct inode *inode, struct file *filp )
else if ( dev->lock.hw_lock ) {
/* The lock is required to reclaim buffers */
DECLARE_WAITQUEUE( entry, current );
+
add_wait_queue( &dev->lock.lock_queue, &entry );
for (;;) {
current->state = TASK_INTERRUPTIBLE;
@@ -799,7 +798,7 @@ int DRM(release)( struct inode *inode, struct file *filp )
}
if ( DRM(lock_take)( &dev->lock.hw_lock->lock,
DRM_KERNEL_CONTEXT ) ) {
- dev->lock.pid = priv->pid;
+ dev->lock.filp = filp;
dev->lock.lock_time = jiffies;
atomic_inc( &dev->counts[_DRM_STAT_LOCKS] );
break; /* Got lock */
@@ -823,7 +822,7 @@ int DRM(release)( struct inode *inode, struct file *filp )
}
}
#elif __HAVE_DMA
- DRM(reclaim_buffers)( dev, priv->pid );
+ DRM(reclaim_buffers)( filp );
#endif
DRM(fasync)( -1, filp, 0 );
@@ -847,7 +846,7 @@ int DRM(release)( struct inode *inode, struct file *filp )
dev->file_last = priv->prev;
}
up( &dev->struct_sem );
-
+
DRM(free)( priv, sizeof(*priv), DRM_MEM_FILES );
/* ========================================================
@@ -872,6 +871,7 @@ int DRM(release)( struct inode *inode, struct file *filp )
spin_unlock( &dev->count_lock );
unlock_kernel();
+
return retcode;
}
@@ -969,7 +969,7 @@ int DRM(lock)( struct inode *inode, struct file *filp,
}
if ( DRM(lock_take)( &dev->lock.hw_lock->lock,
lock.context ) ) {
- dev->lock.pid = current->pid;
+ dev->lock.filp = filp;
dev->lock.lock_time = jiffies;
atomic_inc( &dev->counts[_DRM_STAT_LOCKS] );
break; /* Got lock */
@@ -1051,7 +1051,7 @@ int DRM(unlock)( struct inode *inode, struct file *filp,
* agent to request it then we should just be able to
* take it immediately and not eat the ioctl.
*/
- dev->lock.pid = 0;
+ dev->lock.filp = 0;
{
__volatile__ unsigned int *plock = &dev->lock.hw_lock->lock;
unsigned int old, new, prev, ctx;
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm_lists.h b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm_lists.h
index 5cd8cd47b..4a64df718 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm_lists.h
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm_lists.h
@@ -73,8 +73,8 @@ int DRM(waitlist_put)(drm_waitlist_t *bl, drm_buf_t *buf)
left = DRM_LEFTCOUNT(bl);
if (!left) {
- DRM_ERROR("Overflow while adding buffer %d from pid %d\n",
- buf->idx, buf->pid);
+ DRM_ERROR("Overflow while adding buffer %d from filp %p\n",
+ buf->idx, buf->filp);
return -EINVAL;
}
#if __HAVE_DMA_HISTOGRAM
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm_lock.h b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm_lock.h
index c887d1f66..e9b17cc40 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm_lock.h
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm_lock.h
@@ -79,7 +79,7 @@ int DRM(lock_transfer)(drm_device_t *dev,
{
unsigned int old, new, prev;
- dev->lock.pid = 0;
+ dev->lock.filp = 0;
do {
old = *lock;
new = context | _DRM_LOCK_HELD;
@@ -92,19 +92,17 @@ int DRM(lock_free)(drm_device_t *dev,
__volatile__ unsigned int *lock, unsigned int context)
{
unsigned int old, new, prev;
- pid_t pid = dev->lock.pid;
- dev->lock.pid = 0;
+ dev->lock.filp = 0;
do {
old = *lock;
new = 0;
prev = cmpxchg(lock, old, new);
} while (prev != old);
if (_DRM_LOCK_IS_HELD(old) && _DRM_LOCKING_CONTEXT(old) != context) {
- DRM_ERROR("%d freed heavyweight lock held by %d (pid %d)\n",
+ DRM_ERROR("%d freed heavyweight lock held by %d\n",
context,
- _DRM_LOCKING_CONTEXT(old),
- pid);
+ _DRM_LOCKING_CONTEXT(old));
return 1;
}
wake_up_interruptible(&dev->lock.lock_queue);
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm_os_linux.h b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm_os_linux.h
index b99b48997..b57efd348 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm_os_linux.h
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm_os_linux.h
@@ -3,6 +3,7 @@
#include <linux/interrupt.h> /* For task queue support */
#include <linux/delay.h>
+#define DRMFILE struct file *
#define DRM_IOCTL_ARGS struct inode *inode, struct file *filp, unsigned int cmd, unsigned long data
#define DRM_ERR(d) -(d)
#define DRM_CURRENTPID current->pid
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_dma.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_dma.c
index 0cf1f8e07..a3c21d110 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_dma.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_dma.c
@@ -190,7 +190,7 @@ static int gamma_do_dma(drm_device_t *dev, int locked)
if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
DRM_ERROR("Dispatching buffer %d from pid %d"
" \"while locked\", but no lock held\n",
- buf->idx, buf->pid);
+ buf->idx, current->pid);
}
} else {
if (!locked && !gamma_lock_take(&dev->lock.hw_lock->lock,
@@ -342,7 +342,8 @@ again:
return retcode;
}
-static int gamma_dma_priority(drm_device_t *dev, drm_dma_t *d)
+static int gamma_dma_priority(struct file *filp,
+ drm_device_t *dev, drm_dma_t *d)
{
unsigned long address;
unsigned long length;
@@ -380,15 +381,15 @@ static int gamma_dma_priority(drm_device_t *dev, drm_dma_t *d)
continue;
}
buf = dma->buflist[ idx ];
- if (buf->pid != current->pid) {
- DRM_ERROR("Process %d using buffer owned by %d\n",
- current->pid, buf->pid);
+ if (buf->filp != filp) {
+ DRM_ERROR("Process %d using buffer not owned\n",
+ current->pid);
retcode = -EINVAL;
goto cleanup;
}
if (buf->list != DRM_LIST_NONE) {
- DRM_ERROR("Process %d using %d's buffer on list %d\n",
- current->pid, buf->pid, buf->list);
+ DRM_ERROR("Process %d using buffer on list %d\n",
+ current->pid, buf->list);
retcode = -EINVAL;
goto cleanup;
}
@@ -480,7 +481,8 @@ cleanup:
return retcode;
}
-static int gamma_dma_send_buffers(drm_device_t *dev, drm_dma_t *d)
+static int gamma_dma_send_buffers(struct file *filp,
+ drm_device_t *dev, drm_dma_t *d)
{
DECLARE_WAITQUEUE(entry, current);
drm_buf_t *last_buf = NULL;
@@ -492,7 +494,7 @@ static int gamma_dma_send_buffers(drm_device_t *dev, drm_dma_t *d)
add_wait_queue(&last_buf->dma_wait, &entry);
}
- if ((retcode = gamma_dma_enqueue(dev, d))) {
+ if ((retcode = gamma_dma_enqueue(filp, d))) {
if (d->flags & _DRM_DMA_BLOCK)
remove_wait_queue(&last_buf->dma_wait, &entry);
return retcode;
@@ -522,14 +524,13 @@ static int gamma_dma_send_buffers(drm_device_t *dev, drm_dma_t *d)
}
}
if (retcode) {
- DRM_ERROR("ctx%d w%d p%d c%ld i%d l%d %d/%d\n",
+ DRM_ERROR("ctx%d w%d p%d c%ld i%d l%d pid:%d\n",
d->context,
last_buf->waiting,
last_buf->pending,
(long)DRM_WAITCOUNT(dev, d->context),
last_buf->idx,
last_buf->list,
- last_buf->pid,
current->pid);
}
}
@@ -562,15 +563,15 @@ int gamma_dma(struct inode *inode, struct file *filp, unsigned int cmd,
if (d.send_count) {
if (d.flags & _DRM_DMA_PRIORITY)
- retcode = gamma_dma_priority(dev, &d);
+ retcode = gamma_dma_priority(filp, dev, &d);
else
- retcode = gamma_dma_send_buffers(dev, &d);
+ retcode = gamma_dma_send_buffers(filp, dev, &d);
}
d.granted_count = 0;
if (!retcode && d.request_count) {
- retcode = gamma_dma_get_buffers(dev, &d);
+ retcode = gamma_dma_get_buffers(filp, &d);
}
DRM_DEBUG("%d returning, granted = %d\n",
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_drv.h b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_drv.h
index e7d0c8960..2f7d3588f 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_drv.h
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_drv.h
@@ -42,16 +42,6 @@ typedef struct drm_gamma_private {
drm_map_t *mmio3;
} drm_gamma_private_t;
-#define LOCK_TEST_WITH_RETURN( dev ) \
-do { \
- if ( !_DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ) || \
- dev->lock.pid != current->pid ) { \
- DRM_ERROR( "%s called without lock held\n", \
- __FUNCTION__ ); \
- return -EINVAL; \
- } \
-} while (0)
-
/* gamma_dma.c */
extern int gamma_dma_init( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg );
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810.h b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810.h
index ea1e7fe56..f37cb2e87 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810.h
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810.h
@@ -86,7 +86,7 @@
*/
#define __HAVE_RELEASE 1
#define DRIVER_RELEASE() do { \
- i810_reclaim_buffers( dev, priv->pid ); \
+ i810_reclaim_buffers( filp ); \
} while (0)
/* DMA customization:
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_dma.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_dma.c
index 91c204c55..de9345e3b 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_dma.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_dma.c
@@ -209,7 +209,6 @@ static int i810_unmap_buffer(drm_buf_t *buf)
static int i810_dma_get_buffer(drm_device_t *dev, drm_i810_dma_t *d,
struct file *filp)
{
- drm_file_t *priv = filp->private_data;
drm_buf_t *buf;
drm_i810_buf_priv_t *buf_priv;
int retcode = 0;
@@ -227,7 +226,7 @@ static int i810_dma_get_buffer(drm_device_t *dev, drm_i810_dma_t *d,
DRM_ERROR("mapbuf failed, retcode %d\n", retcode);
return retcode;
}
- buf->pid = priv->pid;
+ buf->filp = filp;
buf_priv = buf->dev_private;
d->granted = 1;
d->request_idx = buf->idx;
@@ -856,8 +855,10 @@ static int i810_flush_queue(drm_device_t *dev)
}
/* Must be called with the lock held */
-void i810_reclaim_buffers(drm_device_t *dev, pid_t pid)
+void i810_reclaim_buffers(struct file *filp)
{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
drm_device_dma_t *dma = dev->dma;
int i;
@@ -871,7 +872,7 @@ void i810_reclaim_buffers(drm_device_t *dev, pid_t pid)
drm_buf_t *buf = dma->buflist[ i ];
drm_i810_buf_priv_t *buf_priv = buf->dev_private;
- if (buf->pid == pid && buf_priv) {
+ if (buf->filp == filp && buf_priv) {
int used = cmpxchg(buf_priv->in_use, I810_BUF_CLIENT,
I810_BUF_FREE);
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drv.h b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drv.h
index 24bcc55f2..bbb570bc6 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drv.h
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drv.h
@@ -88,7 +88,7 @@ extern int i810_dma_init(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
extern int i810_flush_ioctl(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
-extern void i810_reclaim_buffers(drm_device_t *dev, pid_t pid);
+extern void i810_reclaim_buffers(struct file *filp);
extern int i810_getage(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
extern int i810_mmap_buffers(struct file *filp, struct vm_area_struct *vma);
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i830.h b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i830.h
index c8ba1fdb3..a351a4cff 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i830.h
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i830.h
@@ -87,7 +87,7 @@
*/
#define __HAVE_RELEASE 1
#define DRIVER_RELEASE() do { \
- i830_reclaim_buffers( dev, priv->pid ); \
+ i830_reclaim_buffers( filp ); \
} while (0)
/* DMA customization:
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i830_dma.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i830_dma.c
index 419cea123..d2555c922 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i830_dma.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i830_dma.c
@@ -217,7 +217,6 @@ static int i830_unmap_buffer(drm_buf_t *buf)
static int i830_dma_get_buffer(drm_device_t *dev, drm_i830_dma_t *d,
struct file *filp)
{
- drm_file_t *priv = filp->private_data;
drm_buf_t *buf;
drm_i830_buf_priv_t *buf_priv;
int retcode = 0;
@@ -235,7 +234,7 @@ static int i830_dma_get_buffer(drm_device_t *dev, drm_i830_dma_t *d,
DRM_ERROR("mapbuf failed, retcode %d\n", retcode);
return retcode;
}
- buf->pid = priv->pid;
+ buf->filp = filp;
buf_priv = buf->dev_private;
d->granted = 1;
d->request_idx = buf->idx;
@@ -1301,8 +1300,10 @@ static int i830_flush_queue(drm_device_t *dev)
}
/* Must be called with the lock held */
-void i830_reclaim_buffers(drm_device_t *dev, pid_t pid)
+void i830_reclaim_buffers( struct file *filp )
{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
drm_device_dma_t *dma = dev->dma;
int i;
@@ -1316,7 +1317,7 @@ void i830_reclaim_buffers(drm_device_t *dev, pid_t pid)
drm_buf_t *buf = dma->buflist[ i ];
drm_i830_buf_priv_t *buf_priv = buf->dev_private;
- if (buf->pid == pid && buf_priv) {
+ if (buf->filp == filp && buf_priv) {
int used = cmpxchg(buf_priv->in_use, I830_BUF_CLIENT,
I830_BUF_FREE);
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i830_drv.h b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i830_drv.h
index daad4760c..37313afd4 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i830_drv.h
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i830_drv.h
@@ -101,7 +101,7 @@ extern int i830_dma_init(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
extern int i830_flush_ioctl(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
-extern void i830_reclaim_buffers(drm_device_t *dev, pid_t pid);
+extern void i830_reclaim_buffers(struct file *filp);
extern int i830_getage(struct inode *inode, struct file *filp, unsigned int cmd,
unsigned long arg);
extern int i830_mmap_buffers(struct file *filp, struct vm_area_struct *vma);
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/mga_dma.c b/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/mga_dma.c
index 22bd61f03..5e95c9f9b 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/mga_dma.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/mga_dma.c
@@ -686,7 +686,7 @@ int mga_dma_flush( DRM_IOCTL_ARGS )
drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private;
drm_lock_t lock;
- LOCK_TEST_WITH_RETURN( dev );
+ LOCK_TEST_WITH_RETURN( dev, filp );
DRM_COPY_FROM_USER_IOCTL( lock, (drm_lock_t *)data, sizeof(lock) );
@@ -720,7 +720,7 @@ int mga_dma_reset( DRM_IOCTL_ARGS )
DRM_DEVICE;
drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private;
- LOCK_TEST_WITH_RETURN( dev );
+ LOCK_TEST_WITH_RETURN( dev, filp );
return mga_do_dma_reset( dev_priv );
}
@@ -730,7 +730,8 @@ int mga_dma_reset( DRM_IOCTL_ARGS )
* DMA buffer management
*/
-static int mga_dma_get_buffers( drm_device_t *dev, drm_dma_t *d )
+static int mga_dma_get_buffers( DRMFILE filp,
+ drm_device_t *dev, drm_dma_t *d )
{
drm_buf_t *buf;
int i;
@@ -739,7 +740,7 @@ static int mga_dma_get_buffers( drm_device_t *dev, drm_dma_t *d )
buf = mga_freelist_get( dev );
if ( !buf ) return DRM_ERR(EAGAIN);
- buf->pid = DRM_CURRENTPID;
+ buf->filp = filp;
if ( DRM_COPY_TO_USER( &d->request_indices[i],
&buf->idx, sizeof(buf->idx) ) )
@@ -761,7 +762,7 @@ int mga_dma_buffers( DRM_IOCTL_ARGS )
drm_dma_t d;
int ret = 0;
- LOCK_TEST_WITH_RETURN( dev );
+ LOCK_TEST_WITH_RETURN( dev, filp );
DRM_COPY_FROM_USER_IOCTL( d, (drm_dma_t *)data, sizeof(d) );
@@ -786,7 +787,7 @@ int mga_dma_buffers( DRM_IOCTL_ARGS )
d.granted_count = 0;
if ( d.request_count ) {
- ret = mga_dma_get_buffers( dev, &d );
+ ret = mga_dma_get_buffers( filp, dev, &d );
}
DRM_COPY_TO_USER_IOCTL( (drm_dma_t *)data, d, sizeof(d) );
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/mga_drv.h b/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/mga_drv.h
index 0e650b428..7efc89bce 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/mga_drv.h
+++ b/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/mga_drv.h
@@ -184,16 +184,6 @@ do { \
} \
} while (0)
-#define LOCK_TEST_WITH_RETURN( dev ) \
-do { \
- if ( !_DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ) || \
- dev->lock.pid != DRM_CURRENTPID ) { \
- DRM_ERROR( "%s called without lock held\n", \
- __FUNCTION__ ); \
- return DRM_ERR(EINVAL); \
- } \
-} while (0)
-
#define WRAP_TEST_WITH_RETURN( dev_priv ) \
do { \
if ( test_bit( 0, &dev_priv->prim.wrapped ) ) { \
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/mga_state.c b/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/mga_state.c
index 610772200..256dd47d6 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/mga_state.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/mga_state.c
@@ -887,7 +887,7 @@ int mga_dma_clear( DRM_IOCTL_ARGS )
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
drm_mga_clear_t clear;
- LOCK_TEST_WITH_RETURN( dev );
+ LOCK_TEST_WITH_RETURN( dev, filp );
DRM_COPY_FROM_USER_IOCTL( clear, (drm_mga_clear_t *)data, sizeof(clear) );
@@ -911,7 +911,7 @@ int mga_dma_swap( DRM_IOCTL_ARGS )
drm_mga_private_t *dev_priv = dev->dev_private;
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
- LOCK_TEST_WITH_RETURN( dev );
+ LOCK_TEST_WITH_RETURN( dev, filp );
if ( sarea_priv->nbox > MGA_NR_SAREA_CLIPRECTS )
sarea_priv->nbox = MGA_NR_SAREA_CLIPRECTS;
@@ -936,7 +936,7 @@ int mga_dma_vertex( DRM_IOCTL_ARGS )
drm_mga_buf_priv_t *buf_priv;
drm_mga_vertex_t vertex;
- LOCK_TEST_WITH_RETURN( dev );
+ LOCK_TEST_WITH_RETURN( dev, filp );
DRM_COPY_FROM_USER_IOCTL( vertex,
(drm_mga_vertex_t *)data,
@@ -975,7 +975,7 @@ int mga_dma_indices( DRM_IOCTL_ARGS )
drm_mga_buf_priv_t *buf_priv;
drm_mga_indices_t indices;
- LOCK_TEST_WITH_RETURN( dev );
+ LOCK_TEST_WITH_RETURN( dev, filp );
DRM_COPY_FROM_USER_IOCTL( indices,
(drm_mga_indices_t *)data,
@@ -1015,7 +1015,7 @@ int mga_dma_iload( DRM_IOCTL_ARGS )
drm_mga_iload_t iload;
DRM_DEBUG( "\n" );
- LOCK_TEST_WITH_RETURN( dev );
+ LOCK_TEST_WITH_RETURN( dev, filp );
DRM_COPY_FROM_USER_IOCTL( iload, (drm_mga_iload_t *)data, sizeof(iload) );
@@ -1055,7 +1055,7 @@ int mga_dma_blit( DRM_IOCTL_ARGS )
drm_mga_blit_t blit;
DRM_DEBUG( "\n" );
- LOCK_TEST_WITH_RETURN( dev );
+ LOCK_TEST_WITH_RETURN( dev, filp );
DRM_COPY_FROM_USER_IOCTL( blit, (drm_mga_blit_t *)data, sizeof(blit) );
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/r128_cce.c b/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/r128_cce.c
index 8d305b75d..7f0f43254 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/r128_cce.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/r128_cce.c
@@ -664,7 +664,7 @@ int r128_cce_start( DRM_IOCTL_ARGS )
drm_r128_private_t *dev_priv = dev->dev_private;
DRM_DEBUG( "\n" );
- LOCK_TEST_WITH_RETURN( dev );
+ LOCK_TEST_WITH_RETURN( dev, filp );
if ( dev_priv->cce_running || dev_priv->cce_mode == R128_PM4_NONPM4 ) {
DRM_DEBUG( "%s while CCE running\n", __FUNCTION__ );
@@ -687,7 +687,7 @@ int r128_cce_stop( DRM_IOCTL_ARGS )
int ret;
DRM_DEBUG( "\n" );
- LOCK_TEST_WITH_RETURN( dev );
+ LOCK_TEST_WITH_RETURN( dev, filp );
DRM_COPY_FROM_USER_IOCTL(stop, (drm_r128_cce_stop_t *)data, sizeof(stop) );
@@ -726,7 +726,7 @@ int r128_cce_reset( DRM_IOCTL_ARGS )
drm_r128_private_t *dev_priv = dev->dev_private;
DRM_DEBUG( "\n" );
- LOCK_TEST_WITH_RETURN( dev );
+ LOCK_TEST_WITH_RETURN( dev, filp );
if ( !dev_priv ) {
DRM_DEBUG( "%s called before init done\n", __FUNCTION__ );
@@ -747,7 +747,7 @@ int r128_cce_idle( DRM_IOCTL_ARGS )
drm_r128_private_t *dev_priv = dev->dev_private;
DRM_DEBUG( "\n" );
- LOCK_TEST_WITH_RETURN( dev );
+ LOCK_TEST_WITH_RETURN( dev, filp );
if ( dev_priv->cce_running ) {
r128_do_cce_flush( dev_priv );
@@ -761,7 +761,7 @@ int r128_engine_reset( DRM_IOCTL_ARGS )
DRM_DEVICE;
DRM_DEBUG( "\n" );
- LOCK_TEST_WITH_RETURN( dev );
+ LOCK_TEST_WITH_RETURN( dev, filp );
return r128_do_engine_reset( dev );
}
@@ -808,7 +808,7 @@ int r128_fullscreen( DRM_IOCTL_ARGS )
DRM_DEVICE;
drm_r128_fullscreen_t fs;
- LOCK_TEST_WITH_RETURN( dev );
+ LOCK_TEST_WITH_RETURN( dev, filp );
DRM_COPY_FROM_USER_IOCTL( fs, (drm_r128_fullscreen_t *)data, sizeof(fs) );
@@ -890,7 +890,7 @@ drm_buf_t *r128_freelist_get( drm_device_t *dev )
for ( i = 0 ; i < dma->buf_count ; i++ ) {
buf = dma->buflist[i];
buf_priv = buf->dev_private;
- if ( buf->pid == 0 )
+ if ( buf->filp == 0 )
return buf;
}
@@ -949,7 +949,7 @@ int r128_wait_ring( drm_r128_private_t *dev_priv, int n )
return DRM_ERR(EBUSY);
}
-static int r128_cce_get_buffers( drm_device_t *dev, drm_dma_t *d )
+static int r128_cce_get_buffers( DRMFILE filp, drm_device_t *dev, drm_dma_t *d )
{
int i;
drm_buf_t *buf;
@@ -958,7 +958,7 @@ static int r128_cce_get_buffers( drm_device_t *dev, drm_dma_t *d )
buf = r128_freelist_get( dev );
if ( !buf ) return DRM_ERR(EAGAIN);
- buf->pid = DRM_CURRENTPID;
+ buf->filp = filp;
if ( DRM_COPY_TO_USER( &d->request_indices[i], &buf->idx,
sizeof(buf->idx) ) )
@@ -979,7 +979,7 @@ int r128_cce_buffers( DRM_IOCTL_ARGS )
int ret = 0;
drm_dma_t d;
- LOCK_TEST_WITH_RETURN( dev );
+ LOCK_TEST_WITH_RETURN( dev, filp );
DRM_COPY_FROM_USER_IOCTL( d, (drm_dma_t *) data, sizeof(d) );
@@ -1002,7 +1002,7 @@ int r128_cce_buffers( DRM_IOCTL_ARGS )
d.granted_count = 0;
if ( d.request_count ) {
- ret = r128_cce_get_buffers( dev, &d );
+ ret = r128_cce_get_buffers( filp, dev, &d );
}
DRM_COPY_TO_USER_IOCTL((drm_dma_t *) data, d, sizeof(d) );
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/r128_drv.h b/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/r128_drv.h
index 5e6f12156..bd913878c 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/r128_drv.h
+++ b/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/r128_drv.h
@@ -399,15 +399,6 @@ extern int R128_READ_PLL(drm_device_t *dev, int addr);
* Misc helper macros
*/
-#define LOCK_TEST_WITH_RETURN( dev ) \
-do { \
- if ( !_DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ) || \
- dev->lock.pid != DRM_CURRENTPID ) { \
- DRM_ERROR( "%s called without lock held\n", __FUNCTION__ ); \
- return DRM_ERR(EINVAL); \
- } \
-} while (0)
-
#define RING_SPACE_TEST_WITH_RETURN( dev_priv ) \
do { \
drm_r128_ring_buffer_t *ring = &dev_priv->ring; int i; \
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/r128_state.c b/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/r128_state.c
index 20307c042..12c4a0eea 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/r128_state.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/r128_state.c
@@ -778,7 +778,8 @@ static void r128_cce_dispatch_indices( drm_device_t *dev,
sarea_priv->nbox = 0;
}
-static int r128_cce_dispatch_blit( drm_device_t *dev,
+static int r128_cce_dispatch_blit( DRMFILE filp,
+ drm_device_t *dev,
drm_r128_blit_t *blit )
{
drm_r128_private_t *dev_priv = dev->dev_private;
@@ -829,9 +830,9 @@ static int r128_cce_dispatch_blit( drm_device_t *dev,
buf = dma->buflist[blit->idx];
buf_priv = buf->dev_private;
- if ( buf->pid != DRM_CURRENTPID ) {
+ if ( buf->filp != filp ) {
DRM_ERROR( "process %d using buffer owned by %d\n",
- DRM_CURRENTPID, buf->pid );
+ DRM_CURRENTPID, buf->filp );
return DRM_ERR(EINVAL);
}
if ( buf->pending ) {
@@ -1244,7 +1245,7 @@ int r128_cce_clear( DRM_IOCTL_ARGS )
drm_r128_clear_t clear;
DRM_DEBUG( "\n" );
- LOCK_TEST_WITH_RETURN( dev );
+ LOCK_TEST_WITH_RETURN( dev, filp );
DRM_COPY_FROM_USER_IOCTL( clear, (drm_r128_clear_t *) data,
sizeof(clear) );
@@ -1270,7 +1271,7 @@ int r128_cce_swap( DRM_IOCTL_ARGS )
drm_r128_sarea_t *sarea_priv = dev_priv->sarea_priv;
DRM_DEBUG( "%s\n", __FUNCTION__ );
- LOCK_TEST_WITH_RETURN( dev );
+ LOCK_TEST_WITH_RETURN( dev, filp );
RING_SPACE_TEST_WITH_RETURN( dev_priv );
@@ -1297,7 +1298,7 @@ int r128_cce_vertex( DRM_IOCTL_ARGS )
drm_r128_buf_priv_t *buf_priv;
drm_r128_vertex_t vertex;
- LOCK_TEST_WITH_RETURN( dev );
+ LOCK_TEST_WITH_RETURN( dev, filp );
if ( !dev_priv ) {
DRM_ERROR( "%s called with no initialization\n", __FUNCTION__ );
@@ -1328,9 +1329,9 @@ int r128_cce_vertex( DRM_IOCTL_ARGS )
buf = dma->buflist[vertex.idx];
buf_priv = buf->dev_private;
- if ( buf->pid != DRM_CURRENTPID ) {
+ if ( buf->filp != filp ) {
DRM_ERROR( "process %d using buffer owned by %d\n",
- DRM_CURRENTPID, buf->pid );
+ DRM_CURRENTPID, buf->filp );
return DRM_ERR(EINVAL);
}
if ( buf->pending ) {
@@ -1357,7 +1358,7 @@ int r128_cce_indices( DRM_IOCTL_ARGS )
drm_r128_indices_t elts;
int count;
- LOCK_TEST_WITH_RETURN( dev );
+ LOCK_TEST_WITH_RETURN( dev, filp );
if ( !dev_priv ) {
DRM_ERROR( "%s called with no initialization\n", __FUNCTION__ );
@@ -1387,9 +1388,9 @@ int r128_cce_indices( DRM_IOCTL_ARGS )
buf = dma->buflist[elts.idx];
buf_priv = buf->dev_private;
- if ( buf->pid != DRM_CURRENTPID ) {
+ if ( buf->filp != filp ) {
DRM_ERROR( "process %d using buffer owned by %d\n",
- DRM_CURRENTPID, buf->pid );
+ DRM_CURRENTPID, buf->filp );
return DRM_ERR(EINVAL);
}
if ( buf->pending ) {
@@ -1425,7 +1426,7 @@ int r128_cce_blit( DRM_IOCTL_ARGS )
drm_r128_private_t *dev_priv = dev->dev_private;
drm_r128_blit_t blit;
- LOCK_TEST_WITH_RETURN( dev );
+ LOCK_TEST_WITH_RETURN( dev, filp );
DRM_COPY_FROM_USER_IOCTL( blit, (drm_r128_blit_t *) data,
sizeof(blit) );
@@ -1441,7 +1442,7 @@ int r128_cce_blit( DRM_IOCTL_ARGS )
RING_SPACE_TEST_WITH_RETURN( dev_priv );
VB_AGE_TEST_WITH_RETURN( dev_priv );
- return r128_cce_dispatch_blit( dev, &blit );
+ return r128_cce_dispatch_blit( filp, dev, &blit );
}
int r128_cce_depth( DRM_IOCTL_ARGS )
@@ -1450,7 +1451,7 @@ int r128_cce_depth( DRM_IOCTL_ARGS )
drm_r128_private_t *dev_priv = dev->dev_private;
drm_r128_depth_t depth;
- LOCK_TEST_WITH_RETURN( dev );
+ LOCK_TEST_WITH_RETURN( dev, filp );
DRM_COPY_FROM_USER_IOCTL( depth, (drm_r128_depth_t *) data,
sizeof(depth) );
@@ -1478,7 +1479,7 @@ int r128_cce_stipple( DRM_IOCTL_ARGS )
drm_r128_stipple_t stipple;
u32 mask[32];
- LOCK_TEST_WITH_RETURN( dev );
+ LOCK_TEST_WITH_RETURN( dev, filp );
DRM_COPY_FROM_USER_IOCTL( stipple, (drm_r128_stipple_t *) data,
sizeof(stipple) );
@@ -1506,7 +1507,7 @@ int r128_cce_indirect( DRM_IOCTL_ARGS )
RING_LOCALS;
#endif
- LOCK_TEST_WITH_RETURN( dev );
+ LOCK_TEST_WITH_RETURN( dev, filp );
if ( !dev_priv ) {
DRM_ERROR( "%s called with no initialization\n", __FUNCTION__ );
@@ -1529,9 +1530,9 @@ int r128_cce_indirect( DRM_IOCTL_ARGS )
buf = dma->buflist[indirect.idx];
buf_priv = buf->dev_private;
- if ( buf->pid != DRM_CURRENTPID ) {
+ if ( buf->filp != filp ) {
DRM_ERROR( "process %d using buffer owned by %d\n",
- DRM_CURRENTPID, buf->pid );
+ DRM_CURRENTPID, buf->filp );
return DRM_ERR(EINVAL);
}
if ( buf->pending ) {
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/radeon.h b/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/radeon.h
index c36accb49..d465773e1 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/radeon.h
+++ b/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/radeon.h
@@ -120,19 +120,17 @@ do { \
if ( dev_priv->page_flipping ) { \
radeon_do_cleanup_pageflip( dev ); \
} \
- radeon_mem_release( dev_priv->agp_heap ); \
- radeon_mem_release( dev_priv->fb_heap ); \
+ radeon_mem_release( filp, dev_priv->agp_heap ); \
+ radeon_mem_release( filp, dev_priv->fb_heap ); \
} \
} while (0)
/* When the last client dies, shut down the CP and free dev->dev_priv.
*/
-#define __HAVE_RELEASE 1
-#define DRIVER_RELEASE() \
+/* #define __HAVE_RELEASE 1 */
+#define DRIVER_PRETAKEDOWN() \
do { \
- DRM(reclaim_buffers)( dev, priv->pid ); \
- if ( dev->open_count == 1) \
- radeon_do_release( dev ); \
+ radeon_do_release( dev ); \
} while (0)
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/radeon_cp.c b/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/radeon_cp.c
index 89c9eab1b..3ec8dfd17 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/radeon_cp.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/radeon_cp.c
@@ -1323,7 +1323,7 @@ int radeon_cp_start( DRM_IOCTL_ARGS )
drm_radeon_private_t *dev_priv = dev->dev_private;
DRM_DEBUG( "\n" );
- LOCK_TEST_WITH_RETURN( dev );
+ LOCK_TEST_WITH_RETURN( dev, filp );
if ( dev_priv->cp_running ) {
DRM_DEBUG( "%s while CP running\n", __FUNCTION__ );
@@ -1351,7 +1351,7 @@ int radeon_cp_stop( DRM_IOCTL_ARGS )
int ret;
DRM_DEBUG( "\n" );
- LOCK_TEST_WITH_RETURN( dev );
+ LOCK_TEST_WITH_RETURN( dev, filp );
DRM_COPY_FROM_USER_IOCTL( stop, (drm_radeon_cp_stop_t *)data, sizeof(stop) );
@@ -1426,7 +1426,7 @@ int radeon_cp_reset( DRM_IOCTL_ARGS )
drm_radeon_private_t *dev_priv = dev->dev_private;
DRM_DEBUG( "\n" );
- LOCK_TEST_WITH_RETURN( dev );
+ LOCK_TEST_WITH_RETURN( dev, filp );
if ( !dev_priv ) {
DRM_DEBUG( "%s called before init done\n", __FUNCTION__ );
@@ -1447,7 +1447,7 @@ int radeon_cp_idle( DRM_IOCTL_ARGS )
drm_radeon_private_t *dev_priv = dev->dev_private;
DRM_DEBUG( "\n" );
- LOCK_TEST_WITH_RETURN( dev );
+ LOCK_TEST_WITH_RETURN( dev, filp );
return radeon_do_cp_idle( dev_priv );
}
@@ -1457,7 +1457,7 @@ int radeon_engine_reset( DRM_IOCTL_ARGS )
DRM_DEVICE;
DRM_DEBUG( "\n" );
- LOCK_TEST_WITH_RETURN( dev );
+ LOCK_TEST_WITH_RETURN( dev, filp );
return radeon_do_engine_reset( dev );
}
@@ -1516,7 +1516,7 @@ drm_buf_t *radeon_freelist_get( drm_device_t *dev )
for ( i = start ; i < dma->buf_count ; i++ ) {
buf = dma->buflist[i];
buf_priv = buf->dev_private;
- if ( buf->pid == 0 || (buf->pending &&
+ if ( buf->filp == 0 || (buf->pending &&
buf_priv->age <= done_age) ) {
dev_priv->stats.requested_bufs++;
buf->pending = 0;
@@ -1555,7 +1555,7 @@ drm_buf_t *radeon_freelist_get( drm_device_t *dev )
for ( i = start ; i < dma->buf_count ; i++ ) {
buf = dma->buflist[i];
buf_priv = buf->dev_private;
- if ( buf->pid == 0 || (buf->pending &&
+ if ( buf->filp == 0 || (buf->pending &&
buf_priv->age <= done_age) ) {
dev_priv->stats.requested_bufs++;
buf->pending = 0;
@@ -1620,7 +1620,7 @@ int radeon_wait_ring( drm_radeon_private_t *dev_priv, int n )
return DRM_ERR(EBUSY);
}
-static int radeon_cp_get_buffers( drm_device_t *dev, drm_dma_t *d )
+static int radeon_cp_get_buffers( DRMFILE filp, drm_device_t *dev, drm_dma_t *d )
{
int i;
drm_buf_t *buf;
@@ -1629,7 +1629,7 @@ static int radeon_cp_get_buffers( drm_device_t *dev, drm_dma_t *d )
buf = radeon_freelist_get( dev );
if ( !buf ) return DRM_ERR(EBUSY); /* NOTE: broken client */
- buf->pid = DRM_CURRENTPID;
+ buf->filp = filp;
if ( DRM_COPY_TO_USER( &d->request_indices[i], &buf->idx,
sizeof(buf->idx) ) )
@@ -1650,7 +1650,7 @@ int radeon_cp_buffers( DRM_IOCTL_ARGS )
int ret = 0;
drm_dma_t d;
- LOCK_TEST_WITH_RETURN( dev );
+ LOCK_TEST_WITH_RETURN( dev, filp );
DRM_COPY_FROM_USER_IOCTL( d, (drm_dma_t *)data, sizeof(d) );
@@ -1673,7 +1673,7 @@ int radeon_cp_buffers( DRM_IOCTL_ARGS )
d.granted_count = 0;
if ( d.request_count ) {
- ret = radeon_cp_get_buffers( dev, &d );
+ ret = radeon_cp_get_buffers( filp, dev, &d );
}
DRM_COPY_TO_USER_IOCTL( (drm_dma_t *)data, d, sizeof(d) );
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/radeon_drv.h b/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/radeon_drv.h
index 502ba89b4..7faffa7ab 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/radeon_drv.h
+++ b/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/radeon_drv.h
@@ -68,7 +68,7 @@ struct mem_block {
struct mem_block *prev;
int start;
int size;
- int pid; /* 0: free, -1: heap, other: real pids */
+ DRMFILE filp; /* 0: free, -1: heap, other: real files */
};
typedef struct drm_radeon_private {
@@ -184,7 +184,7 @@ extern int radeon_mem_alloc( DRM_IOCTL_ARGS );
extern int radeon_mem_free( DRM_IOCTL_ARGS );
extern int radeon_mem_init_heap( DRM_IOCTL_ARGS );
extern void radeon_mem_takedown( struct mem_block **heap );
-extern void radeon_mem_release( struct mem_block *heap );
+extern void radeon_mem_release( DRMFILE filp, struct mem_block *heap );
/* radeon_irq.c */
extern int radeon_irq_emit( DRM_IOCTL_ARGS );
@@ -770,16 +770,6 @@ extern int RADEON_READ_PLL( drm_device_t *dev, int addr );
* Misc helper macros
*/
-#define LOCK_TEST_WITH_RETURN( dev ) \
-do { \
- if ( !_DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ) || \
- dev->lock.pid != DRM_CURRENTPID ) { \
- DRM_ERROR( "%s called without lock held\n", __FUNCTION__ ); \
- return DRM_ERR(EINVAL); \
- } \
-} while (0)
-
-
/* Perfbox functionality only.
*/
#define RING_SPACE_TEST_WITH_RETURN( dev_priv ) \
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/radeon_irq.c b/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/radeon_irq.c
index 596706bf3..9199fbbf2 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/radeon_irq.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/radeon_irq.c
@@ -179,7 +179,7 @@ int radeon_irq_emit( DRM_IOCTL_ARGS )
drm_radeon_irq_emit_t emit;
int result;
- LOCK_TEST_WITH_RETURN( dev );
+ LOCK_TEST_WITH_RETURN( dev, filp );
if ( !dev_priv ) {
DRM_ERROR( "%s called with no initialization\n", __FUNCTION__ );
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/radeon_mem.c b/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/radeon_mem.c
index 3a2c89690..c3cbd3a9f 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/radeon_mem.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/radeon_mem.c
@@ -40,7 +40,7 @@
*/
static struct mem_block *split_block(struct mem_block *p, int start, int size,
- int pid )
+ DRMFILE filp )
{
/* Maybe cut off the start of an existing block */
if (start > p->start) {
@@ -49,7 +49,7 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size,
goto out;
newblock->start = start;
newblock->size = p->size - (start - p->start);
- newblock->pid = 0;
+ newblock->filp = 0;
newblock->next = p->next;
newblock->prev = p;
p->next->prev = newblock;
@@ -65,7 +65,7 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size,
goto out;
newblock->start = start + size;
newblock->size = p->size - size;
- newblock->pid = 0;
+ newblock->filp = 0;
newblock->next = p->next;
newblock->prev = p;
p->next->prev = newblock;
@@ -75,20 +75,20 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size,
out:
/* Our block is in the middle */
- p->pid = pid;
+ p->filp = filp;
return p;
}
static struct mem_block *alloc_block( struct mem_block *heap, int size,
- int align2, int pid )
+ int align2, DRMFILE filp )
{
struct mem_block *p;
int mask = (1 << align2)-1;
for (p = heap->next ; p != heap ; p = p->next) {
int start = (p->start + mask) & ~mask;
- if (p->pid == 0 && start + size <= p->start + p->size)
- return split_block( p, start, size, pid );
+ if (p->filp == 0 && start + size <= p->start + p->size)
+ return split_block( p, start, size, filp );
}
return NULL;
@@ -108,12 +108,12 @@ static struct mem_block *find_block( struct mem_block *heap, int start )
static void free_block( struct mem_block *p )
{
- p->pid = 0;
+ p->filp = 0;
- /* Assumes a single contiguous range. Needs a special pid in
+ /* Assumes a single contiguous range. Needs a special filp in
* 'heap' to stop it being subsumed.
*/
- if (p->next->pid == 0) {
+ if (p->next->filp == 0) {
struct mem_block *q = p->next;
p->size += q->size;
p->next = q->next;
@@ -121,7 +121,7 @@ static void free_block( struct mem_block *p )
DRM_FREE(q, sizeof(*q));
}
- if (p->prev->pid == 0) {
+ if (p->prev->filp == 0) {
struct mem_block *q = p->prev;
q->size += p->size;
q->next = p->next;
@@ -147,36 +147,35 @@ static int init_heap(struct mem_block **heap, int start, int size)
blocks->start = start;
blocks->size = size;
- blocks->pid = 0;
+ blocks->filp = 0;
blocks->next = blocks->prev = *heap;
memset( *heap, 0, sizeof(**heap) );
- (*heap)->pid = -1;
+ (*heap)->filp = (DRMFILE) -1;
(*heap)->next = (*heap)->prev = blocks;
return 0;
}
-/* Free all blocks associated with the releasing pid.
+/* Free all blocks associated with the releasing file.
*/
-void radeon_mem_release( struct mem_block *heap )
+void radeon_mem_release( DRMFILE filp, struct mem_block *heap )
{
- int pid = DRM_CURRENTPID;
struct mem_block *p;
if (!heap || !heap->next)
return;
for (p = heap->next ; p != heap ; p = p->next) {
- if (p->pid == pid)
- p->pid = 0;
+ if (p->filp == filp)
+ p->filp = 0;
}
- /* Assumes a single contiguous range. Needs a special pid in
+ /* Assumes a single contiguous range. Needs a special filp in
* 'heap' to stop it being subsumed.
*/
for (p = heap->next ; p != heap ; p = p->next) {
- while (p->pid == 0 && p->next->pid == 0) {
+ while (p->filp == 0 && p->next->filp == 0) {
struct mem_block *q = p->next;
p->size += q->size;
p->next = q->next;
@@ -248,7 +247,7 @@ int radeon_mem_alloc( DRM_IOCTL_ARGS )
alloc.alignment = 12;
block = alloc_block( *heap, alloc.size, alloc.alignment,
- DRM_CURRENTPID );
+ filp );
if (!block)
return DRM_ERR(ENOMEM);
@@ -287,7 +286,7 @@ int radeon_mem_free( DRM_IOCTL_ARGS )
if (!block)
return DRM_ERR(EFAULT);
- if (block->pid != DRM_CURRENTPID)
+ if (block->filp != filp)
return DRM_ERR(EPERM);
free_block( block );
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/radeon_state.c b/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/radeon_state.c
index d9bc948c0..86cbead5d 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/radeon_state.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/radeon_state.c
@@ -1063,7 +1063,8 @@ static void radeon_cp_dispatch_indices( drm_device_t *dev,
#define RADEON_MAX_TEXTURE_SIZE (RADEON_BUFFER_SIZE - 8 * sizeof(u32))
-static int radeon_cp_dispatch_texture( drm_device_t *dev,
+static int radeon_cp_dispatch_texture( DRMFILE filp,
+ drm_device_t *dev,
drm_radeon_texture_t *tex,
drm_radeon_tex_image_t *image )
{
@@ -1216,7 +1217,7 @@ static int radeon_cp_dispatch_texture( drm_device_t *dev,
}
}
- buf->pid = DRM_CURRENTPID;
+ buf->filp = filp;
buf->used = (dwords + 8) * sizeof(u32);
radeon_cp_dispatch_indirect( dev, buf, 0, buf->used );
radeon_cp_discard_buffer( dev, buf );
@@ -1273,7 +1274,7 @@ int radeon_cp_clear( DRM_IOCTL_ARGS )
drm_radeon_clear_rect_t depth_boxes[RADEON_NR_SAREA_CLIPRECTS];
DRM_DEBUG( "\n" );
- LOCK_TEST_WITH_RETURN( dev );
+ LOCK_TEST_WITH_RETURN( dev, filp );
DRM_COPY_FROM_USER_IOCTL( clear, (drm_radeon_clear_t *)data,
sizeof(clear) );
@@ -1342,7 +1343,7 @@ int radeon_cp_flip( DRM_IOCTL_ARGS )
drm_radeon_private_t *dev_priv = dev->dev_private;
DRM_DEBUG( "\n" );
- LOCK_TEST_WITH_RETURN( dev );
+ LOCK_TEST_WITH_RETURN( dev, filp );
RING_SPACE_TEST_WITH_RETURN( dev_priv );
@@ -1362,7 +1363,7 @@ int radeon_cp_swap( DRM_IOCTL_ARGS )
drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv;
DRM_DEBUG( "\n" );
- LOCK_TEST_WITH_RETURN( dev );
+ LOCK_TEST_WITH_RETURN( dev, filp );
RING_SPACE_TEST_WITH_RETURN( dev_priv );
@@ -1386,7 +1387,7 @@ int radeon_cp_vertex( DRM_IOCTL_ARGS )
drm_radeon_vertex_t vertex;
drm_radeon_tcl_prim_t prim;
- LOCK_TEST_WITH_RETURN( dev );
+ LOCK_TEST_WITH_RETURN( dev, filp );
if ( !dev_priv ) {
DRM_ERROR( "%s called with no initialization\n", __FUNCTION__ );
@@ -1416,9 +1417,9 @@ int radeon_cp_vertex( DRM_IOCTL_ARGS )
buf = dma->buflist[vertex.idx];
- if ( buf->pid != DRM_CURRENTPID ) {
- DRM_ERROR( "process %d using buffer owned by %d\n",
- DRM_CURRENTPID, buf->pid );
+ if ( buf->filp != filp ) {
+ DRM_ERROR( "process %d using buffer owned by %p\n",
+ DRM_CURRENTPID, buf->filp );
return DRM_ERR(EINVAL);
}
if ( buf->pending ) {
@@ -1473,7 +1474,7 @@ int radeon_cp_indices( DRM_IOCTL_ARGS )
drm_radeon_tcl_prim_t prim;
int count;
- LOCK_TEST_WITH_RETURN( dev );
+ LOCK_TEST_WITH_RETURN( dev, filp );
if ( !dev_priv ) {
DRM_ERROR( "%s called with no initialization\n", __FUNCTION__ );
@@ -1503,9 +1504,9 @@ int radeon_cp_indices( DRM_IOCTL_ARGS )
buf = dma->buflist[elts.idx];
- if ( buf->pid != DRM_CURRENTPID ) {
- DRM_ERROR( "process %d using buffer owned by %d\n",
- DRM_CURRENTPID, buf->pid );
+ if ( buf->filp != filp ) {
+ DRM_ERROR( "process %d using buffer owned by %p\n",
+ DRM_CURRENTPID, buf->filp );
return DRM_ERR(EINVAL);
}
if ( buf->pending ) {
@@ -1568,7 +1569,7 @@ int radeon_cp_texture( DRM_IOCTL_ARGS )
drm_radeon_tex_image_t image;
int ret;
- LOCK_TEST_WITH_RETURN( dev );
+ LOCK_TEST_WITH_RETURN( dev, filp );
DRM_COPY_FROM_USER_IOCTL( tex, (drm_radeon_texture_t *)data, sizeof(tex) );
@@ -1585,7 +1586,7 @@ int radeon_cp_texture( DRM_IOCTL_ARGS )
RING_SPACE_TEST_WITH_RETURN( dev_priv );
VB_AGE_TEST_WITH_RETURN( dev_priv );
- ret = radeon_cp_dispatch_texture( dev, &tex, &image );
+ ret = radeon_cp_dispatch_texture( filp, dev, &tex, &image );
COMMIT_RING();
return ret;
@@ -1598,7 +1599,7 @@ int radeon_cp_stipple( DRM_IOCTL_ARGS )
drm_radeon_stipple_t stipple;
u32 mask[32];
- LOCK_TEST_WITH_RETURN( dev );
+ LOCK_TEST_WITH_RETURN( dev, filp );
DRM_COPY_FROM_USER_IOCTL( stipple, (drm_radeon_stipple_t *)data,
sizeof(stipple) );
@@ -1623,7 +1624,7 @@ int radeon_cp_indirect( DRM_IOCTL_ARGS )
drm_radeon_indirect_t indirect;
RING_LOCALS;
- LOCK_TEST_WITH_RETURN( dev );
+ LOCK_TEST_WITH_RETURN( dev, filp );
if ( !dev_priv ) {
DRM_ERROR( "%s called with no initialization\n", __FUNCTION__ );
@@ -1645,9 +1646,9 @@ int radeon_cp_indirect( DRM_IOCTL_ARGS )
buf = dma->buflist[indirect.idx];
- if ( buf->pid != DRM_CURRENTPID ) {
- DRM_ERROR( "process %d using buffer owned by %d\n",
- DRM_CURRENTPID, buf->pid );
+ if ( buf->filp != filp ) {
+ DRM_ERROR( "process %d using buffer owned by %p\n",
+ DRM_CURRENTPID, buf->filp );
return DRM_ERR(EINVAL);
}
if ( buf->pending ) {
@@ -1700,7 +1701,7 @@ int radeon_cp_vertex2( DRM_IOCTL_ARGS )
int i;
unsigned char laststate;
- LOCK_TEST_WITH_RETURN( dev );
+ LOCK_TEST_WITH_RETURN( dev, filp );
if ( !dev_priv ) {
DRM_ERROR( "%s called with no initialization\n", __FUNCTION__ );
@@ -1725,9 +1726,9 @@ int radeon_cp_vertex2( DRM_IOCTL_ARGS )
buf = dma->buflist[vertex.idx];
- if ( buf->pid != DRM_CURRENTPID ) {
- DRM_ERROR( "process %d using buffer owned by %d\n",
- DRM_CURRENTPID, buf->pid );
+ if ( buf->filp != filp ) {
+ DRM_ERROR( "process %d using buffer owned by %p\n",
+ DRM_CURRENTPID, buf->filp );
return DRM_ERR(EINVAL);
}
@@ -2027,7 +2028,7 @@ int radeon_cp_cmdbuf( DRM_IOCTL_ARGS )
drm_radeon_cmd_header_t header;
int orig_nbox;
- LOCK_TEST_WITH_RETURN( dev );
+ LOCK_TEST_WITH_RETURN( dev, filp );
if ( !dev_priv ) {
DRM_ERROR( "%s called with no initialization\n", __FUNCTION__ );
@@ -2096,8 +2097,9 @@ int radeon_cp_cmdbuf( DRM_IOCTL_ARGS )
}
buf = dma->buflist[idx];
- if ( buf->pid != DRM_CURRENTPID || buf->pending ) {
- DRM_ERROR( "bad buffer\n" );
+ if ( buf->filp != filp || buf->pending ) {
+ DRM_ERROR( "bad buffer %p %p %d\n",
+ buf->filp, filp, buf->pending);
return DRM_ERR(EINVAL);
}