]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
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)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Thu, 18 Apr 2013 07:43:23 +0000 (09:43 +0200)
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>
Cc: stable@vger.kernel.org
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
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 51871c248d6dc5d3edb5ab6e9f9a3129eecbda4e..7672f3e49df1401a4beb2103f56b9ac795f5f214 100644 (file)
@@ -9423,6 +9423,9 @@ void intel_modeset_cleanup(struct drm_device *dev)
        /* flush any delayed tasks or pending work */
        flush_scheduled_work();
 
+       /* destroy backlight, if any, before the connectors */
+       intel_panel_destroy_backlight(dev);
+
        drm_mode_config_cleanup(dev);
 
        intel_cleanup_overlay(dev);
index 173add1d819e6c0a6e91064f1920d7bf115e60ba..8845e82ec9ed7941762dfaaa06905936279f633b 100644 (file)
@@ -2474,17 +2474,14 @@ done:
 static void
 intel_dp_destroy(struct drm_connector *connector)
 {
-       struct drm_device *dev = connector->dev;
        struct intel_dp *intel_dp = intel_attached_dp(connector);
        struct intel_connector *intel_connector = to_intel_connector(connector);
 
        if (!IS_ERR_OR_NULL(intel_connector->edid))
                kfree(intel_connector->edid);
 
-       if (is_edp(intel_dp)) {
-               intel_panel_destroy_backlight(dev);
+       if (is_edp(intel_dp))
                intel_panel_fini(&intel_connector->panel);
-       }
 
        drm_sysfs_connector_remove(connector);
        drm_connector_cleanup(connector);
index ca2d903c19bb0340a1bebdb6275b14cf46df0460..f36f1baabd5ad6ced3522148ddb49d9f6cee074b 100644 (file)
@@ -631,7 +631,6 @@ static void intel_lvds_destroy(struct drm_connector *connector)
        if (!IS_ERR_OR_NULL(lvds_connector->base.edid))
                kfree(lvds_connector->base.edid);
 
-       intel_panel_destroy_backlight(connector->dev);
        intel_panel_fini(&lvds_connector->base.panel);
 
        drm_sysfs_connector_remove(connector);
index 7874cecc286355311c55c6a2b49dad7216015cbf..eb5e6e95f3c7ee72e14e9eed3c5cd8167bc7a449 100644 (file)
@@ -428,6 +428,9 @@ int intel_panel_setup_backlight(struct drm_connector *connector)
 
        intel_panel_init_backlight(dev);
 
+       if (WARN_ON(dev_priv->backlight.device))
+               return -ENODEV;
+
        memset(&props, 0, sizeof(props));
        props.type = BACKLIGHT_RAW;
        props.brightness = dev_priv->backlight.level;
@@ -453,8 +456,10 @@ int intel_panel_setup_backlight(struct drm_connector *connector)
 void intel_panel_destroy_backlight(struct drm_device *dev)
 {
        struct drm_i915_private *dev_priv = dev->dev_private;
-       if (dev_priv->backlight.device)
+       if (dev_priv->backlight.device) {
                backlight_device_unregister(dev_priv->backlight.device);
+               dev_priv->backlight.device = NULL;
+       }
 }
 #else
 int intel_panel_setup_backlight(struct drm_connector *connector)