diff options
author | Keith Whitwell <keith@tungstengraphics.com> | 2002-08-30 10:23:07 +0000 |
---|---|---|
committer | Keith Whitwell <keith@tungstengraphics.com> | 2002-08-30 10:23:07 +0000 |
commit | 5e0e50d732493003f9b52708602412f166055c3f (patch) | |
tree | 6db035eb75ccd10065e1fd894ece54519af04ccf | |
parent | e4fcd729f8199173cbae175e2acd975e8c0c2033 (diff) |
irqs work and can be used from userspace
-rw-r--r-- | shared-core/radeon_cp.c | 3 | ||||
-rw-r--r-- | shared-core/radeon_irq.c | 39 | ||||
-rw-r--r-- | shared-core/radeon_state.c | 11 | ||||
-rw-r--r-- | shared/radeon.h | 16 | ||||
-rw-r--r-- | shared/radeon_cp.c | 3 | ||||
-rw-r--r-- | shared/radeon_irq.c | 39 | ||||
-rw-r--r-- | shared/radeon_state.c | 11 |
7 files changed, 58 insertions, 64 deletions
diff --git a/shared-core/radeon_cp.c b/shared-core/radeon_cp.c index 01069e49..1fe4cabe 100644 --- a/shared-core/radeon_cp.c +++ b/shared-core/radeon_cp.c @@ -1412,6 +1412,9 @@ int radeon_cp_idle( DRM_IOCTL_ARGS ) LOCK_TEST_WITH_RETURN( dev ); +/* if (dev->irq) */ +/* radeon_emit_and_wait_irq( dev ); */ + return radeon_do_cp_idle( dev_priv ); } diff --git a/shared-core/radeon_irq.c b/shared-core/radeon_irq.c index 0d448460..d7648539 100644 --- a/shared-core/radeon_irq.c +++ b/shared-core/radeon_irq.c @@ -60,15 +60,13 @@ void DRM(dma_service)(int irq, void *device, struct pt_regs *regs) /* Need to wait for fifo to drain? */ temp = RADEON_READ(RADEON_GEN_INT_STATUS); - printk("%s %x\n", __FUNCTION__, temp); - temp = temp & RADEON_SW_INT_TEST_ACK; if(temp == 0) return; RADEON_WRITE(RADEON_GEN_INT_STATUS, temp); atomic_inc(&dev_priv->irq_received); -/* queue_task(&dev->tq, &tq_immediate); */ -/* mark_bh(IMMEDIATE_BH); */ + queue_task(&dev->tq, &tq_immediate); + mark_bh(IMMEDIATE_BH); } void DRM(dma_immediate_bh)(void *device) @@ -77,7 +75,7 @@ void DRM(dma_immediate_bh)(void *device) drm_radeon_private_t *dev_priv = (drm_radeon_private_t *)dev->dev_private; - wake_up_interruptible(&dev_priv->irq_queue); + wake_up_interruptible(&dev_priv->irq_queue); } @@ -88,13 +86,9 @@ int radeon_emit_irq(drm_device_t *dev) atomic_inc(&dev_priv->irq_emitted); - printk("Emitting irq\n"); - - BEGIN_RING(4); + BEGIN_RING(2); OUT_RING( CP_PACKET0( RADEON_GEN_INT_STATUS, 0 ) ); OUT_RING( RADEON_SW_INT_FIRE ); - OUT_RING( CP_PACKET0( RADEON_GEN_INT_STATUS, 0 ) ); - OUT_RING( 0 ); ADVANCE_RING(); COMMIT_RING(); @@ -108,9 +102,12 @@ int radeon_wait_irq(drm_device_t *dev, int irq_nr) drm_radeon_private_t *dev_priv = (drm_radeon_private_t *)dev->dev_private; unsigned long end = jiffies + HZ*3; + int ret = 0; + +/* if (atomic_read(&dev_priv->irq_received) >= irq_nr) */ +/* return 0; */ - if (atomic_read(&dev_priv->irq_received) >= irq_nr) - return 0; + dev_priv->stats.boxes |= RADEON_BOX_WAIT_IDLE; add_wait_queue(&dev_priv->irq_queue, &entry); @@ -119,17 +116,19 @@ int radeon_wait_irq(drm_device_t *dev, int irq_nr) if (atomic_read(&dev_priv->irq_received) >= irq_nr) break; if((signed)(end - jiffies) <= 0) { - DRM_ERROR("lockup or missed irq\n"); - return -EBUSY; /* ? */ + ret = -EBUSY; /* ? */ + break; } schedule_timeout(HZ*3); - if (signal_pending(current)) - return -EINTR; + if (signal_pending(current)) { + ret = -EINTR; + break; + } } current->state = TASK_RUNNING; remove_wait_queue(&dev_priv->irq_queue, &entry); - return 0; + return ret; } @@ -139,6 +138,8 @@ int radeon_emit_and_wait_irq(drm_device_t *dev) } +/* Needs the lock as it touches the ring. + */ int radeon_irq_emit( DRM_IOCTL_ARGS ) { DRM_DEVICE; @@ -146,6 +147,8 @@ int radeon_irq_emit( DRM_IOCTL_ARGS ) drm_radeon_irq_emit_t emit; int result; + LOCK_TEST_WITH_RETURN( dev ); + if ( !dev_priv ) { DRM_ERROR( "%s called with no initialization\n", __func__ ); return DRM_ERR(EINVAL); @@ -165,6 +168,8 @@ int radeon_irq_emit( DRM_IOCTL_ARGS ) } +/* Doesn't need the hardware lock. + */ int radeon_irq_wait( DRM_IOCTL_ARGS ) { DRM_DEVICE; diff --git a/shared-core/radeon_state.c b/shared-core/radeon_state.c index af7b516f..eb775ce3 100644 --- a/shared-core/radeon_state.c +++ b/shared-core/radeon_state.c @@ -717,16 +717,7 @@ static void radeon_cp_dispatch_swap( drm_device_t *dev ) drm_clip_rect_t *pbox = sarea_priv->boxes; int i; RING_LOCALS; - printk( "%s\n", __FUNCTION__ ); - - - BEGIN_RING( 2 ); - RADEON_WAIT_UNTIL_IDLE(); - ADVANCE_RING(); - - radeon_emit_irq( dev ); -/* return; */ - + DRM_DEBUG( "\n" ); /* Do some trivial performance monitoring... */ diff --git a/shared/radeon.h b/shared/radeon.h index d494887e..9a56d79c 100644 --- a/shared/radeon.h +++ b/shared/radeon.h @@ -132,14 +132,9 @@ #define __HAVE_DMA_IRQ 1 -/* #define __HAVE_DMA_IRQ_BH 1 */ +#define __HAVE_DMA_IRQ_BH 1 #define __HAVE_SHARED_IRQ 1 -#if 0 -#define DRIVER_PREINSTALL() -#define DRIVER_POSTINSTALL() -#define DRIVER_UNINSTALL() -#else #define DRIVER_PREINSTALL() do { \ drm_radeon_private_t *dev_priv = \ (drm_radeon_private_t *)dev->dev_private; \ @@ -158,11 +153,13 @@ drm_radeon_private_t *dev_priv = \ (drm_radeon_private_t *)dev->dev_private; \ \ + atomic_set(&dev_priv->irq_received, 0); \ + atomic_set(&dev_priv->irq_emitted, 0); \ + init_waitqueue_head(&dev_priv->irq_queue); \ + \ /* Turn on SW_INT only */ \ - RADEON_WRITE( RADEON_GEN_INT_CNTL, \ + RADEON_WRITE( RADEON_GEN_INT_CNTL, \ RADEON_SW_INT_ENABLE ); \ - /* practise fire */ \ - RADEON_WRITE( RADEON_GEN_INT_STATUS, RADEON_SW_INT_FIRE ); \ } while (0) #define DRIVER_UNINSTALL() do { \ @@ -173,7 +170,6 @@ RADEON_WRITE( RADEON_GEN_INT_CNTL, 0 ); \ } \ } while (0) -#endif /* Buffer customization: */ diff --git a/shared/radeon_cp.c b/shared/radeon_cp.c index 01069e49..1fe4cabe 100644 --- a/shared/radeon_cp.c +++ b/shared/radeon_cp.c @@ -1412,6 +1412,9 @@ int radeon_cp_idle( DRM_IOCTL_ARGS ) LOCK_TEST_WITH_RETURN( dev ); +/* if (dev->irq) */ +/* radeon_emit_and_wait_irq( dev ); */ + return radeon_do_cp_idle( dev_priv ); } diff --git a/shared/radeon_irq.c b/shared/radeon_irq.c index 0d448460..d7648539 100644 --- a/shared/radeon_irq.c +++ b/shared/radeon_irq.c @@ -60,15 +60,13 @@ void DRM(dma_service)(int irq, void *device, struct pt_regs *regs) /* Need to wait for fifo to drain? */ temp = RADEON_READ(RADEON_GEN_INT_STATUS); - printk("%s %x\n", __FUNCTION__, temp); - temp = temp & RADEON_SW_INT_TEST_ACK; if(temp == 0) return; RADEON_WRITE(RADEON_GEN_INT_STATUS, temp); atomic_inc(&dev_priv->irq_received); -/* queue_task(&dev->tq, &tq_immediate); */ -/* mark_bh(IMMEDIATE_BH); */ + queue_task(&dev->tq, &tq_immediate); + mark_bh(IMMEDIATE_BH); } void DRM(dma_immediate_bh)(void *device) @@ -77,7 +75,7 @@ void DRM(dma_immediate_bh)(void *device) drm_radeon_private_t *dev_priv = (drm_radeon_private_t *)dev->dev_private; - wake_up_interruptible(&dev_priv->irq_queue); + wake_up_interruptible(&dev_priv->irq_queue); } @@ -88,13 +86,9 @@ int radeon_emit_irq(drm_device_t *dev) atomic_inc(&dev_priv->irq_emitted); - printk("Emitting irq\n"); - - BEGIN_RING(4); + BEGIN_RING(2); OUT_RING( CP_PACKET0( RADEON_GEN_INT_STATUS, 0 ) ); OUT_RING( RADEON_SW_INT_FIRE ); - OUT_RING( CP_PACKET0( RADEON_GEN_INT_STATUS, 0 ) ); - OUT_RING( 0 ); ADVANCE_RING(); COMMIT_RING(); @@ -108,9 +102,12 @@ int radeon_wait_irq(drm_device_t *dev, int irq_nr) drm_radeon_private_t *dev_priv = (drm_radeon_private_t *)dev->dev_private; unsigned long end = jiffies + HZ*3; + int ret = 0; + +/* if (atomic_read(&dev_priv->irq_received) >= irq_nr) */ +/* return 0; */ - if (atomic_read(&dev_priv->irq_received) >= irq_nr) - return 0; + dev_priv->stats.boxes |= RADEON_BOX_WAIT_IDLE; add_wait_queue(&dev_priv->irq_queue, &entry); @@ -119,17 +116,19 @@ int radeon_wait_irq(drm_device_t *dev, int irq_nr) if (atomic_read(&dev_priv->irq_received) >= irq_nr) break; if((signed)(end - jiffies) <= 0) { - DRM_ERROR("lockup or missed irq\n"); - return -EBUSY; /* ? */ + ret = -EBUSY; /* ? */ + break; } schedule_timeout(HZ*3); - if (signal_pending(current)) - return -EINTR; + if (signal_pending(current)) { + ret = -EINTR; + break; + } } current->state = TASK_RUNNING; remove_wait_queue(&dev_priv->irq_queue, &entry); - return 0; + return ret; } @@ -139,6 +138,8 @@ int radeon_emit_and_wait_irq(drm_device_t *dev) } +/* Needs the lock as it touches the ring. + */ int radeon_irq_emit( DRM_IOCTL_ARGS ) { DRM_DEVICE; @@ -146,6 +147,8 @@ int radeon_irq_emit( DRM_IOCTL_ARGS ) drm_radeon_irq_emit_t emit; int result; + LOCK_TEST_WITH_RETURN( dev ); + if ( !dev_priv ) { DRM_ERROR( "%s called with no initialization\n", __func__ ); return DRM_ERR(EINVAL); @@ -165,6 +168,8 @@ int radeon_irq_emit( DRM_IOCTL_ARGS ) } +/* Doesn't need the hardware lock. + */ int radeon_irq_wait( DRM_IOCTL_ARGS ) { DRM_DEVICE; diff --git a/shared/radeon_state.c b/shared/radeon_state.c index af7b516f..eb775ce3 100644 --- a/shared/radeon_state.c +++ b/shared/radeon_state.c @@ -717,16 +717,7 @@ static void radeon_cp_dispatch_swap( drm_device_t *dev ) drm_clip_rect_t *pbox = sarea_priv->boxes; int i; RING_LOCALS; - printk( "%s\n", __FUNCTION__ ); - - - BEGIN_RING( 2 ); - RADEON_WAIT_UNTIL_IDLE(); - ADVANCE_RING(); - - radeon_emit_irq( dev ); -/* return; */ - + DRM_DEBUG( "\n" ); /* Do some trivial performance monitoring... */ |