diff options
author | Eric Anholt <anholt@freebsd.org> | 2002-08-31 06:47:32 +0000 |
---|---|---|
committer | Eric Anholt <anholt@freebsd.org> | 2002-08-31 06:47:32 +0000 |
commit | af2412cda18f5aab001c37e4f6703c38b17ed4cb (patch) | |
tree | eb549e6697d5fc0f00cf1111a2ad8954d05571ad | |
parent | a15637555f5d5289ba32c346f5c1468f67b4b172 (diff) |
Port new radeon irq code to FreeBSD, add a couple of macros to drm_os_*.
Untested yet as the userland isn't compiling on my end. More of this
needs to be made os-independent, but that should probably wait until
gamma (the other irq-using driver) is worked on too.
-rw-r--r-- | bsd-core/drm_os_freebsd.h | 4 | ||||
-rw-r--r-- | bsd-core/radeon/Makefile | 2 | ||||
-rw-r--r-- | bsd/Imakefile | 1 | ||||
-rw-r--r-- | bsd/drm_os_freebsd.h | 4 | ||||
-rw-r--r-- | bsd/gamma_dma.c | 4 | ||||
-rw-r--r-- | bsd/radeon/Makefile | 2 | ||||
-rw-r--r-- | linux-core/drm_os_linux.h | 2 | ||||
-rw-r--r-- | linux/drm_os_linux.h | 2 | ||||
-rw-r--r-- | shared-core/radeon_irq.c | 44 | ||||
-rw-r--r-- | shared/radeon_irq.c | 44 |
10 files changed, 79 insertions, 30 deletions
diff --git a/bsd-core/drm_os_freebsd.h b/bsd-core/drm_os_freebsd.h index 6f878d4f..fa0c916f 100644 --- a/bsd-core/drm_os_freebsd.h +++ b/bsd-core/drm_os_freebsd.h @@ -96,8 +96,8 @@ #define DRM_LOCK lockmgr(&dev->dev_lock, LK_EXCLUSIVE, 0, DRM_CURPROC) #define DRM_UNLOCK lockmgr(&dev->dev_lock, LK_RELEASE, 0, DRM_CURPROC) #define DRM_SUSER(p) suser(p) -#define DRM_TASKQUEUE_ARGS void *dev, int pending -#define DRM_IRQ_ARGS void *device +#define DRM_TASKQUEUE_ARGS void *arg, int pending +#define DRM_IRQ_ARGS void *arg #define DRM_DEVICE drm_device_t *dev = kdev->si_drv1 #define DRM_MALLOC(size) malloc( size, DRM(M_DRM), M_NOWAIT ) #define DRM_FREE(pt) free( pt, DRM(M_DRM) ) diff --git a/bsd-core/radeon/Makefile b/bsd-core/radeon/Makefile index 844586a1..255f3966 100644 --- a/bsd-core/radeon/Makefile +++ b/bsd-core/radeon/Makefile @@ -3,7 +3,7 @@ .PATH: ${.CURDIR}/.. KMOD = radeon NOMAN= YES -SRCS = radeon_cp.c radeon_drv.c radeon_state.c +SRCS = radeon_cp.c radeon_drv.c radeon_state.c radeon_irq.c SRCS += device_if.h bus_if.h pci_if.h opt_drm.h CFLAGS += ${DEBUG_FLAGS} -I. -I.. diff --git a/bsd/Imakefile b/bsd/Imakefile index 4923ea5b..d3fedf6e 100644 --- a/bsd/Imakefile +++ b/bsd/Imakefile @@ -36,4 +36,5 @@ LinkSourceFile(radeon.h,$(XF86OSSRC)/shared/drm/kernel) LinkSourceFile(radeon_cp.c,$(XF86OSSRC)/shared/drm/kernel) LinkSourceFile(radeon_drm.h,$(XF86OSSRC)/shared/drm/kernel) LinkSourceFile(radeon_drv.h,$(XF86OSSRC)/shared/drm/kernel) +LinkSourceFile(radeon_irq.c,$(XF86OSSRC)/shared/drm/kernel) LinkSourceFile(radeon_state.c,$(XF86OSSRC)/shared/drm/kernel) diff --git a/bsd/drm_os_freebsd.h b/bsd/drm_os_freebsd.h index 6f878d4f..fa0c916f 100644 --- a/bsd/drm_os_freebsd.h +++ b/bsd/drm_os_freebsd.h @@ -96,8 +96,8 @@ #define DRM_LOCK lockmgr(&dev->dev_lock, LK_EXCLUSIVE, 0, DRM_CURPROC) #define DRM_UNLOCK lockmgr(&dev->dev_lock, LK_RELEASE, 0, DRM_CURPROC) #define DRM_SUSER(p) suser(p) -#define DRM_TASKQUEUE_ARGS void *dev, int pending -#define DRM_IRQ_ARGS void *device +#define DRM_TASKQUEUE_ARGS void *arg, int pending +#define DRM_IRQ_ARGS void *arg #define DRM_DEVICE drm_device_t *dev = kdev->si_drv1 #define DRM_MALLOC(size) malloc( size, DRM(M_DRM), M_NOWAIT ) #define DRM_FREE(pt) free( pt, DRM(M_DRM) ) diff --git a/bsd/gamma_dma.c b/bsd/gamma_dma.c index e7ca0695..20b29793 100644 --- a/bsd/gamma_dma.c +++ b/bsd/gamma_dma.c @@ -116,7 +116,7 @@ static __inline__ int gamma_dma_is_ready(drm_device_t *dev) void gamma_dma_service( DRM_IRQ_ARGS) { - drm_device_t *dev = (drm_device_t *)device; + drm_device_t *dev = (drm_device_t *)arg; drm_device_dma_t *dma = dev->dma; drm_gamma_private_t *dev_priv = (drm_gamma_private_t *)dev->dev_private; @@ -262,7 +262,7 @@ static void gamma_dma_timer_bh(unsigned long dev) void gamma_dma_immediate_bh(DRM_TASKQUEUE_ARGS) { - gamma_dma_schedule(dev, 0); + gamma_dma_schedule(arg, 0); } int gamma_dma_schedule(drm_device_t *dev, int locked) diff --git a/bsd/radeon/Makefile b/bsd/radeon/Makefile index 844586a1..255f3966 100644 --- a/bsd/radeon/Makefile +++ b/bsd/radeon/Makefile @@ -3,7 +3,7 @@ .PATH: ${.CURDIR}/.. KMOD = radeon NOMAN= YES -SRCS = radeon_cp.c radeon_drv.c radeon_state.c +SRCS = radeon_cp.c radeon_drv.c radeon_state.c radeon_irq.c SRCS += device_if.h bus_if.h pci_if.h opt_drm.h CFLAGS += ${DEBUG_FLAGS} -I. -I.. diff --git a/linux-core/drm_os_linux.h b/linux-core/drm_os_linux.h index 8c073f0b..e582150a 100644 --- a/linux-core/drm_os_linux.h +++ b/linux-core/drm_os_linux.h @@ -15,6 +15,8 @@ #define DRM_WRITEMEMORYBARRIER() wmb() #define DRM_DEVICE drm_file_t *priv = filp->private_data; \ drm_device_t *dev = priv->dev +#define DRM_IRQ_ARGS void *arg +#define DRM_TASKQUEUE_ARGS void *arg, int pending /* For data going from/to the kernel through the ioctl argument */ #define DRM_COPY_FROM_USER_IOCTL(arg1, arg2, arg3) \ diff --git a/linux/drm_os_linux.h b/linux/drm_os_linux.h index 8c073f0b..e582150a 100644 --- a/linux/drm_os_linux.h +++ b/linux/drm_os_linux.h @@ -15,6 +15,8 @@ #define DRM_WRITEMEMORYBARRIER() wmb() #define DRM_DEVICE drm_file_t *priv = filp->private_data; \ drm_device_t *dev = priv->dev +#define DRM_IRQ_ARGS void *arg +#define DRM_TASKQUEUE_ARGS void *arg, int pending /* For data going from/to the kernel through the ioctl argument */ #define DRM_COPY_FROM_USER_IOCTL(arg1, arg2, arg3) \ diff --git a/shared-core/radeon_irq.c b/shared-core/radeon_irq.c index 64a4385c..a19a1068 100644 --- a/shared-core/radeon_irq.c +++ b/shared-core/radeon_irq.c @@ -50,13 +50,13 @@ * - as above, but wait with lock held??? */ -void DRM(dma_service)(int irq, void *device, struct pt_regs *regs) +void DRM(dma_service)( DRM_IRQ_ARGS ) { - drm_device_t *dev = (drm_device_t *)device; + drm_device_t *dev = (drm_device_t *) arg; drm_radeon_private_t *dev_priv = (drm_radeon_private_t *)dev->dev_private; u32 temp; - + /* Need to wait for fifo to drain? */ temp = RADEON_READ(RADEON_GEN_INT_STATUS); @@ -65,23 +65,33 @@ void DRM(dma_service)(int irq, void *device, struct pt_regs *regs) RADEON_WRITE(RADEON_GEN_INT_STATUS, temp); atomic_inc(&dev_priv->irq_received); +#ifdef __linux__ queue_task(&dev->tq, &tq_immediate); mark_bh(IMMEDIATE_BH); +#endif /* __linux__ */ +#ifdef __FreeBSD__ + taskqueue_enqueue(taskqueue_swi, &dev->task); +#endif /* __FreeBSD__ */ } -void DRM(dma_immediate_bh)(void *device) +void DRM(dma_immediate_bh)( DRM_TASKQUEUE_ARGS ) { - drm_device_t *dev = (drm_device_t *) device; + drm_device_t *dev = (drm_device_t *) arg; drm_radeon_private_t *dev_priv = (drm_radeon_private_t *)dev->dev_private; +#ifdef __linux__ wake_up_interruptible(&dev_priv->irq_queue); +#endif /* __linux__ */ +#ifdef __FreeBSD__ + wakeup( &dev_priv->irq_queue ); +#endif } int radeon_emit_irq(drm_device_t *dev) { - drm_radeon_private_t *dev_priv = dev->dev_private; + drm_radeon_private_t *dev_priv = dev->dev_private; RING_LOCALS; atomic_inc(&dev_priv->irq_emitted); @@ -98,10 +108,12 @@ int radeon_emit_irq(drm_device_t *dev) int radeon_wait_irq(drm_device_t *dev, int irq_nr) { - DECLARE_WAITQUEUE(entry, current); drm_radeon_private_t *dev_priv = (drm_radeon_private_t *)dev->dev_private; +#ifdef __linux__ + DECLARE_WAITQUEUE(entry, current); unsigned long end = jiffies + HZ*3; +#endif /* __linux__ */ int ret = 0; /* if (atomic_read(&dev_priv->irq_received) >= irq_nr) */ @@ -109,16 +121,17 @@ int radeon_wait_irq(drm_device_t *dev, int irq_nr) dev_priv->stats.boxes |= RADEON_BOX_WAIT_IDLE; - add_wait_queue(&dev_priv->irq_queue, &entry); +#ifdef __linux__ + add_wait_queue(&dev_priv->irq_queue, &entry); - for (;;) { + for (;;) { current->state = TASK_INTERRUPTIBLE; if (atomic_read(&dev_priv->irq_received) >= irq_nr) break; if((signed)(end - jiffies) <= 0) { ret = -EBUSY; /* ? */ break; - } + } schedule_timeout(HZ*3); if (signal_pending(current)) { ret = -EINTR; @@ -129,6 +142,15 @@ int radeon_wait_irq(drm_device_t *dev, int irq_nr) current->state = TASK_RUNNING; remove_wait_queue(&dev_priv->irq_queue, &entry); return ret; +#endif /* __linux__ */ + +#ifdef __FreeBSD__ + ret = tsleep( &dev_priv->irq_queue, PZERO | PCATCH, \ + "rdnirq", 3*hz ); + if ( (ret == EWOULDBLOCK) || (ret == EINTR) ) + return DRM_ERR(EBUSY); + return ret; +#endif /* __FreeBSD__ */ } @@ -158,7 +180,7 @@ int radeon_irq_emit( DRM_IOCTL_ARGS ) sizeof(emit) ); result = radeon_emit_irq( dev ); - + if ( DRM_COPY_TO_USER( emit.irq_seq, &result, sizeof(int) ) ) { DRM_ERROR( "copy_to_user\n" ); return DRM_ERR(EFAULT); diff --git a/shared/radeon_irq.c b/shared/radeon_irq.c index 64a4385c..a19a1068 100644 --- a/shared/radeon_irq.c +++ b/shared/radeon_irq.c @@ -50,13 +50,13 @@ * - as above, but wait with lock held??? */ -void DRM(dma_service)(int irq, void *device, struct pt_regs *regs) +void DRM(dma_service)( DRM_IRQ_ARGS ) { - drm_device_t *dev = (drm_device_t *)device; + drm_device_t *dev = (drm_device_t *) arg; drm_radeon_private_t *dev_priv = (drm_radeon_private_t *)dev->dev_private; u32 temp; - + /* Need to wait for fifo to drain? */ temp = RADEON_READ(RADEON_GEN_INT_STATUS); @@ -65,23 +65,33 @@ void DRM(dma_service)(int irq, void *device, struct pt_regs *regs) RADEON_WRITE(RADEON_GEN_INT_STATUS, temp); atomic_inc(&dev_priv->irq_received); +#ifdef __linux__ queue_task(&dev->tq, &tq_immediate); mark_bh(IMMEDIATE_BH); +#endif /* __linux__ */ +#ifdef __FreeBSD__ + taskqueue_enqueue(taskqueue_swi, &dev->task); +#endif /* __FreeBSD__ */ } -void DRM(dma_immediate_bh)(void *device) +void DRM(dma_immediate_bh)( DRM_TASKQUEUE_ARGS ) { - drm_device_t *dev = (drm_device_t *) device; + drm_device_t *dev = (drm_device_t *) arg; drm_radeon_private_t *dev_priv = (drm_radeon_private_t *)dev->dev_private; +#ifdef __linux__ wake_up_interruptible(&dev_priv->irq_queue); +#endif /* __linux__ */ +#ifdef __FreeBSD__ + wakeup( &dev_priv->irq_queue ); +#endif } int radeon_emit_irq(drm_device_t *dev) { - drm_radeon_private_t *dev_priv = dev->dev_private; + drm_radeon_private_t *dev_priv = dev->dev_private; RING_LOCALS; atomic_inc(&dev_priv->irq_emitted); @@ -98,10 +108,12 @@ int radeon_emit_irq(drm_device_t *dev) int radeon_wait_irq(drm_device_t *dev, int irq_nr) { - DECLARE_WAITQUEUE(entry, current); drm_radeon_private_t *dev_priv = (drm_radeon_private_t *)dev->dev_private; +#ifdef __linux__ + DECLARE_WAITQUEUE(entry, current); unsigned long end = jiffies + HZ*3; +#endif /* __linux__ */ int ret = 0; /* if (atomic_read(&dev_priv->irq_received) >= irq_nr) */ @@ -109,16 +121,17 @@ int radeon_wait_irq(drm_device_t *dev, int irq_nr) dev_priv->stats.boxes |= RADEON_BOX_WAIT_IDLE; - add_wait_queue(&dev_priv->irq_queue, &entry); +#ifdef __linux__ + add_wait_queue(&dev_priv->irq_queue, &entry); - for (;;) { + for (;;) { current->state = TASK_INTERRUPTIBLE; if (atomic_read(&dev_priv->irq_received) >= irq_nr) break; if((signed)(end - jiffies) <= 0) { ret = -EBUSY; /* ? */ break; - } + } schedule_timeout(HZ*3); if (signal_pending(current)) { ret = -EINTR; @@ -129,6 +142,15 @@ int radeon_wait_irq(drm_device_t *dev, int irq_nr) current->state = TASK_RUNNING; remove_wait_queue(&dev_priv->irq_queue, &entry); return ret; +#endif /* __linux__ */ + +#ifdef __FreeBSD__ + ret = tsleep( &dev_priv->irq_queue, PZERO | PCATCH, \ + "rdnirq", 3*hz ); + if ( (ret == EWOULDBLOCK) || (ret == EINTR) ) + return DRM_ERR(EBUSY); + return ret; +#endif /* __FreeBSD__ */ } @@ -158,7 +180,7 @@ int radeon_irq_emit( DRM_IOCTL_ARGS ) sizeof(emit) ); result = radeon_emit_irq( dev ); - + if ( DRM_COPY_TO_USER( emit.irq_seq, &result, sizeof(int) ) ) { DRM_ERROR( "copy_to_user\n" ); return DRM_ERR(EFAULT); |