drm/i915: ensure single initialization and cleanup of backlight device
authorJani Nikula <jani.nikula@intel.com>
Fri, 12 Apr 2013 12:18:38 +0000 (15:18 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 7 Jun 2014 23:02:13 +0000 (16:02 -0700)
commit dc652f90e088798bfa31f496ba994ddadd5d5680 upstream.

Backlight cleanup in the eDP connector destroy callback caused the
backlight device to be removed on some systems that first initialized LVDS
and then attempted to initialize eDP. Prevent multiple backlight
initializations, and ensure backlight cleanup is only done once by moving
it to modeset cleanup.

A small wrinkle is the introduced asymmetry in backlight
setup/cleanup. This could be solved by adding refcounting, but it seems
overkill considering that there should only ever be one backlight device.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=55701
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Tested-by: Peter Verthez <peter.verthez@skynet.be>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
[bwh: Backported to 3.2:
 - Adjust context
 - s/dev_priv->backlight\.device/dev_priv->backlight/]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Cc: Weng Meiling <wengmeiling.weng@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/gpu/drm/i915/intel_display.c
drivers/gpu/drm/i915/intel_dp.c
drivers/gpu/drm/i915/intel_lvds.c
drivers/gpu/drm/i915/intel_panel.c

index 2a1111f247114742aef9601171de49632251f073..c975c996ff5feb6d0ad1b8d58e4e04db9728ffa3 100644 (file)
@@ -9471,6 +9471,9 @@ void intel_modeset_cleanup(struct drm_device *dev)
        del_timer_sync(&dev_priv->idle_timer);
        cancel_work_sync(&dev_priv->idle_work);
 
+       /* destroy backlight, if any, before the connectors */
+       intel_panel_destroy_backlight(dev);
+
        drm_mode_config_cleanup(dev);
 }
 
index eee6cd391993dec20cb8cc0d07199e7c5650fe26..9a3ecd61de7c10765f421716b9f4e98d33dae991 100644 (file)
@@ -2289,11 +2289,6 @@ done:
 static void
 intel_dp_destroy(struct drm_connector *connector)
 {
-       struct drm_device *dev = connector->dev;
-
-       if (intel_dpd_is_edp(dev))
-               intel_panel_destroy_backlight(dev);
-
        drm_sysfs_connector_remove(connector);
        drm_connector_cleanup(connector);
        kfree(connector);
index 4f2019b2c166cee70c09f603c915a9d4087148c1..b695ab48ebf013891ee2c4abee36c8da739611ad 100644 (file)
@@ -553,8 +553,6 @@ static void intel_lvds_destroy(struct drm_connector *connector)
        struct drm_device *dev = connector->dev;
        struct drm_i915_private *dev_priv = dev->dev_private;
 
-       intel_panel_destroy_backlight(dev);
-
        if (dev_priv->lid_notifier.notifier_call)
                acpi_lid_notifier_unregister(&dev_priv->lid_notifier);
        drm_sysfs_connector_remove(connector);
index e42588aef616cf9fae1ac1881b1594f03bdcb0c6..0bae2bbe7b3c6105a6d8f11c0d400bb8d86d4d78 100644 (file)
@@ -359,6 +359,9 @@ int intel_panel_setup_backlight(struct drm_device *dev)
 
        intel_panel_init_backlight(dev);
 
+       if (WARN_ON(dev_priv->backlight))
+               return -ENODEV;
+
        if (dev_priv->int_lvds_connector)
                connector = dev_priv->int_lvds_connector;
        else if (dev_priv->int_edp_connector)
@@ -386,8 +389,10 @@ int intel_panel_setup_backlight(struct drm_device *dev)
 void intel_panel_destroy_backlight(struct drm_device *dev)
 {
        struct drm_i915_private *dev_priv = dev->dev_private;
-       if (dev_priv->backlight)
+       if (dev_priv->backlight) {
                backlight_device_unregister(dev_priv->backlight);
+               dev_priv->backlight = NULL;
+       }
 }
 #else
 int intel_panel_setup_backlight(struct drm_device *dev)