diff mbox

[v2] drm/arm/malidp: Ensure that the crtcs are shutdown before removing any encoder/connector

Message ID 1523633388-15112-1-git-send-email-ayan.halder@arm.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ayan Halder April 13, 2018, 3:29 p.m. UTC
One needs to ensure that the crtcs are shutdown so that the
drm_crtc_state->connector_mask reflects that no connectors
are currently active. Further, it reduces the reference
count for each connector. This ensures that the connectors
and encoders can be cleanly removed either when _unbind
is called for the corresponding drivers or by
drm_mode_config_cleanup().

Signed-off-by: Ayan Kumar Halder <ayan.halder@arm.com>
---

Changes in v2:
 - Reset the connectors' mask and the reference counts in drm_device
before unbinding any of its components (ie connectors and 
encoders).

---
 drivers/gpu/drm/arm/malidp_drv.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Liviu Dudau April 16, 2018, 9:45 a.m. UTC | #1
On Fri, Apr 13, 2018 at 04:29:48PM +0100, Ayan Kumar Halder wrote:
> One needs to ensure that the crtcs are shutdown so that the
> drm_crtc_state->connector_mask reflects that no connectors
> are currently active. Further, it reduces the reference
> count for each connector. This ensures that the connectors
> and encoders can be cleanly removed either when _unbind
> is called for the corresponding drivers or by
> drm_mode_config_cleanup().

Describing what the code does is nice and good, however it is also
useful to have a description of what the patch fixes, or why the fix
provided by the patch is better.

In this case, we need drm_atomic_helper_shutdown() to be called before
component_unbind_all() otherwise the connectors attached to the
component device will have the wrong reference count value and will not
be cleanly cleared up.

> 
> Signed-off-by: Ayan Kumar Halder <ayan.halder@arm.com>

With the updated commit message:

Acked-by: Liviu Dudau <liviu.dudau@arm.com>

> ---
> 
> Changes in v2:
>  - Reset the connectors' mask and the reference counts in drm_device
> before unbinding any of its components (ie connectors and 
> encoders).
> 
> ---
>  drivers/gpu/drm/arm/malidp_drv.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c
> index 8d20faa..0a788d7 100644
> --- a/drivers/gpu/drm/arm/malidp_drv.c
> +++ b/drivers/gpu/drm/arm/malidp_drv.c
> @@ -278,7 +278,6 @@ static int malidp_init(struct drm_device *drm)
>  
>  static void malidp_fini(struct drm_device *drm)
>  {
> -	drm_atomic_helper_shutdown(drm);
>  	drm_mode_config_cleanup(drm);
>  }
>  
> @@ -646,6 +645,7 @@ static int malidp_bind(struct device *dev)
>  	malidp_de_irq_fini(drm);
>  	drm->irq_enabled = false;
>  irq_init_fail:
> +	drm_atomic_helper_shutdown(drm);
>  	component_unbind_all(dev, drm);
>  bind_fail:
>  	of_node_put(malidp->crtc.port);
> @@ -681,6 +681,7 @@ static void malidp_unbind(struct device *dev)
>  	malidp_se_irq_fini(drm);
>  	malidp_de_irq_fini(drm);
>  	drm->irq_enabled = false;
> +	drm_atomic_helper_shutdown(drm);
>  	component_unbind_all(dev, drm);
>  	of_node_put(malidp->crtc.port);
>  	malidp->crtc.port = NULL;
> -- 
> 2.7.4
>
diff mbox

Patch

diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c
index 8d20faa..0a788d7 100644
--- a/drivers/gpu/drm/arm/malidp_drv.c
+++ b/drivers/gpu/drm/arm/malidp_drv.c
@@ -278,7 +278,6 @@  static int malidp_init(struct drm_device *drm)
 
 static void malidp_fini(struct drm_device *drm)
 {
-	drm_atomic_helper_shutdown(drm);
 	drm_mode_config_cleanup(drm);
 }
 
@@ -646,6 +645,7 @@  static int malidp_bind(struct device *dev)
 	malidp_de_irq_fini(drm);
 	drm->irq_enabled = false;
 irq_init_fail:
+	drm_atomic_helper_shutdown(drm);
 	component_unbind_all(dev, drm);
 bind_fail:
 	of_node_put(malidp->crtc.port);
@@ -681,6 +681,7 @@  static void malidp_unbind(struct device *dev)
 	malidp_se_irq_fini(drm);
 	malidp_de_irq_fini(drm);
 	drm->irq_enabled = false;
+	drm_atomic_helper_shutdown(drm);
 	component_unbind_all(dev, drm);
 	of_node_put(malidp->crtc.port);
 	malidp->crtc.port = NULL;