From ae7a1713139f1eacec9cc1629cacef0394e270cc Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Sat, 6 Nov 2004 20:27:19 +0000 Subject: Move the lock/unlock ioctls to a more logical place, in drm_lock.c. --- bsd-core/drm_drv.c | 81 ------------------------------------------------------ 1 file changed, 81 deletions(-) (limited to 'bsd-core/drm_drv.c') diff --git a/bsd-core/drm_drv.c b/bsd-core/drm_drv.c index cdf99eac..372b0f4e 100644 --- a/bsd-core/drm_drv.c +++ b/bsd-core/drm_drv.c @@ -880,87 +880,6 @@ int drm_ioctl(struct cdev *kdev, u_long cmd, caddr_t data, int flags, return DRM_ERR(retcode); } -int drm_lock(DRM_IOCTL_ARGS) -{ - DRM_DEVICE; - drm_lock_t lock; - int ret = 0; - - DRM_COPY_FROM_USER_IOCTL( lock, (drm_lock_t *)data, sizeof(lock) ); - - if ( lock.context == DRM_KERNEL_CONTEXT ) { - DRM_ERROR( "Process %d using kernel context %d\n", - DRM_CURRENTPID, lock.context ); - return DRM_ERR(EINVAL); - } - - DRM_DEBUG( "%d (pid %d) requests lock (0x%08x), flags = 0x%08x\n", - lock.context, DRM_CURRENTPID, - dev->lock.hw_lock->lock, lock.flags ); - - if (dev->use_dma_queue && lock.context < 0) - return DRM_ERR(EINVAL); - - DRM_LOCK(); - for (;;) { - if (drm_lock_take(&dev->lock.hw_lock->lock, lock.context)) { - dev->lock.filp = (void *)(uintptr_t)DRM_CURRENTPID; - dev->lock.lock_time = jiffies; - atomic_inc(&dev->counts[_DRM_STAT_LOCKS]); - break; /* Got lock */ - } - - /* Contention */ -#if defined(__FreeBSD__) && __FreeBSD_version > 500000 - ret = msleep((void *)&dev->lock.lock_queue, &dev->dev_lock, - PZERO | PCATCH, "drmlk2", 0); -#else - ret = tsleep((void *)&dev->lock.lock_queue, PZERO | PCATCH, - "drmlk2", 0); -#endif - if (ret != 0) - break; - } - DRM_UNLOCK(); - DRM_DEBUG( "%d %s\n", lock.context, ret ? "interrupted" : "has lock" ); - - if (ret != 0) - return ret; - - /* XXX: Add signal blocking here */ - - if (dev->dma_quiescent != NULL && (lock.flags & _DRM_LOCK_QUIESCENT)) - dev->dma_quiescent(dev); - - return 0; -} - - -int drm_unlock(DRM_IOCTL_ARGS) -{ - DRM_DEVICE; - drm_lock_t lock; - - DRM_COPY_FROM_USER_IOCTL( lock, (drm_lock_t *)data, sizeof(lock) ) ; - - if ( lock.context == DRM_KERNEL_CONTEXT ) { - DRM_ERROR( "Process %d using kernel context %d\n", - DRM_CURRENTPID, lock.context ); - return DRM_ERR(EINVAL); - } - - atomic_inc( &dev->counts[_DRM_STAT_UNLOCKS] ); - - DRM_LOCK(); - drm_lock_transfer(dev, &dev->lock.hw_lock->lock, DRM_KERNEL_CONTEXT); - - if (drm_lock_free(dev, &dev->lock.hw_lock->lock, DRM_KERNEL_CONTEXT)) { - DRM_ERROR( "\n" ); - } - DRM_UNLOCK(); - - return 0; -} #if DRM_LINUX -- cgit v1.2.3