Move the excitingly named DRM(flush_block_and_flush) and friends to
authorKeith Whitwell <keith@tungstengraphics.com>
Tue, 22 Apr 2003 12:07:24 +0000 (12:07 +0000)
committerKeith Whitwell <keith@tungstengraphics.com>
Tue, 22 Apr 2003 12:07:24 +0000 (12:07 +0000)
    gamma-specific code.
Fix templates so i8x0 drivers don't have to define __HAVE_DMA_WAITLIST.

linux-core/drmP.h
linux-core/drm_drv.c
linux-core/drm_lock.c
linux/drmP.h
linux/drm_drv.h
linux/drm_lock.h
linux/gamma_drv.c
linux/i810.h
linux/i830.h

index c530ca0..9fd4149 100644 (file)
@@ -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,
index 3d369b2..036cee3 100644 (file)
@@ -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]),
index e9b17cc..cc9571e 100644 (file)
 #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.
 
index c530ca0..9fd4149 100644 (file)
@@ -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,
index 3d369b2..036cee3 100644 (file)
@@ -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]),
index e9b17cc..cc9571e 100644 (file)
 #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.
 
index 52b8983..32b12e0 100644 (file)
@@ -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"
index f37cb2e..72cbed3 100644 (file)
@@ -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
index a351a4c..432397a 100644 (file)
@@ -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