public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: drm/bridge: display-connector: trigger initial HPD event for DP
Date: Mon, 16 Mar 2026 12:14:39 +1000	[thread overview]
Message-ID: <review-patch2-20260314-dp-connector-hpd-v1-2-786044cedc17@oss.qualcomm.com> (raw)
In-Reply-To: <20260314-dp-connector-hpd-v1-2-786044cedc17@oss.qualcomm.com>

Patch Review

This patch adds a `work_struct` to schedule an initial HPD notification when `hpd_enable` is called for DP connectors. On `hpd_disable`, it cancels the work with `cancel_work_sync`.

**The use of a workqueue is appropriate** because `hpd_enable` is called under `bridge->hpd_mutex` (see `drm_bridge_hpd_enable()` in `drm_bridge.c`), and `drm_bridge_hpd_notify()` also takes `hpd_mutex`. Calling `drm_bridge_hpd_notify()` directly from `hpd_enable` would deadlock. The workqueue defers the notification outside the mutex.

**Observations:**

1. **`INIT_WORK` is conditional but callbacks are not.** The `INIT_WORK` call at line 661 is guarded by `conn->hpd_irq >= 0 && type == DRM_MODE_CONNECTOR_DisplayPort`, and the `schedule_work`/`cancel_work_sync` calls are guarded by `conn->bridge.type == DRM_MODE_CONNECTOR_DisplayPort`. This is consistent – DP connectors without HPD IRQ won't reach `hpd_enable` (since `DRM_BRIDGE_OP_HPD` won't be set), and non-DP connectors won't touch the work. However, if `INIT_WORK` is never called, the `work_struct` is zero-initialized (from `devm_drm_bridge_alloc` which uses `devm_kzalloc`), and `cancel_work_sync` on an uninitialized (zero) `work_struct` is technically undefined behavior. In practice, this path is unreachable for non-DP connectors because the `bridge.type` check guards it. Still, it would be slightly cleaner to always call `INIT_WORK` when `hpd_irq >= 0`, removing the type check from the init path, since the `schedule_work` is already guarded by the DP type check.

2. **Race between work and disable.** The ordering in `hpd_disable` is: `cancel_work_sync` first, then `disable_irq`. This is correct – it ensures the synthetic HPD work is cancelled before the IRQ is disabled. If the order were reversed, a pending work item could call `display_connector_detect` → `gpiod_get_value_cansleep` after the IRQ was disabled, which would be fine functionally but inconsistent.

3. **No cleanup on remove.** The `display_connector_remove` function doesn't call `cancel_work_sync`. This should be fine because `drm_bridge_hpd_disable` (and thus `hpd_disable`) is called during connector cleanup before bridge removal, so the work should already be cancelled. But it's worth considering whether there's a window where `hpd_enable` was called but `hpd_disable` was not before `remove`. Given the DRM lifecycle, this shouldn't happen.

4. **Minor typo in commit message:** "externall" should be "external".

Overall, this is a well-structured fix for a real problem. The series is correct and ready to merge with perhaps the typo fix in the commit message.

---
Generated by Claude Code Patch Reviewer

  reply	other threads:[~2026-03-16  2:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-14  0:43 [PATCH 0/2] drm/bridge: display-connector: detect DP state if cable is plugged on boot Dmitry Baryshkov
2026-03-14  0:43 ` [PATCH 1/2] drm/bridge: display-connector: don't autoenable HPD IRQ Dmitry Baryshkov
2026-03-16  2:14   ` Claude review: " Claude Code Review Bot
2026-03-14  0:43 ` [PATCH 2/2] drm/bridge: display-connector: trigger initial HPD event for DP Dmitry Baryshkov
2026-03-16  2:14   ` Claude Code Review Bot [this message]
2026-03-16  2:14 ` Claude review: drm/bridge: display-connector: detect DP state if cable is plugged on boot Claude Code Review 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=review-patch2-20260314-dp-connector-hpd-v1-2-786044cedc17@oss.qualcomm.com \
    --to=claude-review@example.com \
    --cc=dri-devel-reviews@example.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox