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/vblank: Introduce deferred vblank enable/disable
Date: Fri, 27 Feb 2026 14:40:52 +1000	[thread overview]
Message-ID: <review-patch2-20260224212639.390768-3-sunpeng.li@amd.com> (raw)
In-Reply-To: <20260224212639.390768-3-sunpeng.li@amd.com>

Patch Review

This is the core patch and has the most substance. The design — wrapping `drm_vblank_enable()`/`vblank_disable_fn()` in workers with pre/post callbacks — is reasonable. However, several issues need attention:

**Issue 1: Unconditional workqueue allocation**

```c
dev->deferred_vblank_wq = alloc_workqueue("drm_vblank_deferred_wq",
                                          WQ_HIGHPRI | WQ_UNBOUND, 0);
if (!dev->deferred_vblank_wq)
    return -ENOMEM;
```

This is allocated for **every** DRM device in `drm_vblank_init()`, even though the vast majority of drivers will never use deferred vblank. Only devices implementing the `pre/post_enable/disable_vblank` callbacks need this workqueue. The allocation (and init of `enable_work`, `disable_work`, `enable_done` per-CRTC) should be deferred or conditional. One approach: allocate it lazily on first use, or check at CRTC init time if any CRTC needs it.

**Issue 2: Missing cancellation of pending deferred work in drm_crtc_vblank_off()**

The patched `drm_crtc_vblank_off()` calls `pre_disable_vblank` and `post_disable_vblank` directly, and calls `drm_vblank_disable_and_save()` under the spinlock. But it does **not** cancel any pending deferred `enable_work` or `disable_work`.

Consider this race:
1. `drm_vblank_get()` queues `enable_work` to the deferred workqueue
2. Before the worker runs, `drm_crtc_vblank_off()` is called (modeset)
3. `vblank_off` disables vblank and sets `inmodeset`
4. The queued `enable_work` now runs, takes `vbl_lock`, calls `drm_vblank_enable()` — which checks `!vblank->enabled`, sees it's false, and **re-enables vblank** after `vblank_off` has already shut everything down

This could lead to vblank interrupts firing on hardware that the driver expects to be quiesced. `drm_crtc_vblank_off()` should `cancel_work_sync(&vblank->enable_work)` and `cancel_delayed_work_sync(&vblank->disable_work)` (after dropping spinlocks, before or after the existing `drm_vblank_flush_worker()` call).

Similarly, `drm_crtc_vblank_on_config()` should cancel any pending deferred `disable_work` to avoid a stale disable racing with the new enable.

**Issue 3: Cosmetic extra parentheses**

```c
if ((!needs_deferred_enable && !vblank->enabled)) {
```

The outer parentheses are unnecessary.

**Issue 4: Comment style**

```c
/* Initialize in the completed state, the first deferred vblank
 * enable will reinitialize this. */
```

Kernel multi-line comment style puts `*/` on its own line:
```c
/*
 * Initialize in the completed state, the first deferred vblank
 * enable will reinitialize this.
 */
```

---
Generated by Claude Code Patch Reviewer

  parent reply	other threads:[~2026-02-27  4:40 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-24 21:26 [PATCH 0/5] drm/vblank: Deferred Enable and Disable sunpeng.li
2026-02-24 21:26 ` [PATCH 1/5] drm/vblank: Add drm_crtc_vblank_is_off() helper sunpeng.li
2026-02-27  4:40   ` Claude review: " Claude Code Review Bot
2026-02-24 21:26 ` [PATCH 2/5] drm/vblank: Introduce deferred vblank enable/disable sunpeng.li
2026-02-25  4:42   ` kernel test robot
2026-02-27  4:40   ` Claude Code Review Bot [this message]
2026-02-24 21:26 ` [PATCH 3/5] drm/amd/display: Refactor amdgpu_dm_crtc_set_vblank sunpeng.li
2026-02-27  4:40   ` Claude review: " Claude Code Review Bot
2026-02-24 21:26 ` [PATCH 4/5] drm/amd/display: Implement deferred vblanks on IPS platforms sunpeng.li
2026-02-27  4:40   ` Claude review: " Claude Code Review Bot
2026-02-24 21:26 ` [PATCH 5/5] drm/vblank: Add some debugging trace events sunpeng.li
2026-02-27  4:40   ` Claude review: " Claude Code Review Bot
2026-02-27  4:40 ` Claude review: drm/vblank: Deferred Enable and Disable Claude Code Review Bot
  -- strict thread matches above, loose matches on Subject: below --
2026-03-23 20:27 [PATCH v2 0/5] " sunpeng.li
2026-03-23 20:27 ` [PATCH v2 2/5] drm/vblank: Introduce deferred vblank enable/disable sunpeng.li
2026-03-24 21:22   ` Claude review: " 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-20260224212639.390768-3-sunpeng.li@amd.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