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: Add support for client indicating support for luminance
Date: Thu, 04 Jun 2026 14:54:31 +1000	[thread overview]
Message-ID: <review-patch4-20260531114908.1693426-5-superm1@kernel.org> (raw)
In-Reply-To: <20260531114908.1693426-5-superm1@kernel.org>

Patch Review

**Issue: Modifying connector->state without holding atomic lock**

```c
+	if (connector->state)
+		connector->state->luminance = set;
```

This is in `__drm_backlight_real_changed`, called under the spinlock. Writing to `connector->state->luminance` without holding the atomic modeset lock is a race with any concurrent atomic commit that might be swapping connector states.

**Concern: DPMS handling in drm_atomic_connector_commit_dpms**

The patch modifies this function significantly, but the base code has changed — upstream uses `struct drm_atomic_commit *state` while the patch shows `struct drm_atomic_state *state`. This indicates a base mismatch that will need rebasing.

The DPMS backlight coordination logic is complex with both legacy and atomic paths:
```c
+	crtc = connector->state ? connector->state->crtc : NULL;
+
+	if (old_mode != DRM_MODE_DPMS_OFF && mode == DRM_MODE_DPMS_OFF) {
+		if (crtc)
+			drm_atomic_crtc_set_backlight(crtc, false);
```

This null-checks `connector->state` (good, fixing a potential NULL deref in the original), but the original code unconditionally did `crtc = connector->state->crtc`. So this is also a bugfix, but it should be a separate patch.

**Issue: `drm_backlight_set_luminance` WARN_ON on failure then fallback**

```c
+		int rc = backlight_set_brightness(bd, set, BACKLIGHT_UPDATE_DRM);
+		WARN_ON(rc);
+		if (rc)
+			backlight_set_brightness(bd, max, BACKLIGHT_UPDATE_DRM);
```

`WARN_ON` in normal operation is too aggressive. If the hardware is busy or the panel is off, the brightness set can legitimately fail. Using `WARN_ON` will spam dmesg and could be flagged by CI. The fallback to max brightness on failure is also questionable — if setting `set` failed, why would setting `max` succeed? And setting max on failure seems wrong — the user asked for a specific brightness.

**Issue: drm_takeover atomic vs spinlock**

`drm_takeover` is an `atomic_t` on `backlight_device`, modified under `drm_backlight_lock` spinlock:
```c
+	if (b->link)
+		atomic_inc(&b->link->drm_takeover);
```

But it's read without the spinlock in `brightness_store`:
```c
+	if (atomic_read(&bd->drm_takeover) > 0)
+		return -EBUSY;
```

This is fine for the intended purpose (advisory check, TOCTOU is acceptable here), but the use of both a spinlock and atomics is redundant — if the atomic is sufficient for the read side, the spinlock protection on the write side is unnecessary overhead. Pick one synchronization mechanism.

**Leftover text in changelog**: Line `f-luminance` appears to be a stray fragment in the commit message changelog area.

---
Generated by Claude Code Patch Reviewer

  reply	other threads:[~2026-06-04  4:54 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-31 11:48 [PATCH v5 00/11] Add support for a DRM backlight capability Mario Limonciello (AMD)
2026-05-31 11:48 ` [PATCH v5 01/11] Revert "backlight: Remove notifier" Mario Limonciello (AMD)
2026-06-04  4:54   ` Claude review: " Claude Code Review Bot
2026-05-31 11:48 ` [PATCH v5 02/11] backlight: add kernel-internal backlight API Mario Limonciello (AMD)
2026-06-04  4:54   ` Claude review: " Claude Code Review Bot
2026-05-31 11:49 ` [PATCH v5 03/11] drm: link connectors to backlight devices Mario Limonciello (AMD)
2026-06-04  4:54   ` Claude review: " Claude Code Review Bot
2026-05-31 11:49 ` [PATCH v5 04/11] DRM: Add support for client indicating support for luminance Mario Limonciello (AMD)
2026-06-04  4:54   ` Claude Code Review Bot [this message]
2026-05-31 11:49 ` [PATCH v5 05/11] drm/amd/display: Pass up errors reading actual brightness Mario Limonciello (AMD)
2026-06-04  4:54   ` Claude review: " Claude Code Review Bot
2026-05-31 11:49 ` [PATCH v5 06/11] drm/amd/display: Allow backlight registration to fail Mario Limonciello (AMD)
2026-06-04  4:54   ` Claude review: " Claude Code Review Bot
2026-05-31 11:49 ` [PATCH v5 07/11] drm/amd/display: Move backlight tracing out of the dc lock Mario Limonciello (AMD)
2026-06-04  4:54   ` Claude review: " Claude Code Review Bot
2026-05-31 11:49 ` [PATCH v5 08/11] drm/amd/display: use drm backlight Mario Limonciello (AMD)
2026-06-04  4:54   ` Claude review: " Claude Code Review Bot
2026-05-31 11:49 ` [PATCH v5 09/11] drm/amd/display: Drop brightness caching in amdgpu_dm Mario Limonciello (AMD)
2026-06-04  4:54   ` Claude review: " Claude Code Review Bot
2026-05-31 11:49 ` [PATCH v5 10/11] drm/bridge: auto-link panel backlight in bridge connector Mario Limonciello (AMD)
2026-06-04  4:54   ` Claude review: " Claude Code Review Bot
2026-05-31 11:49 ` [PATCH v5 11/11] drm/i915/display: use drm backlight Mario Limonciello (AMD)
2026-06-04  4:54   ` Claude review: " Claude Code Review Bot
2026-06-04  4:54 ` Claude review: Add support for a DRM backlight capability 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-patch4-20260531114908.1693426-5-superm1@kernel.org \
    --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