Re: [PATCH 5.10 016/101] drm/vc4: hdmi: Make sure the controller is powered in detect

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi!

> [ Upstream commit 9984d6664ce9dcbbc713962539eaf7636ea246c2 ]
> 
> If the HPD GPIO is not available and drm_probe_ddc fails, we end up
> reading the HDMI_HOTPLUG register, but the controller might be powered
> off resulting in a CPU hang. Make sure we have the power domain and the
> HSM clock powered during the detect cycle to prevent the hang from
> happening.

If the WARN_ON ever triggers, we'll get unbalance on pm usage
counts. This should use pm_runtime_get_sync().

Plus, we don't really need to duplicate code at function exit.

Signed-off-by: Pavel Machek <pavel@xxxxxxx>

> +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
> @@ -146,6 +146,8 @@ vc4_hdmi_connector_detect(struct drm_connector *connector, bool force)
>  	struct vc4_hdmi *vc4_hdmi = connector_to_vc4_hdmi(connector);
>  	bool connected = false;
>  
> +	WARN_ON(pm_runtime_resume_and_get(&vc4_hdmi->pdev->dev));
> +
>  	if (vc4_hdmi->hpd_gpio) {
>  		if (gpio_get_value_cansleep(vc4_hdmi->hpd_gpio) ^
>  		    vc4_hdmi->hpd_active_low)
> @@ -167,10 +169,12 @@ vc4_hdmi_connector_detect(struct drm_connector *connector, bool force)
>  			}
>  		}
>  
> +		pm_runtime_put(&vc4_hdmi->pdev->dev);
>  		return connector_status_connected;
>  	}
>  
>  	cec_phys_addr_invalidate(vc4_hdmi->cec_adap);
> +	pm_runtime_put(&vc4_hdmi->pdev->dev);
>  	return connector_status_disconnected;
>  }
>  

diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c
index 88a8cb840cd5..3b145f9f6c87 100644
--- a/drivers/gpu/drm/vc4/vc4_hdmi.c
+++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
@@ -146,7 +146,7 @@ vc4_hdmi_connector_detect(struct drm_connector *connector, bool force)
 	struct vc4_hdmi *vc4_hdmi = connector_to_vc4_hdmi(connector);
 	bool connected = false;
 
-	WARN_ON(pm_runtime_resume_and_get(&vc4_hdmi->pdev->dev));
+	WARN_ON(pm_runtime_get_sync(&vc4_hdmi->pdev->dev));
 
 	if (vc4_hdmi->hpd_gpio) {
 		if (gpio_get_value_cansleep(vc4_hdmi->hpd_gpio) ^
@@ -168,12 +168,9 @@ vc4_hdmi_connector_detect(struct drm_connector *connector, bool force)
 				kfree(edid);
 			}
 		}
+	} else
+		cec_phys_addr_invalidate(vc4_hdmi->cec_adap);
 
-		pm_runtime_put(&vc4_hdmi->pdev->dev);
-		return connector_status_connected;
-	}
-
-	cec_phys_addr_invalidate(vc4_hdmi->cec_adap);
 	pm_runtime_put(&vc4_hdmi->pdev->dev);
 	return connector_status_disconnected;
 }

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

Attachment: signature.asc
Description: Digital signature


[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux