From: sashiko-bot@kernel.org
To: "Yongbang Shi" <shiyongbang@huawei.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH for drm-misc-fixes v6 1/2] drm/hisilicon/hibmc: Modify the method of obtaining the hpd_status
Date: Thu, 26 Nov 2026 03:32:20 +0000 [thread overview]
Message-ID: <sashiko-outbox-234699@kernel.org> (raw)
In-Reply-To: <20261126030648.3231196-2-shiyongbang@huawei.com>
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] drm/hisilicon/hibmc: lost hotplug event on unplug+plug in
hibmc_dp_hpd_isr()
- [Medium] drm/hisilicon/hibmc: race on link.status in
hibmc_dp_reset_link()
- [Medium] drm/hisilicon/hibmc: stale HIBMC_HPD_OUT breaks
hibmc_dp_detect()
--
commit be71ebe3ac9a8ced23cdd19669fbac348e9d77c8
Author: Lin He <helin52@huawei.com>
drm/hisilicon/hibmc: Modify the method of obtaining the hpd_status
This commit samples the DisplayPort HPD state in the hardirq handler
hibmc_dp_interrupt() via hibmc_dp_get_hpd_status() instead of polling in
the threaded handler, and serializes AUX transfers against
hibmc_dp_hpd_cfg() with aux_lock.
> diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_dp.c b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_dp.c
> index 9cf0b6be15bdc..245d6b9e2836a 100644
> --- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_dp.c
> +++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_dp.c
[ ... ]
> @@ -60,13 +58,13 @@ static int hibmc_dp_detect(struct drm_connector *connector,
> {
> struct hibmc_dp *dp = to_hibmc_dp(connector);
> struct hibmc_dp_dev *dp_dev = dp->dp_dev;
> + int hpd_status = READ_ONCE(dp->hpd_status);
> int ret = connector_status_disconnected;
>
> - if (dp->irq_status) {
> - if (dp_dev->hpd_status != HIBMC_HPD_IN) {
> - ret = connector_status_disconnected;
> - goto exit;
> - }
> + if (hpd_status != HIBMC_HPD_IN) {
> + drm_dbg_dp(dp->drm_dev, "dp detect skipped, hpd (%d)\n",
> + hpd_status);
> + goto exit;
> }
[Severity: Medium]
Can dp->hpd_status remain stuck at HIBMC_HPD_OUT when hibmc_dp_detect()
runs, causing connected monitors to be reported as disconnected?
Previously, hibmc_dp_detect() only checked hpd_status after an HPD
interrupt had set dp->irq_status, and otherwise probed DPCD directly.
Now hibmc_dp_init() sets dp->hpd_status = HIBMC_HPD_OUT,
hibmc_dp_hw_init() sleeps 100 ms with HIBMC_DP_INTR_ENABLE masked without
calling hibmc_dp_get_hpd_status(), and only hibmc_dp_interrupt() ever
updates dp->hpd_status.
If pci_alloc_irq_vectors() in hibmc_msi_init() only allocates
HIBMC_MIN_VECTORS (1 vector), only the vblank interrupt is requested and
hibmc_dp_interrupt() is never registered, leaving dp->hpd_status at
HIBMC_HPD_OUT permanently. dp->hpd_status is also not refreshed across
hibmc_pm_suspend() and hibmc_pm_resume() if a monitor is connected or
disconnected while suspended, or if connector detection runs during
registration before the HPD MSI fires.
> @@ -188,24 +186,26 @@ irqreturn_t hibmc_dp_hpd_isr(int irq, void *arg)
> {
> struct drm_device *dev = (struct drm_device *)arg;
> struct hibmc_drm_private *priv = to_hibmc_drm_private(dev);
> - int idx, exp_status;
> + int status = READ_ONCE(priv->dp.hpd_status);
> + int idx;
>
> if (!drm_dev_enter(dev, &idx))
> return -ENODEV;
>
> - if (priv->dp.irq_status & DP_MASKED_SINK_HPD_PLUG_INT) {
> + if (status == HIBMC_HPD_IN) {
> + /* Plug takes aux_lock, so it must run in the thread. */
> drm_dbg_dp(&priv->dev, "HPD IN isr occur!\n");
> hibmc_dp_hpd_cfg(&priv->dp);
> - exp_status = HIBMC_HPD_IN;
> - } else {
> + } else if (status == HIBMC_HPD_OUT) {
> drm_dbg_dp(&priv->dev, "HPD OUT isr occur!\n");
> - hibmc_dp_reset_link(&priv->dp);
> - exp_status = HIBMC_HPD_OUT;
> + } else {
> + drm_err(&priv->dev, "HPD status (%d) error\n", status);
> + goto exit;
> }
>
> - if (hibmc_dp_check_hpd_status(&priv->dp, exp_status))
> - drm_connector_helper_hpd_irq_event(&priv->dp.connector);
> + drm_connector_helper_hpd_irq_event(&priv->dp.connector);
[Severity: Medium]
Can an unplug followed by a plug before hibmc_dp_hpd_isr() runs still lose
the hotplug notification and leave the link untrained?
<hardirq> irq/hibmc-hpd
hibmc_dp_interrupt() [unplug]
priv->dp.hpd_status = HIBMC_HPD_OUT
hibmc_dp_reset_link(&priv->dp)
channel_equalized = false
hibmc_dp_interrupt() [plug]
priv->dp.hpd_status = HIBMC_HPD_IN
hibmc_dp_hpd_isr()
hibmc_dp_hpd_cfg()
drm_connector_helper_hpd_irq_event()
check_connector_changed()
hibmc_dp_detect()
returns connected
old_status == connected
--> returns false (event dropped)
Because hibmc_dp_detect() never ran while priv->dp.hpd_status was
HIBMC_HPD_OUT, connector->status is still connector_status_connected when
hibmc_dp_detect() runs for the new plug. drm_helper_probe_detect_ctx()
only increments connector->epoch_counter when the status changes, so
check_connector_changed() returns false and
drm_connector_helper_hpd_irq_event() suppresses the hotplug event.
Without a hotplug event to trigger a modeset, hibmc_dp_mode_set() does not
run to re-train the link after hibmc_dp_reset_link() cleared
channel_equalized.
Also, if hibmc_dp_hpd_isr() reads status == HIBMC_HPD_OUT at entry and the
plug hardirq updates priv->dp.hpd_status to HIBMC_HPD_IN before
hibmc_dp_detect() runs, hibmc_dp_detect() will perform DPCD AUX reads for
the newly plugged sink without hibmc_dp_hpd_cfg() having configured the
AUX and DPTX registers first.
[ ... ]
> diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c
> index 602930964e930..a110b5e15e596 100644
> --- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c
> +++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c
> @@ -59,11 +59,18 @@ static irqreturn_t hibmc_dp_interrupt(int irq, void *arg)
> {
> struct drm_device *dev = (struct drm_device *)arg;
> struct hibmc_drm_private *priv = to_hibmc_drm_private(dev);
> + int hpd_status;
> u32 status;
>
> status = readl(priv->mmio + HIBMC_DP_INTSTAT);
> if (status) {
> - priv->dp.irq_status = status;
> + hpd_status = hibmc_dp_get_hpd_status(&priv->dp);
> + WRITE_ONCE(priv->dp.hpd_status, hpd_status);
> +
> + /* Reset here so a later plug cannot hide this unplug. */
> + if (hpd_status == HIBMC_HPD_OUT)
> + hibmc_dp_reset_link(&priv->dp);
[Severity: Medium]
Can calling hibmc_dp_reset_link() from hardirq context race with ongoing
link training in hibmc_dp_mode_set()?
hibmc_dp_mode_set()
hibmc_dp_link_training()
hibmc_dp_link_training_channel_eq()
drm_dp_dpcd_read_link_status(dp->aux, lane_status)
<hardirq>
hibmc_dp_interrupt()
hibmc_dp_reset_link(&priv->dp)
dp->link.status.clock_recovered = false
dp->link.status.channel_equalized = false
if (drm_dp_channel_eq_ok(lane_status, ...))
dp->link.status.channel_equalized = true <-- overwrites reset
hibmc_dp_reset_link() and hibmc_dp_link_training_channel_eq() update
dp->link.status without synchronization. If an unplug interrupt arrives
just after drm_dp_dpcd_read_link_status() finishes,
hibmc_dp_link_training_channel_eq() sets channel_equalized back to true
from the pre-unplug lane_status. Because hibmc_dp_reset_link() only runs
on HIBMC_HPD_OUT, channel_equalized stays true across a subsequent plug,
and hibmc_dp_mode_set() skips hibmc_dp_link_training().
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261126030648.3231196-1-shiyongbang@huawei.com?part=1
next prev parent reply other threads:[~2026-11-26 3:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 3:06 [PATCH for drm-misc-fixes v6 0/2] Fix some bugs in the hibmc DP Yongbang Shi
2026-11-26 3:06 ` [PATCH for drm-misc-fixes v6 1/2] drm/hisilicon/hibmc: Modify the method of obtaining the hpd_status Yongbang Shi
2026-11-26 3:32 ` sashiko-bot [this message]
2026-11-26 3:06 ` [PATCH for drm-misc-fixes v6 2/2] drm/hisilicon/hibmc: Add a flag to indicate whether the OS-side driver has been loaded Yongbang Shi
2026-11-26 3:25 ` sashiko-bot
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-234699@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=shiyongbang@huawei.com \
/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.