summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorJonathan Gray <jsg@jsg.id.au>2013-03-12 15:10:26 +1100
committerJonathan Gray <jsg@jsg.id.au>2013-03-12 15:10:26 +1100
commit1889b19e74310395d5f3a42ae382eb3e33bb7cd0 (patch)
treeb2a21418d9bb63399f3008360c2fc6c1d0001b58 /sys/dev
parent8fd957708b975362f6119aec15945e0bd01cacab (diff)
move ring_wait_for_space closer to 3.8.2
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/pci/drm/drmP.h1
-rw-r--r--sys/dev/pci/drm/intel_ringbuffer.c13
2 files changed, 8 insertions, 6 deletions
diff --git a/sys/dev/pci/drm/drmP.h b/sys/dev/pci/drm/drmP.h
index 0b04858cd12..1b828a2a21a 100644
--- a/sys/dev/pci/drm/drmP.h
+++ b/sys/dev/pci/drm/drmP.h
@@ -121,6 +121,7 @@
#define roundup2(x, y) (((x)+((y)-1))&(~((y)-1))) /* if y is powers of two */
#define jiffies_to_msecs(x) (((int64_t)(x)) * 1000 / hz)
#define msecs_to_jiffies(x) (((int64_t)(x)) * hz / 1000)
+#define time_after(a,b) ((long)(b) - (long)(a) < 0)
#define time_after_eq(a,b) ((long)(b) - (long)(a) <= 0)
#define drm_msleep(x, msg) delay(x * 1000)
diff --git a/sys/dev/pci/drm/intel_ringbuffer.c b/sys/dev/pci/drm/intel_ringbuffer.c
index e9b5f0f1686..bac97527d2c 100644
--- a/sys/dev/pci/drm/intel_ringbuffer.c
+++ b/sys/dev/pci/drm/intel_ringbuffer.c
@@ -94,6 +94,8 @@ int blt_ring_flush(struct intel_ring_buffer *, u32, u32);
int intel_ring_flush_all_caches(struct intel_ring_buffer *);
int intel_ring_invalidate_all_caches(struct intel_ring_buffer *);
+extern int ticks;
+
static inline int
ring_space(struct intel_ring_buffer *ring)
{
@@ -1449,8 +1451,8 @@ ring_wait_for_space(struct intel_ring_buffer *ring, int n)
{
struct drm_device *dev = ring->dev;
drm_i915_private_t *dev_priv = dev->dev_private;
-// unsigned long end;
- int ret, i;
+ unsigned long end;
+ int ret;
ret = intel_ring_wait_request(ring, n);
if (ret != -ENOSPC)
@@ -1462,10 +1464,9 @@ ring_wait_for_space(struct intel_ring_buffer *ring, int n)
* to running on almost untested codepaths). But on resume
* timers don't work yet, so prevent a complete hang in that
* case by choosing an insanely large timeout. */
-// end = jiffies + 60 * HZ;
+ end = ticks + 60 * hz;
- /* ugh. Could really do with a proper, resettable timer here. */
- for (i = 0; i < 100000; i++) {
+ do {
ring->head = I915_READ_HEAD(ring);
ring->space = ring_space(ring);
if (ring->space >= n) {
@@ -1486,7 +1487,7 @@ ring_wait_for_space(struct intel_ring_buffer *ring, int n)
ret = i915_gem_check_wedge(dev_priv, dev_priv->mm.interruptible);
if (ret)
return ret;
- }
+ } while (!time_after(ticks, end));
// trace_i915_ring_wait_end(ring);
return -EBUSY;
}