gma500: unload fixes
authorAlan Cox <alan@linux.intel.com>
Mon, 14 May 2012 11:04:00 +0000 (12:04 +0100)
committerDave Airlie <airlied@redhat.com>
Thu, 17 May 2012 10:05:30 +0000 (11:05 +0100)
Debugging the lid problem tested various error paths which were found
wanting so start fixing them up.

There is a ton of improvement work could be done here so that every bit
of functionality agrees if its _fini, _uninit, etc, and they agree who
is responsible for deciding if the clean up is needed.

That can come later.

Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
drivers/gpu/drm/gma500/framebuffer.c
drivers/gpu/drm/gma500/intel_bios.c
drivers/gpu/drm/gma500/psb_drv.c
drivers/gpu/drm/gma500/psb_drv.h

index 659ed3933b5bc722ff330eb82849e53d81ee9ce6..8d77224afc3422521048a311fc3fe9af6844ef89 100644 (file)
@@ -800,15 +800,20 @@ void psb_modeset_init(struct drm_device *dev)
 
        if (dev_priv->ops->errata)
                dev_priv->ops->errata(dev);
+
+        dev_priv->modeset = true;
 }
 
 void psb_modeset_cleanup(struct drm_device *dev)
 {
-       mutex_lock(&dev->struct_mutex);
+       struct drm_psb_private *dev_priv = dev->dev_private;
+       if (dev_priv->modeset) {
+               mutex_lock(&dev->struct_mutex);
 
-       drm_kms_helper_poll_fini(dev);
-       psb_fbdev_fini(dev);
-       drm_mode_config_cleanup(dev);
+               drm_kms_helper_poll_fini(dev);
+               psb_fbdev_fini(dev);
+               drm_mode_config_cleanup(dev);
 
-       mutex_unlock(&dev->struct_mutex);
+               mutex_unlock(&dev->struct_mutex);
+       }
 }
index 479e4497d26ce19257425898342298e660d27311..973d7f6d66b7076d9bd55277b0e3235ba2e4dfac 100644 (file)
@@ -490,26 +490,8 @@ bool psb_intel_init_bios(struct drm_device *dev)
 void psb_intel_destroy_bios(struct drm_device *dev)
 {
        struct drm_psb_private *dev_priv = dev->dev_private;
-       struct drm_display_mode *sdvo_lvds_vbt_mode =
-                               dev_priv->sdvo_lvds_vbt_mode;
-       struct drm_display_mode *lfp_lvds_vbt_mode =
-                               dev_priv->lfp_lvds_vbt_mode;
-       struct bdb_lvds_backlight *lvds_bl =
-                               dev_priv->lvds_bl;
-
-       /*free sdvo panel mode*/
-       if (sdvo_lvds_vbt_mode) {
-               dev_priv->sdvo_lvds_vbt_mode = NULL;
-               kfree(sdvo_lvds_vbt_mode);
-       }
-
-       if (lfp_lvds_vbt_mode) {
-               dev_priv->lfp_lvds_vbt_mode = NULL;
-               kfree(lfp_lvds_vbt_mode);
-       }
 
-       if (lvds_bl) {
-               dev_priv->lvds_bl = NULL;
-               kfree(lvds_bl);
-       }
+       kfree(dev_priv->sdvo_lvds_vbt_mode);
+       kfree(dev_priv->lfp_lvds_vbt_mode);
+       kfree(dev_priv->lvds_bl);
 }
index c4c6c8ea129ab1aac99d80d77307bdfe7518be4c..0c995ba0f2ec393d32251f62b6c7efb56a6288d4 100644 (file)
@@ -152,10 +152,6 @@ static void psb_lastclose(struct drm_device *dev)
        return;
 }
 
-static void psb_do_takedown(struct drm_device *dev)
-{
-}
-
 static int psb_do_init(struct drm_device *dev)
 {
        struct drm_psb_private *dev_priv = dev->dev_private;
@@ -194,7 +190,6 @@ static int psb_do_init(struct drm_device *dev)
        PSB_WSGX32(pg->gatt_start, PSB_CR_BIF_TWOD_REQ_BASE);
        return 0;
 out_err:
-       psb_do_takedown(dev);
        return ret;
 }
 
@@ -204,17 +199,16 @@ static int psb_driver_unload(struct drm_device *dev)
 
        /* Kill vblank etc here */
 
-       gma_backlight_exit(dev);
-       psb_modeset_cleanup(dev);
 
        if (dev_priv) {
+               if (dev_priv->backlight_device)
+                       gma_backlight_exit(dev);
+               psb_modeset_cleanup(dev);
 
                if (dev_priv->ops->chip_teardown)
                        dev_priv->ops->chip_teardown(dev);
 
                psb_intel_opregion_fini(dev);
-               psb_do_takedown(dev);
-
 
                if (dev_priv->pf_pd) {
                        psb_mmu_free_pagedir(dev_priv->pf_pd);
@@ -248,15 +242,13 @@ static int psb_driver_unload(struct drm_device *dev)
                        dev_priv->sgx_reg = NULL;
                }
 
+               /* Destroy VBT data */
+               psb_intel_destroy_bios(dev);
+
                kfree(dev_priv);
                dev->dev_private = NULL;
-
-               /*destroy VBT data*/
-               psb_intel_destroy_bios(dev);
        }
-
        gma_power_uninit(dev);
-
        return 0;
 }
 
index fd1bc8f6bf979243760bc0a6da90d72026cd95c5..a1b0c0bce972f7d8a6a43c839a3c776d490fa1a9 100644 (file)
@@ -507,6 +507,7 @@ struct drm_psb_private {
         * Modesetting
         */
        struct psb_intel_mode_device mode_dev;
+       bool modeset;   /* true if we have done the mode_device setup */
 
        struct drm_crtc *plane_to_crtc_mapping[PSB_NUM_PIPE];
        struct drm_crtc *pipe_to_crtc_mapping[PSB_NUM_PIPE];