drm/msm/hdmi: handle runtime resume failure during power on
PATCH 1/1 drm/msm/hdmi: handle runtime resume failure during power on
msm_hdmi_power_on() ignores runtime resume failures, and atomic_pre_enable then records the bridge as powered and accesses HDMI registers. The later disable path also drops a runtime PM reference that was not acquired.
Return the resume error to atomic_pre_enable, unwind the PHY resources, and stop the enable sequence without setting power_on. Also honor errors from the preceding PHY resource enable operation so the unwind is only used after successful acquisition.
--- drivers/gpu/drm/msm/hdmi/hdmi_bridge.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-)
drivers/gpu/drm/msm/hdmi/hdmi_bridge.c +22 -4
@@ -13,14 +13,16 @@#include "msm_kms.h" #include "hdmi.h" -static void msm_hdmi_power_on (struct drm_bridge *bridge) +static int msm_hdmi_power_on (struct drm_bridge *bridge) {struct drm_device *dev = bridge->dev;struct hdmi_bridge *hdmi_bridge =to_hdmi_bridge (bridge);struct hdmi *hdmi = hdmi_bridge->hdmi;int ret; -pm_runtime_resume_and_get (&hdmi->pdev->dev); + ret =pm_runtime_resume_and_get (&hdmi->pdev->dev); +if (ret <0 ) +return ret;if (hdmi->extp_clk) {DBG ("pixclock: %lu" , hdmi->pixclock);
@@ -32,6 +34,8 @@ static void msm_hdmi_power_on(struct drm_bridge *bridge)if (ret)DRM_DEV_ERROR (dev->dev,"failed to enable extp clk: %d\n" , ret); } + +return 0 ; }static void power_off (struct drm_bridge *bridge)
@@ -276,6 +280,7 @@ static void msm_hdmi_bridge_atomic_pre_enable(struct drm_bridge *bridge,struct drm_connector *connector;struct drm_connector_state *conn_state;struct drm_crtc_state *crtc_state; +int ret;DBG ("power up" );
@@ -289,8 +294,16 @@ static void msm_hdmi_bridge_atomic_pre_enable(struct drm_bridge *bridge,mutex_lock (&hdmi->state_mutex);if (!hdmi->power_on) { -msm_hdmi_phy_resource_enable (phy); -msm_hdmi_power_on (bridge); + ret =msm_hdmi_phy_resource_enable (phy); +if (ret) + goto unlock; + + ret =msm_hdmi_power_on (bridge); +if (ret) { +msm_hdmi_phy_resource_disable (phy); + goto unlock; + } + hdmi->power_on = true; }mutex_unlock (&hdmi->state_mutex);
@@ -306,6 +319,11 @@ static void msm_hdmi_bridge_atomic_pre_enable(struct drm_bridge *bridge,if (hdmi->hdcp_ctrl)msm_hdmi_hdcp_on (hdmi->hdcp_ctrl); + +return ; + +unlock: +mutex_unlock (&hdmi->state_mutex); } static void msm_hdmi_bridge_atomic_post_disable(struct drm_bridge *bridge,
Signature · 1 line
2.34.1
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] drm/msm/hdmi: system crash in post_disable on unclocked MMIO due to pre_enable error path --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] drm/msm/hdmi: system crash in post_disable on unclocked MMIO due to pre_enable error path --
commit 15a43ff6d8f2324644d0916454344e0a91654014
Author: Jiale Yao <[email protected]>
drm/msm/hdmi: handle runtime resume failure during power on
This commit attempts to handle runtime PM failures in msm_hdmi_power_on() by returning errors to msm_hdmi_bridge_atomic_pre_enable(). It unwinds the PHY resources and aborts the sequence early if power-on or PHY resource enablement fails.
Quoted 4 lines
drivers/gpu/drm/msm/hdmi/hdmi_bridge.c +0
-0
[ ... ]
Quoted 6 lines
drivers/gpu/drm/msm/hdmi/hdmi_bridge.c +0
-2@@ -289,8 +294,16 @@ static void msm_hdmi_bridge_atomic_pre_enable(struct drm_bridge *bridge,mutex_lock (&hdmi->state_mutex);if (!hdmi->power_on) { -msm_hdmi_phy_resource_enable (phy); -msm_hdmi_power_on (bridge);
drivers/gpu/drm/msm/hdmi/hdmi_bridge.c static void msm_hdmi_bridge_atomic_pre_enable(struct drm_bridge *bridge, · line 306
Quoted 10 lines
drivers/gpu/drm/msm/hdmi/hdmi_bridge.c +10
-0+ ret =msm_hdmi_phy_resource_enable (phy); +if (ret) + goto unlock; + + ret =msm_hdmi_power_on (bridge); +if (ret) { +msm_hdmi_phy_resource_disable (phy); + goto unlock; + } +
[Severity: High]
Does this error path lead to a system crash later during teardown?
If msm_hdmi_power_on() fails, this new path turns off the PHY resources and jumps to the unlock label, leaving hdmi->power_on = false. However, msm_hdmi_bridge_atomic_pre_enable() returns void, so the DRM core is unaware of the failure and assumes the display pipeline was successfully enabled.
When the DRM core later tears down the pipeline, it will call msm_hdmi_bridge_atomic_post_disable(). Looking at that function:
drivers/gpu/drm/msm/hdmi/hdmi_bridge.c:msm_hdmi_bridge_atomic_post_disable() {
...
/* Keep the HDMI enabled if the HPD is enabled */
mutex_lock(&hdmi->state_mutex);
msm_hdmi_set_mode(hdmi, hdmi->hpd_enabled);
msm_hdmi_phy_powerdown(phy);
if (hdmi->power_on) {
...
}These MMIO writes in msm_hdmi_set_mode() and msm_hdmi_phy_powerdown() are executed unconditionally, before the hdmi->power_on check.
Because the clocks were never enabled (or were disabled during this error unwind), will these unconditional MMIO writes cause a system crash (Synchronous External Abort) by accessing unclocked hardware?
Quoted 3 lines
drivers/gpu/drm/msm/hdmi/hdmi_bridge.c +0
-0hdmi->power_on = true; }mutex_unlock (&hdmi->state_mutex);
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1