drm/i915: Convert backlight_lock to a mutex
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Mon, 15 Sep 2014 12:35:09 +0000 (14:35 +0200)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Fri, 19 Sep 2014 12:43:15 +0000 (14:43 +0200)
Originally the irq safe spinlock was required because of asle
interrupts. But since

commit 91a60f20712179e56b7a6c3d332a5f6f9a54aa11
Author: Jani Nikula <jani.nikula@intel.com>
Date:   Thu Oct 31 18:55:48 2013 +0200

    drm/i915: move opregion asle request handling to a work queue

there's no need for this any more. So switch to the simpler mutex.

v2: Cite the right commit, spotted by Jani.

Cc: Jani Nikula <jani.nikula@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/i915/i915_dma.c
drivers/gpu/drm/i915/i915_drv.h
drivers/gpu/drm/i915/intel_panel.c

index 1403b01e821695cce6c42cb8b3704eb284aba17e..0bc1583114e72be9f5d46c8f6fd0c266f9635465 100644 (file)
@@ -1614,7 +1614,7 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
 
        spin_lock_init(&dev_priv->irq_lock);
        spin_lock_init(&dev_priv->gpu_error.lock);
-       spin_lock_init(&dev_priv->backlight_lock);
+       mutex_init(&dev_priv->backlight_lock);
        spin_lock_init(&dev_priv->uncore.lock);
        spin_lock_init(&dev_priv->mm.object_stat_lock);
        spin_lock_init(&dev_priv->mmio_flip_lock);
index 17dfce0f4e68d88d04b09afb796c076a1a760ff9..07dafa2c2d8c6a164d7c54c714c64385c0f30c2f 100644 (file)
@@ -1528,7 +1528,7 @@ struct drm_i915_private {
        struct intel_overlay *overlay;
 
        /* backlight registers and fields in struct intel_panel */
-       spinlock_t backlight_lock;
+       struct mutex backlight_lock;
 
        /* LVDS info */
        bool no_aux_handshake;
index 18784470a760def6c6fd4af4938e53145acd4cab..f17ada3742de651325f96b3ac114d92b594d2b86 100644 (file)
@@ -538,14 +538,13 @@ static u32 intel_panel_get_backlight(struct intel_connector *connector)
        struct drm_device *dev = connector->base.dev;
        struct drm_i915_private *dev_priv = dev->dev_private;
        u32 val;
-       unsigned long flags;
 
-       spin_lock_irqsave(&dev_priv->backlight_lock, flags);
+       mutex_lock(&dev_priv->backlight_lock);
 
        val = dev_priv->display.get_backlight(connector);
        val = intel_panel_compute_brightness(connector, val);
 
-       spin_unlock_irqrestore(&dev_priv->backlight_lock, flags);
+       mutex_unlock(&dev_priv->backlight_lock);
 
        DRM_DEBUG_DRIVER("get backlight PWM = %d\n", val);
        return val;
@@ -629,12 +628,11 @@ static void intel_panel_set_backlight(struct intel_connector *connector,
        struct intel_panel *panel = &connector->panel;
        enum pipe pipe = intel_get_pipe_from_connector(connector);
        u32 hw_level;
-       unsigned long flags;
 
        if (!panel->backlight.present || pipe == INVALID_PIPE)
                return;
 
-       spin_lock_irqsave(&dev_priv->backlight_lock, flags);
+       mutex_lock(&dev_priv->backlight_lock);
 
        WARN_ON(panel->backlight.max == 0);
 
@@ -644,7 +642,7 @@ static void intel_panel_set_backlight(struct intel_connector *connector,
        if (panel->backlight.enabled)
                intel_panel_actually_set_backlight(connector, hw_level);
 
-       spin_unlock_irqrestore(&dev_priv->backlight_lock, flags);
+       mutex_unlock(&dev_priv->backlight_lock);
 }
 
 /* set backlight brightness to level in range [0..max], assuming hw min is
@@ -658,12 +656,11 @@ void intel_panel_set_backlight_acpi(struct intel_connector *connector,
        struct intel_panel *panel = &connector->panel;
        enum pipe pipe = intel_get_pipe_from_connector(connector);
        u32 hw_level;
-       unsigned long flags;
 
        if (!panel->backlight.present || pipe == INVALID_PIPE)
                return;
 
-       spin_lock_irqsave(&dev_priv->backlight_lock, flags);
+       mutex_lock(&dev_priv->backlight_lock);
 
        WARN_ON(panel->backlight.max == 0);
 
@@ -679,7 +676,7 @@ void intel_panel_set_backlight_acpi(struct intel_connector *connector,
        if (panel->backlight.enabled)
                intel_panel_actually_set_backlight(connector, hw_level);
 
-       spin_unlock_irqrestore(&dev_priv->backlight_lock, flags);
+       mutex_unlock(&dev_priv->backlight_lock);
 }
 
 static void pch_disable_backlight(struct intel_connector *connector)
@@ -733,7 +730,6 @@ void intel_panel_disable_backlight(struct intel_connector *connector)
        struct drm_i915_private *dev_priv = dev->dev_private;
        struct intel_panel *panel = &connector->panel;
        enum pipe pipe = intel_get_pipe_from_connector(connector);
-       unsigned long flags;
 
        if (!panel->backlight.present || pipe == INVALID_PIPE)
                return;
@@ -749,14 +745,14 @@ void intel_panel_disable_backlight(struct intel_connector *connector)
                return;
        }
 
-       spin_lock_irqsave(&dev_priv->backlight_lock, flags);
+       mutex_lock(&dev_priv->backlight_lock);
 
        if (panel->backlight.device)
                panel->backlight.device->props.power = FB_BLANK_POWERDOWN;
        panel->backlight.enabled = false;
        dev_priv->display.disable_backlight(connector);
 
-       spin_unlock_irqrestore(&dev_priv->backlight_lock, flags);
+       mutex_unlock(&dev_priv->backlight_lock);
 }
 
 static void bdw_enable_backlight(struct intel_connector *connector)
@@ -937,14 +933,13 @@ void intel_panel_enable_backlight(struct intel_connector *connector)
        struct drm_i915_private *dev_priv = dev->dev_private;
        struct intel_panel *panel = &connector->panel;
        enum pipe pipe = intel_get_pipe_from_connector(connector);
-       unsigned long flags;
 
        if (!panel->backlight.present || pipe == INVALID_PIPE)
                return;
 
        DRM_DEBUG_KMS("pipe %c\n", pipe_name(pipe));
 
-       spin_lock_irqsave(&dev_priv->backlight_lock, flags);
+       mutex_lock(&dev_priv->backlight_lock);
 
        WARN_ON(panel->backlight.max == 0);
 
@@ -962,7 +957,7 @@ void intel_panel_enable_backlight(struct intel_connector *connector)
        if (panel->backlight.device)
                panel->backlight.device->props.power = FB_BLANK_UNBLANK;
 
-       spin_unlock_irqrestore(&dev_priv->backlight_lock, flags);
+       mutex_unlock(&dev_priv->backlight_lock);
 }
 
 #if IS_ENABLED(CONFIG_BACKLIGHT_CLASS_DEVICE)
@@ -1267,7 +1262,6 @@ int intel_panel_setup_backlight(struct drm_connector *connector)
        struct drm_i915_private *dev_priv = dev->dev_private;
        struct intel_connector *intel_connector = to_intel_connector(connector);
        struct intel_panel *panel = &intel_connector->panel;
-       unsigned long flags;
        int ret;
 
        if (!dev_priv->vbt.backlight.present) {
@@ -1280,9 +1274,9 @@ int intel_panel_setup_backlight(struct drm_connector *connector)
        }
 
        /* set level and max in panel struct */
-       spin_lock_irqsave(&dev_priv->backlight_lock, flags);
+       mutex_lock(&dev_priv->backlight_lock);
        ret = dev_priv->display.setup_backlight(intel_connector);
-       spin_unlock_irqrestore(&dev_priv->backlight_lock, flags);
+       mutex_unlock(&dev_priv->backlight_lock);
 
        if (ret) {
                DRM_DEBUG_KMS("failed to setup backlight for connector %s\n",