From 0cf1887139eb1ce18d09f7be0567aa93d802040d Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Sun, 19 Oct 2003 23:35:58 +0000 Subject: - SMPng lock the DRM. This is only partial -- there are a few code paths used by root (the X Server) which are not locked. However, it should deal with lost-IRQ issues on -current which I think people have been experiencing but I am unable to reproduce (though I understand why they would occur, because of a bug of mine). Note that most of the locking (DRM_LOCK()/UNLOCK()) is all covered by Giant still, so it doesn't matter yet. - Remove locking on FreeBSD-stable and NetBSD. These are covered by the fact that there is no reentrancy of the kernel except by interrupts, which are locked using spldrm()/splx() instead. --- bsd-core/drm_os_freebsd.h | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) (limited to 'bsd-core/drm_os_freebsd.h') diff --git a/bsd-core/drm_os_freebsd.h b/bsd-core/drm_os_freebsd.h index 3894f54d..320db342 100644 --- a/bsd-core/drm_os_freebsd.h +++ b/bsd-core/drm_os_freebsd.h @@ -123,15 +123,23 @@ #define DRM_SPINLOCK(l) mtx_lock(l) #define DRM_SPINUNLOCK(u) mtx_unlock(u); #define DRM_CURRENTPID curthread->td_proc->p_pid +#define DRM_LOCK() mtx_lock(&dev->dev_lock) +#define DRM_UNLOCK() mtx_unlock(&dev->dev_lock) #else +/* There is no need for locking on FreeBSD 4.x. Synchronization is handled by + * the fact that there is no reentrancy of the kernel except for interrupt + * handlers, and the interrupt handler synchronization is managed by spls. + */ #define DRM_CURPROC curproc #define DRM_STRUCTPROC struct proc -#define DRM_SPINTYPE struct simplelock -#define DRM_SPININIT(l,name) simple_lock_init(&l) +#define DRM_SPINTYPE +#define DRM_SPININIT(l,name) #define DRM_SPINUNINIT(l) -#define DRM_SPINLOCK(l) simple_lock(l) -#define DRM_SPINUNLOCK(u) simple_unlock(u); +#define DRM_SPINLOCK(l) +#define DRM_SPINUNLOCK(u) #define DRM_CURRENTPID curproc->p_pid +#define DRM_LOCK() +#define DRM_UNLOCK() #endif /* Currently our DRMFILE (filp) is a void * which is actually the pid @@ -139,8 +147,6 @@ * code for that is not yet written */ #define DRMFILE void * #define DRM_IOCTL_ARGS dev_t kdev, u_long cmd, caddr_t data, int flags, DRM_STRUCTPROC *p, DRMFILE filp -#define DRM_LOCK() lockmgr(&dev->dev_lock, LK_EXCLUSIVE, 0, DRM_CURPROC) -#define DRM_UNLOCK() lockmgr(&dev->dev_lock, LK_RELEASE, 0, DRM_CURPROC) #define DRM_SUSER(p) suser(p) #define DRM_TASKQUEUE_ARGS void *arg, int pending #define DRM_IRQ_ARGS void *arg @@ -165,13 +171,6 @@ typedef void irqreturn_t; #define DRM_AGP_FIND_DEVICE() agp_find_device() #define DRM_ERR(v) v -#define DRM_PRIV \ - drm_file_t *priv = (drm_file_t *) DRM(find_file_by_proc)(dev, p); \ - if (!priv) { \ - DRM_DEBUG("can't find authenticator\n"); \ - return EINVAL; \ - } - #define LOCK_TEST_WITH_RETURN(dev, filp) \ do { \ if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) || \ @@ -207,6 +206,16 @@ do { \ #define DRM_HZ hz +#if defined(__FreeBSD__) && __FreeBSD_version > 500000 +#define DRM_WAIT_ON( ret, queue, timeout, condition ) \ +for ( ret = 0 ; !ret && !(condition) ; ) { \ + mtx_lock(&dev->irq_lock); \ + if (!(condition)) \ + ret = msleep(&(queue), &dev->irq_lock, \ + PZERO | PCATCH, "drmwtq", (timeout)); \ + mtx_unlock(&dev->irq_lock); \ +} +#else #define DRM_WAIT_ON( ret, queue, timeout, condition ) \ for ( ret = 0 ; !ret && !(condition) ; ) { \ int s = spldrm(); \ @@ -215,6 +224,7 @@ for ( ret = 0 ; !ret && !(condition) ; ) { \ "drmwtq", (timeout) ); \ splx(s); \ } +#endif #define DRM_WAKEUP( queue ) wakeup( queue ) #define DRM_WAKEUP_INT( queue ) wakeup( queue ) -- cgit v1.2.3