drm: add drm_fb_helper_restore_fbdev_mode_unlocked()
authorRob Clark <robdclark@gmail.com>
Fri, 30 May 2014 16:29:48 +0000 (12:29 -0400)
committerDave Airlie <airlied@redhat.com>
Thu, 5 Jun 2014 00:02:40 +0000 (10:02 +1000)
All drm_fb_helper_restore_fbdev_mode() call sites, save one, do the same
locking.  Simplify this into drm_fb_helper_restore_fbdev_mode_unlocked().

Signed-off-by: Rob Clark <robdclark@gmail.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Dave Airlie <airlied@redhat.com>
drivers/gpu/drm/armada/armada_fbdev.c
drivers/gpu/drm/drm_fb_cma_helper.c
drivers/gpu/drm/drm_fb_helper.c
drivers/gpu/drm/exynos/exynos_drm_fbdev.c
drivers/gpu/drm/gma500/psb_drv.c
drivers/gpu/drm/i915/intel_fbdev.c
drivers/gpu/drm/msm/msm_drv.c
drivers/gpu/drm/omapdrm/omap_drv.c
drivers/gpu/drm/tegra/fb.c
include/drm/drm_fb_helper.h

index 948cb14c561ec501e10bae0f89adb043dc0b2808..fd166f532ab94f30f2bc3b0d9eff226ea9a07fd7 100644 (file)
@@ -181,10 +181,8 @@ void armada_fbdev_lastclose(struct drm_device *dev)
 {
        struct armada_private *priv = dev->dev_private;
 
-       drm_modeset_lock_all(dev);
        if (priv->fbdev)
-               drm_fb_helper_restore_fbdev_mode(priv->fbdev);
-       drm_modeset_unlock_all(dev);
+               drm_fb_helper_restore_fbdev_mode_unlocked(priv->fbdev);
 }
 
 void armada_fbdev_fini(struct drm_device *dev)
index 61b5a47ad239115f00b2359f41bd99734645e443..f27c883be391f51dfe0ef41e9cada8ed76ee67dc 100644 (file)
@@ -429,13 +429,8 @@ EXPORT_SYMBOL_GPL(drm_fbdev_cma_fini);
  */
 void drm_fbdev_cma_restore_mode(struct drm_fbdev_cma *fbdev_cma)
 {
-       if (fbdev_cma) {
-               struct drm_device *dev = fbdev_cma->fb_helper.dev;
-
-               drm_modeset_lock_all(dev);
-               drm_fb_helper_restore_fbdev_mode(&fbdev_cma->fb_helper);
-               drm_modeset_unlock_all(dev);
-       }
+       if (fbdev_cma)
+               drm_fb_helper_restore_fbdev_mode_unlocked(&fbdev_cma->fb_helper);
 }
 EXPORT_SYMBOL_GPL(drm_fbdev_cma_restore_mode);
 
index 43329cee299f6d6173a95114923a7aa55f56d1fa..d5d8cea1a67996a4a3e61ebc657e68ec7ae6d9b6 100644 (file)
@@ -273,15 +273,7 @@ int drm_fb_helper_debug_leave(struct fb_info *info)
 }
 EXPORT_SYMBOL(drm_fb_helper_debug_leave);
 
-/**
- * drm_fb_helper_restore_fbdev_mode - restore fbdev configuration
- * @fb_helper: fbcon to restore
- *
- * This should be called from driver's drm ->lastclose callback
- * when implementing an fbcon on top of kms using this helper. This ensures that
- * the user isn't greeted with a black screen when e.g. X dies.
- */
-bool drm_fb_helper_restore_fbdev_mode(struct drm_fb_helper *fb_helper)
+static bool restore_fbdev_mode(struct drm_fb_helper *fb_helper)
 {
        struct drm_device *dev = fb_helper->dev;
        struct drm_plane *plane;
@@ -311,7 +303,40 @@ bool drm_fb_helper_restore_fbdev_mode(struct drm_fb_helper *fb_helper)
        }
        return error;
 }
-EXPORT_SYMBOL(drm_fb_helper_restore_fbdev_mode);
+/**
+ * drm_fb_helper_restore_fbdev_mode - restore fbdev configuration
+ * @fb_helper: fbcon to restore
+ *
+ * This should be called from driver's drm ->lastclose callback
+ * when implementing an fbcon on top of kms using this helper. This ensures that
+ * the user isn't greeted with a black screen when e.g. X dies.
+ *
+ * Use this variant if you need to bypass locking (panic), or already
+ * hold all modeset locks.  Otherwise use drm_fb_helper_restore_fbdev_mode_unlocked()
+ */
+static bool drm_fb_helper_restore_fbdev_mode(struct drm_fb_helper *fb_helper)
+{
+       return restore_fbdev_mode(fb_helper);
+}
+
+/**
+ * drm_fb_helper_restore_fbdev_mode_unlocked - restore fbdev configuration
+ * @fb_helper: fbcon to restore
+ *
+ * This should be called from driver's drm ->lastclose callback
+ * when implementing an fbcon on top of kms using this helper. This ensures that
+ * the user isn't greeted with a black screen when e.g. X dies.
+ */
+bool drm_fb_helper_restore_fbdev_mode_unlocked(struct drm_fb_helper *fb_helper)
+{
+       struct drm_device *dev = fb_helper->dev;
+       bool ret;
+       drm_modeset_lock_all(dev);
+       ret = restore_fbdev_mode(fb_helper);
+       drm_modeset_unlock_all(dev);
+       return ret;
+}
+EXPORT_SYMBOL(drm_fb_helper_restore_fbdev_mode_unlocked);
 
 /*
  * restore fbcon display for all kms driver's using this helper, used for sysrq
@@ -824,7 +849,6 @@ EXPORT_SYMBOL(drm_fb_helper_check_var);
 int drm_fb_helper_set_par(struct fb_info *info)
 {
        struct drm_fb_helper *fb_helper = info->par;
-       struct drm_device *dev = fb_helper->dev;
        struct fb_var_screeninfo *var = &info->var;
 
        if (var->pixclock != 0) {
@@ -832,9 +856,7 @@ int drm_fb_helper_set_par(struct fb_info *info)
                return -EINVAL;
        }
 
-       drm_modeset_lock_all(dev);
-       drm_fb_helper_restore_fbdev_mode(fb_helper);
-       drm_modeset_unlock_all(dev);
+       drm_fb_helper_restore_fbdev_mode_unlocked(fb_helper);
 
        if (fb_helper->delayed_hotplug) {
                fb_helper->delayed_hotplug = false;
index 14bbaa33b4770c3bbab2caa4d411b2982094f040..d771b467cf0c03c70446f58bc68d3029dd5f6305 100644 (file)
@@ -367,7 +367,5 @@ void exynos_drm_fbdev_restore_mode(struct drm_device *dev)
        if (!private || !private->fb_helper)
                return;
 
-       drm_modeset_lock_all(dev);
-       drm_fb_helper_restore_fbdev_mode(private->fb_helper);
-       drm_modeset_unlock_all(dev);
+       drm_fb_helper_restore_fbdev_mode_unlocked(private->fb_helper);
 }
index 0a3101a3db19bb2fc068d7b34468b07826b09148..59ea45e5c97edb90ae32948ccf4221a6de7a3163 100644 (file)
@@ -112,11 +112,9 @@ static void psb_driver_lastclose(struct drm_device *dev)
        struct drm_psb_private *dev_priv = dev->dev_private;
        struct psb_fbdev *fbdev = dev_priv->fbdev;
 
-       drm_modeset_lock_all(dev);
-       ret = drm_fb_helper_restore_fbdev_mode(&fbdev->psb_fb_helper);
+       ret = drm_fb_helper_restore_fbdev_mode_unlocked(&fbdev->psb_fb_helper);
        if (ret)
                DRM_DEBUG("failed to restore crtc mode\n");
-       drm_modeset_unlock_all(dev);
 
        return;
 }
index e2d416149f53726df7cbdf816a635a3c0679fdb3..6ea2d75464da517dd05cc4b07f81e13bb37a157b 100644 (file)
@@ -687,11 +687,7 @@ void intel_fbdev_restore_mode(struct drm_device *dev)
        if (!dev_priv->fbdev)
                return;
 
-       drm_modeset_lock_all(dev);
-
-       ret = drm_fb_helper_restore_fbdev_mode(&dev_priv->fbdev->helper);
+       ret = drm_fb_helper_restore_fbdev_mode_unlocked(&dev_priv->fbdev->helper);
        if (ret)
                DRM_DEBUG("failed to restore crtc mode\n");
-
-       drm_modeset_unlock_all(dev);
 }
index c071aacf2752fd0f26dc8cc447c2639416729fd0..0d2562fb681eee5704228fe5eeea708c86f6b23d 100644 (file)
@@ -386,11 +386,8 @@ static void msm_preclose(struct drm_device *dev, struct drm_file *file)
 static void msm_lastclose(struct drm_device *dev)
 {
        struct msm_drm_private *priv = dev->dev_private;
-       if (priv->fbdev) {
-               drm_modeset_lock_all(dev);
-               drm_fb_helper_restore_fbdev_mode(priv->fbdev);
-               drm_modeset_unlock_all(dev);
-       }
+       if (priv->fbdev)
+               drm_fb_helper_restore_fbdev_mode_unlocked(priv->fbdev);
 }
 
 static irqreturn_t msm_irq(int irq, void *arg)
index c8270e4b26f3f7d15c4e0bfcb1230a5fb3e4cd05..002b9721e85a348077f09285c99bbb7600ecce32 100644 (file)
@@ -588,9 +588,7 @@ static void dev_lastclose(struct drm_device *dev)
                }
        }
 
-       drm_modeset_lock_all(dev);
-       ret = drm_fb_helper_restore_fbdev_mode(priv->fbdev);
-       drm_modeset_unlock_all(dev);
+       ret = drm_fb_helper_restore_fbdev_mode_unlocked(priv->fbdev);
        if (ret)
                DBG("failed to restore crtc mode");
 }
index f7fca09d49211c5afebdc797590c001a88e72d6d..9798a708032219adde9cfd6f75c75d937c704769 100644 (file)
@@ -346,11 +346,8 @@ static void tegra_fbdev_free(struct tegra_fbdev *fbdev)
 
 void tegra_fbdev_restore_mode(struct tegra_fbdev *fbdev)
 {
-       if (fbdev) {
-               drm_modeset_lock_all(fbdev->base.dev);
-               drm_fb_helper_restore_fbdev_mode(&fbdev->base);
-               drm_modeset_unlock_all(fbdev->base.dev);
-       }
+       if (fbdev)
+               drm_fb_helper_restore_fbdev_mode_unlocked(&fbdev->base);
 }
 
 static void tegra_fb_output_poll_changed(struct drm_device *drm)
index 6e622f7d481d85b76219edab75815423b69ba47b..7997246d4039fdfc9cf0dd183484187f04624c15 100644 (file)
@@ -108,7 +108,7 @@ int drm_fb_helper_set_par(struct fb_info *info);
 int drm_fb_helper_check_var(struct fb_var_screeninfo *var,
                            struct fb_info *info);
 
-bool drm_fb_helper_restore_fbdev_mode(struct drm_fb_helper *fb_helper);
+bool drm_fb_helper_restore_fbdev_mode_unlocked(struct drm_fb_helper *fb_helper);
 void drm_fb_helper_fill_var(struct fb_info *info, struct drm_fb_helper *fb_helper,
                            uint32_t fb_width, uint32_t fb_height);
 void drm_fb_helper_fill_fix(struct fb_info *info, uint32_t pitch,