summaryrefslogtreecommitdiff
path: root/linux/drm_drv.h
diff options
context:
space:
mode:
authorKeith Whitwell <keith@tungstengraphics.com>2003-04-27 09:53:58 +0000
committerKeith Whitwell <keith@tungstengraphics.com>2003-04-27 09:53:58 +0000
commitc584292e30f1f3fc22da32117dfbb72bb79cdbe2 (patch)
tree60a4f86d5e825803a97f1a214377c74cf196d225 /linux/drm_drv.h
parent22b9b720d572ba6fec288e2a13537aec069cec7f (diff)
Put back __HAVE_KERNEL_CTX_SWITCH for David Miller's sparc drm driver
(which doesn't live in our cvs).
Diffstat (limited to 'linux/drm_drv.h')
-rw-r--r--linux/drm_drv.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/linux/drm_drv.h b/linux/drm_drv.h
index 4a15faec..2d1a9448 100644
--- a/linux/drm_drv.h
+++ b/linux/drm_drv.h
@@ -84,6 +84,9 @@
#ifndef __HAVE_SG
#define __HAVE_SG 0
#endif
+#ifndef __HAVE_KERNEL_CTX_SWITCH
+#define __HAVE_KERNEL_CTX_SWITCH 0
+#endif
#ifndef __HAVE_DRIVER_FOPS_READ
#define __HAVE_DRIVER_FOPS_READ 0
#endif
@@ -1015,6 +1018,12 @@ int DRM(lock)( struct inode *inode, struct file *filp,
DRIVER_DMA_QUIESCENT();
}
#endif
+#if __HAVE_KERNEL_CTX_SWITCH
+ if ( dev->last_context != lock.context ) {
+ DRM(context_switch)(dev, dev->last_context,
+ lock.context);
+ }
+#endif
}
DRM_DEBUG( "%d %s\n", lock.context, ret ? "interrupted" : "has lock" );
@@ -1041,6 +1050,25 @@ int DRM(unlock)( struct inode *inode, struct file *filp,
atomic_inc( &dev->counts[_DRM_STAT_UNLOCKS] );
+#if __HAVE_KERNEL_CTX_SWITCH
+ /* We no longer really hold it, but if we are the next
+ * agent to request it then we should just be able to
+ * take it immediately and not eat the ioctl.
+ */
+ dev->lock.filp = 0;
+ {
+ __volatile__ unsigned int *plock = &dev->lock.hw_lock->lock;
+ unsigned int old, new, prev, ctx;
+
+ ctx = lock.context;
+ do {
+ old = *plock;
+ new = ctx;
+ prev = cmpxchg(plock, old, new);
+ } while (prev != old);
+ }
+ wake_up_interruptible(&dev->lock.lock_queue);
+#else
DRM(lock_transfer)( dev, &dev->lock.hw_lock->lock,
DRM_KERNEL_CONTEXT );
#if __HAVE_DMA_SCHEDULE
@@ -1055,6 +1083,7 @@ int DRM(unlock)( struct inode *inode, struct file *filp,
DRM_ERROR( "\n" );
}
}
+#endif /* !__HAVE_KERNEL_CTX_SWITCH */
unblock_all_signals();
return 0;