drm/i915: Fix locking for intel_enable_pipe_a()
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Mon, 11 Aug 2014 10:15:35 +0000 (13:15 +0300)
committerJani Nikula <jani.nikula@intel.com>
Mon, 18 Aug 2014 07:42:40 +0000 (10:42 +0300)
commit208bf9fdcd3575aa4a5d48b3e0295f7cdaf6fc44
treeb33603d0c3129b59cc5b3d695e3bee8ea9d06354
parent7d1311b93e58ed55f3a31cc8f94c4b8fe988a2b9
drm/i915: Fix locking for intel_enable_pipe_a()

intel_enable_pipe_a() gets called with all the modeset locks already
held (by drm_modeset_lock_all()), so trying to grab the same
locks using another drm_modeset_acquire_ctx is going to fail miserably.

Move most of the drm_modeset_acquire_ctx handling (init/drop/fini)
out from intel_{get,release}_load_detect_pipe() into the callers
(intel_{crt,tv}_detect()). Only the actual locking and backoff
handling is left in intel_get_load_detect_pipe(). And in
intel_enable_pipe_a() we just share the mode_config.acquire_ctx from
drm_modeset_lock_all() which is already holding all the relevant locks.

It's perfectly legal to lock the same ww_mutex multiple times using the
same ww_acquire_ctx. drm_modeset_lock() will convert the returned
-EALREADY into 0, so the caller doesn't need to do antyhing special.

Fixes a hang on resume on my 830.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: stable@vger.kernel.org
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
drivers/gpu/drm/i915/intel_crt.c
drivers/gpu/drm/i915/intel_display.c
drivers/gpu/drm/i915/intel_drv.h
drivers/gpu/drm/i915/intel_tv.c