summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorOwain Ainsworth <oga@cvs.openbsd.org>2009-04-03 11:31:37 +0000
committerOwain Ainsworth <oga@cvs.openbsd.org>2009-04-03 11:31:37 +0000
commitc869e9dab9822b474b8d72c4bb9fe9ec3547f8d3 (patch)
tree06a2db2670456294b364b33e24896fb5332cbfea /sys/dev
parent70411cf63903f9756f566a59c36c13284cd44715 (diff)
Convert DRM_WAIT_ON to take additional parameters, the wmsg for msleep,
and the lock to manipulate. first step of removing drm_irq_handler_wrap which just grabs the irq_lock, and eventually irq_lock. drivers should manage their own.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/pci/drm/drmP.h20
-rw-r--r--sys/dev/pci/drm/drm_irq.c13
-rw-r--r--sys/dev/pci/drm/i915_irq.c36
-rw-r--r--sys/dev/pci/drm/mga_irq.c30
-rw-r--r--sys/dev/pci/drm/radeon_irq.c11
5 files changed, 51 insertions, 59 deletions
diff --git a/sys/dev/pci/drm/drmP.h b/sys/dev/pci/drm/drmP.h
index 10aa28c9245..43d3fd77d84 100644
--- a/sys/dev/pci/drm/drmP.h
+++ b/sys/dev/pci/drm/drmP.h
@@ -164,7 +164,6 @@ typedef u_int8_t u8;
#define le32_to_cpu(x) letoh32(x)
#define cpu_to_le32(x) htole32(x)
-#define DRM_HZ hz
#define DRM_UDELAY(udelay) DELAY(udelay)
#define LOCK_TEST_WITH_RETURN(dev, file_priv) \
@@ -177,15 +176,16 @@ do { \
} \
} while (0)
-#define DRM_WAIT_ON( ret, queue, timeout, condition ) \
-mtx_enter(&dev->irq_lock); \
-while ( ret == 0 ) { \
- if (condition) \
- break; \
- ret = msleep((queue), &dev->irq_lock, \
- PZERO | PCATCH, "drmwtq", (timeout)); \
-} \
-mtx_leave(&dev->irq_lock)
+#define DRM_WAIT_ON(ret, queue, lock, timeout, msg, condition ) do { \
+ mtx_enter(lock); \
+ while ((ret) == 0) { \
+ if (condition) \
+ break; \
+ ret = msleep((queue), (lock), PZERO | PCATCH, \
+ (msg), (timeout)); \
+ } \
+ mtx_leave(lock); \
+} while (/* CONSTCOND */ 0)
#define DRM_ERROR(fmt, arg...) \
printf("error: [" DRM_NAME ":pid%d:%s] *ERROR* " fmt, \
diff --git a/sys/dev/pci/drm/drm_irq.c b/sys/dev/pci/drm/drm_irq.c
index 2a0f7cf592c..9d72580e3d1 100644
--- a/sys/dev/pci/drm/drm_irq.c
+++ b/sys/dev/pci/drm/drm_irq.c
@@ -346,16 +346,9 @@ drm_wait_vblank(struct drm_device *dev, void *data, struct drm_file *file_priv)
if (flags & _DRM_VBLANK_SIGNAL) {
ret = EINVAL;
} else {
- mtx_enter(&dev->vbl_lock);
- while (ret == 0) {
- if ((drm_vblank_count(dev, crtc)
- - vblwait->request.sequence) <= (1 << 23))
- break;
- ret = msleep(&dev->vblank[crtc],
- &dev->vbl_lock, PZERO | PCATCH,
- "drmvblq", 3 * DRM_HZ);
- }
- mtx_leave(&dev->vbl_lock);
+ DRM_WAIT_ON(ret, &dev->vblank[crtc], &dev->vbl_lock, 3 * hz,
+ "drmvblq", (drm_vblank_count(dev, crtc) -
+ vblwait->request.sequence) <= (1 << 23));
if (ret != EINTR) {
struct timeval now;
diff --git a/sys/dev/pci/drm/i915_irq.c b/sys/dev/pci/drm/i915_irq.c
index 71bc282cbd0..6aa8541d9f0 100644
--- a/sys/dev/pci/drm/i915_irq.c
+++ b/sys/dev/pci/drm/i915_irq.c
@@ -159,13 +159,13 @@ i915_pipe_enabled(struct drm_device *dev, int pipe)
return 0;
}
-u32 i915_get_vblank_counter(struct drm_device *dev, int plane)
+u_int32_t
+i915_get_vblank_counter(struct drm_device *dev, int plane)
{
- drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
- unsigned long high_frame;
- unsigned long low_frame;
- u32 high1, high2, low, count;
- int pipe;
+ drm_i915_private_t *dev_priv = dev->dev_private;
+ bus_size_t high_frame, low_frame;
+ u_int32_t high1, high2, low;
+ int pipe;
pipe = i915_get_pipe(dev, plane);
high_frame = pipe ? PIPEBFRAMEHIGH : PIPEAFRAMEHIGH;
@@ -174,7 +174,7 @@ u32 i915_get_vblank_counter(struct drm_device *dev, int plane)
if (!i915_pipe_enabled(dev, pipe)) {
DRM_DEBUG("trying to get vblank count for disabled pipe %d\n",
pipe);
- return 0;
+ return (0);
}
/*
@@ -191,12 +191,11 @@ u32 i915_get_vblank_counter(struct drm_device *dev, int plane)
PIPE_FRAME_HIGH_SHIFT);
} while (high1 != high2);
- count = (high1 << 8) | low;
-
- return count;
+ return ((high1 << 8) | low);
}
-irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS)
+irqreturn_t
+i915_driver_irq_handler(DRM_IRQ_ARGS)
{
struct drm_device *dev = (struct drm_device *)arg;
drm_i915_private_t *dev_priv = (drm_i915_private_t *)dev->dev_private;
@@ -281,10 +280,11 @@ void i915_user_irq_put(struct drm_device *dev)
}
-int i915_wait_irq(struct drm_device * dev, int irq_nr)
+int
+i915_wait_irq(struct drm_device *dev, int irq_nr)
{
- drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
- int ret = 0;
+ drm_i915_private_t *dev_priv = dev->dev_private;
+ int ret = 0;
DRM_DEBUG("irq_nr=%d breadcrumb=%d\n", irq_nr,
READ_BREADCRUMB(dev_priv));
@@ -294,12 +294,12 @@ int i915_wait_irq(struct drm_device * dev, int irq_nr)
dev_priv->sarea_priv->last_dispatch =
READ_BREADCRUMB(dev_priv);
}
- return 0;
+ return (0);
}
i915_user_irq_get(dev);
- DRM_WAIT_ON(ret, dev_priv, 3 * DRM_HZ,
- READ_BREADCRUMB(dev_priv) >= irq_nr);
+ DRM_WAIT_ON(ret, dev_priv, &dev->irq_lock, 3 * hz, "i915wt",
+ READ_BREADCRUMB(dev_priv) >= irq_nr);
i915_user_irq_put(dev);
if (ret == EBUSY) {
@@ -309,7 +309,7 @@ int i915_wait_irq(struct drm_device * dev, int irq_nr)
if (dev_priv->sarea_priv != NULL)
dev_priv->sarea_priv->last_dispatch = READ_BREADCRUMB(dev_priv);
- return ret;
+ return (ret);
}
/* Needs the lock as it touches the ring.
diff --git a/sys/dev/pci/drm/mga_irq.c b/sys/dev/pci/drm/mga_irq.c
index 441948836c4..0d3bdac8730 100644
--- a/sys/dev/pci/drm/mga_irq.c
+++ b/sys/dev/pci/drm/mga_irq.c
@@ -36,26 +36,26 @@
#include "mga_drm.h"
#include "mga_drv.h"
-u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
+u_int32_t
+mga_get_vblank_counter(struct drm_device *dev, int crtc)
{
- const drm_mga_private_t *const dev_priv =
- (drm_mga_private_t *) dev->dev_private;
+ const drm_mga_private_t *const dev_priv = dev->dev_private;
if (crtc != 0) {
- return 0;
+ return (0);
}
- return atomic_read(&dev_priv->vbl_received);
+ return (atomic_read(&dev_priv->vbl_received));
}
-irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
+irqreturn_t
+mga_driver_irq_handler(DRM_IRQ_ARGS)
{
- struct drm_device *dev = (struct drm_device *) arg;
- drm_mga_private_t *dev_priv = (drm_mga_private_t *) dev->dev_private;
- int status;
- int handled = 0;
+ struct drm_device *dev = arg;
+ drm_mga_private_t *dev_priv = dev->dev_private;
+ int status, handled = 0;
status = MGA_READ(MGA_STATUS);
@@ -88,8 +88,8 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
}
if (handled)
- return IRQ_HANDLED;
- return IRQ_NONE;
+ return (IRQ_HANDLED);
+ return (IRQ_NONE);
}
int mga_enable_vblank(struct drm_device *dev, int crtc)
@@ -132,9 +132,9 @@ int mga_driver_fence_wait(struct drm_device * dev, unsigned int *sequence)
* by about a day rather than she wants to wait for years
* using fences.
*/
- DRM_WAIT_ON(ret, dev_priv, 3 * DRM_HZ,
- (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
- - *sequence) <= (1 << 23)));
+ DRM_WAIT_ON(ret, dev_priv, &dev->irq_lock, 3 * hz, "mgawt",
+ (((cur_fence = atomic_read(&dev_priv->last_fence_retired)) -
+ *sequence) <= (1 << 23)));
*sequence = cur_fence;
diff --git a/sys/dev/pci/drm/radeon_irq.c b/sys/dev/pci/drm/radeon_irq.c
index 0ebfabcec27..ec407aeeebc 100644
--- a/sys/dev/pci/drm/radeon_irq.c
+++ b/sys/dev/pci/drm/radeon_irq.c
@@ -245,17 +245,16 @@ radeon_emit_irq(struct drm_device * dev)
int
radeon_wait_irq(struct drm_device * dev, int swi_nr)
{
- drm_radeon_private_t *dev_priv =
- (drm_radeon_private_t *) dev->dev_private;
- int ret = 0;
+ drm_radeon_private_t *dev_priv = dev->dev_private;
+ int ret = 0;
if (RADEON_READ(RADEON_LAST_SWI_REG) >= swi_nr)
return 0;
- DRM_WAIT_ON(ret, dev_priv, 3 * DRM_HZ,
- RADEON_READ(RADEON_LAST_SWI_REG) >= swi_nr);
+ DRM_WAIT_ON(ret, dev_priv, &dev->irq_lock, 3 * hz, "rdnwt",
+ RADEON_READ(RADEON_LAST_SWI_REG) >= swi_nr);
- return ret;
+ return (ret);
}
u32 radeon_get_vblank_counter(struct drm_device *dev, int crtc)