summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Whitwell <keith@tungstengraphics.com>2000-02-08 02:20:01 +0000
committerKeith Whitwell <keith@tungstengraphics.com>2000-02-08 02:20:01 +0000
commit3169aa74b737ffd11e62407cf3eba741b52797c9 (patch)
tree6d00b6db89d6e808274238954c10a36dc08ad2dd
parentc179c78025bd3d49294eeb9661d86e5c9fcb37c5 (diff)
Fixes for jeff
-rw-r--r--linux/mga_dma.c69
-rw-r--r--linux/mga_drm_public.h46
2 files changed, 50 insertions, 65 deletions
diff --git a/linux/mga_dma.c b/linux/mga_dma.c
index aed29f5b..1464576f 100644
--- a/linux/mga_dma.c
+++ b/linux/mga_dma.c
@@ -238,7 +238,6 @@ static void __mga_iload_small(drm_device_t *dev,
{
drm_mga_private_t *dev_priv = dev->dev_private;
drm_mga_buf_priv_t *buf_priv = buf->dev_private;
- drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
unsigned long address = (unsigned long)buf->bus_address;
int length = buf->used;
int y1 = buf_priv->boxes[0].y1;
@@ -290,7 +289,6 @@ static void __mga_iload_xy(drm_device_t *dev,
{
drm_mga_private_t *dev_priv = dev->dev_private;
drm_mga_buf_priv_t *buf_priv = buf->dev_private;
- drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
unsigned long address = (unsigned long)buf->bus_address;
int length = buf->used;
int y1 = buf_priv->boxes[0].y1;
@@ -631,10 +629,12 @@ static int mga_do_dma(drm_device_t *dev, int locked)
return retcode;
}
+/*
static void mga_dma_schedule_timer_wrapper(unsigned long dev)
{
mga_dma_schedule((drm_device_t *)dev, 0);
}
+*/
static void mga_dma_schedule_tq_wrapper(void *dev)
{
@@ -696,7 +696,6 @@ again:
}
clear_bit(0, &dev->interrupt_flag);
-
return retcode;
}
@@ -802,7 +801,6 @@ int mga_lock(struct inode *inode, struct file *filp, unsigned int cmd,
DECLARE_WAITQUEUE(entry, current);
int ret = 0;
drm_lock_t lock;
- drm_queue_t *q;
copy_from_user_ret(&lock, (drm_lock_t *)arg, sizeof(lock), -EFAULT);
@@ -821,57 +819,38 @@ int mga_lock(struct inode *inode, struct file *filp, unsigned int cmd,
return -EINVAL;
}
- /* Only one queue:
- */
- q = dev->queuelist[DRM_KERNEL_CONTEXT];
- ret = drm_flush_queue(dev, DRM_KERNEL_CONTEXT);
+
+ for (;;) {
+ if (!dev->lock.hw_lock) { /* Device has been unregistered */
+ ret = -EINTR;
+ break;
+ }
- if (!ret) {
- if (_DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock)
- != lock.context) {
- long j = jiffies - dev->lock.lock_time;
-
- if (j > 0 && j <= DRM_LOCK_SLICE) {
- /* Can't take lock if we just had it and
- there is contention. */
- current->state = TASK_INTERRUPTIBLE;
- schedule_timeout(j);
- }
+ if (drm_lock_take(&dev->lock.hw_lock->lock, lock.context)) {
+ dev->lock.pid = current->pid;
+ dev->lock.lock_time = jiffies;
+ atomic_inc(&dev->total_locks);
+ break; /* Got lock */
}
- add_wait_queue(&dev->lock.lock_queue, &entry);
- for (;;) {
- if (!dev->lock.hw_lock) {
- /* Device has been unregistered */
- ret = -EINTR;
- break;
- }
- if (drm_lock_take(&dev->lock.hw_lock->lock,
- lock.context)) {
- dev->lock.pid = current->pid;
- dev->lock.lock_time = jiffies;
- atomic_inc(&dev->total_locks);
- atomic_inc(&q->total_locks);
- break; /* Got lock */
- }
- /* Contention */
- atomic_inc(&dev->total_sleeps);
- current->state = TASK_INTERRUPTIBLE;
- schedule();
- if (signal_pending(current)) {
- ret = -ERESTARTSYS;
- break;
- }
+ /* Contention */
+ atomic_inc(&dev->total_sleeps);
+ current->state = TASK_INTERRUPTIBLE;
+ schedule();
+ if (signal_pending(current)) {
+ ret = -ERESTARTSYS;
+ break;
}
- current->state = TASK_RUNNING;
- remove_wait_queue(&dev->lock.lock_queue, &entry);
}
- drm_flush_unblock_queue(dev, DRM_KERNEL_CONTEXT); /* cleanup phase */
+ current->state = TASK_RUNNING;
+ remove_wait_queue(&dev->lock.lock_queue, &entry);
if (!ret) {
if (lock.flags & _DRM_LOCK_QUIESCENT) {
DRM_DEBUG("_DRM_LOCK_QUIESCENT\n");
+ drm_flush_queue(dev, DRM_KERNEL_CONTEXT);
+ drm_flush_unblock_queue(dev, DRM_KERNEL_CONTEXT);
mga_dma_quiescent(dev);
}
}
diff --git a/linux/mga_drm_public.h b/linux/mga_drm_public.h
index e6e9b2d7..dae53982 100644
--- a/linux/mga_drm_public.h
+++ b/linux/mga_drm_public.h
@@ -108,27 +108,10 @@ typedef struct _xf86drmClipRectRec {
unsigned short y2;
} xf86drmClipRectRec;
-#define MGA_CLEAR_FRONTBUFFER 0x1
-#define MGA_CLEAR_BACKBUFFER 0x2
-#define MGA_CLEAR_DEPTHBUFFER 0x4
+#define MGA_CLEAR_FRONT 0x1
+#define MGA_CLEAR_BACK 0x2
+#define MGA_CLEAR_DEPTH 0x4
-typedef struct {
- int clear_color;
- int clear_depth;
- int flags;
-} drm_mga_clear_t;
-
-typedef struct {
- int flags; /* not actually used? */
-} drm_mga_swap_t;
-
-typedef struct {
- unsigned int destOrg;
- unsigned int mAccess;
- unsigned int pitch;
- xf86drmClipRectRec texture;
- int idx;
-} drm_mga_iload_t;
/* Each context has a state:
*/
@@ -205,6 +188,29 @@ typedef struct
int texAge;
} drm_mga_sarea_t;
+
+/* Device specific ioctls:
+ */
+typedef struct {
+ int clear_color;
+ int clear_depth;
+ int flags;
+} drm_mga_clear_t;
+
+
+typedef struct {
+ int flags; /* not actually used? */
+} drm_mga_swap_t;
+
+typedef struct {
+ unsigned int destOrg;
+ unsigned int mAccess;
+ unsigned int pitch;
+ xf86drmClipRectRec texture;
+ int idx;
+} drm_mga_iload_t;
+
+
#define DRM_IOCTL_MGA_INIT DRM_IOW( 0x40, drm_mga_init_t)
#define DRM_IOCTL_MGA_SWAP DRM_IOW( 0x41, drm_mga_swap_t)
#define DRM_IOCTL_MGA_CLEAR DRM_IOW( 0x42, drm_mga_clear_t)