From 661c48a7d19831e367ecb533badd4135eda21f95 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Wed, 20 Apr 2011 00:01:37 +0100 Subject: [PATCH] drm/i915: Warn if detect() is called without dev->mode_config.lock Despite having fixed one such instance in 007c80a5497a3f9c8393960ec6e6efd30955dcb1 ("drm: Hold the mode mutex whilst probing for sysfs status"), OOPS are still being reported that look like state is being clobbered, load-detect pipe in particular, during a probe. References: https://bugs.freedesktop.org/show_bug.cgi?id=36394 Signed-off-by: Chris Wilson --- drivers/gpu/drm/i915/intel_crt.c | 3 +++ drivers/gpu/drm/i915/intel_dp.c | 3 +++ drivers/gpu/drm/i915/intel_hdmi.c | 3 +++ drivers/gpu/drm/i915/intel_sdvo.c | 3 +++ drivers/gpu/drm/i915/intel_tv.c | 3 +++ 5 files changed, 15 insertions(+), 0 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_crt.c b/drivers/gpu/drm/i915/intel_crt.c index e93f93c..9a14ec7 100644 --- a/drivers/gpu/drm/i915/intel_crt.c +++ b/drivers/gpu/drm/i915/intel_crt.c @@ -432,6 +432,9 @@ intel_crt_detect(struct drm_connector *connector, bool force) struct drm_crtc *crtc; enum drm_connector_status status; + if (WARN_ON(!mutex_is_locked(&connector->dev->mode_config.mutex))) + return connector_status_unknown; + if (I915_HAS_HOTPLUG(dev)) { if (intel_crt_detect_hotplug(connector)) { DRM_DEBUG_KMS("CRT detected via hotplug\n"); diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c index 819afca..e1fa051 100644 --- a/drivers/gpu/drm/i915/intel_dp.c +++ b/drivers/gpu/drm/i915/intel_dp.c @@ -1595,6 +1595,9 @@ intel_dp_detect(struct drm_connector *connector, bool force) enum drm_connector_status status; struct edid *edid = NULL; + if (WARN_ON(!mutex_is_locked(&connector->dev->mode_config.mutex))) + return connector_status_unknown; + intel_dp->has_audio = false; if (HAS_PCH_SPLIT(dev)) diff --git a/drivers/gpu/drm/i915/intel_hdmi.c b/drivers/gpu/drm/i915/intel_hdmi.c index f289b86..94e1f95 100644 --- a/drivers/gpu/drm/i915/intel_hdmi.c +++ b/drivers/gpu/drm/i915/intel_hdmi.c @@ -217,6 +217,9 @@ intel_hdmi_detect(struct drm_connector *connector, bool force) struct edid *edid; enum drm_connector_status status = connector_status_disconnected; + if (WARN_ON(!mutex_is_locked(&connector->dev->mode_config.mutex))) + return connector_status_unknown; + intel_hdmi->has_hdmi_sink = false; intel_hdmi->has_audio = false; edid = drm_get_edid(connector, diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c index 4324f33..c5687d1 100644 --- a/drivers/gpu/drm/i915/intel_sdvo.c +++ b/drivers/gpu/drm/i915/intel_sdvo.c @@ -1373,6 +1373,9 @@ intel_sdvo_detect(struct drm_connector *connector, bool force) struct intel_sdvo_connector *intel_sdvo_connector = to_intel_sdvo_connector(connector); enum drm_connector_status ret; + if (WARN_ON(!mutex_is_locked(&connector->dev->mode_config.mutex))) + return connector_status_unknown; + if (!intel_sdvo_write_cmd(intel_sdvo, SDVO_CMD_GET_ATTACHED_DISPLAYS, NULL, 0)) return connector_status_unknown; diff --git a/drivers/gpu/drm/i915/intel_tv.c b/drivers/gpu/drm/i915/intel_tv.c index 529f232..89c0c9e 100644 --- a/drivers/gpu/drm/i915/intel_tv.c +++ b/drivers/gpu/drm/i915/intel_tv.c @@ -1364,6 +1364,9 @@ intel_tv_detect(struct drm_connector *connector, bool force) struct intel_tv *intel_tv = intel_attached_tv(connector); int type; + if (WARN_ON(!mutex_is_locked(&connector->dev->mode_config.mutex))) + return connector_status_unknown; + mode = reported_modes[0]; drm_mode_set_crtcinfo(&mode, CRTC_INTERLACE_HALVE_V); -- 1.7.4.1