summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2013-11-19 15:08:05 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2013-11-19 15:08:05 +0000
commitfa9928be69386bf677e21a31cadcdb02cd93b28f (patch)
treef771b9b5118da5a56050ad1f18c03d2e41332e32
parentd83c65d8e585fa04420ab6cb0ec011eacd86aa36 (diff)
backout the DRM_IOCTL_I915_GEM_WAIT commit
it seems to leave X unuseable on resume on at least snb/ivb ok kettenis@
-rw-r--r--sys/dev/pci/drm/i915/i915_drv.c4
-rw-r--r--sys/dev/pci/drm/i915/i915_drv.h3
-rw-r--r--sys/dev/pci/drm/i915/i915_gem.c174
-rw-r--r--sys/dev/pci/drm/i915/i915_trace.h12
-rw-r--r--sys/dev/pci/drm/i915/intel_ringbuffer.c34
5 files changed, 44 insertions, 183 deletions
diff --git a/sys/dev/pci/drm/i915/i915_drv.c b/sys/dev/pci/drm/i915/i915_drv.c
index e21b3689217..e5b3df275ae 100644
--- a/sys/dev/pci/drm/i915/i915_drv.c
+++ b/sys/dev/pci/drm/i915/i915_drv.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: i915_drv.c,v 1.48 2013/11/17 20:04:47 kettenis Exp $ */
+/* $OpenBSD: i915_drv.c,v 1.49 2013/11/19 15:08:03 jsg Exp $ */
/*
* Copyright (c) 2008-2009 Owain G. Ainsworth <oga@openbsd.org>
*
@@ -1187,8 +1187,6 @@ inteldrm_doioctl(struct drm_device *dev, u_long cmd, caddr_t data,
case DRM_IOCTL_I915_GEM_GET_CACHING:
return (i915_gem_get_caching_ioctl(dev, data,
file_priv));
- case DRM_IOCTL_I915_GEM_WAIT:
- return (i915_gem_wait_ioctl(dev, data, file_priv));
case DRM_IOCTL_I915_GEM_CONTEXT_CREATE:
return (i915_gem_context_create_ioctl(dev, data,
file_priv));
diff --git a/sys/dev/pci/drm/i915/i915_drv.h b/sys/dev/pci/drm/i915/i915_drv.h
index a0fd90a4b0d..b9fd5171ee3 100644
--- a/sys/dev/pci/drm/i915/i915_drv.h
+++ b/sys/dev/pci/drm/i915/i915_drv.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: i915_drv.h,v 1.34 2013/11/17 20:04:47 kettenis Exp $ */
+/* $OpenBSD: i915_drv.h,v 1.35 2013/11/19 15:08:04 jsg Exp $ */
/* i915_drv.h -- Private header for the I915 driver -*- linux-c -*-
*/
/*
@@ -1102,7 +1102,6 @@ int i915_gem_get_caching_ioctl(struct drm_device *, void *,
struct drm_file *);
int i915_gem_set_caching_ioctl(struct drm_device *, void *,
struct drm_file *);
-int i915_gem_wait_ioctl(struct drm_device *, void *, struct drm_file *);
/* GEM memory manager functions */
int i915_gem_init_object(struct drm_obj *);
diff --git a/sys/dev/pci/drm/i915/i915_gem.c b/sys/dev/pci/drm/i915/i915_gem.c
index 36140f91e91..ae782304836 100644
--- a/sys/dev/pci/drm/i915/i915_gem.c
+++ b/sys/dev/pci/drm/i915/i915_gem.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: i915_gem.c,v 1.43 2013/11/17 18:47:13 kettenis Exp $ */
+/* $OpenBSD: i915_gem.c,v 1.44 2013/11/19 15:08:04 jsg Exp $ */
/*
* Copyright (c) 2008-2009 Owain G. Ainsworth <oga@openbsd.org>
*
@@ -52,7 +52,6 @@
#include <sys/queue.h>
#include <sys/task.h>
-#include <sys/time.h>
static void i915_gem_object_flush_gtt_write_domain(struct drm_i915_gem_object *obj);
static void i915_gem_object_flush_cpu_write_domain(struct drm_i915_gem_object *obj);
@@ -79,11 +78,6 @@ static void i915_gem_shrink_all(struct drm_i915_private *dev_priv);
#endif
static void i915_gem_object_truncate(struct drm_i915_gem_object *obj);
-static inline int timespec_to_jiffies(const struct timespec *);
-static inline int timespec_valid(const struct timespec *);
-static struct timespec ns_to_timespec(const int64_t);
-static inline int64_t timespec_to_ns(const struct timespec *);
-
extern int ticks;
static inline void i915_gem_object_fence_lost(struct drm_i915_gem_object *obj)
@@ -1046,99 +1040,28 @@ i915_gem_check_olr(struct intel_ring_buffer *ring, u32 seqno)
static int __wait_seqno(struct intel_ring_buffer *ring, u32 seqno,
bool interruptible, struct timespec *timeout)
{
- drm_i915_private_t *dev_priv = ring->dev->dev_private;
- struct timespec before, now, wait_time={1,0};
- struct timespec sleep_time;
- unsigned long timeout_jiffies;
- long end;
- bool wait_forever = true;
- int ret;
-
- if (i915_seqno_passed(ring->get_seqno(ring, true), seqno))
- return 0;
-
- trace_i915_gem_request_wait_begin(ring, seqno);
-
- if (timeout != NULL) {
- wait_time = *timeout;
- wait_forever = false;
- }
-
- timeout_jiffies = timespec_to_jiffies(&wait_time);
-
- if (WARN_ON(!ring->irq_get(ring)))
- return -ENODEV;
+ struct drm_device *dev = ring->dev;
+ drm_i915_private_t *dev_priv = dev->dev_private;
+ int ret = 0;
- /* Record current time in case interrupted by signal, or wedged * */
- nanouptime(&before);
-
-#define EXIT_COND \
- (i915_seqno_passed(ring->get_seqno(ring, false), seqno) || \
- atomic_read(&dev_priv->mm.wedged))
- do {
- mtx_enter(&dev_priv->irq_lock);
- do {
- if (EXIT_COND) {
- ret = 0;
+ mtx_enter(&dev_priv->irq_lock);
+ if (!i915_seqno_passed(ring->get_seqno(ring, true), seqno)) {
+ ring->irq_get(ring);
+ while (ret == 0) {
+ if (i915_seqno_passed(ring->get_seqno(ring, false),
+ seqno) || dev_priv->mm.wedged)
break;
- }
- ret = msleep(ring, &dev_priv->irq_lock,
+ ret = -msleep(ring, &dev_priv->irq_lock,
PZERO | (interruptible ? PCATCH : 0),
- "gemwt", timeout_jiffies);
- nanouptime(&now);
- timespecsub(&now, &before, &sleep_time);
- timeout_jiffies = timespec_to_jiffies(&wait_time);
- timeout_jiffies -= timespec_to_jiffies(&sleep_time);
- if (timeout_jiffies <= 0) {
- timeout_jiffies = 0;
- break;
- }
- } while (ret == 0);
- mtx_leave(&dev_priv->irq_lock);
- switch (ret) {
- case 0:
- end = timeout_jiffies;
- break;
- case ERESTART:
- end = -ERESTARTSYS;
- break;
- case EWOULDBLOCK:
- end = 0;
- break;
- default:
- end = -ret;
- break;
+ "gemwt", 0);
}
-
- ret = i915_gem_check_wedge(dev_priv, interruptible);
- if (ret)
- end = ret;
- } while (end == 0 && wait_forever);
-
- nanouptime(&now);
-
- ring->irq_put(ring);
- trace_i915_gem_request_wait_end(ring, seqno);
-#undef EXIT_COND
-
- if (timeout) {
- timespecsub(&now, &before, &sleep_time);
- timespecsub(timeout, &sleep_time, timeout);
- }
-
- switch (end) {
- case -EIO:
- case -EAGAIN: /* Wedged */
- case -ERESTARTSYS: /* Signal */
- return (int)end;
- case 0: /* Timeout */
- if (timeout)
- timeout->tv_sec = timeout->tv_nsec = 0;
- return -ETIMEDOUT;
- default: /* Completed */
- WARN_ON(end < 0); /* We're not aware of other errors */
- return 0;
+ ring->irq_put(ring);
}
+ mtx_leave(&dev_priv->irq_lock);
+ if (dev_priv->mm.wedged)
+ ret = -EIO;
+
+ return ret;
}
/**
@@ -2451,6 +2374,7 @@ i915_gem_object_flush_active(struct drm_i915_gem_object *obj)
return 0;
}
+#ifdef notyet
/**
* i915_gem_wait_ioctl - implements DRM_IOCTL_I915_GEM_WAIT
* @DRM_IOCTL_ARGS: standard ioctl arguments
@@ -2494,7 +2418,7 @@ i915_gem_wait_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
obj = to_intel_bo(drm_gem_object_lookup(dev, file, args->bo_handle));
if (&obj->base == NULL) {
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
return -ENOENT;
}
@@ -2515,12 +2439,12 @@ i915_gem_wait_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
* on this IOCTL with a 0 timeout (like busy ioctl)
*/
if (!args->timeout_ns) {
- ret = -ETIMEDOUT;
+ ret = -ETIME;
goto out;
}
drm_gem_object_unreference(&obj->base);
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
ret = __wait_seqno(ring, seqno, true, timeout);
if (timeout) {
@@ -2531,9 +2455,10 @@ i915_gem_wait_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
out:
drm_gem_object_unreference(&obj->base);
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
return ret;
}
+#endif /* notyet */
/**
* i915_gem_object_sync - sync an object to a ring.
@@ -4550,54 +4475,3 @@ i915_gem_inactive_shrink(struct shrinker *shrinker, struct shrink_control *sc)
return cnt;
}
#endif /* notyet */
-
-#define NSEC_PER_SEC 1000000000L
-
-static inline int64_t
-timespec_to_ns(const struct timespec *ts)
-{
- return ((ts->tv_sec * NSEC_PER_SEC) + ts->tv_nsec);
-}
-
-static inline int
-timespec_to_jiffies(const struct timespec *ts)
-{
- long long to_ticks;
-
- to_ticks = (long long)hz * ts->tv_sec + ts->tv_nsec / (tick * 1000);
- if (to_ticks > INT_MAX)
- to_ticks = INT_MAX;
-
- return ((int)to_ticks);
-}
-
-static struct timespec
-ns_to_timespec(const int64_t nsec)
-{
- struct timespec ts;
- int32_t rem;
-
- if (nsec == 0) {
- ts.tv_sec = 0;
- ts.tv_nsec = 0;
- return (ts);
- }
-
- ts.tv_sec = nsec / NSEC_PER_SEC;
- rem = nsec % NSEC_PER_SEC;
- if (rem < 0) {
- ts.tv_sec--;
- rem += NSEC_PER_SEC;
- }
- ts.tv_nsec = rem;
- return (ts);
-}
-
-static inline int
-timespec_valid(const struct timespec *ts)
-{
- if (ts->tv_sec < 0 || ts->tv_sec > 100000000 ||
- ts->tv_nsec < 0 || ts->tv_nsec >= 1000000000)
- return (0);
- return (1);
-}
diff --git a/sys/dev/pci/drm/i915/i915_trace.h b/sys/dev/pci/drm/i915/i915_trace.h
index 0cf1e6fbfd8..6c91cb09d44 100644
--- a/sys/dev/pci/drm/i915/i915_trace.h
+++ b/sys/dev/pci/drm/i915/i915_trace.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: i915_trace.h,v 1.4 2013/11/17 18:47:13 kettenis Exp $ */
+/* $OpenBSD: i915_trace.h,v 1.5 2013/11/19 15:08:04 jsg Exp $ */
/*
* Copyright (c) 2013 Mark Kettenis <kettenis@openbsd.org>
*
@@ -31,16 +31,6 @@ trace_i915_gem_request_retire(struct intel_ring_buffer *ring, u32 seqno)
}
static inline void
-trace_i915_gem_request_wait_begin(struct intel_ring_buffer *ring, u32 seqno)
-{
-}
-
-static inline void
-trace_i915_gem_request_wait_end(struct intel_ring_buffer *ring, u32 seqno)
-{
-}
-
-static inline void
trace_i915_gem_object_change_domain(struct drm_i915_gem_object *obj,
u32 old_read, u32 old_write)
{
diff --git a/sys/dev/pci/drm/i915/intel_ringbuffer.c b/sys/dev/pci/drm/i915/intel_ringbuffer.c
index ab74fd54b10..433c5dbade2 100644
--- a/sys/dev/pci/drm/i915/intel_ringbuffer.c
+++ b/sys/dev/pci/drm/i915/intel_ringbuffer.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: intel_ringbuffer.c,v 1.6 2013/11/17 18:47:13 kettenis Exp $ */
+/* $OpenBSD: intel_ringbuffer.c,v 1.7 2013/11/19 15:08:04 jsg Exp $ */
/*
* Copyright © 2008-2010 Intel Corporation
*
@@ -770,13 +770,13 @@ gen5_ring_get_irq(struct intel_ring_buffer *ring)
if (!dev->irq_enabled)
return false;
- mtx_enter(&dev_priv->irq_lock);
+// mtx_enter(&dev_priv->irq_lock);
if (ring->irq_refcount++ == 0) {
dev_priv->gt_irq_mask &= ~ring->irq_enable_mask;
I915_WRITE(GTIMR, dev_priv->gt_irq_mask);
POSTING_READ(GTIMR);
}
- mtx_leave(&dev_priv->irq_lock);
+// mtx_leave(&dev_priv->irq_lock);
return true;
}
@@ -787,13 +787,13 @@ gen5_ring_put_irq(struct intel_ring_buffer *ring)
struct drm_device *dev = ring->dev;
drm_i915_private_t *dev_priv = dev->dev_private;
- mtx_enter(&dev_priv->irq_lock);
+// mtx_enter(&dev_priv->irq_lock);
if (--ring->irq_refcount == 0) {
dev_priv->gt_irq_mask |= ring->irq_enable_mask;
I915_WRITE(GTIMR, dev_priv->gt_irq_mask);
POSTING_READ(GTIMR);
}
- mtx_leave(&dev_priv->irq_lock);
+// mtx_leave(&dev_priv->irq_lock);
}
static bool
@@ -805,13 +805,13 @@ i9xx_ring_get_irq(struct intel_ring_buffer *ring)
if (!dev->irq_enabled)
return false;
- mtx_enter(&dev_priv->irq_lock);
+// mtx_enter(&dev_priv->irq_lock);
if (ring->irq_refcount++ == 0) {
dev_priv->irq_mask &= ~ring->irq_enable_mask;
I915_WRITE(IMR, dev_priv->irq_mask);
POSTING_READ(IMR);
}
- mtx_leave(&dev_priv->irq_lock);
+// mtx_leave(&dev_priv->irq_lock);
return true;
}
@@ -822,13 +822,13 @@ i9xx_ring_put_irq(struct intel_ring_buffer *ring)
struct drm_device *dev = ring->dev;
drm_i915_private_t *dev_priv = dev->dev_private;
- mtx_enter(&dev_priv->irq_lock);
+// mtx_enter(&dev_priv->irq_lock);
if (--ring->irq_refcount == 0) {
dev_priv->irq_mask |= ring->irq_enable_mask;
I915_WRITE(IMR, dev_priv->irq_mask);
POSTING_READ(IMR);
}
- mtx_leave(&dev_priv->irq_lock);
+// mtx_leave(&dev_priv->irq_lock);
}
static bool
@@ -840,13 +840,13 @@ i8xx_ring_get_irq(struct intel_ring_buffer *ring)
if (!dev->irq_enabled)
return false;
- mtx_enter(&dev_priv->irq_lock);
+// mtx_enter(&dev_priv->irq_lock);
if (ring->irq_refcount++ == 0) {
dev_priv->irq_mask &= ~ring->irq_enable_mask;
I915_WRITE16(IMR, dev_priv->irq_mask);
POSTING_READ16(IMR);
}
- mtx_leave(&dev_priv->irq_lock);
+// mtx_leave(&dev_priv->irq_lock);
return true;
}
@@ -857,13 +857,13 @@ i8xx_ring_put_irq(struct intel_ring_buffer *ring)
struct drm_device *dev = ring->dev;
drm_i915_private_t *dev_priv = dev->dev_private;
- mtx_enter(&dev_priv->irq_lock);
+// mtx_enter(&dev_priv->irq_lock);
if (--ring->irq_refcount == 0) {
dev_priv->irq_mask |= ring->irq_enable_mask;
I915_WRITE16(IMR, dev_priv->irq_mask);
POSTING_READ16(IMR);
}
- mtx_leave(&dev_priv->irq_lock);
+// mtx_leave(&dev_priv->irq_lock);
}
void intel_ring_setup_status_page(struct intel_ring_buffer *ring)
@@ -946,7 +946,7 @@ gen6_ring_get_irq(struct intel_ring_buffer *ring)
* blt/bsd rings on ivb. */
gen6_gt_force_wake_get(dev_priv);
- mtx_enter(&dev_priv->irq_lock);
+// mtx_enter(&dev_priv->irq_lock);
if (ring->irq_refcount++ == 0) {
if (HAS_L3_GPU_CACHE(dev) && ring->id == RCS)
I915_WRITE_IMR(ring, ~(ring->irq_enable_mask |
@@ -957,7 +957,7 @@ gen6_ring_get_irq(struct intel_ring_buffer *ring)
I915_WRITE(GTIMR, dev_priv->gt_irq_mask);
POSTING_READ(GTIMR);
}
- mtx_leave(&dev_priv->irq_lock);
+// mtx_leave(&dev_priv->irq_lock);
return true;
}
@@ -968,7 +968,7 @@ gen6_ring_put_irq(struct intel_ring_buffer *ring)
struct drm_device *dev = ring->dev;
drm_i915_private_t *dev_priv = dev->dev_private;
- mtx_enter(&dev_priv->irq_lock);
+// mtx_enter(&dev_priv->irq_lock);
if (--ring->irq_refcount == 0) {
if (HAS_L3_GPU_CACHE(dev) && ring->id == RCS)
I915_WRITE_IMR(ring, ~GEN6_RENDER_L3_PARITY_ERROR);
@@ -978,7 +978,7 @@ gen6_ring_put_irq(struct intel_ring_buffer *ring)
I915_WRITE(GTIMR, dev_priv->gt_irq_mask);
POSTING_READ(GTIMR);
}
- mtx_leave(&dev_priv->irq_lock);
+// mtx_leave(&dev_priv->irq_lock);
gen6_gt_force_wake_put(dev_priv);
}