From: sashiko-bot@kernel.org
To: "Abhash Kumar Jha" <a-kumar2@ti.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v4] drm/bridge: cdns-mhdp8546: Add suspend resume support to the bridge driver
Date: Thu, 26 Nov 2026 06:21:57 +0000 [thread overview]
Message-ID: <sashiko-outbox-234835@kernel.org> (raw)
In-Reply-To: <20261126060532.2379444-1-a-kumar2@ti.com>
Thank you for your contribution! Sashiko AI review found 5 potential
issues to consider:
- [High] drm/bridge: cdns-mhdp8546: build failure on mhdp->no_hpd in
cdns_mhdp_resume()
- [High] drm/bridge: cdns-mhdp8546: unbalanced phy_power_off() and
phy_power_on()
- [High] drm/bridge: cdns-mhdp8546: uncanceled async fw load on
cdns_mhdp_resume() error
- [High] drm/bridge: cdns-mhdp8546: unmasked HPD IRQ race in
cdns_mhdp_suspend()
- [Medium] drm/bridge: cdns-mhdp8546: double clk and phy teardown after
failed resume
--
commit 8f4412907134191fa8e20db994148c5d7ad2f2b4
Author: Abhash Kumar Jha <a-kumar2@ti.com>
drm/bridge: cdns-mhdp8546: Add suspend resume support to the bridge driver
This commit adds system suspend and resume hooks to the cdns-mhdp8546
bridge driver, checking the KEEP_ALIVE register on resume to either
reload the firmware or reactivate it if the device did not lose power.
> diff --git a/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c b/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c
> index f47717bd10798..5c481562203b0 100644
> --- a/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c
> +++ b/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c
[ ... ]
> @@ -2258,6 +2257,125 @@ 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 int keep_alive, keep_alive_inc;
> + 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 phy_exit;
> + }
> +
> + /*
> + * The KEEP_ALIVE register is incremented at every scheduler loop of the
> + * firmware. If it changes between reads, the firmware is still running
> + * (e.g. the suspend was aborted) and only needs to be activated. If it
> + * does not change, the bridge lost power and the firmware must be loaded
> + * again.
> + */
> + keep_alive = readl(mhdp->regs + CDNS_KEEP_ALIVE) & CDNS_KEEP_ALIVE_MASK;
> + ret = readl_poll_timeout(mhdp->regs + CDNS_KEEP_ALIVE, keep_alive_inc,
> + (keep_alive_inc & CDNS_KEEP_ALIVE_MASK) != keep_alive,
> + 2000, 2 * CDNS_KEEP_ALIVE_TIMEOUT);
> + if (ret) {
> + 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;
> + }
[Severity: High]
Can a timeout here leave the asynchronous cdns_mhdp_fw_cb() callback running
after mhdp->clk is disabled?
cdns_mhdp_load_firmware() schedules cdns_mhdp_fw_cb() via
request_firmware_nowait(). If wait_event_timeout() times out after 1000 ms,
jumping to phy_off disables mhdp->clk without cancelling or synchronizing with
the pending callback:
CPU0 kworker
cdns_mhdp_resume()
cdns_mhdp_load_firmware()
request_firmware_nowait(...)
wait_event_timeout(...) == 0
...
clk_disable_unprepare(mhdp->clk)
cdns_mhdp_fw_cb()
cdns_mhdp_fw_activate()
writel(..., mhdp->regs + CDNS_APB_CTRL)
<-- unclocked MMIO access
cdns_mhdp_fw_activate() then writes to mhdp->regs and copies the firmware
image to CDNS_MHDP_IMEM while the clock is disabled, which triggers a
synchronous external abort on ARM64 SoCs.
> + } 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;
> + }
> +
> + spin_lock(&mhdp->start_lock);
> + mhdp->hw_state = MHDP_HW_READY;
> + if (!mhdp->no_hpd)
> + cdns_mhdp_bridge_hpd_enable(&mhdp->bridge);
> + spin_unlock(&mhdp->start_lock);
> + }
[Severity: High]
Does this compile when CONFIG_DRM_CDNS_MHDP8546 is enabled? struct
cdns_mhdp_device has no no_hpd member.
> +
> + return 0;
> +
> +phy_off:
> + phy_power_off(mhdp->phy);
> +phy_exit:
> + phy_exit(mhdp->phy);
> +disable_clk:
> + clk_disable_unprepare(mhdp->clk);
> +
> + return ret;
> +}
[Severity: Medium]
If cdns_mhdp_resume() fails, won't driver removal later double-exit mhdp->phy
and double-disable mhdp->clk?
cdns_mhdp_probe() enables mhdp->clk with devm_clk_get_enabled() and calls
phy_init(mhdp->phy), and cdns_mhdp_remove() unconditionally calls
phy_exit(mhdp->phy) before devres disables and unprepares mhdp->clk. When
cdns_mhdp_resume() fails, mhdp->phy and mhdp->clk are left torn down, so
unbinding the driver underflows phy->init_count and triggers clk framework
WARN_ON splats.
> +
> +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;
> +
> + cancel_work_sync(&mhdp->hpd_work);
[Severity: High]
Can an HPD interrupt fire after cancel_work_sync(&mhdp->hpd_work) and access
mhdp->regs after mhdp->clk is disabled?
cdns_mhdp_suspend() runs in .suspend_late while device IRQs are still
enabled, and it never masks CDNS_APB_INT_MASK. Because cdns_mhdp_irq_handler()
only checks mhdp->bridge_attached before scheduling mhdp->hpd_work, an HPD
interrupt after cancel_work_sync() re-queues the work while suspend proceeds
to disable the clock:
CPU0 CPU1
cdns_mhdp_suspend()
cancel_work_sync(&mhdp->hpd_work)
cdns_mhdp_irq_handler()
schedule_work(&mhdp->hpd_work)
...
clk_disable_unprepare(mhdp->clk)
cdns_mhdp_hpd_work()
cdns_mhdp_update_link_status()
<-- unclocked MMIO/mailbox access
Masking CDNS_APB_INT_MASK (or calling cdns_mhdp_bridge_hpd_disable()) and
synchronizing with the IRQ before cancelling mhdp->hpd_work would prevent it
from being re-queued.
> +
> + ret = wait_event_timeout(mhdp->fw_load_wq,
> + mhdp->hw_state == MHDP_HW_READY,
> + timeout);
> + if (ret == 0) {
> + dev_err(mhdp->dev, "%s: Timeout waiting for fw loading\n", __func__);
> + return -ETIMEDOUT;
> + }
> +
> + spin_lock(&mhdp->start_lock);
> + 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);
> + return ret;
> + }
> +
> + phy_power_off(mhdp->phy);
> + phy_exit(mhdp->phy);
> + clk_disable_unprepare(mhdp->clk);
> +
> + return 0;
> +}
[Severity: High]
Are phy_power_off() here and phy_power_on() in cdns_mhdp_resume() balanced
with cdns_mhdp_probe()?
cdns_mhdp_probe() only calls phy_init(mhdp->phy) and never calls
phy_power_on(mhdp->phy) (phy_power_on() is only called in
cdns_mhdp_connector_enable() / cdns_mhdp_atomic_enable() and balanced in the
corresponding disable hooks). When the bridge is not actively enabled,
mhdp->phy->power_count is 0, so calling phy_power_off() here underflows
power_count to -1, performs an unbalanced runtime PM put and regulator
disable on the PHY, and causes both phy_power_off() and the subsequent
phy_power_on() in cdns_mhdp_resume() to skip the PHY driver's callbacks.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261126060532.2379444-1-a-kumar2@ti.com?part=1
next prev parent reply other threads:[~2026-11-26 6:22 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 6:05 [PATCH v4] drm/bridge: cdns-mhdp8546: Add suspend resume support to the bridge driver Abhash Kumar Jha
2026-11-26 6:21 ` sashiko-bot [this message]
2026-11-26 12:46 ` kernel test robot
2026-11-26 16:44 ` kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-234835@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=a-kumar2@ti.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.