Commit 33196ded authored by Daniel Vetter's avatar Daniel Vetter

drm/i915: move wedged to the other gpu error handling stuff

And to make Ben Widawsky happier, use the gpu_error instead of
the entire device as the argument in some functions.

Drop the outdated comment on ->wedged for now, a follow-up patch will
change the semantics and add a proper comment again.
Reviewed-by: default avatarDamien Lespiau <damien.lespiau@intel.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent 99584db3
...@@ -1672,7 +1672,7 @@ i915_wedged_read(struct file *filp, ...@@ -1672,7 +1672,7 @@ i915_wedged_read(struct file *filp,
len = snprintf(buf, sizeof(buf), len = snprintf(buf, sizeof(buf),
"wedged : %d\n", "wedged : %d\n",
atomic_read(&dev_priv->mm.wedged)); atomic_read(&dev_priv->gpu_error.wedged));
if (len > sizeof(buf)) if (len > sizeof(buf))
len = sizeof(buf); len = sizeof(buf);
......
...@@ -744,15 +744,6 @@ struct i915_gem_mm { ...@@ -744,15 +744,6 @@ struct i915_gem_mm {
*/ */
int suspended; int suspended;
/**
* Flag if the hardware appears to be wedged.
*
* This is set when attempts to idle the device timeout.
* It prevents command submission from occurring and makes
* every pending request fail
*/
atomic_t wedged;
/** Bit 6 swizzling required for X tiling */ /** Bit 6 swizzling required for X tiling */
uint32_t bit_6_swizzle_x; uint32_t bit_6_swizzle_x;
/** Bit 6 swizzling required for Y tiling */ /** Bit 6 swizzling required for Y tiling */
...@@ -784,6 +775,8 @@ struct i915_gpu_error { ...@@ -784,6 +775,8 @@ struct i915_gpu_error {
unsigned long last_reset; unsigned long last_reset;
atomic_t wedged;
/* For gpu hang simulation. */ /* For gpu hang simulation. */
unsigned int stop_rings; unsigned int stop_rings;
}; };
...@@ -1548,7 +1541,7 @@ i915_gem_object_unpin_fence(struct drm_i915_gem_object *obj) ...@@ -1548,7 +1541,7 @@ i915_gem_object_unpin_fence(struct drm_i915_gem_object *obj)
void i915_gem_retire_requests(struct drm_device *dev); void i915_gem_retire_requests(struct drm_device *dev);
void i915_gem_retire_requests_ring(struct intel_ring_buffer *ring); void i915_gem_retire_requests_ring(struct intel_ring_buffer *ring);
int __must_check i915_gem_check_wedge(struct drm_i915_private *dev_priv, int __must_check i915_gem_check_wedge(struct i915_gpu_error *error,
bool interruptible); bool interruptible);
void i915_gem_reset(struct drm_device *dev); void i915_gem_reset(struct drm_device *dev);
......
...@@ -87,14 +87,13 @@ static void i915_gem_info_remove_obj(struct drm_i915_private *dev_priv, ...@@ -87,14 +87,13 @@ static void i915_gem_info_remove_obj(struct drm_i915_private *dev_priv,
} }
static int static int
i915_gem_wait_for_error(struct drm_device *dev) i915_gem_wait_for_error(struct i915_gpu_error *error)
{ {
struct drm_i915_private *dev_priv = dev->dev_private; struct completion *x = &error->completion;
struct completion *x = &dev_priv->gpu_error.completion;
unsigned long flags; unsigned long flags;
int ret; int ret;
if (!atomic_read(&dev_priv->mm.wedged)) if (!atomic_read(&error->wedged))
return 0; return 0;
/* /*
...@@ -110,7 +109,7 @@ i915_gem_wait_for_error(struct drm_device *dev) ...@@ -110,7 +109,7 @@ i915_gem_wait_for_error(struct drm_device *dev)
return ret; return ret;
} }
if (atomic_read(&dev_priv->mm.wedged)) { if (atomic_read(&error->wedged)) {
/* GPU is hung, bump the completion count to account for /* GPU is hung, bump the completion count to account for
* the token we just consumed so that we never hit zero and * the token we just consumed so that we never hit zero and
* end up waiting upon a subsequent completion event that * end up waiting upon a subsequent completion event that
...@@ -125,9 +124,10 @@ i915_gem_wait_for_error(struct drm_device *dev) ...@@ -125,9 +124,10 @@ i915_gem_wait_for_error(struct drm_device *dev)
int i915_mutex_lock_interruptible(struct drm_device *dev) int i915_mutex_lock_interruptible(struct drm_device *dev)
{ {
struct drm_i915_private *dev_priv = dev->dev_private;
int ret; int ret;
ret = i915_gem_wait_for_error(dev); ret = i915_gem_wait_for_error(&dev_priv->gpu_error);
if (ret) if (ret)
return ret; return ret;
...@@ -939,11 +939,11 @@ i915_gem_pwrite_ioctl(struct drm_device *dev, void *data, ...@@ -939,11 +939,11 @@ i915_gem_pwrite_ioctl(struct drm_device *dev, void *data,
} }
int int
i915_gem_check_wedge(struct drm_i915_private *dev_priv, i915_gem_check_wedge(struct i915_gpu_error *error,
bool interruptible) bool interruptible)
{ {
if (atomic_read(&dev_priv->mm.wedged)) { if (atomic_read(&error->wedged)) {
struct completion *x = &dev_priv->gpu_error.completion; struct completion *x = &error->completion;
bool recovery_complete; bool recovery_complete;
unsigned long flags; unsigned long flags;
...@@ -1025,7 +1025,7 @@ static int __wait_seqno(struct intel_ring_buffer *ring, u32 seqno, ...@@ -1025,7 +1025,7 @@ static int __wait_seqno(struct intel_ring_buffer *ring, u32 seqno,
#define EXIT_COND \ #define EXIT_COND \
(i915_seqno_passed(ring->get_seqno(ring, false), seqno) || \ (i915_seqno_passed(ring->get_seqno(ring, false), seqno) || \
atomic_read(&dev_priv->mm.wedged)) atomic_read(&dev_priv->gpu_error.wedged))
do { do {
if (interruptible) if (interruptible)
end = wait_event_interruptible_timeout(ring->irq_queue, end = wait_event_interruptible_timeout(ring->irq_queue,
...@@ -1035,7 +1035,7 @@ static int __wait_seqno(struct intel_ring_buffer *ring, u32 seqno, ...@@ -1035,7 +1035,7 @@ static int __wait_seqno(struct intel_ring_buffer *ring, u32 seqno,
end = wait_event_timeout(ring->irq_queue, EXIT_COND, end = wait_event_timeout(ring->irq_queue, EXIT_COND,
timeout_jiffies); timeout_jiffies);
ret = i915_gem_check_wedge(dev_priv, interruptible); ret = i915_gem_check_wedge(&dev_priv->gpu_error, interruptible);
if (ret) if (ret)
end = ret; end = ret;
} while (end == 0 && wait_forever); } while (end == 0 && wait_forever);
...@@ -1081,7 +1081,7 @@ i915_wait_seqno(struct intel_ring_buffer *ring, uint32_t seqno) ...@@ -1081,7 +1081,7 @@ i915_wait_seqno(struct intel_ring_buffer *ring, uint32_t seqno)
BUG_ON(!mutex_is_locked(&dev->struct_mutex)); BUG_ON(!mutex_is_locked(&dev->struct_mutex));
BUG_ON(seqno == 0); BUG_ON(seqno == 0);
ret = i915_gem_check_wedge(dev_priv, interruptible); ret = i915_gem_check_wedge(&dev_priv->gpu_error, interruptible);
if (ret) if (ret)
return ret; return ret;
...@@ -1146,7 +1146,7 @@ i915_gem_object_wait_rendering__nonblocking(struct drm_i915_gem_object *obj, ...@@ -1146,7 +1146,7 @@ i915_gem_object_wait_rendering__nonblocking(struct drm_i915_gem_object *obj,
if (seqno == 0) if (seqno == 0)
return 0; return 0;
ret = i915_gem_check_wedge(dev_priv, true); ret = i915_gem_check_wedge(&dev_priv->gpu_error, true);
if (ret) if (ret)
return ret; return ret;
...@@ -1379,7 +1379,7 @@ int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf) ...@@ -1379,7 +1379,7 @@ int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
/* If this -EIO is due to a gpu hang, give the reset code a /* If this -EIO is due to a gpu hang, give the reset code a
* chance to clean up the mess. Otherwise return the proper * chance to clean up the mess. Otherwise return the proper
* SIGBUS. */ * SIGBUS. */
if (!atomic_read(&dev_priv->mm.wedged)) if (!atomic_read(&dev_priv->gpu_error.wedged))
return VM_FAULT_SIGBUS; return VM_FAULT_SIGBUS;
case -EAGAIN: case -EAGAIN:
/* Give the error handler a chance to run and move the /* Give the error handler a chance to run and move the
...@@ -3390,7 +3390,7 @@ i915_gem_ring_throttle(struct drm_device *dev, struct drm_file *file) ...@@ -3390,7 +3390,7 @@ i915_gem_ring_throttle(struct drm_device *dev, struct drm_file *file)
u32 seqno = 0; u32 seqno = 0;
int ret; int ret;
if (atomic_read(&dev_priv->mm.wedged)) if (atomic_read(&dev_priv->gpu_error.wedged))
return -EIO; return -EIO;
spin_lock(&file_priv->mm.lock); spin_lock(&file_priv->mm.lock);
...@@ -3978,9 +3978,9 @@ i915_gem_entervt_ioctl(struct drm_device *dev, void *data, ...@@ -3978,9 +3978,9 @@ i915_gem_entervt_ioctl(struct drm_device *dev, void *data,
if (drm_core_check_feature(dev, DRIVER_MODESET)) if (drm_core_check_feature(dev, DRIVER_MODESET))
return 0; return 0;
if (atomic_read(&dev_priv->mm.wedged)) { if (atomic_read(&dev_priv->gpu_error.wedged)) {
DRM_ERROR("Reenabling wedged hardware, good luck\n"); DRM_ERROR("Reenabling wedged hardware, good luck\n");
atomic_set(&dev_priv->mm.wedged, 0); atomic_set(&dev_priv->gpu_error.wedged, 0);
} }
mutex_lock(&dev->struct_mutex); mutex_lock(&dev->struct_mutex);
......
...@@ -871,11 +871,11 @@ static void i915_error_work_func(struct work_struct *work) ...@@ -871,11 +871,11 @@ static void i915_error_work_func(struct work_struct *work)
kobject_uevent_env(&dev->primary->kdev.kobj, KOBJ_CHANGE, error_event); kobject_uevent_env(&dev->primary->kdev.kobj, KOBJ_CHANGE, error_event);
if (atomic_read(&dev_priv->mm.wedged)) { if (atomic_read(&dev_priv->gpu_error.wedged)) {
DRM_DEBUG_DRIVER("resetting chip\n"); DRM_DEBUG_DRIVER("resetting chip\n");
kobject_uevent_env(&dev->primary->kdev.kobj, KOBJ_CHANGE, reset_event); kobject_uevent_env(&dev->primary->kdev.kobj, KOBJ_CHANGE, reset_event);
if (!i915_reset(dev)) { if (!i915_reset(dev)) {
atomic_set(&dev_priv->mm.wedged, 0); atomic_set(&dev_priv->gpu_error.wedged, 0);
kobject_uevent_env(&dev->primary->kdev.kobj, KOBJ_CHANGE, reset_done_event); kobject_uevent_env(&dev->primary->kdev.kobj, KOBJ_CHANGE, reset_done_event);
} }
complete_all(&dev_priv->gpu_error.completion); complete_all(&dev_priv->gpu_error.completion);
...@@ -1483,7 +1483,7 @@ void i915_handle_error(struct drm_device *dev, bool wedged) ...@@ -1483,7 +1483,7 @@ void i915_handle_error(struct drm_device *dev, bool wedged)
if (wedged) { if (wedged) {
INIT_COMPLETION(dev_priv->gpu_error.completion); INIT_COMPLETION(dev_priv->gpu_error.completion);
atomic_set(&dev_priv->mm.wedged, 1); atomic_set(&dev_priv->gpu_error.wedged, 1);
/* /*
* Wakeup waiting processes so they don't hang * Wakeup waiting processes so they don't hang
......
...@@ -2223,7 +2223,7 @@ intel_finish_fb(struct drm_framebuffer *old_fb) ...@@ -2223,7 +2223,7 @@ intel_finish_fb(struct drm_framebuffer *old_fb)
WARN_ON(waitqueue_active(&dev_priv->pending_flip_queue)); WARN_ON(waitqueue_active(&dev_priv->pending_flip_queue));
wait_event(dev_priv->pending_flip_queue, wait_event(dev_priv->pending_flip_queue,
atomic_read(&dev_priv->mm.wedged) || atomic_read(&dev_priv->gpu_error.wedged) ||
atomic_read(&obj->pending_flip) == 0); atomic_read(&obj->pending_flip) == 0);
/* Big Hammer, we also need to ensure that any pending /* Big Hammer, we also need to ensure that any pending
...@@ -2871,7 +2871,7 @@ static bool intel_crtc_has_pending_flip(struct drm_crtc *crtc) ...@@ -2871,7 +2871,7 @@ static bool intel_crtc_has_pending_flip(struct drm_crtc *crtc)
unsigned long flags; unsigned long flags;
bool pending; bool pending;
if (atomic_read(&dev_priv->mm.wedged)) if (atomic_read(&dev_priv->gpu_error.wedged))
return false; return false;
spin_lock_irqsave(&dev->event_lock, flags); spin_lock_irqsave(&dev->event_lock, flags);
......
...@@ -1371,7 +1371,8 @@ static int ring_wait_for_space(struct intel_ring_buffer *ring, int n) ...@@ -1371,7 +1371,8 @@ static int ring_wait_for_space(struct intel_ring_buffer *ring, int n)
msleep(1); msleep(1);
ret = i915_gem_check_wedge(dev_priv, dev_priv->mm.interruptible); ret = i915_gem_check_wedge(&dev_priv->gpu_error,
dev_priv->mm.interruptible);
if (ret) if (ret)
return ret; return ret;
} while (!time_after(jiffies, end)); } while (!time_after(jiffies, end));
...@@ -1460,7 +1461,8 @@ int intel_ring_begin(struct intel_ring_buffer *ring, ...@@ -1460,7 +1461,8 @@ int intel_ring_begin(struct intel_ring_buffer *ring,
drm_i915_private_t *dev_priv = ring->dev->dev_private; drm_i915_private_t *dev_priv = ring->dev->dev_private;
int ret; int ret;
ret = i915_gem_check_wedge(dev_priv, dev_priv->mm.interruptible); ret = i915_gem_check_wedge(&dev_priv->gpu_error,
dev_priv->mm.interruptible);
if (ret) if (ret)
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment