diff mbox series

drm/komeda: Reordered the komeda's de-init functions

Message ID 20190820174606.1133-1-ayan.halder@arm.com (mailing list archive)
State New, archived
Headers show
Series drm/komeda: Reordered the komeda's de-init functions | expand

Commit Message

Ayan Halder Aug. 20, 2019, 5:46 p.m. UTC
The de-init routine should be doing the following in order:-
1. Unregister the drm device
2. Shut down the crtcs - failing to do this might cause a connector leakage
See the 'commit 109c4d18e574 ("drm/arm/malidp: Ensure that the crtcs are
shutdown before removing any encoder/connector")'
3. Disable the interrupts
4. Unbind the components
5. Free up DRM mode_config info

Signed-off-by: Ayan Kumar Halder <ayan.halder@arm.com>
---
 .../gpu/drm/arm/display/komeda/komeda_kms.c   | 20 +++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

Comments

Mihail Atanassov Aug. 23, 2019, 10:42 a.m. UTC | #1
On Tuesday, 20 August 2019 18:46:19 BST Ayan Halder wrote:
> The de-init routine should be doing the following in order:-
> 1. Unregister the drm device
> 2. Shut down the crtcs - failing to do this might cause a connector leakage
> See the 'commit 109c4d18e574 ("drm/arm/malidp: Ensure that the crtcs are
> shutdown before removing any encoder/connector")'
> 3. Disable the interrupts
> 4. Unbind the components
> 5. Free up DRM mode_config info
> 
> Signed-off-by: Ayan Kumar Halder <ayan.halder@arm.com>
> ---
>  .../gpu/drm/arm/display/komeda/komeda_kms.c   | 20 +++++++++++++------
>  1 file changed, 14 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c
> index 89191a555c84..e219d1b67100 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c
> @@ -13,6 +13,7 @@
>  #include <drm/drm_fb_helper.h>
>  #include <drm/drm_gem_cma_helper.h>
>  #include <drm/drm_gem_framebuffer_helper.h>
> +#include <drm/drm_probe_helper.h>
Can we keep the include list in alphabetical order?
>  #include <drm/drm_irq.h>
>  #include <drm/drm_vblank.h>
>  
> @@ -304,24 +305,30 @@ struct komeda_kms_dev *komeda_kms_attach(struct komeda_dev *mdev)
>  			       komeda_kms_irq_handler, IRQF_SHARED,
>  			       drm->driver->name, drm);
>  	if (err)
> -		goto cleanup_mode_config;
> +		goto free_component_binding;
>  
>  	err = mdev->funcs->enable_irq(mdev);
>  	if (err)
> -		goto cleanup_mode_config;
> +		goto free_component_binding;
>  
>  	drm->irq_enabled = true;
>  
>  	err = drm_dev_register(drm, 0);
>  	if (err)
> -		goto cleanup_mode_config;
> +		goto free_interrupts;
>  
>  	return kms;
>  
> -cleanup_mode_config:
> +free_interrupts:
>  	drm->irq_enabled = false;
> +	mdev->funcs->disable_irq(mdev);
> +free_component_binding:
> +	component_unbind_all(mdev->dev, drm);
> +cleanup_mode_config:
>  	drm_mode_config_cleanup(drm);
>  	komeda_kms_cleanup_private_objs(kms);
> +	drm->dev_private = NULL;
> +	drm_dev_put(drm);
>  free_kms:
>  	kfree(kms);
>  	return ERR_PTR(err);
> @@ -332,12 +339,13 @@ void komeda_kms_detach(struct komeda_kms_dev *kms)
>  	struct drm_device *drm = &kms->base;
>  	struct komeda_dev *mdev = drm->dev_private;
>  
> +	drm_dev_unregister(drm);
> +	drm_atomic_helper_shutdown(drm);
>  	drm->irq_enabled = false;
>  	mdev->funcs->disable_irq(mdev);
> -	drm_dev_unregister(drm);
>  	component_unbind_all(mdev->dev, drm);
> -	komeda_kms_cleanup_private_objs(kms);
>  	drm_mode_config_cleanup(drm);
> +	komeda_kms_cleanup_private_objs(kms);
>  	drm->dev_private = NULL;
>  	drm_dev_put(drm);
>  }
> 

Thanks. See my include order comment above, with that fixed:

Reviewed-by: Mihail Atanassov <mihail.atanassov@arm.com>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c
index 89191a555c84..e219d1b67100 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c
@@ -13,6 +13,7 @@ 
 #include <drm/drm_fb_helper.h>
 #include <drm/drm_gem_cma_helper.h>
 #include <drm/drm_gem_framebuffer_helper.h>
+#include <drm/drm_probe_helper.h>
 #include <drm/drm_irq.h>
 #include <drm/drm_vblank.h>
 
@@ -304,24 +305,30 @@  struct komeda_kms_dev *komeda_kms_attach(struct komeda_dev *mdev)
 			       komeda_kms_irq_handler, IRQF_SHARED,
 			       drm->driver->name, drm);
 	if (err)
-		goto cleanup_mode_config;
+		goto free_component_binding;
 
 	err = mdev->funcs->enable_irq(mdev);
 	if (err)
-		goto cleanup_mode_config;
+		goto free_component_binding;
 
 	drm->irq_enabled = true;
 
 	err = drm_dev_register(drm, 0);
 	if (err)
-		goto cleanup_mode_config;
+		goto free_interrupts;
 
 	return kms;
 
-cleanup_mode_config:
+free_interrupts:
 	drm->irq_enabled = false;
+	mdev->funcs->disable_irq(mdev);
+free_component_binding:
+	component_unbind_all(mdev->dev, drm);
+cleanup_mode_config:
 	drm_mode_config_cleanup(drm);
 	komeda_kms_cleanup_private_objs(kms);
+	drm->dev_private = NULL;
+	drm_dev_put(drm);
 free_kms:
 	kfree(kms);
 	return ERR_PTR(err);
@@ -332,12 +339,13 @@  void komeda_kms_detach(struct komeda_kms_dev *kms)
 	struct drm_device *drm = &kms->base;
 	struct komeda_dev *mdev = drm->dev_private;
 
+	drm_dev_unregister(drm);
+	drm_atomic_helper_shutdown(drm);
 	drm->irq_enabled = false;
 	mdev->funcs->disable_irq(mdev);
-	drm_dev_unregister(drm);
 	component_unbind_all(mdev->dev, drm);
-	komeda_kms_cleanup_private_objs(kms);
 	drm_mode_config_cleanup(drm);
+	komeda_kms_cleanup_private_objs(kms);
 	drm->dev_private = NULL;
 	drm_dev_put(drm);
 }