Skip to contentSkip to conversation

drm/bridge: cdns-mhdp8546: Add suspend resume support to the bridge driver

PATCH In review Abhash Kumar Jha 3 participants 8 messages Jun 1 – Nov 20

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 drm/bridge: cdns-mhdp8546: Add suspend resume support to the bridge driver

Add system suspend and resume hooks to the cdns-mhdp8546 bridge driver.

While resuming we either load the firmware or activate it. Firmware is loaded only when resuming from a successful suspend-resume cycle.

If resuming due to an aborted suspend, loading the firmware is not possible because the uCPU's IMEM is only accessible after a reset and the bridge has not gone through a reset in this case. Hence, Activate the firmware that is already loaded.

Use genpd_notifier to get the power domain status of the bridge and accordingly load the firmware.

Additionally, introduce phy_power_off/on to control the power to the phy.

---
Hi,

Changes in v3:
- Register genpd_notifier callback only when genpd is available.
- Mark mhdp->powered_off = false after resume is successful.
- Use SIMPLE_DEV_PM_OPS instead of SET_SYSTEM_SLEEP_PM_OPS.
- Set mhdp->hw_state appropriately in error paths.
- Link to v2: https://lore.kernel.org/all/[email protected]/

Changes in v2:
- Fixed defined but not used [-Wunused-function] warning for suspend and resume calls.
- Link to v1: https://lore.kernel.org/all/[email protected]/

Thanks and Regards,
Abhash

 .../drm/bridge/cadence/cdns-mhdp8546-core.c   | 138 +++++++++++++++++-
 .../drm/bridge/cadence/cdns-mhdp8546-core.h   |   4 +
 2 files changed, 140 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c +136 -2
index 99888f8d55736..90d8c037a2220 100644
@@ -32,6 +32,7 @@
 #include <linux/phy/phy.h>
 #include <linux/phy/phy-dp.h>
 #include <linux/platform_device.h>
+#include <linux/pm_domain.h>
 #include <linux/slab.h>
 #include <linux/wait.h>
 
@@ -2287,6 +2288,121 @@ static void cdns_mhdp_hpd_work(struct work_struct *work)
 	drm_bridge_hpd_notify(&mhdp->bridge, cdns_mhdp_detect(mhdp));
 }
 
+static int cdns_mhdp_resume(struct device *dev)
+{
+	struct cdns_mhdp_device *mhdp = dev_get_drvdata(dev);
+	unsigned long rate;
+	int ret;
+
+	ret = clk_prepare_enable(mhdp->clk);
+	if (ret)
+		return ret;
+
+	rate = clk_get_rate(mhdp->clk);
+	writel(rate % 1000000, mhdp->regs + CDNS_SW_CLK_L);
+	writel(rate / 1000000, mhdp->regs + CDNS_SW_CLK_H);
+	writel(~0, mhdp->regs + CDNS_APB_INT_MASK);
+
+	ret = phy_init(mhdp->phy);
+	if (ret) {
+		dev_err(mhdp->dev, "Failed to initialize PHY: %d\n", ret);
+		goto disable_clk;
+	}
+	ret = phy_power_on(mhdp->phy);
+	if (ret < 0) {
+		dev_err(mhdp->dev, "Failed to power on PHY: %d\n", ret);
+		goto error;
+	}
+
+	if (mhdp->powered_off) {
+		ret = cdns_mhdp_load_firmware(mhdp);
+		if (ret)
+			goto phy_off;
+
+		ret = wait_event_timeout(mhdp->fw_load_wq,
+					mhdp->hw_state == MHDP_HW_READY,
+					msecs_to_jiffies(1000));
+		if (ret == 0) {
+			dev_err(mhdp->dev, "%s: Timeout waiting for fw loading\n",
+				__func__);
+			ret = -ETIMEDOUT;
+			goto phy_off;
+		}
+	} else {
+		ret = cdns_mhdp_set_firmware_active(mhdp, true);
+		if (ret) {
+			dev_err(mhdp->dev, "Failed to activate firmware (%pe)\n", ERR_PTR(ret));
+			goto phy_off;
+		}
+	}
+
+	mhdp->powered_off = false;
+	return 0;
+
+phy_off:
+	phy_power_off(mhdp->phy);
+error:
+	phy_exit(mhdp->phy);
+disable_clk:
+	clk_disable_unprepare(mhdp->clk);
+
+	return ret;
+}
+
+static int cdns_mhdp_suspend(struct device *dev)
+{
+	struct cdns_mhdp_device *mhdp = dev_get_drvdata(dev);
+	unsigned long timeout = msecs_to_jiffies(100);
+	int ret = 0;
+
+	cancel_work_sync(&mhdp->hpd_work);
+	ret = wait_event_timeout(mhdp->fw_load_wq,
+				 mhdp->hw_state == MHDP_HW_READY,
+				 timeout);
+
+	spin_lock(&mhdp->start_lock);
+	if (mhdp->hw_state != MHDP_HW_READY) {
+		spin_unlock(&mhdp->start_lock);
+		dev_err(mhdp->dev, "%s: Timeout waiting for fw loading\n", __func__);
+		return -ETIMEDOUT;
+	}
+	mhdp->hw_state = MHDP_HW_STOPPED;
+	spin_unlock(&mhdp->start_lock);
+
+	ret = cdns_mhdp_set_firmware_active(mhdp, false);
+	if (ret) {
+		dev_err(mhdp->dev, "Failed to stop firmware (%pe)\n", ERR_PTR(ret));
+		spin_lock(&mhdp->start_lock);
+		mhdp->hw_state = MHDP_HW_READY;
+		spin_unlock(&mhdp->start_lock);
+		goto error;
+	}
+
+	phy_power_off(mhdp->phy);
+	phy_exit(mhdp->phy);
+	clk_disable_unprepare(mhdp->clk);
+
+	/* if no power domain available, always reload firmware on resume */
+	if (!mhdp->dev->pm_domain)
+		mhdp->powered_off = true;
+
+error:
+	return ret;
+}
+
+static int mhdp_pd_notifier_cb(struct notifier_block *nb,
+			unsigned long action, void *data)
+{
+	struct cdns_mhdp_device *mhdp = container_of(nb, struct cdns_mhdp_device, pd_nb);
+
+	if (action == GENPD_NOTIFY_OFF)
+		mhdp->powered_off = true;
+
+	return 0;
+}
+
+static DEFINE_SIMPLE_DEV_PM_OPS(cdns_mhdp_pm_ops, cdns_mhdp_suspend, cdns_mhdp_resume);
+
 static int cdns_mhdp_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -2401,6 +2517,11 @@ static int cdns_mhdp_probe(struct platform_device *pdev)
 		dev_err(mhdp->dev, "Failed to initialize PHY: %d\n", ret);
 		goto plat_fini;
 	}
+	ret = phy_power_on(mhdp->phy);
+	if (ret < 0) {
+		dev_err(mhdp->dev, "Failed to power on PHY: %d\n", ret);
+		goto phy_exit;
+	}
 
 	/* Initialize the work for modeset in case of link train failure */
 	INIT_WORK(&mhdp->modeset_retry_work, cdns_mhdp_modeset_retry_fn);
@@ -2411,15 +2532,26 @@ static int cdns_mhdp_probe(struct platform_device *pdev)
 
 	ret = cdns_mhdp_load_firmware(mhdp);
 	if (ret)
-		goto phy_exit;
+		goto power_off;
 
 	if (mhdp->hdcp_supported)
 		cdns_mhdp_hdcp_init(mhdp);
 
-	drm_bridge_add(&mhdp->bridge);
+	mhdp->powered_off = false;
+	if (mhdp->dev->pm_domain) {
+		mhdp->pd_nb.notifier_call = mhdp_pd_notifier_cb;
+		ret = dev_pm_genpd_add_notifier(mhdp->dev, &mhdp->pd_nb);
+		if (ret) {
+			dev_err_probe(dev, ret, "failed to add power domain notifier\n");
+			goto power_off;
+		}
+	}
 
+	drm_bridge_add(&mhdp->bridge);
 	return 0;
 
+power_off:
+	phy_power_off(mhdp->phy);
 phy_exit:
 	phy_exit(mhdp->phy);
 plat_fini:
@@ -2457,6 +2589,7 @@ static void cdns_mhdp_remove(struct platform_device *pdev)
 				ERR_PTR(ret));
 	}
 
+	phy_power_off(mhdp->phy);
 	phy_exit(mhdp->phy);
 
 	if (mhdp->info && mhdp->info->ops && mhdp->info->ops->exit)
@@ -2488,6 +2621,7 @@ static struct platform_driver mhdp_driver = {
 	.driver	= {
 		.name		= "cdns-mhdp8546",
 		.of_match_table	= mhdp_ids,
+		.pm = pm_sleep_ptr(&cdns_mhdp_pm_ops),
 	},
 	.probe	= cdns_mhdp_probe,
 	.remove = cdns_mhdp_remove,
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.h +4 -0
index 2041ffbc019a5..31dbeaf33ccb6 100644
@@ -413,6 +413,10 @@ struct cdns_mhdp_device {
 
 	struct cdns_mhdp_hdcp hdcp;
 	bool hdcp_supported;
+
+	/* Power domain status notifier */
+	struct notifier_block pd_nb;
+	bool powered_off;
 };
 
 #define connector_to_mhdp(x) container_of(x, struct cdns_mhdp_device, connector)
Signature · 1 line
2.34.1
#1 lore raw

Hi,

Quoted 4 lines · Abhash Kumar Jha

Add system suspend and resume hooks to the cdns-mhdp8546 bridge driver.

While resuming we either load the firmware or activate it. Firmware is loaded only when resuming from a successful suspend-resume cycle.

It's not clear from the patch if this is a fix or improvement. It sounds a bit like a fix, but it doesn't mention any kind of issue in the driver. So, why is this patch needed?

Quoted 9 lines

If resuming due to an aborted suspend, loading the firmware is not possible because the uCPU's IMEM is only accessible after a reset and the bridge has not gone through a reset in this case. Hence, Activate the firmware that is already loaded.

Use genpd_notifier to get the power domain status of the bridge and accordingly load the firmware.

Additionally, introduce phy_power_off/on to control the power to the phy.

If you write "also" or "additionally" or such in a commit desc, you should stop and think if that part should actually be a separate patch. Also, why is that change needed?

Overall, this sounds fragile/hacky to me.

The first thing is that usually you shouldn't use system suspend/resume in a bridge driver. When a system suspend happend, the display pipeline will be disabled, so this driver will get an atomic_disable() call, and enable when resuming. You can use runtime PM hooks if you need resume/suspend hooks.

The second thing is the PD notifier. Is there really no way we can see the state from the MDHP IP registers?

Tomi

Quoted 228 lines

---
Hi,

Changes in v3:
- Register genpd_notifier callback only when genpd is available.
- Mark mhdp->powered_off = false after resume is successful.
- Use SIMPLE_DEV_PM_OPS instead of SET_SYSTEM_SLEEP_PM_OPS.
- Set mhdp->hw_state appropriately in error paths.
- Link to v2: https://lore.kernel.org/all/[email protected]/

Changes in v2:
- Fixed defined but not used [-Wunused-function] warning for suspend and resume calls.
- Link to v1: https://lore.kernel.org/all/[email protected]/

Thanks and Regards,
Abhash

  .../drm/bridge/cadence/cdns-mhdp8546-core.c   | 138 +++++++++++++++++-
  .../drm/bridge/cadence/cdns-mhdp8546-core.h   |   4 +
  2 files changed, 140 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c +136 -2
index 99888f8d55736..90d8c037a2220 100644
@@ -32,6 +32,7 @@
  #include <linux/phy/phy.h>
  #include <linux/phy/phy-dp.h>
  #include <linux/platform_device.h>
+#include <linux/pm_domain.h>
  #include <linux/slab.h>
  #include <linux/wait.h>
 
@@ -2287,6 +2288,121 @@ static void cdns_mhdp_hpd_work(struct work_struct *work)
  	drm_bridge_hpd_notify(&mhdp->bridge, cdns_mhdp_detect(mhdp));
  }
 
+static int cdns_mhdp_resume(struct device *dev)
+{
+	struct cdns_mhdp_device *mhdp = dev_get_drvdata(dev);
+	unsigned long rate;
+	int ret;
+
+	ret = clk_prepare_enable(mhdp->clk);
+	if (ret)
+		return ret;
+
+	rate = clk_get_rate(mhdp->clk);
+	writel(rate % 1000000, mhdp->regs + CDNS_SW_CLK_L);
+	writel(rate / 1000000, mhdp->regs + CDNS_SW_CLK_H);
+	writel(~0, mhdp->regs + CDNS_APB_INT_MASK);
+
+	ret = phy_init(mhdp->phy);
+	if (ret) {
+		dev_err(mhdp->dev, "Failed to initialize PHY: %d\n", ret);
+		goto disable_clk;
+	}
+	ret = phy_power_on(mhdp->phy);
+	if (ret < 0) {
+		dev_err(mhdp->dev, "Failed to power on PHY: %d\n", ret);
+		goto error;
+	}
+
+	if (mhdp->powered_off) {
+		ret = cdns_mhdp_load_firmware(mhdp);
+		if (ret)
+			goto phy_off;
+
+		ret = wait_event_timeout(mhdp->fw_load_wq,
+					mhdp->hw_state == MHDP_HW_READY,
+					msecs_to_jiffies(1000));
+		if (ret == 0) {
+			dev_err(mhdp->dev, "%s: Timeout waiting for fw loading\n",
+				__func__);
+			ret = -ETIMEDOUT;
+			goto phy_off;
+		}
+	} else {
+		ret = cdns_mhdp_set_firmware_active(mhdp, true);
+		if (ret) {
+			dev_err(mhdp->dev, "Failed to activate firmware (%pe)\n", ERR_PTR(ret));
+			goto phy_off;
+		}
+	}
+
+	mhdp->powered_off = false;
+	return 0;
+
+phy_off:
+	phy_power_off(mhdp->phy);
+error:
+	phy_exit(mhdp->phy);
+disable_clk:
+	clk_disable_unprepare(mhdp->clk);
+
+	return ret;
+}
+
+static int cdns_mhdp_suspend(struct device *dev)
+{
+	struct cdns_mhdp_device *mhdp = dev_get_drvdata(dev);
+	unsigned long timeout = msecs_to_jiffies(100);
+	int ret = 0;
+
+	cancel_work_sync(&mhdp->hpd_work);
+	ret = wait_event_timeout(mhdp->fw_load_wq,
+				 mhdp->hw_state == MHDP_HW_READY,
+				 timeout);
+
+	spin_lock(&mhdp->start_lock);
+	if (mhdp->hw_state != MHDP_HW_READY) {
+		spin_unlock(&mhdp->start_lock);
+		dev_err(mhdp->dev, "%s: Timeout waiting for fw loading\n", __func__);
+		return -ETIMEDOUT;
+	}
+	mhdp->hw_state = MHDP_HW_STOPPED;
+	spin_unlock(&mhdp->start_lock);
+
+	ret = cdns_mhdp_set_firmware_active(mhdp, false);
+	if (ret) {
+		dev_err(mhdp->dev, "Failed to stop firmware (%pe)\n", ERR_PTR(ret));
+		spin_lock(&mhdp->start_lock);
+		mhdp->hw_state = MHDP_HW_READY;
+		spin_unlock(&mhdp->start_lock);
+		goto error;
+	}
+
+	phy_power_off(mhdp->phy);
+	phy_exit(mhdp->phy);
+	clk_disable_unprepare(mhdp->clk);
+
+	/* if no power domain available, always reload firmware on resume */
+	if (!mhdp->dev->pm_domain)
+		mhdp->powered_off = true;
+
+error:
+	return ret;
+}
+
+static int mhdp_pd_notifier_cb(struct notifier_block *nb,
+			unsigned long action, void *data)
+{
+	struct cdns_mhdp_device *mhdp = container_of(nb, struct cdns_mhdp_device, pd_nb);
+
+	if (action == GENPD_NOTIFY_OFF)
+		mhdp->powered_off = true;
+
+	return 0;
+}
+
+static DEFINE_SIMPLE_DEV_PM_OPS(cdns_mhdp_pm_ops, cdns_mhdp_suspend, cdns_mhdp_resume);
+
  static int cdns_mhdp_probe(struct platform_device *pdev)
  {
  	struct device *dev = &pdev->dev;
@@ -2401,6 +2517,11 @@ static int cdns_mhdp_probe(struct platform_device *pdev)
  		dev_err(mhdp->dev, "Failed to initialize PHY: %d\n", ret);
  		goto plat_fini;
  	}
+	ret = phy_power_on(mhdp->phy);
+	if (ret < 0) {
+		dev_err(mhdp->dev, "Failed to power on PHY: %d\n", ret);
+		goto phy_exit;
+	}
 
  	/* Initialize the work for modeset in case of link train failure */
  	INIT_WORK(&mhdp->modeset_retry_work, cdns_mhdp_modeset_retry_fn);
@@ -2411,15 +2532,26 @@ static int cdns_mhdp_probe(struct platform_device *pdev)
 
  	ret = cdns_mhdp_load_firmware(mhdp);
  	if (ret)
-		goto phy_exit;
+		goto power_off;
 
  	if (mhdp->hdcp_supported)
  		cdns_mhdp_hdcp_init(mhdp);
 
-	drm_bridge_add(&mhdp->bridge);
+	mhdp->powered_off = false;
+	if (mhdp->dev->pm_domain) {
+		mhdp->pd_nb.notifier_call = mhdp_pd_notifier_cb;
+		ret = dev_pm_genpd_add_notifier(mhdp->dev, &mhdp->pd_nb);
+		if (ret) {
+			dev_err_probe(dev, ret, "failed to add power domain notifier\n");
+			goto power_off;
+		}
+	}
 
+	drm_bridge_add(&mhdp->bridge);
  	return 0;
 
+power_off:
+	phy_power_off(mhdp->phy);
  phy_exit:
  	phy_exit(mhdp->phy);
  plat_fini:
@@ -2457,6 +2589,7 @@ static void cdns_mhdp_remove(struct platform_device *pdev)
  				ERR_PTR(ret));
  	}
 
+	phy_power_off(mhdp->phy);
  	phy_exit(mhdp->phy);
 
  	if (mhdp->info && mhdp->info->ops && mhdp->info->ops->exit)
@@ -2488,6 +2621,7 @@ static struct platform_driver mhdp_driver = {
  	.driver	= {
  		.name		= "cdns-mhdp8546",
  		.of_match_table	= mhdp_ids,
+		.pm = pm_sleep_ptr(&cdns_mhdp_pm_ops),
  	},
  	.probe	= cdns_mhdp_probe,
  	.remove = cdns_mhdp_remove,
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.h +4 -0
index 2041ffbc019a5..31dbeaf33ccb6 100644
@@ -413,6 +413,10 @@ struct cdns_mhdp_device {
 
  	struct cdns_mhdp_hdcp hdcp;
  	bool hdcp_supported;
+
+	/* Power domain status notifier */
+	struct notifier_block pd_nb;
+	bool powered_off;
  };
 
  #define connector_to_mhdp(x) container_of(x, struct cdns_mhdp_device, connector)
author
#2 lore raw

Hi Tomi,

Thanks for the review.

Quoted 9 lines · Tomi Valkeinen

Hi,

Quoted 4 lines · Abhash Kumar Jha

Add system suspend and resume hooks to the cdns-mhdp8546 bridge driver.

While resuming we either load the firmware or activate it. Firmware is loaded only when resuming from a successful suspend-resume cycle.

It's not clear from the patch if this is a fix or improvement. It sounds a bit like a fix, but it doesn't mention any kind of issue in the driver. So, why is this patch needed?

The driver lacked support for suspend-resume as stated in the todo on the driver, So the patch adds this improvement.

Quoted 6 lines
Quoted 6 lines

If resuming due to an aborted suspend, loading the firmware is not possible because the uCPU's IMEM is only accessible after a reset and the bridge has not gone through a reset in this case. Hence, Activate the firmware that is already loaded.

Quoted 6 lines
Quoted 4 lines

Use genpd_notifier to get the power domain status of the bridge and accordingly load the firmware.

Additionally, introduce phy_power_off/on to control the power to the phy.

If you write "also" or "additionally" or such in a commit desc, you should stop and think if that part should actually be a separate patch. Also, why is that change needed?

The phy device could be powered off while resuming. So we are explicitly powering it on.

The phy driver api also recommends to always call phy_init() first followed by a phy_power_on().

"Some PHY drivers may not implement phy_init or phy_power_on, but controllers should always call these functions to be compatible with other PHYs"

Quoted 4 lines

Overall, this sounds fragile/hacky to me.

The first thing is that usually you shouldn't use system suspend/resume in a bridge driver. When a system suspend happend, the display pipeline will be disabled, so this driver will get an atomic_disable() call, and enable when resuming. You can use runtime PM hooks if you need resume/suspend hooks.

Thanks for the suggestion, I will use the runtime PM instead.

Quoted 1 line

The second thing is the PD notifier. Is there really no way we can see the state from the MDHP IP registers?

The other way that i found was to read the MHDP KEEP_ALIVE_p register twice to know if the firmware is incrementing the counter.

Based on that we can decide if the bridge is active or not. Do you think this approach would be okay over the PD notifier?

Thanks,

Abhash

Quoted 233 lines

 Tomi

Quoted 229 lines

---
Hi,

Changes in v3:
- Register genpd_notifier callback only when genpd is available.
- Mark mhdp->powered_off = false after resume is successful.
- Use SIMPLE_DEV_PM_OPS instead of SET_SYSTEM_SLEEP_PM_OPS.
- Set mhdp->hw_state appropriately in error paths.
- Link to v2:
https://lore.kernel.org/all/[email protected]/

Changes in v2:
- Fixed defined but not used [-Wunused-function] warning for suspend and resume calls.
- Link to v1:
https://lore.kernel.org/all/[email protected]/

Thanks and Regards,
Abhash

  .../drm/bridge/cadence/cdns-mhdp8546-core.c   | 138 +++++++++++++++++- .../drm/bridge/cadence/cdns-mhdp8546-core.h   |   4 +

  2 files changed, 140 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c +1 -0
index 99888f8d55736..90d8c037a2220 100644
@@ -32,6 +32,7 @@
   #include <linux/phy/phy.h>
   #include <linux/phy/phy-dp.h>
   #include <linux/platform_device.h>
+#include <linux/pm_domain.h>
   #include <linux/slab.h>
   #include <linux/wait.h>
   @@ -2287,6 +2288,121 @@ static void cdns_mhdp_hpd_work(struct work_struct *work)

      drm_bridge_hpd_notify(&mhdp->bridge, cdns_mhdp_detect(mhdp)); }
  +static int cdns_mhdp_resume(struct device *dev)

drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c +43 -0
+{
+    struct cdns_mhdp_device *mhdp = dev_get_drvdata(dev);
+    unsigned long rate;
+    int ret;
+
+    ret = clk_prepare_enable(mhdp->clk);
+    if (ret)
+        return ret;
+
+    rate = clk_get_rate(mhdp->clk);
+    writel(rate % 1000000, mhdp->regs + CDNS_SW_CLK_L);
+    writel(rate / 1000000, mhdp->regs + CDNS_SW_CLK_H);
+    writel(~0, mhdp->regs + CDNS_APB_INT_MASK);
+
+    ret = phy_init(mhdp->phy);
+    if (ret) {
+        dev_err(mhdp->dev, "Failed to initialize PHY: %d\n", ret);
+        goto disable_clk;
+    }
+    ret = phy_power_on(mhdp->phy);
+    if (ret < 0) {
+        dev_err(mhdp->dev, "Failed to power on PHY: %d\n", ret);
+        goto error;
+    }
+
+    if (mhdp->powered_off) {
+        ret = cdns_mhdp_load_firmware(mhdp);
+        if (ret)
+            goto phy_off;
+
+        ret = wait_event_timeout(mhdp->fw_load_wq,
+                    mhdp->hw_state == MHDP_HW_READY,
+                    msecs_to_jiffies(1000));
+        if (ret == 0) {
+            dev_err(mhdp->dev, "%s: Timeout waiting for fw loading\n",
+                __func__);
+            ret = -ETIMEDOUT;
+            goto phy_off;
+        }
+    } else {
+        ret = cdns_mhdp_set_firmware_active(mhdp, true);
+        if (ret) {
+            dev_err(mhdp->dev, "Failed to activate firmware 

(%pe)\n", ERR_PTR(ret));
+            goto phy_off;
+        }
+    }

drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c +29 -0
+
+    mhdp->powered_off = false;
+    return 0;
+
+phy_off:
+    phy_power_off(mhdp->phy);
+error:
+    phy_exit(mhdp->phy);
+disable_clk:
+    clk_disable_unprepare(mhdp->clk);
+
+    return ret;
+}
+
+static int cdns_mhdp_suspend(struct device *dev)
+{
+    struct cdns_mhdp_device *mhdp = dev_get_drvdata(dev);
+    unsigned long timeout = msecs_to_jiffies(100);
+    int ret = 0;
+
+    cancel_work_sync(&mhdp->hpd_work);
+    ret = wait_event_timeout(mhdp->fw_load_wq,
+                 mhdp->hw_state == MHDP_HW_READY,
+                 timeout);
+
+    spin_lock(&mhdp->start_lock);
+    if (mhdp->hw_state != MHDP_HW_READY) {
+        spin_unlock(&mhdp->start_lock);
+        dev_err(mhdp->dev, "%s: Timeout waiting for fw loading\n", 

__func__);
+        return -ETIMEDOUT;
+    }
+    mhdp->hw_state = MHDP_HW_STOPPED;
+    spin_unlock(&mhdp->start_lock);
+
+    ret = cdns_mhdp_set_firmware_active(mhdp, false); +    if (ret) {
+        dev_err(mhdp->dev, "Failed to stop firmware (%pe)\n", ERR_PTR(ret));
+        spin_lock(&mhdp->start_lock);
+        mhdp->hw_state = MHDP_HW_READY;
+        spin_unlock(&mhdp->start_lock);
+        goto error;
+    }

drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c +6 -0
+
+    phy_power_off(mhdp->phy);
+    phy_exit(mhdp->phy);
+    clk_disable_unprepare(mhdp->clk);
+
+    /* if no power domain available, always reload firmware on 

resume */
+    if (!mhdp->dev->pm_domain)
+        mhdp->powered_off = true;

drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c +9 -0
+
+error:
+    return ret;
+}
+
+static int mhdp_pd_notifier_cb(struct notifier_block *nb,
+            unsigned long action, void *data)
+{
+    struct cdns_mhdp_device *mhdp = container_of(nb, struct 

cdns_mhdp_device, pd_nb);

drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c +8 -0
+
+    if (action == GENPD_NOTIFY_OFF)
+        mhdp->powered_off = true;
+
+    return 0;
+}
+
+static DEFINE_SIMPLE_DEV_PM_OPS(cdns_mhdp_pm_ops, cdns_mhdp_suspend, 

cdns_mhdp_resume);
+
  static int cdns_mhdp_probe(struct platform_device *pdev) {
      struct device *dev = &pdev->dev;

drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c +15 -1
@@ -2401,6 +2517,11 @@ static int cdns_mhdp_probe(struct 
 platform_device *pdev)
           dev_err(mhdp->dev, "Failed to initialize PHY: %d\n", ret);
           goto plat_fini;
       }
+    ret = phy_power_on(mhdp->phy);
+    if (ret < 0) {
+        dev_err(mhdp->dev, "Failed to power on PHY: %d\n", ret);
+        goto phy_exit;
+    }
         /* Initialize the work for modeset in case of link train failure */
       INIT_WORK(&mhdp->modeset_retry_work, cdns_mhdp_modeset_retry_fn);
@@ -2411,15 +2532,26 @@ static int cdns_mhdp_probe(struct 
 platform_device *pdev)
         ret = cdns_mhdp_load_firmware(mhdp);
       if (ret)
-        goto phy_exit;
+        goto power_off;
         if (mhdp->hdcp_supported)
           cdns_mhdp_hdcp_init(mhdp);
   -    drm_bridge_add(&mhdp->bridge);
+    mhdp->powered_off = false;
+    if (mhdp->dev->pm_domain) {
+        mhdp->pd_nb.notifier_call = mhdp_pd_notifier_cb;
+        ret = dev_pm_genpd_add_notifier(mhdp->dev, &mhdp->pd_nb);
+        if (ret) {
+            dev_err_probe(dev, ret, "failed to add power domain 
 notifier\n");
+            goto power_off;
+        }
+    }
   +    drm_bridge_add(&mhdp->bridge);
       return 0;

  +power_off:
+    phy_power_off(mhdp->phy);
  phy_exit:
      phy_exit(mhdp->phy);
  plat_fini:

drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c +1 -0
@@ -2457,6 +2589,7 @@ static void cdns_mhdp_remove(struct 
 platform_device *pdev)
                   ERR_PTR(ret));
       }
   +    phy_power_off(mhdp->phy);
       phy_exit(mhdp->phy);
         if (mhdp->info && mhdp->info->ops && mhdp->info->ops->exit)
@@ -2488,6 +2621,7 @@ static struct platform_driver mhdp_driver = {
       .driver    = {
           .name        = "cdns-mhdp8546",
           .of_match_table    = mhdp_ids,
+        .pm = pm_sleep_ptr(&cdns_mhdp_pm_ops),
       },
       .probe    = cdns_mhdp_probe,
       .remove = cdns_mhdp_remove,
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.h +4 -0
index 2041ffbc019a5..31dbeaf33ccb6 100644
@@ -413,6 +413,10 @@ struct cdns_mhdp_device {
         struct cdns_mhdp_hdcp hdcp;
       bool hdcp_supported;
+
+    /* Power domain status notifier */
+    struct notifier_block pd_nb;
+    bool powered_off;
   };
     #define connector_to_mhdp(x) container_of(x, struct cdns_mhdp_device, connector)
#3 lore raw

Hi,

Quoted 9 lines · abhash

Hi Tomi,

Thanks for the review.

Quoted 3 lines · Tomi Valkeinen

Hi,

On 01/06/2026 12:50, Abhash Kumar Jha wrote:

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

Add system suspend and resume hooks to the cdns-mhdp8546 bridge driver.

While resuming we either load the firmware or activate it. Firmware is loaded only when resuming from a successful suspend-resume cycle.

It's not clear from the patch if this is a fix or improvement. It sounds a bit like a fix, but it doesn't mention any kind of issue in the driver. So, why is this patch needed?

The driver lacked support for suspend-resume as stated in the todo on the driver, So the patch adds this improvement.

The patch doesn't remove any todo lines. Was that just a miss, or is there more to add wrt. PM?

What does it mean it didn't support PM? Does the driver not work after suspend-resume cycle? Or does the driver prevent a proper suspend?

Quoted 10 lines
Quoted 10 lines
Quoted 9 lines

If resuming due to an aborted suspend, loading the firmware is not possible because the uCPU's IMEM is only accessible after a reset and the bridge has not gone through a reset in this case. Hence, Activate the firmware that is already loaded.

Use genpd_notifier to get the power domain status of the bridge and accordingly load the firmware.

Additionally, introduce phy_power_off/on to control the power to the phy.

Quoted 7 lines
Quoted 1 line

If you write "also" or "additionally" or such in a commit desc, you should stop and think if that part should actually be a separate patch. Also, why is that change needed?

The phy device could be powered off while resuming. So we are explicitly powering it on.

The phy driver api also recommends to always call phy_init() first followed by a phy_power_on().

"Some PHY drivers may not implement phy_init or phy_power_on, but controllers should always call these functions to be compatible with other PHYs"

It still sounds like a separate patch to me: the current driver is missing phy_power_on/off from the probe/remove functions.

Quoted 11 lines
Quoted 4 lines

Overall, this sounds fragile/hacky to me.

The first thing is that usually you shouldn't use system suspend/ resume in a bridge driver. When a system suspend happend, the display pipeline will be disabled, so this driver will get an atomic_disable() call, and enable when resuming. You can use runtime PM hooks if you need resume/suspend hooks.

Thanks for the suggestion, I will use the runtime PM instead.

Quoted 1 line

The second thing is the PD notifier. Is there really no way we can see the state from the MDHP IP registers?

The other way that i found was to read the MHDP KEEP_ALIVE_p register twice to know if the firmware is incrementing the counter.

Based on that we can decide if the bridge is active or not. Do you think this approach would be okay over the PD notifier?

I think it would be best to be able somehow to ask this from the HW to find the true state, instead of guessing it second hand from the PD notifier (which also doesn't tell us the initial HW state at probe).

KEEP_ALIVE_p sounds fine. Or what does the mdhp IP do if you send a message to the firmware when it's not up? Say, if you always do cdns_mhdp_set_firmware_active, what happens if the FW has not been loaded? I would guess that there's a timeout, and that could be used to find out the FW is not up.

Also, if the IMEM is not accessible and you load the FW, what happens?

Tomi

#4 lore raw

Hi,

Quoted 14 lines · Tomi Valkeinen

Hi,

Quoted 11 lines · abhash

Hi Tomi,

Thanks for the review.

Quoted 5 lines · Tomi Valkeinen

Hi,

Quoted 2 lines · Abhash Kumar Jha

Add system suspend and resume hooks to the cdns-mhdp8546 bridge driver.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

While resuming we either load the firmware or activate it. Firmware is loaded only when resuming from a successful suspend-resume cycle.

It's not clear from the patch if this is a fix or improvement. It sounds a bit like a fix, but it doesn't mention any kind of issue in the driver. So, why is this patch needed?

The driver lacked support for suspend-resume as stated in the todo on the driver, So the patch adds this improvement.

The patch doesn't remove any todo lines. Was that just a miss, or is there more to add wrt. PM?

Yeah, i will remove the TODO in the next revision.

Quoted 2 lines

What does it mean it didn't support PM? Does the driver not work after suspend-resume cycle? Or does the driver prevent a proper suspend?

When we resume, the cdns_mhdp_link_up function fails.

Failure log at resume:

[  55.329452] tidss 4a00000.dss: PM: calling tidss_resume [tidss] @ 1053, parent: bus@100000

[ 183.381228] cdns-mhdp8546 a000000.bridge: Failed to read receiver capabilities

[ 191.391548] cdns-mhdp8546 a000000.bridge: get block[0] edid failed: -110

[ 193.392713] cdns-mhdp8546 a000000.bridge: Failed to read register

[ 261.415544] cdns-mhdp8546 a000000.bridge: Failed to read register

[ 263.946153] tidss 4a00000.dss: Timeout waiting for framedone on crtc 0

[ 391.991358] cdns-mhdp8546 a000000.bridge: Failed to read receiver capabilities

[ 392.026847] tidss 4a00000.dss: PM: tidss_resume [tidss] returned 0 after 336689133 usecs

I guess it is fair to say that the driver does not work after suspend-resume cycle.

Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
Quoted 9 lines

If resuming due to an aborted suspend, loading the firmware is not possible because the uCPU's IMEM is only accessible after a reset and the bridge has not gone through a reset in this case. Hence, Activate the firmware that is already loaded.

Use genpd_notifier to get the power domain status of the bridge and accordingly load the firmware.

Additionally, introduce phy_power_off/on to control the power to the phy.

If you write "also" or "additionally" or such in a commit desc, you should stop and think if that part should actually be a separate patch. Also, why is that change needed?

Quoted 8 lines
Quoted 5 lines

The phy device could be powered off while resuming. So we are explicitly powering it on.

The phy driver api also recommends to always call phy_init() first followed by a phy_power_on().

"Some PHY drivers may not implement phy_init or phy_power_on, but controllers should always call these functions to be compatible with other PHYs"

It still sounds like a separate patch to me: the current driver is missing phy_power_on/off from the probe/remove functions.

I will add that as a separate patch

Quoted 6 lines
Quoted 6 lines
Quoted 4 lines

Overall, this sounds fragile/hacky to me.

The first thing is that usually you shouldn't use system suspend/ resume in a bridge driver. When a system suspend happend, the display pipeline will be disabled, so this driver will get an atomic_disable() call, and enable when resuming. You can use runtime PM hooks if you need resume/suspend hooks.

Thanks for the suggestion, I will use the runtime PM instead.

Quoted 9 lines
Quoted 5 lines
Quoted 1 line

The second thing is the PD notifier. Is there really no way we can see the state from the MDHP IP registers?

The other way that i found was to read the MHDP KEEP_ALIVE_p register twice to know if the firmware is incrementing the counter.

Based on that we can decide if the bridge is active or not. Do you think this approach would be okay over the PD notifier?

I think it would be best to be able somehow to ask this from the HW to find the true state, instead of guessing it second hand from the PD notifier (which also doesn't tell us the initial HW state at probe).

KEEP_ALIVE_p sounds fine. Or what does the mdhp IP do if you send a message to the firmware when it's not up? Say, if you always do cdns_mhdp_set_firmware_active, what happens if the FW has not been loaded? I would guess that there's a timeout, and that could be used to find out the FW is not up.

Yes, there is a 2 second timeout if we send a message and the firmware is not up. I would prefer the KEEP_ALIVE_p method, as that is a better indication of the

firmware being active.

Quoted 1 line

Also, if the IMEM is not accessible and you load the FW, what happens?

If IMEM is not accessible and we load the FW, the kernel crashes due to S-error.

Thanks,

Abhash

#5 lore raw

Hi,

Quoted 80 lines · Abhash

Hi,

Quoted 14 lines · Tomi Valkeinen

Hi,

Quoted 11 lines · abhash

Hi Tomi,

Thanks for the review.

Quoted 5 lines · Tomi Valkeinen

Hi,

Quoted 2 lines · Abhash Kumar Jha

Add system suspend and resume hooks to the cdns-mhdp8546 bridge driver.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

While resuming we either load the firmware or activate it. Firmware is loaded only when resuming from a successful suspend-resume cycle.

It's not clear from the patch if this is a fix or improvement. It sounds a bit like a fix, but it doesn't mention any kind of issue in the driver. So, why is this patch needed?

The driver lacked support for suspend-resume as stated in the todo on the driver, So the patch adds this improvement.

The patch doesn't remove any todo lines. Was that just a miss, or is there more to add wrt. PM?

Yeah, i will remove the TODO in the next revision.

Quoted 2 lines

What does it mean it didn't support PM? Does the driver not work after suspend-resume cycle? Or does the driver prevent a proper suspend?

When we resume, the cdns_mhdp_link_up function fails.

Failure log at resume:

[  55.329452] tidss 4a00000.dss: PM: calling tidss_resume [tidss] @ 1053, parent: bus@100000

[ 183.381228] cdns-mhdp8546 a000000.bridge: Failed to read receiver capabilities

[ 191.391548] cdns-mhdp8546 a000000.bridge: get block[0] edid failed: -110

[ 193.392713] cdns-mhdp8546 a000000.bridge: Failed to read register

[ 261.415544] cdns-mhdp8546 a000000.bridge: Failed to read register

[ 263.946153] tidss 4a00000.dss: Timeout waiting for framedone on crtc 0

[ 391.991358] cdns-mhdp8546 a000000.bridge: Failed to read receiver capabilities

[ 392.026847] tidss 4a00000.dss: PM: tidss_resume [tidss] returned 0 after 336689133 usecs

I guess it is fair to say that the driver does not work after suspend- resume cycle.

Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
Quoted 9 lines

If resuming due to an aborted suspend, loading the firmware is not possible because the uCPU's IMEM is only accessible after a reset and the bridge has not gone through a reset in this case. Hence, Activate the firmware that is already loaded.

Use genpd_notifier to get the power domain status of the bridge and accordingly load the firmware.

Additionally, introduce phy_power_off/on to control the power to the phy.

If you write "also" or "additionally" or such in a commit desc, you should stop and think if that part should actually be a separate patch. Also, why is that change needed?

Quoted 8 lines
Quoted 5 lines

The phy device could be powered off while resuming. So we are explicitly powering it on.

The phy driver api also recommends to always call phy_init() first followed by a phy_power_on().

"Some PHY drivers may not implement phy_init or phy_power_on, but controllers should always call these functions to be compatible with other PHYs"

It still sounds like a separate patch to me: the current driver is missing phy_power_on/off from the probe/remove functions.

I will add that as a separate patch

Quoted 8 lines
Quoted 8 lines
Quoted 4 lines

Overall, this sounds fragile/hacky to me.

The first thing is that usually you shouldn't use system suspend/ resume in a bridge driver. When a system suspend happend, the display pipeline will be disabled, so this driver will get an atomic_disable() call, and enable when resuming. You can use runtime PM hooks if you need resume/suspend hooks.

Thanks for the suggestion, I will use the runtime PM instead.

Quoted 1 line

The second thing is the PD notifier. Is there really no way we can see the state from the MDHP IP registers?

Quoted 8 lines
Quoted 7 lines
Quoted 3 lines

The other way that i found was to read the MHDP KEEP_ALIVE_p register twice to know if the firmware is incrementing the counter.

Based on that we can decide if the bridge is active or not. Do you think this approach would be okay over the PD notifier?

I think it would be best to be able somehow to ask this from the HW to find the true state, instead of guessing it second hand from the PD notifier (which also doesn't tell us the initial HW state at probe).

KEEP_ALIVE_p sounds fine. Or what does the mdhp IP do if you send a message to the firmware when it's not up? Say, if you always do cdns_mhdp_set_firmware_active, what happens if the FW has not been loaded? I would guess that there's a timeout, and that could be used to find out the FW is not up.

Yes, there is a 2 second timeout if we send a message and the firmware is not up. I would prefer the KEEP_ALIVE_p method, as that is a better indication of the

But that's a driver imposed timeout, and it sounds rather arbitrary (and bad). How quickly does the firmware usually reply? What would be the situation where the firmware takes e.g. 1.5s to reply? I would guess that if the FW updates the KEEP_ALIVE_p every N us, it would also reply to us in that time.

In any case, changing MAILBOX_TIMEOUT_US would be another patch. KEEP_ALIVE_p sounds fine if you know how often the FW updates it.

Tomi

#6 lore raw
Quoted 133 lines · Tomi Valkeinen

Hi,

Quoted 120 lines · Abhash

Hi,

Quoted 22 lines · Tomi Valkeinen

Hi,

Quoted 19 lines · abhash

Hi Tomi,

Thanks for the review.

Quoted 12 lines · Tomi Valkeinen

Hi,

Quoted 5 lines · Abhash Kumar Jha

Add system suspend and resume hooks to the cdns-mhdp8546 bridge driver.

While resuming we either load the firmware or activate it. Firmware is loaded only when resuming from a successful suspend-resume cycle.

It's not clear from the patch if this is a fix or improvement. It sounds a bit like a fix, but it doesn't mention any kind of issue in the driver. So, why is this patch needed?

Quoted 5 lines
Quoted 2 lines

The driver lacked support for suspend-resume as stated in the todo on the driver, So the patch adds this improvement.

The patch doesn't remove any todo lines. Was that just a miss, or is there more to add wrt. PM?

Yeah, i will remove the TODO in the next revision.

Quoted 3 lines

What does it mean it didn't support PM? Does the driver not work after suspend-resume cycle? Or does the driver prevent a proper suspend?

When we resume, the cdns_mhdp_link_up function fails.

Failure log at resume:

[  55.329452] tidss 4a00000.dss: PM: calling tidss_resume [tidss] @ 

1053, parent: bus@100000

[ 183.381228] cdns-mhdp8546 a000000.bridge: Failed to read receiver 

capabilities

[ 191.391548] cdns-mhdp8546 a000000.bridge: get block[0] edid failed: -110
[ 193.392713] cdns-mhdp8546 a000000.bridge: Failed to read register
[ 261.415544] cdns-mhdp8546 a000000.bridge: Failed to read register
[ 263.946153] tidss 4a00000.dss: Timeout waiting for framedone on crtc 0
[ 391.991358] cdns-mhdp8546 a000000.bridge: Failed to read receiver 

capabilities

[ 392.026847] tidss 4a00000.dss: PM: tidss_resume [tidss] returned 0 

after 336689133 usecs

I guess it is fair to say that the driver does not work after suspend- resume cycle.

Quoted 22 lines
Quoted 22 lines
Quoted 9 lines
Quoted 9 lines

If resuming due to an aborted suspend, loading the firmware is not possible because the uCPU's IMEM is only accessible after a reset and the
bridge has not gone through a reset in this case. Hence, Activate the firmware that is already loaded.

Use genpd_notifier to get the power domain status of the bridge and accordingly load the firmware.

Quoted 6 lines
Quoted 2 lines

Additionally, introduce phy_power_off/on to control the power to the phy.

If you write "also" or "additionally" or such in a commit desc, you should stop and think if that part should actually be a separate patch. Also, why is that change needed?

The phy device could be powered off while resuming. So we are explicitly powering it on.

The phy driver api also recommends to always call phy_init() first followed by a phy_power_on().

Quoted 7 lines
Quoted 3 lines

"Some PHY drivers may not implement phy_init or phy_power_on, but controllers should always call these functions to be compatible with other PHYs"

It still sounds like a separate patch to me: the current driver is missing phy_power_on/off from the probe/remove functions.

I will add that as a separate patch

Quoted 22 lines
Quoted 10 lines
Quoted 8 lines

Overall, this sounds fragile/hacky to me.

The first thing is that usually you shouldn't use system suspend/ resume in a bridge driver. When a system suspend happend, the display pipeline will be disabled, so this driver will get an atomic_disable() call, and enable when resuming. You can use runtime PM hooks if you need resume/suspend hooks.

Thanks for the suggestion, I will use the runtime PM instead.

Quoted 8 lines
Quoted 2 lines

The second thing is the PD notifier. Is there really no way we can see the state from the MDHP IP registers?

The other way that i found was to read the MHDP KEEP_ALIVE_p register twice to know if the firmware is incrementing the counter.

Based on that we can decide if the bridge is active or not. Do you think this approach would be okay over the PD notifier?

I think it would be best to be able somehow to ask this from the HW to find the true state, instead of guessing it second hand from the PD notifier (which also doesn't tell us the initial HW state at probe).

Quoted 6 lines

KEEP_ALIVE_p sounds fine. Or what does the mdhp IP do if you send a message to the firmware when it's not up? Say, if you always do cdns_mhdp_set_firmware_active, what happens if the FW has not been loaded? I would guess that there's a timeout, and that could be used to find out the FW is not up.

Quoted 3 lines

Yes, there is a 2 second timeout if we send a message and the firmware is not up. I would prefer the KEEP_ALIVE_p method, as that is a better indication of the

But that's a driver imposed timeout, and it sounds rather arbitrary (and bad). How quickly does the firmware usually reply? What would be the situation where the firmware takes e.g. 1.5s to reply? I would guess that if the FW updates the KEEP_ALIVE_p every N us, it would also reply to us in that time.

Quoted 4 lines

In any case, changing MAILBOX_TIMEOUT_US would be another patch. KEEP_ALIVE_p sounds fine if you know how often the FW updates it.

Tomi

Hi,

I wanted to check on the status of this series, as I'm quite interested in it since my series [1] depends on it.

For my use case, the suspend/resume support isn't essential, but the calls to phy_power_on() and phy_power_off() are.

Thanks for any update.

[1] https://lore.kernel.org/all/[email protected]/T/

Signature · 3 lines
Benjamin Robin, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#7 lore raw

Hi,

Quoted 144 lines · Benjamin Robin
Quoted 133 lines · Tomi Valkeinen

Hi,

Quoted 120 lines · Abhash

Hi,

Quoted 22 lines · Tomi Valkeinen

Hi,

Quoted 19 lines · abhash

Hi Tomi,

Thanks for the review.

Quoted 12 lines · Tomi Valkeinen

Hi,

Quoted 5 lines · Abhash Kumar Jha

Add system suspend and resume hooks to the cdns-mhdp8546 bridge driver.

While resuming we either load the firmware or activate it. Firmware is loaded only when resuming from a successful suspend-resume cycle.

It's not clear from the patch if this is a fix or improvement. It sounds a bit like a fix, but it doesn't mention any kind of issue in the driver. So, why is this patch needed?

Quoted 5 lines
Quoted 2 lines

The driver lacked support for suspend-resume as stated in the todo on the driver, So the patch adds this improvement.

The patch doesn't remove any todo lines. Was that just a miss, or is there more to add wrt. PM?

Yeah, i will remove the TODO in the next revision.

Quoted 3 lines

What does it mean it didn't support PM? Does the driver not work after suspend-resume cycle? Or does the driver prevent a proper suspend?

When we resume, the cdns_mhdp_link_up function fails.

Failure log at resume:

[  55.329452] tidss 4a00000.dss: PM: calling tidss_resume [tidss] @

1053, parent: bus@100000

[ 183.381228] cdns-mhdp8546 a000000.bridge: Failed to read receiver

capabilities

[ 191.391548] cdns-mhdp8546 a000000.bridge: get block[0] edid failed: -110
[ 193.392713] cdns-mhdp8546 a000000.bridge: Failed to read register
[ 261.415544] cdns-mhdp8546 a000000.bridge: Failed to read register
[ 263.946153] tidss 4a00000.dss: Timeout waiting for framedone on crtc 0
[ 391.991358] cdns-mhdp8546 a000000.bridge: Failed to read receiver

capabilities

[ 392.026847] tidss 4a00000.dss: PM: tidss_resume [tidss] returned 0

after 336689133 usecs

I guess it is fair to say that the driver does not work after suspend- resume cycle.

Quoted 22 lines
Quoted 22 lines
Quoted 9 lines
Quoted 9 lines

If resuming due to an aborted suspend, loading the firmware is not possible because the uCPU's IMEM is only accessible after a reset and the
bridge has not gone through a reset in this case. Hence, Activate the firmware that is already loaded.

Use genpd_notifier to get the power domain status of the bridge and accordingly load the firmware.

Quoted 6 lines
Quoted 2 lines

Additionally, introduce phy_power_off/on to control the power to the phy.

If you write "also" or "additionally" or such in a commit desc, you should stop and think if that part should actually be a separate patch. Also, why is that change needed?

The phy device could be powered off while resuming. So we are explicitly powering it on.

The phy driver api also recommends to always call phy_init() first followed by a phy_power_on().

Quoted 7 lines
Quoted 3 lines

"Some PHY drivers may not implement phy_init or phy_power_on, but controllers should always call these functions to be compatible with other PHYs"

It still sounds like a separate patch to me: the current driver is missing phy_power_on/off from the probe/remove functions.

I will add that as a separate patch

Quoted 22 lines
Quoted 10 lines
Quoted 8 lines

Overall, this sounds fragile/hacky to me.

The first thing is that usually you shouldn't use system suspend/ resume in a bridge driver. When a system suspend happend, the display pipeline will be disabled, so this driver will get an atomic_disable() call, and enable when resuming. You can use runtime PM hooks if you need resume/suspend hooks.

Thanks for the suggestion, I will use the runtime PM instead.

Quoted 8 lines
Quoted 2 lines

The second thing is the PD notifier. Is there really no way we can see the state from the MDHP IP registers?

The other way that i found was to read the MHDP KEEP_ALIVE_p register twice to know if the firmware is incrementing the counter.

Based on that we can decide if the bridge is active or not. Do you think this approach would be okay over the PD notifier?

I think it would be best to be able somehow to ask this from the HW to find the true state, instead of guessing it second hand from the PD notifier (which also doesn't tell us the initial HW state at probe).

Quoted 6 lines

KEEP_ALIVE_p sounds fine. Or what does the mdhp IP do if you send a message to the firmware when it's not up? Say, if you always do cdns_mhdp_set_firmware_active, what happens if the FW has not been loaded? I would guess that there's a timeout, and that could be used to find out the FW is not up.

Quoted 3 lines

Yes, there is a 2 second timeout if we send a message and the firmware is not up. I would prefer the KEEP_ALIVE_p method, as that is a better indication of the

But that's a driver imposed timeout, and it sounds rather arbitrary (and bad). How quickly does the firmware usually reply? What would be the situation where the firmware takes e.g. 1.5s to reply? I would guess that if the FW updates the KEEP_ALIVE_p every N us, it would also reply to us in that time.

Quoted 4 lines

In any case, changing MAILBOX_TIMEOUT_US would be another patch. KEEP_ALIVE_p sounds fine if you know how often the FW updates it.

Tomi

Hi,

I wanted to check on the status of this series, as I'm quite interested in it since my series [1] depends on it.

Quoted 7 lines

For my use case, the suspend/resume support isn't essential, but the calls to phy_power_on() and phy_power_off() are.

Thanks for any update.

[1] https://lore.kernel.org/all/[email protected]/T/

Yep, it could as well be sent separately. Abhash, are you working on this still? Can you send the phy power on/off as a separate patch.

Tomi