From 928c25d14f76ff537bd56f135b91cf681dee326b Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 22 Apr 2003 12:07:24 +0000 Subject: Move the excitingly named DRM(flush_block_and_flush) and friends to gamma-specific code. Fix templates so i8x0 drivers don't have to define __HAVE_DMA_WAITLIST. --- linux/drmP.h | 7 ++-- linux/drm_drv.h | 12 +++++- linux/drm_lock.h | 115 +----------------------------------------------------- linux/gamma_drv.c | 3 +- linux/i810.h | 2 +- linux/i830.h | 2 +- 6 files changed, 18 insertions(+), 123 deletions(-) (limited to 'linux') diff --git a/linux/drmP.h b/linux/drmP.h index c530ca0c..9fd4149a 100644 --- a/linux/drmP.h +++ b/linux/drmP.h @@ -768,12 +768,11 @@ extern int DRM(getmagic)(struct inode *inode, struct file *filp, extern int DRM(authmagic)(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); + /* Placeholder for ioctls past */ +extern int DRM(noop)(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg); /* Locking IOCTL support (drm_lock.h) */ -extern int DRM(block)(struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long arg); -extern int DRM(unblock)(struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long arg); extern int DRM(lock_take)(__volatile__ unsigned int *lock, unsigned int context); extern int DRM(lock_transfer)(drm_device_t *dev, diff --git a/linux/drm_drv.h b/linux/drm_drv.h index 3d369b28..036cee35 100644 --- a/linux/drm_drv.h +++ b/linux/drm_drv.h @@ -162,8 +162,8 @@ static drm_ioctl_desc_t DRM(ioctls)[] = { [DRM_IOCTL_NR(DRM_IOCTL_GET_STATS)] = { DRM(getstats), 0, 0 }, [DRM_IOCTL_NR(DRM_IOCTL_SET_UNIQUE)] = { DRM(setunique), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_BLOCK)] = { DRM(block), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_UNBLOCK)] = { DRM(unblock), 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_BLOCK)] = { DRM(noop), 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_UNBLOCK)] = { DRM(noop), 1, 1 }, [DRM_IOCTL_NR(DRM_IOCTL_AUTH_MAGIC)] = { DRM(authmagic), 1, 1 }, [DRM_IOCTL_NR(DRM_IOCTL_ADD_MAP)] = { DRM(addmap), 1, 1 }, @@ -187,7 +187,13 @@ static drm_ioctl_desc_t DRM(ioctls)[] = { [DRM_IOCTL_NR(DRM_IOCTL_LOCK)] = { DRM(lock), 1, 0 }, [DRM_IOCTL_NR(DRM_IOCTL_UNLOCK)] = { DRM(unlock), 1, 0 }, + +#if __HAVE_DMA_FLUSH + /* Gamma only, really */ [DRM_IOCTL_NR(DRM_IOCTL_FINISH)] = { DRM(finish), 1, 0 }, +#else + [DRM_IOCTL_NR(DRM_IOCTL_FINISH)] = { DRM(noop), 1, 0 }, +#endif #if __HAVE_DMA [DRM_IOCTL_NR(DRM_IOCTL_ADD_BUFS)] = { DRM(addbufs), 1, 1 }, @@ -470,7 +476,9 @@ static int DRM(takedown)( drm_device_t *dev ) #if __HAVE_DMA_QUEUE || __HAVE_MULTIPLE_DMA_QUEUES if ( dev->queuelist ) { for ( i = 0 ; i < dev->queue_count ; i++ ) { +#if __HAVE_DMA_WAITLIST DRM(waitlist_destroy)( &dev->queuelist[i]->waitlist ); +#endif if ( dev->queuelist[i] ) { DRM(free)( dev->queuelist[i], sizeof(*dev->queuelist[0]), diff --git a/linux/drm_lock.h b/linux/drm_lock.h index e9b17cc4..cc9571ed 100644 --- a/linux/drm_lock.h +++ b/linux/drm_lock.h @@ -32,19 +32,13 @@ #define __NO_VERSION__ #include "drmP.h" -int DRM(block)(struct inode *inode, struct file *filp, unsigned int cmd, +int DRM(noop)(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { DRM_DEBUG("\n"); return 0; } -int DRM(unblock)(struct inode *inode, struct file *filp, unsigned int cmd, - unsigned long arg) -{ - DRM_DEBUG("\n"); - return 0; -} int DRM(lock_take)(__volatile__ unsigned int *lock, unsigned int context) { @@ -109,113 +103,6 @@ int DRM(lock_free)(drm_device_t *dev, return 0; } -static int DRM(flush_queue)(drm_device_t *dev, int context) -{ - DECLARE_WAITQUEUE(entry, current); - int ret = 0; - drm_queue_t *q = dev->queuelist[context]; - - DRM_DEBUG("\n"); - - atomic_inc(&q->use_count); - if (atomic_read(&q->use_count) > 1) { - atomic_inc(&q->block_write); - add_wait_queue(&q->flush_queue, &entry); - atomic_inc(&q->block_count); - for (;;) { - current->state = TASK_INTERRUPTIBLE; - if (!DRM_BUFCOUNT(&q->waitlist)) break; - schedule(); - if (signal_pending(current)) { - ret = -EINTR; /* Can't restart */ - break; - } - } - atomic_dec(&q->block_count); - current->state = TASK_RUNNING; - remove_wait_queue(&q->flush_queue, &entry); - } - atomic_dec(&q->use_count); - - /* NOTE: block_write is still incremented! - Use drm_flush_unlock_queue to decrement. */ - return ret; -} - -static int DRM(flush_unblock_queue)(drm_device_t *dev, int context) -{ - drm_queue_t *q = dev->queuelist[context]; - - DRM_DEBUG("\n"); - - atomic_inc(&q->use_count); - if (atomic_read(&q->use_count) > 1) { - if (atomic_read(&q->block_write)) { - atomic_dec(&q->block_write); - wake_up_interruptible(&q->write_queue); - } - } - atomic_dec(&q->use_count); - return 0; -} - -int DRM(flush_block_and_flush)(drm_device_t *dev, int context, - drm_lock_flags_t flags) -{ - int ret = 0; - int i; - - DRM_DEBUG("\n"); - - if (flags & _DRM_LOCK_FLUSH) { - ret = DRM(flush_queue)(dev, DRM_KERNEL_CONTEXT); - if (!ret) ret = DRM(flush_queue)(dev, context); - } - if (flags & _DRM_LOCK_FLUSH_ALL) { - for (i = 0; !ret && i < dev->queue_count; i++) { - ret = DRM(flush_queue)(dev, i); - } - } - return ret; -} - -int DRM(flush_unblock)(drm_device_t *dev, int context, drm_lock_flags_t flags) -{ - int ret = 0; - int i; - - DRM_DEBUG("\n"); - - if (flags & _DRM_LOCK_FLUSH) { - ret = DRM(flush_unblock_queue)(dev, DRM_KERNEL_CONTEXT); - if (!ret) ret = DRM(flush_unblock_queue)(dev, context); - } - if (flags & _DRM_LOCK_FLUSH_ALL) { - for (i = 0; !ret && i < dev->queue_count; i++) { - ret = DRM(flush_unblock_queue)(dev, i); - } - } - - return ret; -} - -int DRM(finish)(struct inode *inode, struct file *filp, unsigned int cmd, - unsigned long arg) -{ - drm_file_t *priv = filp->private_data; - drm_device_t *dev = priv->dev; - int ret = 0; - drm_lock_t lock; - - DRM_DEBUG("\n"); - - if (copy_from_user(&lock, (drm_lock_t *)arg, sizeof(lock))) - return -EFAULT; - ret = DRM(flush_block_and_flush)(dev, lock.context, lock.flags); - DRM(flush_unblock)(dev, lock.context, lock.flags); - return ret; -} - /* If we get here, it means that the process has called DRM_IOCTL_LOCK without calling DRM_IOCTL_UNLOCK. diff --git a/linux/gamma_drv.c b/linux/gamma_drv.c index 52b8983f..32b12e0a 100644 --- a/linux/gamma_drv.c +++ b/linux/gamma_drv.c @@ -41,7 +41,7 @@ #include "drm_bufs.h" #include "gamma_context.h" /* NOTE! */ #include "drm_dma.h" -#include "gamma_old_dma.h" +#include "gamma_old_dma.h" /* NOTE */ #include "drm_drawable.h" #include "drm_drv.h" @@ -50,6 +50,7 @@ #include "drm_ioctl.h" #include "drm_lists.h" #include "drm_lock.h" +#include "gamma_lock.h" /* NOTE */ #include "drm_memory.h" #include "drm_proc.h" #include "drm_vm.h" diff --git a/linux/i810.h b/linux/i810.h index f37cb2e8..72cbed32 100644 --- a/linux/i810.h +++ b/linux/i810.h @@ -93,7 +93,7 @@ */ #define __HAVE_DMA 1 #define __HAVE_DMA_QUEUE 1 -#define __HAVE_DMA_WAITLIST 1 +#define __HAVE_DMA_WAITLIST 0 #define __HAVE_DMA_RECLAIM 1 #define __HAVE_DMA_QUIESCENT 1 diff --git a/linux/i830.h b/linux/i830.h index a351a4cf..432397a8 100644 --- a/linux/i830.h +++ b/linux/i830.h @@ -94,7 +94,7 @@ */ #define __HAVE_DMA 1 #define __HAVE_DMA_QUEUE 1 -#define __HAVE_DMA_WAITLIST 1 +#define __HAVE_DMA_WAITLIST 0 #define __HAVE_DMA_RECLAIM 1 #define __HAVE_DMA_QUIESCENT 1 -- cgit v1.2.3