diff mbox series

[v2] drm/msm/dp: power off DP phy bases on phy state at suspend

Message ID 1622225335-9875-1-git-send-email-khsieh@codeaurora.org
State New
Headers show
Series [v2] drm/msm/dp: power off DP phy bases on phy state at suspend | expand

Commit Message

Kuogee Hsieh May 28, 2021, 6:08 p.m. UTC
Normal DP suspend operation contains two steps, display off followed
by dp suspend, to complete system wide suspending cycle if display is
up at that time. In this case, DP phy will be powered off at display
off. However there is an exception case that depending on the timing
of dongle plug in during system wide suspending, sometimes display off
procedure may be skipped and dp suspend was called directly. In this
case, dp phy is stay at powered on (phy->power_count = 1) so that at
next resume dp driver crash at main link clock enable due to phy is
not physically powered on.  This patch add phy_power_off() at
dp_ctrl_host_deinit() which is called by dp_pm_suspend() to power off
phy according to the state of is_phy_on flag.

Changes in V2:
-- stashed changes into dp_ctrl.c
-- add is_phy_on to monitor phy state

Fixes: 0114f31a2903 ("drm/msm/dp: handle irq_hpd with sink_count = 0 correctly)

Sgned-off-by: Kuogee Hsieh <khsieh@codeaurora.org>
---
 drivers/gpu/drm/msm/dp/dp_ctrl.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/msm/dp/dp_ctrl.c b/drivers/gpu/drm/msm/dp/dp_ctrl.c
index dbd8943..3924ac6 100644
--- a/drivers/gpu/drm/msm/dp/dp_ctrl.c
+++ b/drivers/gpu/drm/msm/dp/dp_ctrl.c
@@ -77,6 +77,8 @@  struct dp_ctrl_private {
 	struct dp_parser *parser;
 	struct dp_catalog *catalog;
 
+	bool is_phy_on;
+
 	struct opp_table *opp_table;
 
 	struct completion idle_comp;
@@ -1336,6 +1338,7 @@  static int dp_ctrl_enable_mainlink_clocks(struct dp_ctrl_private *ctrl)
 
 	phy_configure(phy, &dp_io->phy_opts);
 	phy_power_on(phy);
+	ctrl->is_phy_on = true;
 
 	ret = dp_power_clk_enable(ctrl->power, DP_CTRL_PM, true);
 	if (ret)
@@ -1414,6 +1417,11 @@  void dp_ctrl_host_deinit(struct dp_ctrl *dp_ctrl)
 	phy = dp_io->phy;
 
 	dp_catalog_ctrl_enable_irq(ctrl->catalog, false);
+	if (ctrl->is_phy_on) {
+		phy_power_off(phy);
+		ctrl->is_phy_on = false;
+	}
+
 	phy_exit(phy);
 
 	DRM_DEBUG_DP("Host deinitialized successfully\n");
@@ -1457,6 +1465,8 @@  static int dp_ctrl_reinitialize_mainlink(struct dp_ctrl_private *ctrl)
 		return ret;
 	}
 	phy_power_off(phy);
+	ctrl->is_phy_on = false;
+
 	/* hw recommended delay before re-enabling clocks */
 	msleep(20);
 
@@ -1488,6 +1498,8 @@  static int dp_ctrl_deinitialize_mainlink(struct dp_ctrl_private *ctrl)
 	}
 
 	phy_power_off(phy);
+	ctrl->is_phy_on = false;
+
 	phy_exit(phy);
 
 	return 0;
@@ -1840,6 +1852,7 @@  int dp_ctrl_off_link_stream(struct dp_ctrl *dp_ctrl)
 	}
 
 	phy_power_off(phy);
+	ctrl->is_phy_on = false;
 
 	/* aux channel down, reinit phy */
 	phy_exit(phy);
@@ -1894,6 +1907,8 @@  int dp_ctrl_off(struct dp_ctrl *dp_ctrl)
 	}
 
 	phy_power_off(phy);
+	ctrl->is_phy_on = false;
+
 	phy_exit(phy);
 
 	DRM_DEBUG_DP("DP off done\n");