From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: drm: link connectors to backlight devices
Date: Thu, 04 Jun 2026 14:54:30 +1000 [thread overview]
Message-ID: <review-patch3-20260531114908.1693426-4-superm1@kernel.org> (raw)
In-Reply-To: <20260531114908.1693426-4-superm1@kernel.org>
Patch Review
This is the core patch and has the most issues.
**Bug: Spinlock used in sleeping context**
`drm_backlight_lock` is defined as:
```c
+static DEFINE_SPINLOCK(drm_backlight_lock);
```
But `__drm_backlight_link` is called under this spinlock, and it calls:
- `backlight_device_unref(b->link)` → `put_device()` which can trigger device cleanup (sleeping)
- `backlight_device_ref(b->link)` → `get_device()` (this is fine)
And in the notifier callback `drm_backlight_notify`, the spinlock is held while iterating and calling `__drm_backlight_link(b, NULL)`, which again calls `put_device`.
This should be a mutex, not a spinlock, or the ref/unref should be deferred outside the lock.
**Bug: Global property range shared across connectors**
```c
+static void __drm_backlight_update_prop_range(struct drm_backlight *b)
+{
+ struct drm_device *dev = b->connector->dev;
+ struct drm_property *prop = dev->mode_config.luminance_property;
+ ...
+ if (prop->values[1] != max) {
+ prop->values[0] = max ? 1 : 0;
+ prop->values[1] = max;
+ }
```
The `luminance_property` is a single property object shared by all connectors on the device. Modifying `prop->values[0]` and `prop->values[1]` affects the range for ALL connectors, not just the one being linked. If two eDP panels have different `max_brightness`, the last one linked wins. This is a design problem — each connector should have its own property instance, or a per-connector range mechanism is needed.
**Bug: drm_backlight_get_device returns pointer without refcount**
```c
+struct backlight_device *drm_backlight_get_device(struct drm_backlight *b)
+{
+ if (!b)
+ return NULL;
+
+ guard(spinlock)(&drm_backlight_lock);
+ return b->link;
+}
```
The pointer is returned after the spinlock is released. The caller in `drm_sysfs_connector_add_late` uses it to create a sysfs link:
```c
+ struct backlight_device *bd = drm_backlight_get_device(connector->backlight);
+ if (bd) {
+ int ret = sysfs_create_link(...)
```
Between `drm_backlight_get_device` returning and `sysfs_create_link`, the link could be changed and `bd` could be freed. The function should take a reference, or the caller should hold a lock.
**Issue: `__drm_backlight_real_changed` is a no-op in this patch**
```c
+static void __drm_backlight_real_changed(struct drm_backlight *b, uint64_t v)
+{
+ unsigned int max, set;
+ ...
+ set = v;
+ if (set >= max)
+ set = max;
+}
```
`set` is computed but never used. The function does nothing except check bounds. It's only completed in patch 4 where `connector->state->luminance = set` is added. This makes the intermediate state confusing and means patch 3 alone doesn't actually do anything useful with brightness values.
**Issue: select BACKLIGHT_CLASS_DEVICE unconditionally**
```c
+ select BACKLIGHT_CLASS_DEVICE
```
This forces all DRM builds to pull in backlight support. This may be undesirable for embedded/server builds that never use backlight. Consider making it conditional or using `depends on`.
**Issue: WARN_ON outside spinlock in drm_backlight_unregister**
```c
+void drm_backlight_unregister(struct drm_backlight *b)
+{
+ ...
+ WARN_ON(!__drm_backlight_is_registered(b));
+
+ scoped_guard(spinlock, &drm_backlight_lock) {
```
`__drm_backlight_is_registered` asserts `lockdep_assert_held(&drm_backlight_lock)`, but it's called outside the spinlock guard. This will trigger a lockdep warning. Similarly in `drm_backlight_register`:
```c
+ WARN_ON(__drm_backlight_is_registered(b));
+ guard(spinlock)(&drm_backlight_lock);
```
---
Generated by Claude Code Patch Reviewer
next prev parent 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 Code Review Bot [this message]
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 review: " Claude Code Review Bot
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-patch3-20260531114908.1693426-4-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