summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichel Daenzer <michel@daenzer.net>2002-12-03 00:43:47 +0000
committerMichel Daenzer <michel@daenzer.net>2002-12-03 00:43:47 +0000
commit4acba63bb7045e6bf665580cf6cea111f0786f77 (patch)
treea45078534bae7643c6aca60c58a6c5054e0cf8d4
parent40891ac190fb74f389ea1a9758249a2f642fd99b (diff)
vertical blank interrupt cleanups: use spinlock instead of semaphore, send
signal directly from interrupt handler instead of using a taskqueue (based on feedback by Linus Torvalds)
-rw-r--r--linux-core/drmP.h5
-rw-r--r--linux-core/drm_dma.c25
-rw-r--r--linux/drmP.h5
-rw-r--r--linux/drm_dma.h25
-rw-r--r--shared-core/mga_irq.c5
-rw-r--r--shared-core/r128_irq.c5
-rw-r--r--shared-core/radeon_irq.c5
-rw-r--r--shared/mga_irq.c5
-rw-r--r--shared/r128_irq.c5
-rw-r--r--shared/radeon_irq.c5
10 files changed, 32 insertions, 58 deletions
diff --git a/linux-core/drmP.h b/linux-core/drmP.h
index 181f61f1..3f51b9b0 100644
--- a/linux-core/drmP.h
+++ b/linux-core/drmP.h
@@ -591,8 +591,7 @@ typedef struct drm_device {
#if __HAVE_VBL_IRQ
wait_queue_head_t vbl_queue;
atomic_t vbl_received;
- struct tq_struct vbl_tq;
- struct semaphore vbl_sem;
+ spinlock_t vbl_lock;
drm_vbl_sig_t vbl_sigs;
#endif
cycles_t ctx_start;
@@ -834,7 +833,7 @@ extern void DRM(driver_irq_uninstall)( drm_device_t *dev );
extern int DRM(wait_vblank)(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
extern int DRM(vblank_wait)(drm_device_t *dev, unsigned int *vbl_seq);
-extern void DRM(vbl_immediate_bh)( void *arg );
+extern void DRM(vbl_send_signals)( drm_device_t *dev );
#endif
#if __HAVE_DMA_IRQ_BH
extern void DRM(dma_immediate_bh)( void *dev );
diff --git a/linux-core/drm_dma.c b/linux-core/drm_dma.c
index 01121ce9..9dd46d21 100644
--- a/linux-core/drm_dma.c
+++ b/linux-core/drm_dma.c
@@ -509,6 +509,9 @@ int DRM(dma_get_buffers)(drm_device_t *dev, drm_dma_t *dma)
int DRM(irq_install)( drm_device_t *dev, int irq )
{
int ret;
+#if __HAVE_VBL_IRQ
+ unsigned long flags;
+#endif
if ( !irq )
return -EINVAL;
@@ -541,16 +544,9 @@ int DRM(irq_install)( drm_device_t *dev, int irq )
#if __HAVE_VBL_IRQ
init_waitqueue_head(&dev->vbl_queue);
- sema_init( &dev->vbl_sem, 0 );
+ spin_lock_init( &dev->vbl_lock );
INIT_LIST_HEAD( &dev->vbl_sigs.head );
-
- up( &dev->vbl_sem );
-
- INIT_LIST_HEAD( &dev->vbl_tq.list );
- dev->vbl_tq.sync = 0;
- dev->vbl_tq.routine = DRM(vbl_immediate_bh);
- dev->vbl_tq.data = dev;
#endif
/* Before installing handler */
@@ -642,6 +638,7 @@ int DRM(wait_vblank)( DRM_IOCTL_ARGS )
flags = vblwait.request.type & _DRM_VBLANK_FLAGS_MASK;
if ( flags & _DRM_VBLANK_SIGNAL ) {
+ unsigned long flags;
drm_vbl_sig_t *vbl_sig = DRM_MALLOC( sizeof( drm_vbl_sig_t ) );
if ( !vbl_sig )
@@ -656,11 +653,11 @@ int DRM(wait_vblank)( DRM_IOCTL_ARGS )
vblwait.reply.sequence = atomic_read( &dev->vbl_received );
/* Hook signal entry into list */
- down( &dev->vbl_sem );
+ spin_lock_irqsave( &dev->vbl_lock, flags );
list_add_tail( (struct list_head *) vbl_sig, &dev->vbl_sigs.head );
- up( &dev->vbl_sem );
+ spin_unlock_irqrestore( &dev->vbl_lock, flags );
} else {
ret = DRM(vblank_wait)( dev, &vblwait.request.sequence );
@@ -675,14 +672,14 @@ int DRM(wait_vblank)( DRM_IOCTL_ARGS )
return ret;
}
-void DRM(vbl_immediate_bh)( void *arg )
+void DRM(vbl_send_signals)( drm_device_t *dev )
{
- drm_device_t *dev = (drm_device_t *) arg;
struct list_head *entry, *tmp;
drm_vbl_sig_t *vbl_sig;
unsigned int vbl_seq = atomic_read( &dev->vbl_received );
+ unsigned long flags;
- down( &dev->vbl_sem );
+ spin_lock_irqsave( &dev->vbl_lock, flags );
list_for_each_safe( entry, tmp, &dev->vbl_sigs.head ) {
@@ -699,7 +696,7 @@ void DRM(vbl_immediate_bh)( void *arg )
}
}
- up( &dev->vbl_sem );
+ spin_unlock_irqrestore( &dev->vbl_lock, flags );
}
#endif /* __HAVE_VBL_IRQ */
diff --git a/linux/drmP.h b/linux/drmP.h
index 181f61f1..3f51b9b0 100644
--- a/linux/drmP.h
+++ b/linux/drmP.h
@@ -591,8 +591,7 @@ typedef struct drm_device {
#if __HAVE_VBL_IRQ
wait_queue_head_t vbl_queue;
atomic_t vbl_received;
- struct tq_struct vbl_tq;
- struct semaphore vbl_sem;
+ spinlock_t vbl_lock;
drm_vbl_sig_t vbl_sigs;
#endif
cycles_t ctx_start;
@@ -834,7 +833,7 @@ extern void DRM(driver_irq_uninstall)( drm_device_t *dev );
extern int DRM(wait_vblank)(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
extern int DRM(vblank_wait)(drm_device_t *dev, unsigned int *vbl_seq);
-extern void DRM(vbl_immediate_bh)( void *arg );
+extern void DRM(vbl_send_signals)( drm_device_t *dev );
#endif
#if __HAVE_DMA_IRQ_BH
extern void DRM(dma_immediate_bh)( void *dev );
diff --git a/linux/drm_dma.h b/linux/drm_dma.h
index 01121ce9..9dd46d21 100644
--- a/linux/drm_dma.h
+++ b/linux/drm_dma.h
@@ -509,6 +509,9 @@ int DRM(dma_get_buffers)(drm_device_t *dev, drm_dma_t *dma)
int DRM(irq_install)( drm_device_t *dev, int irq )
{
int ret;
+#if __HAVE_VBL_IRQ
+ unsigned long flags;
+#endif
if ( !irq )
return -EINVAL;
@@ -541,16 +544,9 @@ int DRM(irq_install)( drm_device_t *dev, int irq )
#if __HAVE_VBL_IRQ
init_waitqueue_head(&dev->vbl_queue);
- sema_init( &dev->vbl_sem, 0 );
+ spin_lock_init( &dev->vbl_lock );
INIT_LIST_HEAD( &dev->vbl_sigs.head );
-
- up( &dev->vbl_sem );
-
- INIT_LIST_HEAD( &dev->vbl_tq.list );
- dev->vbl_tq.sync = 0;
- dev->vbl_tq.routine = DRM(vbl_immediate_bh);
- dev->vbl_tq.data = dev;
#endif
/* Before installing handler */
@@ -642,6 +638,7 @@ int DRM(wait_vblank)( DRM_IOCTL_ARGS )
flags = vblwait.request.type & _DRM_VBLANK_FLAGS_MASK;
if ( flags & _DRM_VBLANK_SIGNAL ) {
+ unsigned long flags;
drm_vbl_sig_t *vbl_sig = DRM_MALLOC( sizeof( drm_vbl_sig_t ) );
if ( !vbl_sig )
@@ -656,11 +653,11 @@ int DRM(wait_vblank)( DRM_IOCTL_ARGS )
vblwait.reply.sequence = atomic_read( &dev->vbl_received );
/* Hook signal entry into list */
- down( &dev->vbl_sem );
+ spin_lock_irqsave( &dev->vbl_lock, flags );
list_add_tail( (struct list_head *) vbl_sig, &dev->vbl_sigs.head );
- up( &dev->vbl_sem );
+ spin_unlock_irqrestore( &dev->vbl_lock, flags );
} else {
ret = DRM(vblank_wait)( dev, &vblwait.request.sequence );
@@ -675,14 +672,14 @@ int DRM(wait_vblank)( DRM_IOCTL_ARGS )
return ret;
}
-void DRM(vbl_immediate_bh)( void *arg )
+void DRM(vbl_send_signals)( drm_device_t *dev )
{
- drm_device_t *dev = (drm_device_t *) arg;
struct list_head *entry, *tmp;
drm_vbl_sig_t *vbl_sig;
unsigned int vbl_seq = atomic_read( &dev->vbl_received );
+ unsigned long flags;
- down( &dev->vbl_sem );
+ spin_lock_irqsave( &dev->vbl_lock, flags );
list_for_each_safe( entry, tmp, &dev->vbl_sigs.head ) {
@@ -699,7 +696,7 @@ void DRM(vbl_immediate_bh)( void *arg )
}
}
- up( &dev->vbl_sem );
+ spin_unlock_irqrestore( &dev->vbl_lock, flags );
}
#endif /* __HAVE_VBL_IRQ */
diff --git a/shared-core/mga_irq.c b/shared-core/mga_irq.c
index 30ee7834..66236053 100644
--- a/shared-core/mga_irq.c
+++ b/shared-core/mga_irq.c
@@ -50,10 +50,7 @@ void mga_dma_service( DRM_IRQ_ARGS )
MGA_WRITE( MGA_ICLEAR, MGA_VLINEICLR );
atomic_inc(&dev->vbl_received);
DRM_WAKEUP(&dev->vbl_queue);
-
- /* kick off bottom half for signals */
- queue_task(&dev->vbl_tq, &tq_immediate);
- mark_bh(IMMEDIATE_BH);
+ DRM(vbl_send_signals)( dev );
}
}
diff --git a/shared-core/r128_irq.c b/shared-core/r128_irq.c
index 722f2362..8dfee07e 100644
--- a/shared-core/r128_irq.c
+++ b/shared-core/r128_irq.c
@@ -50,10 +50,7 @@ void r128_dma_service( DRM_IRQ_ARGS )
R128_WRITE( R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK );
atomic_inc(&dev->vbl_received);
DRM_WAKEUP(&dev->vbl_queue);
-
- /* kick off bottom half for signals */
- queue_task(&dev->vbl_tq, &tq_immediate);
- mark_bh(IMMEDIATE_BH);
+ DRM(vbl_send_signals)( dev );
}
}
diff --git a/shared-core/radeon_irq.c b/shared-core/radeon_irq.c
index b8f33f95..e2182ff7 100644
--- a/shared-core/radeon_irq.c
+++ b/shared-core/radeon_irq.c
@@ -74,10 +74,7 @@ void DRM(dma_service)( DRM_IRQ_ARGS )
if (stat & RADEON_CRTC_VBLANK_STAT) {
atomic_inc(&dev->vbl_received);
DRM_WAKEUP(&dev->vbl_queue);
-
- /* kick off bottom half for signals */
- queue_task(&dev->vbl_tq, &tq_immediate);
- mark_bh(IMMEDIATE_BH);
+ DRM(vbl_send_signals)( dev );
}
/* Acknowledge all the bits in GEN_INT_STATUS -- seem to get
diff --git a/shared/mga_irq.c b/shared/mga_irq.c
index 30ee7834..66236053 100644
--- a/shared/mga_irq.c
+++ b/shared/mga_irq.c
@@ -50,10 +50,7 @@ void mga_dma_service( DRM_IRQ_ARGS )
MGA_WRITE( MGA_ICLEAR, MGA_VLINEICLR );
atomic_inc(&dev->vbl_received);
DRM_WAKEUP(&dev->vbl_queue);
-
- /* kick off bottom half for signals */
- queue_task(&dev->vbl_tq, &tq_immediate);
- mark_bh(IMMEDIATE_BH);
+ DRM(vbl_send_signals)( dev );
}
}
diff --git a/shared/r128_irq.c b/shared/r128_irq.c
index 722f2362..8dfee07e 100644
--- a/shared/r128_irq.c
+++ b/shared/r128_irq.c
@@ -50,10 +50,7 @@ void r128_dma_service( DRM_IRQ_ARGS )
R128_WRITE( R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK );
atomic_inc(&dev->vbl_received);
DRM_WAKEUP(&dev->vbl_queue);
-
- /* kick off bottom half for signals */
- queue_task(&dev->vbl_tq, &tq_immediate);
- mark_bh(IMMEDIATE_BH);
+ DRM(vbl_send_signals)( dev );
}
}
diff --git a/shared/radeon_irq.c b/shared/radeon_irq.c
index b8f33f95..e2182ff7 100644
--- a/shared/radeon_irq.c
+++ b/shared/radeon_irq.c
@@ -74,10 +74,7 @@ void DRM(dma_service)( DRM_IRQ_ARGS )
if (stat & RADEON_CRTC_VBLANK_STAT) {
atomic_inc(&dev->vbl_received);
DRM_WAKEUP(&dev->vbl_queue);
-
- /* kick off bottom half for signals */
- queue_task(&dev->vbl_tq, &tq_immediate);
- mark_bh(IMMEDIATE_BH);
+ DRM(vbl_send_signals)( dev );
}
/* Acknowledge all the bits in GEN_INT_STATUS -- seem to get