aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/intel_display.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2012-04-03 12:58:35 -0400
committerDaniel Vetter <daniel.vetter@ffwll.ch>2012-04-09 15:53:30 -0400
commit14667a4bde4361b7ac420d68a2e9e9b9b2df5231 (patch)
tree2a26ed34eb36153d485d7f385be64aa365dc5cc8 /drivers/gpu/drm/i915/intel_display.c
parentb2a71642b8bfa1965700ba248a99016e4d6b685d (diff)
drm/i915: Finish any pending operations on the framebuffer before disabling
Similar to the case where we are changing from one framebuffer to another, we need to be sure that there are no pending WAIT_FOR_EVENTs on the pipe for the current framebuffer before switching. If we disable the pipe, and then try to execute a WAIT_FOR_EVENT it will block indefinitely and cause a GPU hang. We attempted to fix this in commit 85345517fe6d4de27b0d6ca19fef9d28ac947c4a (drm/i915: Retire any pending operations on the old scanout when switching) for the case of mode switching, but this leaves the condition where we are switching off the pipe vulnerable. There still remains the race condition were a display may be unplugged, switched off by the core, a uevent sent to notify the DDX and the DDX may issue a WAIT_FOR_EVENT before it processes the uevent. This window does not exist if the pipe is only switched off in response to the uevent. Time to make sure that is so... Reported-by: Francis Leblanc <Francis.Leblanc-Lebeau@verint.com> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=36515 Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=45413 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Eugeni Dodonov <eugeni.dodonov@intel.com> [danvet: fixup spelling in comment, noticed by Eugeni.] Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers/gpu/drm/i915/intel_display.c')
-rw-r--r--drivers/gpu/drm/i915/intel_display.c65
1 files changed, 46 insertions, 19 deletions
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 91b35fd1db8c..f446e66cbdaf 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -2245,6 +2245,33 @@ intel_pipe_set_base_atomic(struct drm_crtc *crtc, struct drm_framebuffer *fb,
2245} 2245}
2246 2246
2247static int 2247static int
2248intel_finish_fb(struct drm_framebuffer *old_fb)
2249{
2250 struct drm_i915_gem_object *obj = to_intel_framebuffer(old_fb)->obj;
2251 struct drm_i915_private *dev_priv = obj->base.dev->dev_private;
2252 bool was_interruptible = dev_priv->mm.interruptible;
2253 int ret;
2254
2255 wait_event(dev_priv->pending_flip_queue,
2256 atomic_read(&dev_priv->mm.wedged) ||
2257 atomic_read(&obj->pending_flip) == 0);
2258
2259 /* Big Hammer, we also need to ensure that any pending
2260 * MI_WAIT_FOR_EVENT inside a user batch buffer on the
2261 * current scanout is retired before unpinning the old
2262 * framebuffer.
2263 *
2264 * This should only fail upon a hung GPU, in which case we
2265 * can safely continue.
2266 */
2267 dev_priv->mm.interruptible = false;
2268 ret = i915_gem_object_finish_gpu(obj);
2269 dev_priv->mm.interruptible = was_interruptible;
2270
2271 return ret;
2272}
2273
2274static int
2248intel_pipe_set_base(struct drm_crtc *crtc, int x, int y, 2275intel_pipe_set_base(struct drm_crtc *crtc, int x, int y,
2249 struct drm_framebuffer *old_fb) 2276 struct drm_framebuffer *old_fb)
2250{ 2277{
@@ -2282,25 +2309,8 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y,
2282 return ret; 2309 return ret;
2283 } 2310 }
2284 2311
2285 if (old_fb) { 2312 if (old_fb)
2286 struct drm_i915_private *dev_priv = dev->dev_private; 2313 intel_finish_fb(old_fb);
2287 struct drm_i915_gem_object *obj = to_intel_framebuffer(old_fb)->obj;
2288
2289 wait_event(dev_priv->pending_flip_queue,
2290 atomic_read(&dev_priv->mm.wedged) ||
2291 atomic_read(&obj->pending_flip) == 0);
2292
2293 /* Big Hammer, we also need to ensure that any pending
2294 * MI_WAIT_FOR_EVENT inside a user batch buffer on the
2295 * current scanout is retired before unpinning the old
2296 * framebuffer.
2297 *
2298 * This should only fail upon a hung GPU, in which case we
2299 * can safely continue.
2300 */
2301 ret = i915_gem_object_finish_gpu(obj);
2302 (void) ret;
2303 }
2304 2314
2305 ret = intel_pipe_set_base_atomic(crtc, crtc->fb, x, y, 2315 ret = intel_pipe_set_base_atomic(crtc, crtc->fb, x, y,
2306 LEAVE_ATOMIC_MODE_SET); 2316 LEAVE_ATOMIC_MODE_SET);
@@ -3371,6 +3381,23 @@ static void intel_crtc_disable(struct drm_crtc *crtc)
3371 struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private; 3381 struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
3372 struct drm_device *dev = crtc->dev; 3382 struct drm_device *dev = crtc->dev;
3373 3383
3384 /* Flush any pending WAITs before we disable the pipe. Note that
3385 * we need to drop the struct_mutex in order to acquire it again
3386 * during the lowlevel dpms routines around a couple of the
3387 * operations. It does not look trivial nor desirable to move
3388 * that locking higher. So instead we leave a window for the
3389 * submission of further commands on the fb before we can actually
3390 * disable it. This race with userspace exists anyway, and we can
3391 * only rely on the pipe being disabled by userspace after it
3392 * receives the hotplug notification and has flushed any pending
3393 * batches.
3394 */
3395 if (crtc->fb) {
3396 mutex_lock(&dev->struct_mutex);
3397 intel_finish_fb(crtc->fb);
3398 mutex_unlock(&dev->struct_mutex);
3399 }
3400
3374 crtc_funcs->dpms(crtc, DRM_MODE_DPMS_OFF); 3401 crtc_funcs->dpms(crtc, DRM_MODE_DPMS_OFF);
3375 assert_plane_disabled(dev->dev_private, to_intel_crtc(crtc)->plane); 3402 assert_plane_disabled(dev->dev_private, to_intel_crtc(crtc)->plane);
3376 assert_pipe_disabled(dev->dev_private, to_intel_crtc(crtc)->pipe); 3403 assert_pipe_disabled(dev->dev_private, to_intel_crtc(crtc)->pipe);