Use cv(9) instead of mtsleep/wakeup. Also, define drm_hz as

mstohz(333) (this seems to eliminate lockups for me using the r300
driver).  Tested with i915 and radeon on amd64.
This commit is contained in:
bjs 2008-05-18 02:45:17 +00:00
parent da04fccfd8
commit 52c6ca762a
12 changed files with 156 additions and 91 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: drmP.h,v 1.23 2008/05/06 01:51:00 bjs Exp $ */
/* $NetBSD: drmP.h,v 1.24 2008/05/18 02:45:17 bjs Exp $ */
/* drmP.h -- Private header for Direct Rendering Manager -*- linux-c -*-
* Created: Mon Jan 4 10:05:05 1999 by faith@precisioninsight.com
@ -69,6 +69,7 @@ typedef struct drm_file drm_file_t;
#endif
#include <sys/proc.h>
#include <sys/lock.h>
#include <sys/condvar.h>
#include <sys/fcntl.h>
#include <sys/uio.h>
#include <sys/filio.h>
@ -198,10 +199,31 @@ MALLOC_DECLARE(M_DRM);
#define DRM_DEV_UID 0
#define DRM_DEV_GID 0
#define wait_queue_head_t atomic_t
#define DRM_WAKEUP(w) wakeup((void *)w)
#define DRM_WAKEUP_INT(w) wakeup(w)
#define DRM_INIT_WAITQUEUE(queue) do {(void)(queue);} while (0)
typedef struct drm_wait_queue {
kcondvar_t cv;
kmutex_t lock;
} wait_queue_head_t;
#define DRM_INIT_WAITQUEUE(q) \
{ \
mutex_init(&(q)->lock, MUTEX_DEFAULT, IPL_VM); \
cv_init(&(q)->cv, "drmwtq"); \
}
#define DRM_DESTROY_WAITQUEUE(q) \
{ \
mutex_destroy(&(q)->lock); \
cv_destroy(&(q)->cv); \
}
#define DRM_WAKEUP(q) \
{ \
mutex_enter(&(q)->lock); \
cv_broadcast(&(q)->cv); \
mutex_exit(&(q)->lock); \
}
#define DRM_WAKEUP_INT DRM_WAKEUP
#if defined(__FreeBSD__) && __FreeBSD_version < 502109
#define bus_alloc_resource_any(dev, type, rid, flags) \
@ -230,8 +252,12 @@ MALLOC_DECLARE(M_DRM);
#define DRM_STRUCTPROC struct proc
#define DRM_STRUCTCDEVPROC struct lwp
#define DRM_SPINTYPE kmutex_t
#define DRM_SPININIT(l,name) mutex_init(l, MUTEX_DEFAULT, IPL_VM)
#define DRM_SPINUNINIT(l) mutex_destroy(l)
/*
* XXX unused
* #define DRM_SPININIT(l,name) mutex_init(l, MUTEX_DEFAULT, IPL_VM)
* #define DRM_SPINUNINIT(l) mutex_destroy(l)
*
*/
#define DRM_SPINLOCK(l) mutex_enter(l)
#define DRM_SPINUNLOCK(u) mutex_exit(u)
#define DRM_SPINLOCK_ASSERT(l) mutex_owned(l)
@ -448,7 +474,7 @@ typedef vaddr_t vm_offset_t;
#define le32_to_cpu(x) le32toh(x)
#define DRM_ERR(v) v
#define DRM_HZ hz
#define DRM_HZ mstohz(333)
#define DRM_UDELAY(udelay) DELAY(udelay)
#define DRM_TIME_SLICE (hz/20) /* Time slice for GLXContexts */
@ -504,16 +530,27 @@ for ( ret = 0 ; !ret && !(condition) ; ) { \
DRM_LOCK(); \
}
#elif defined(__NetBSD__)
#define DRM_WAIT_ON( ret, queue, timeout, condition ) \
for ( ret = 0 ; !ret && !(condition) ; ) { \
DRM_UNLOCK(); \
mutex_enter(&dev->irq_lock); \
if (!(condition)) \
ret = mtsleep(&(queue), PZERO | PCATCH, \
"drmwtq", (timeout), &dev->irq_lock); \
mutex_exit(&dev->irq_lock); \
DRM_LOCK(); \
}
#define DRM_WAIT_ON(ret, q, timeout, condition) \
mutex_enter(&(q)->lock); \
while (!(condition)) { \
ret = cv_timedwait_sig(&(q)->cv, &(q)->lock, (timeout)); \
if (ret != 0 && ret != EWOULDBLOCK) { \
ret = EINTR; \
break; \
} else { \
ret = 0; \
} \
} \
mutex_exit(&(q)->lock);
#define DRM_LOCAL_WAIT_ON(ret, mutex, cv) \
do { \
mutex_enter(mutex); \
ret = cv_wait_sig(cv, mutex); \
if (ret != 0 && ret != EWOULDBLOCK) \
ret = EINTR; \
ret = 0; \
mutex_exit(mutex); \
} while (0);
#else
#define DRM_WAIT_ON( ret, queue, timeout, condition ) \
for ( ret = 0 ; !ret && !(condition) ; ) { \
@ -642,7 +679,8 @@ struct drm_file {
typedef struct drm_lock_data {
drm_hw_lock_t *hw_lock; /* Hardware lock */
DRMFILE filp; /* Unique identifier of holding process (NULL is kernel)*/
int lock_queue; /* Queue of blocked processes */
kmutex_t lock_mutex;
kcondvar_t lock_cv; /* Queue of blocked processes */
unsigned long lock_time; /* Time of last lock in jiffies */
} drm_lock_data_t;
@ -908,7 +946,8 @@ struct drm_device {
atomic_t context_flag; /* Context swapping flag */
int last_context; /* Last current context */
int vbl_queue; /* vbl wait channel */
wait_queue_head_t vbl_queue; /* vbl wait channel */
atomic_t vbl_received;
#ifdef __FreeBSD__
@ -926,6 +965,7 @@ struct drm_device {
void *dev_private;
unsigned int agp_buffer_token;
drm_local_map_t *agp_buffer_map;
};
extern int drm_debug_flag;
@ -1148,7 +1188,7 @@ static __inline__ struct drm_local_map *drm_core_findmap(struct drm_device *dev,
DRM_SPINLOCK_ASSERT(&dev->dev_lock);
TAILQ_FOREACH(map, &dev->maplist, link) {
if (map->offset == offset)
if ((map->offset == offset) || (map->offset == DRM_NETBSD_HANDLE2ADDR((uintptr_t)offset)))
return map;
}
return NULL;

View File

@ -1,4 +1,4 @@
/* $NetBSD: drm_dma.c,v 1.5 2007/12/11 11:17:31 lukem Exp $ */
/* $NetBSD: drm_dma.c,v 1.6 2008/05/18 02:45:17 bjs Exp $ */
/* drm_dma.c -- DMA IOCTL and function support -*- linux-c -*-
* Created: Fri Mar 19 14:30:16 1999 by faith@valinux.com
@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: drm_dma.c,v 1.5 2007/12/11 11:17:31 lukem Exp $");
__KERNEL_RCSID(0, "$NetBSD: drm_dma.c,v 1.6 2008/05/18 02:45:17 bjs Exp $");
/*
__FBSDID("$FreeBSD: src/sys/dev/drm/drm_dma.c,v 1.2 2005/11/28 23:13:52 anholt Exp $");
*/
@ -48,7 +48,7 @@ int drm_dma_setup(drm_device_t *dev)
if (dev->dma == NULL)
return DRM_ERR(ENOMEM);
DRM_SPININIT(&dev->dma_lock, "drmdma");
mutex_init(&dev->dma_lock, MUTEX_DEFAULT, IPL_NONE);
return 0;
}
@ -93,7 +93,7 @@ void drm_dma_takedown(drm_device_t *dev)
if (dev->dma)
free(dev->dma, M_DRM);
dev->dma = NULL;
DRM_SPINUNINIT(&dev->dma_lock);
mutex_destroy(&dev->dma_lock);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: drm_drv.c,v 1.12 2008/05/05 14:00:10 jmcneill Exp $ */
/* $NetBSD: drm_drv.c,v 1.13 2008/05/18 02:45:17 bjs Exp $ */
/* drm_drv.h -- Generic driver template -*- linux-c -*-
* Created: Thu Nov 23 03:10:50 2000 by gareth@valinux.com
@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: drm_drv.c,v 1.12 2008/05/05 14:00:10 jmcneill Exp $");
__KERNEL_RCSID(0, "$NetBSD: drm_drv.c,v 1.13 2008/05/18 02:45:17 bjs Exp $");
/*
__FBSDID("$FreeBSD: src/sys/dev/drm/drm_drv.c,v 1.6 2006/09/07 23:04:47 anholt Exp $");
*/
@ -201,7 +201,6 @@ void drm_attach(struct device *kdev, struct pci_attach_args *pa,
/* dev->maplist : drm_load */
dev->context_sareas = NULL;
dev->max_context = 0;
mutex_init(&dev->dev_lock, MUTEX_DEFAULT, IPL_NONE);
dev->dma = NULL;
/* dev->irq : drm_load */
dev->irq_enabled = 0;
@ -235,7 +234,6 @@ void drm_attach(struct device *kdev, struct pci_attach_args *pa,
}
dev->context_flag = 0;
dev->last_context = 0;
dev->vbl_queue = 0;
dev->vbl_received = 0;
dev->buf_pgid = 0;
dev->sysctl = NULL;
@ -329,7 +327,6 @@ static int drm_firstopen(drm_device_t *dev)
dev->magiclist[i].tail = NULL;
}
dev->lock.lock_queue = 0;
dev->irq_enabled = 0;
dev->context_flag = 0;
dev->last_context = 0;
@ -419,7 +416,9 @@ static int drm_lastclose(drm_device_t *dev)
if ( dev->lock.hw_lock ) {
dev->lock.hw_lock = NULL; /* SHM removed */
dev->lock.filp = NULL;
DRM_WAKEUP_INT((void *)&dev->lock.lock_queue);
mutex_enter(&(dev->lock.lock_mutex));
cv_broadcast(&(dev->lock.lock_cv));
mutex_exit(&(dev->lock.lock_mutex));
}
while ((filep = TAILQ_FIRST(&dev->files)) != NULL) {
@ -436,6 +435,12 @@ static int drm_load(drm_device_t *dev)
{
int retcode;
cv_init(&(dev->lock.lock_cv), "drm_cv");
mutex_init(&(dev->lock.lock_mutex), MUTEX_DEFAULT, IPL_NONE);
mutex_init(&(dev->dev_lock), MUTEX_DEFAULT, IPL_NONE);
/*mutex_init(&dev->drw_lock, MUTEX_DEFAULT, IPL_NONE);*/
DRM_DEBUG( "\n" );
dev->irq = dev->pa.pa_intrline;
@ -499,7 +504,10 @@ error:
DRM_LOCK();
drm_lastclose(dev);
DRM_UNLOCK();
DRM_SPINUNINIT(&dev->dev_lock);
cv_destroy(&(dev->lock.lock_cv));
mutex_destroy(&(dev->lock.lock_mutex));
mutex_destroy(&dev->dev_lock);
/*mutex_destroy(&dev->drw_lock);*/
return retcode;
}
@ -551,7 +559,6 @@ static void drm_unload(drm_device_t *dev)
dev->driver.unload(dev);
drm_mem_uninit();
DRM_SPINUNINIT(&dev->dev_lock);
}
@ -654,8 +661,10 @@ int drm_close_pid(drm_device_t *dev, drm_file_t *priv, pid_t pid)
break; /* Got lock */
}
/* Contention */
retcode = mtsleep((void *)&dev->lock.lock_queue,
PZERO | PCATCH, "drmlk2", 0, &dev->dev_lock);
DRM_LOCAL_WAIT_ON(retcode, &dev->dev_lock,
&dev->lock.lock_cv);
if (retcode)
break;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: drm_irq.c,v 1.10 2008/05/06 01:45:47 bjs Exp $ */
/* $NetBSD: drm_irq.c,v 1.11 2008/05/18 02:45:17 bjs Exp $ */
/* drm_irq.c -- IRQ IOCTL and function support
* Created: Fri Oct 18 2003 by anholt@FreeBSD.org
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: drm_irq.c,v 1.10 2008/05/06 01:45:47 bjs Exp $");
__KERNEL_RCSID(0, "$NetBSD: drm_irq.c,v 1.11 2008/05/18 02:45:17 bjs Exp $");
/*
__FBSDID("$FreeBSD: src/sys/dev/drm/drm_irq.c,v 1.2 2005/11/28 23:13:52 anholt Exp $");
*/
@ -68,9 +68,9 @@ drm_irq_handler_wrap(DRM_IRQ_ARGS)
irqreturn_t ret;
drm_device_t *dev = (drm_device_t *)arg;
DRM_SPINLOCK(&dev->irq_lock);
mutex_enter(&dev->irq_lock);
ret = dev->driver.irq_handler(arg);
DRM_SPINUNLOCK(&dev->irq_lock);
mutex_exit(&dev->irq_lock);
return ret;
}
@ -94,7 +94,7 @@ int drm_irq_install(drm_device_t *dev)
dev->context_flag = 0;
DRM_SPININIT(&dev->irq_lock, "DRM IRQ lock");
mutex_init(&dev->irq_lock, MUTEX_DEFAULT, IPL_VM);
/* Before installing handler */
@ -107,7 +107,7 @@ int drm_irq_install(drm_device_t *dev)
goto err;
}
istr = pci_intr_string(dev->pa.pa_pc, ih);
dev->irqh = pci_intr_establish(dev->pa.pa_pc, ih, IPL_TTY,
dev->irqh = pci_intr_establish(dev->pa.pa_pc, ih, IPL_VM,
drm_irq_handler_wrap, dev);
if (!dev->irqh) {
retcode = ENOENT;
@ -124,7 +124,7 @@ int drm_irq_install(drm_device_t *dev)
err:
DRM_LOCK();
dev->irq_enabled = 0;
DRM_SPINUNINIT(&dev->irq_lock);
mutex_destroy(&dev->irq_lock);
DRM_UNLOCK();
return retcode;
}
@ -141,7 +141,7 @@ int drm_irq_uninstall(drm_device_t *dev)
dev->driver.irq_uninstall(dev);
pci_intr_disestablish(dev->pa.pa_pc, dev->irqh);
DRM_SPINUNINIT(&dev->irq_lock);
mutex_destroy(&dev->irq_lock);
return 0;
}
@ -209,9 +209,9 @@ int drm_wait_vblank(DRM_IOCTL_ARGS)
vblwait.reply.sequence = atomic_read(&dev->vbl_received);
DRM_SPINLOCK(&dev->irq_lock);
mutex_enter(&dev->irq_lock);
TAILQ_INSERT_HEAD(&dev->vbl_sig_list, vbl_sig, link);
DRM_SPINUNLOCK(&dev->irq_lock);
mutex_exit(&dev->irq_lock);
ret = 0;
#endif
ret = EINVAL;

View File

@ -1,4 +1,4 @@
/* $NetBSD: drm_lock.c,v 1.5 2007/12/11 11:17:32 lukem Exp $ */
/* $NetBSD: drm_lock.c,v 1.6 2008/05/18 02:45:17 bjs Exp $ */
/* lock.c -- IOCTLs for locking -*- linux-c -*-
* Created: Tue Feb 2 08:37:54 1999 by faith@valinux.com
@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: drm_lock.c,v 1.5 2007/12/11 11:17:32 lukem Exp $");
__KERNEL_RCSID(0, "$NetBSD: drm_lock.c,v 1.6 2008/05/18 02:45:17 bjs Exp $");
/*
__FBSDID("$FreeBSD: src/sys/dev/drm/drm_lock.c,v 1.2 2005/11/28 23:13:52 anholt Exp $");
*/
@ -88,6 +88,7 @@ int drm_lock_free(drm_device_t *dev,
{
unsigned int old, new;
mutex_enter(&dev->lock.lock_mutex);
dev->lock.filp = NULL;
do {
old = *lock;
@ -97,9 +98,11 @@ int drm_lock_free(drm_device_t *dev,
if (_DRM_LOCK_IS_HELD(old) && _DRM_LOCKING_CONTEXT(old) != context) {
DRM_ERROR("%d freed heavyweight lock held by %d\n",
context, _DRM_LOCKING_CONTEXT(old));
mutex_exit(&dev->lock.lock_mutex);
return 1;
}
DRM_WAKEUP_INT((void *)&dev->lock.lock_queue);
cv_broadcast(&(dev->lock.lock_cv));
mutex_exit(&(dev->lock.lock_mutex));
return 0;
}
@ -123,7 +126,7 @@ int drm_lock(DRM_IOCTL_ARGS)
if (dev->driver.use_dma_queue && lock.context < 0)
return EINVAL;
DRM_LOCK();
mutex_enter(&(dev->lock.lock_mutex));
for (;;) {
if (drm_lock_take(&dev->lock.hw_lock->lock, lock.context)) {
dev->lock.filp = (void *)(uintptr_t)DRM_CURRENTPID;
@ -133,12 +136,13 @@ int drm_lock(DRM_IOCTL_ARGS)
}
/* Contention */
ret = mtsleep((void *)&dev->lock.lock_queue, PZERO | PCATCH,
"drmlk2", 0, &dev->dev_lock);
if (ret != 0)
ret = cv_wait_sig(&(dev->lock.lock_cv), &(dev->lock.lock_mutex));
if (ret != 0) {
mutex_exit(&(dev->lock.lock_mutex));
break;
}
DRM_UNLOCK();
}
mutex_exit(&(dev->lock.lock_mutex));
DRM_DEBUG("%d %s\n", lock.context, ret ? "interrupted" : "has lock");
if (ret != 0)

View File

@ -1,4 +1,4 @@
/* $NetBSD: i915_irq.c,v 1.3 2007/12/15 00:39:30 perry Exp $ */
/* $NetBSD: i915_irq.c,v 1.4 2008/05/18 02:45:17 bjs Exp $ */
/* i915_irq.c -- IRQ support for the I915 -*- linux-c -*-
*/
@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: i915_irq.c,v 1.3 2007/12/15 00:39:30 perry Exp $");
__KERNEL_RCSID(0, "$NetBSD: i915_irq.c,v 1.4 2008/05/18 02:45:17 bjs Exp $");
/*
__FBSDID("$FreeBSD: src/sys/dev/drm/i915_irq.c,v 1.4 2006/09/07 23:04:47 anholt Exp $");
*/
@ -67,11 +67,11 @@ irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS)
dev_priv->sarea_priv->last_dispatch = READ_BREADCRUMB(dev_priv);
if (temp & USER_INT_FLAG)
DRM_WAKEUP(&dev_priv->irq_queue);
DRM_WAKEUP(&(dev_priv->irq_queue));
if (temp & (VSYNC_PIPEA_FLAG | VSYNC_PIPEB_FLAG)) {
atomic_inc(&dev->vbl_received);
DRM_WAKEUP(&dev->vbl_queue);
DRM_WAKEUP(&(dev->vbl_queue));
drm_vbl_send_signals(dev);
}
@ -121,7 +121,7 @@ static int i915_wait_irq(drm_device_t * dev, int irq_nr)
dev_priv->sarea_priv->perf_boxes |= I915_BOX_WAIT;
DRM_WAIT_ON(ret, dev_priv->irq_queue, 3 * DRM_HZ,
DRM_WAIT_ON(ret, &(dev_priv->irq_queue), 3 * DRM_HZ,
READ_BREADCRUMB(dev_priv) >= irq_nr);
if (ret == DRM_ERR(EBUSY)) {
@ -145,7 +145,7 @@ int i915_driver_vblank_wait(drm_device_t *dev, unsigned int *sequence)
return DRM_ERR(EINVAL);
}
DRM_WAIT_ON(ret, dev->vbl_queue, 3 * DRM_HZ,
DRM_WAIT_ON(ret, &(dev->vbl_queue), 3 * DRM_HZ,
(((cur_vblank = atomic_read(&dev->vbl_received))
- *sequence) <= (1<<23)));
@ -280,7 +280,7 @@ void i915_driver_irq_postinstall(drm_device_t * dev)
drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
i915_enable_interrupt(dev);
DRM_INIT_WAITQUEUE(&dev_priv->irq_queue);
DRM_INIT_WAITQUEUE(&(dev_priv->irq_queue));
}
void i915_driver_irq_uninstall(drm_device_t * dev)
@ -296,4 +296,5 @@ void i915_driver_irq_uninstall(drm_device_t * dev)
temp = I915_READ16(I915REG_INT_IDENTITY_R);
I915_WRITE16(I915REG_INT_IDENTITY_R, temp);
DRM_DESTROY_WAITQUEUE(&(dev_priv->irq_queue));
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: mach64_irq.c,v 1.3 2007/12/11 11:48:42 lukem Exp $ */
/* $NetBSD: mach64_irq.c,v 1.4 2008/05/18 02:45:17 bjs Exp $ */
/* mach64_irq.c -- IRQ handling for ATI Mach64 -*- linux-c -*-
* Created: Tue Feb 25, 2003 by Leif Delgass, based on radeon_irq.c/r128_irq.c
@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mach64_irq.c,v 1.3 2007/12/11 11:48:42 lukem Exp $");
__KERNEL_RCSID(0, "$NetBSD: mach64_irq.c,v 1.4 2008/05/18 02:45:17 bjs Exp $");
/*
__FBSDID("$FreeBSD: src/sys/dev/drm/mach64_irq.c,v 1.2 2005/11/28 23:13:53 anholt Exp $");
*/
@ -71,7 +71,7 @@ irqreturn_t mach64_driver_irq_handler(DRM_IRQ_ARGS)
| MACH64_CRTC_VBLANK_INT);
atomic_inc(&dev->vbl_received);
DRM_WAKEUP(&dev->vbl_queue);
DRM_WAKEUP(&(dev->vbl_queue));
drm_vbl_send_signals(dev);
return IRQ_HANDLED;
}
@ -87,7 +87,7 @@ int mach64_driver_vblank_wait(drm_device_t * dev, unsigned int *sequence)
* by about a day rather than she wants to wait for years
* using vertical blanks...
*/
DRM_WAIT_ON(ret, dev->vbl_queue, 3 * DRM_HZ,
DRM_WAIT_ON(ret, &(dev->vbl_queue), 3 * DRM_HZ,
(((cur_vblank = atomic_read(&dev->vbl_received))
- *sequence) <= (1 << 23)));

View File

@ -1,4 +1,4 @@
/* $NetBSD: mga_irq.c,v 1.3 2007/12/11 11:48:43 lukem Exp $ */
/* $NetBSD: mga_irq.c,v 1.4 2008/05/18 02:45:17 bjs Exp $ */
/* mga_irq.c -- IRQ handling for radeon -*- linux-c -*-
*/
@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mga_irq.c,v 1.3 2007/12/11 11:48:43 lukem Exp $");
__KERNEL_RCSID(0, "$NetBSD: mga_irq.c,v 1.4 2008/05/18 02:45:17 bjs Exp $");
/*
__FBSDID("$FreeBSD: src/sys/dev/drm/mga_irq.c,v 1.6 2005/11/28 23:13:53 anholt Exp $");
*/
@ -57,7 +57,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
if (status & MGA_VLINEPEN) {
MGA_WRITE(MGA_ICLEAR, MGA_VLINEICLR);
atomic_inc(&dev->vbl_received);
DRM_WAKEUP(&dev->vbl_queue);
DRM_WAKEUP(&(dev->vbl_queue));
drm_vbl_send_signals(dev);
handled = 1;
}
@ -78,7 +78,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
}
atomic_inc(&dev_priv->last_fence_retired);
DRM_WAKEUP(&dev_priv->fence_queue);
DRM_WAKEUP(&(dev_priv->fence_queue));
handled = 1;
}
@ -97,7 +97,7 @@ int mga_driver_vblank_wait(drm_device_t * dev, unsigned int *sequence)
* by about a day rather than she wants to wait for years
* using vertical blanks...
*/
DRM_WAIT_ON(ret, dev->vbl_queue, 3 * DRM_HZ,
DRM_WAIT_ON(ret, &(dev->vbl_queue), 3 * DRM_HZ,
(((cur_vblank = atomic_read(&dev->vbl_received))
- *sequence) <= (1 << 23)));
@ -116,7 +116,7 @@ int mga_driver_fence_wait(drm_device_t * dev, unsigned int *sequence)
* by about a day rather than she wants to wait for years
* using fences.
*/
DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * DRM_HZ,
DRM_WAIT_ON(ret, &(dev_priv->fence_queue), 3 * DRM_HZ,
(((cur_fence = atomic_read(&dev_priv->last_fence_retired))
- *sequence) <= (1 << 23)));
@ -139,7 +139,7 @@ void mga_driver_irq_postinstall(drm_device_t * dev)
{
drm_mga_private_t *dev_priv = (drm_mga_private_t *) dev->dev_private;
DRM_INIT_WAITQUEUE( &dev_priv->fence_queue );
DRM_INIT_WAITQUEUE( &(dev_priv->fence_queue) );
/* Turn on vertical blank interrupt and soft trap interrupt. */
MGA_WRITE(MGA_IEN, MGA_VLINEIEN | MGA_SOFTRAPEN);
@ -153,6 +153,7 @@ void mga_driver_irq_uninstall(drm_device_t * dev)
/* Disable *all* interrupts */
MGA_WRITE(MGA_IEN, 0);
DRM_DESTROY_WAITQUEUE(&(dev_priv->fence_queue));
dev->irq_enabled = 0;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: r128_irq.c,v 1.3 2007/12/11 11:48:44 lukem Exp $ */
/* $NetBSD: r128_irq.c,v 1.4 2008/05/18 02:45:17 bjs Exp $ */
/* r128_irq.c -- IRQ handling for radeon -*- linux-c -*-
*/
@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: r128_irq.c,v 1.3 2007/12/11 11:48:44 lukem Exp $");
__KERNEL_RCSID(0, "$NetBSD: r128_irq.c,v 1.4 2008/05/18 02:45:17 bjs Exp $");
/*
__FBSDID("$FreeBSD: src/sys/dev/drm/r128_irq.c,v 1.6 2005/11/28 23:13:53 anholt Exp $");
*/
@ -72,7 +72,7 @@ int r128_driver_vblank_wait(drm_device_t * dev, unsigned int *sequence)
* by about a day rather than she wants to wait for years
* using vertical blanks...
*/
DRM_WAIT_ON(ret, dev->vbl_queue, 3 * DRM_HZ,
DRM_WAIT_ON(ret, &(dev->vbl_queue), 3 * DRM_HZ,
(((cur_vblank = atomic_read(&dev->vbl_received))
- *sequence) <= (1 << 23)));

View File

@ -1,4 +1,4 @@
/* $NetBSD: radeon_irq.c,v 1.4 2007/12/15 00:39:33 perry Exp $ */
/* $NetBSD: radeon_irq.c,v 1.5 2008/05/18 02:45:17 bjs Exp $ */
/* radeon_irq.c -- IRQ handling for radeon -*- linux-c -*- */
/*-
@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: radeon_irq.c,v 1.4 2007/12/15 00:39:33 perry Exp $");
__KERNEL_RCSID(0, "$NetBSD: radeon_irq.c,v 1.5 2008/05/18 02:45:17 bjs Exp $");
/*
__FBSDID("$FreeBSD: src/sys/dev/drm/radeon_irq.c,v 1.7 2005/11/28 23:13:54 anholt Exp $");
*/
@ -87,13 +87,13 @@ irqreturn_t radeon_driver_irq_handler(DRM_IRQ_ARGS)
/* SW interrupt */
if (stat & RADEON_SW_INT_TEST) {
DRM_WAKEUP(&dev_priv->swi_queue);
DRM_WAKEUP(&(dev_priv->swi_queue));
}
/* VBLANK interrupt */
if (stat & RADEON_CRTC_VBLANK_STAT) {
atomic_inc(&dev->vbl_received);
DRM_WAKEUP(&dev->vbl_queue);
DRM_WAKEUP(&(dev->vbl_queue));
drm_vbl_send_signals(dev);
}
@ -129,7 +129,7 @@ static int radeon_wait_irq(drm_device_t * dev, int swi_nr)
dev_priv->stats.boxes |= RADEON_BOX_WAIT_IDLE;
DRM_WAIT_ON(ret, dev_priv->swi_queue, 3 * DRM_HZ,
DRM_WAIT_ON(ret, &(dev_priv->swi_queue), 3 * DRM_HZ,
RADEON_READ(RADEON_LAST_SWI_REG) >= swi_nr);
return ret;
@ -155,7 +155,7 @@ int radeon_driver_vblank_wait(drm_device_t * dev, unsigned int *sequence)
* by about a day rather than she wants to wait for years
* using vertical blanks...
*/
DRM_WAIT_ON(ret, dev->vbl_queue, 3 * DRM_HZ,
DRM_WAIT_ON(ret, &(dev->vbl_queue), 3 * DRM_HZ,
(((cur_vblank = atomic_read(&dev->vbl_received))
- *sequence) <= (1 << 23)));
@ -233,7 +233,7 @@ void radeon_driver_irq_postinstall(drm_device_t * dev)
(drm_radeon_private_t *) dev->dev_private;
atomic_set(&dev_priv->swi_emitted, 0);
DRM_INIT_WAITQUEUE(&dev_priv->swi_queue);
DRM_INIT_WAITQUEUE(&(dev_priv->swi_queue));
/* Turn on SW and VBL ints */
RADEON_WRITE(RADEON_GEN_INT_CNTL,
@ -249,4 +249,5 @@ void radeon_driver_irq_uninstall(drm_device_t * dev)
/* Disable *all* interrupts */
RADEON_WRITE(RADEON_GEN_INT_CNTL, 0);
DRM_DESTROY_WAITQUEUE(&(dev_priv->swi_queue));
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: via_irq.c,v 1.3 2007/12/15 00:39:34 perry Exp $ */
/* $NetBSD: via_irq.c,v 1.4 2008/05/18 02:45:17 bjs Exp $ */
/* via_irq.c
*
@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: via_irq.c,v 1.3 2007/12/15 00:39:34 perry Exp $");
__KERNEL_RCSID(0, "$NetBSD: via_irq.c,v 1.4 2008/05/18 02:45:17 bjs Exp $");
#include <dev/drm/drmP.h>
#include <dev/drm/drm.h>
@ -142,7 +142,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
for (i=0; i<dev_priv->num_irqs; ++i) {
if (status & cur_irq->pending_mask) {
atomic_inc( &cur_irq->irq_received );
DRM_WAKEUP( &cur_irq->irq_queue );
DRM_WAKEUP( &(cur_irq->irq_queue) );
handled = 1;
#ifdef VIA_HAVE_DMABLIT
if (dev_priv->irq_map[drm_via_irq_dma0_td] == i) {
@ -196,7 +196,7 @@ int via_driver_vblank_wait(drm_device_t * dev, unsigned int *sequence)
* using vertical blanks...
*/
DRM_WAIT_ON(ret, dev->vbl_queue, 3 * DRM_HZ,
DRM_WAIT_ON(ret, &(dev->vbl_queue), 3 * DRM_HZ,
(((cur_vblank = atomic_read(&dev->vbl_received)) -
*sequence) <= (1 << 23)));
@ -240,12 +240,12 @@ via_driver_irq_wait(drm_device_t * dev, unsigned int irq, int force_sequence,
cur_irq = dev_priv->via_irqs + real_irq;
if (masks[real_irq][2] && !force_sequence) {
DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
DRM_WAIT_ON(ret, &(cur_irq->irq_queue), 3 * DRM_HZ,
((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
masks[irq][4]));
cur_irq_sequence = atomic_read(&cur_irq->irq_received);
} else {
DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
DRM_WAIT_ON(ret, &(cur_irq->irq_queue), 3 * DRM_HZ,
(((cur_irq_sequence =
atomic_read(&cur_irq->irq_received)) -
*sequence) <= (1 << 23)));
@ -288,7 +288,7 @@ void via_driver_irq_preinstall(drm_device_t * dev)
atomic_set(&cur_irq->irq_received, 0);
cur_irq->enable_mask = dev_priv->irq_masks[i][0];
cur_irq->pending_mask = dev_priv->irq_masks[i][1];
DRM_INIT_WAITQUEUE( &cur_irq->irq_queue );
DRM_INIT_WAITQUEUE( &(cur_irq->irq_queue) );
dev_priv->irq_enable_mask |= cur_irq->enable_mask;
dev_priv->irq_pending_mask |= cur_irq->pending_mask;
cur_irq++;
@ -330,7 +330,9 @@ void via_driver_irq_postinstall(drm_device_t * dev)
void via_driver_irq_uninstall(drm_device_t * dev)
{
drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
drm_via_irq_t *cur_irq;
u32 status;
int i;
DRM_DEBUG("driver_irq_uninstall)\n");
if (dev_priv) {
@ -343,6 +345,12 @@ void via_driver_irq_uninstall(drm_device_t * dev)
status = VIA_READ(VIA_REG_INTERRUPT);
VIA_WRITE(VIA_REG_INTERRUPT, status &
~(VIA_IRQ_VBLANK_ENABLE | dev_priv->irq_enable_mask));
cur_irq = dev_priv->via_irqs;
for(i = 0; i < dev_priv->num_irqs; ++i) {
DRM_DESTROY_WAITQUEUE(&(cur_irq->irq_queue));
cur_irq++;
}
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: via_video.c,v 1.3 2007/12/15 00:39:35 perry Exp $ */
/* $NetBSD: via_video.c,v 1.4 2008/05/18 02:45:17 bjs Exp $ */
/*
* Copyright 2005 Thomas Hellstrom. All Rights Reserved.
@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: via_video.c,v 1.3 2007/12/15 00:39:35 perry Exp $");
__KERNEL_RCSID(0, "$NetBSD: via_video.c,v 1.4 2008/05/18 02:45:17 bjs Exp $");
#include <dev/drm/drmP.h>
#include <dev/pci/drm/via_drm.h>
@ -67,6 +67,7 @@ void via_release_futex(drm_via_private_t * dev_priv, int context)
}
*lock = 0;
}
DRM_DESTROY_WAITQUEUE(&(dev_priv->decoder_queue[i]));
}
}
@ -91,7 +92,7 @@ int via_decoder_futex(DRM_IOCTL_ARGS)
switch (fx.func) {
case VIA_FUTEX_WAIT:
DRM_WAIT_ON(ret, dev_priv->decoder_queue[fx.lock],
DRM_WAIT_ON(ret, &(dev_priv->decoder_queue[fx.lock]),
(fx.ms / 10) * (DRM_HZ / 100), *lock != fx.val);
return ret;
case VIA_FUTEX_WAKE: