diff options
author | Keith Whitwell <keith@tungstengraphics.com> | 2003-02-25 03:59:00 +0000 |
---|---|---|
committer | Keith Whitwell <keith@tungstengraphics.com> | 2003-02-25 03:59:00 +0000 |
commit | 6afda269546d361c1ec43e0be5aad5738548ae98 (patch) | |
tree | 448ee4715df7efe82a9a8247fd6adf0b0d6fb9e2 /linux/drm_drv.h | |
parent | b487f30ea5c129eed1dd85f7ad79db3d2485b1f8 (diff) |
Use file pointers instead of pids for resource and lock tracking
Diffstat (limited to 'linux/drm_drv.h')
-rw-r--r-- | linux/drm_drv.h | 40 |
1 files changed, 29 insertions, 11 deletions
diff --git a/linux/drm_drv.h b/linux/drm_drv.h index 3ebe7811..7c054fba 100644 --- a/linux/drm_drv.h +++ b/linux/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,7 +732,8 @@ int DRM(open)( struct inode *inode, struct file *filp ) return -ENODEV; } - DRM_DEBUG( "open_count = %d\n", dev->open_count ); + printk( "DRM(open) pid %d open_count = %d\n", + current->pid, dev->open_count ); retcode = DRM(open_helper)( inode, filp, dev ); if ( !retcode ) { @@ -765,15 +766,23 @@ int DRM(release)( struct inode *inode, struct file *filp ) * Begin inline drm_release */ - DRM_DEBUG( "pid = %d, device = 0x%x, open_count = %d\n", + printk( "%s: pid = %d, device = 0x%x, open_count = %d\n", + __FUNCTION__, current->pid, dev->device, dev->open_count ); + printk( "%s: curently hw_lock %p is_held %d lock.filp %p filp %p\n", + __FUNCTION__, + dev->lock.hw_lock, + dev->lock.hw_lock ? _DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) : 0, + dev->lock.filp, + 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 ) { + printk( "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 +798,9 @@ 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 ); + + printk("grabbing lock for %d\n", current->pid); + add_wait_queue( &dev->lock.lock_queue, &entry ); for (;;) { current->state = TASK_INTERRUPTIBLE; @@ -799,7 +811,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 */ @@ -816,6 +828,7 @@ int DRM(release)( struct inode *inode, struct file *filp ) } current->state = TASK_RUNNING; remove_wait_queue( &dev->lock.lock_queue, &entry ); + printk("... done %d\n", retcode); if( !retcode ) { DRIVER_RELEASE(); DRM(lock_free)( dev, &dev->lock.hw_lock->lock, @@ -823,7 +836,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,6 +860,8 @@ int DRM(release)( struct inode *inode, struct file *filp ) dev->file_last = priv->prev; } up( &dev->struct_sem ); + + printk("%d: done 2\n", current->pid); DRM(free)( priv, sizeof(*priv), DRM_MEM_FILES ); @@ -872,6 +887,9 @@ int DRM(release)( struct inode *inode, struct file *filp ) spin_unlock( &dev->count_lock ); unlock_kernel(); + + printk("%d: done 3\n", current->pid); + return retcode; } @@ -968,7 +986,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 */ @@ -1050,7 +1068,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; |