From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: drm/amd/display: Avoid using zero AC/DC brightness levels
Date: Thu, 28 May 2026 12:44:13 +1000 [thread overview]
Message-ID: <review-patch1-20260526210048.1162477-1-edson.drosdeck@gmail.com> (raw)
In-Reply-To: <20260526210048.1162477-1-edson.drosdeck@gmail.com>
Patch Review
**Correctness: Generally good, with one behavioral concern.**
The added checks at `amdgpu_dm.c:5509-5511`:
```c
if (get_brightness_range(caps, &min, &max) &&
caps->ac_level > 0 &&
caps->dc_level > 0) {
```
This requires **both** `ac_level` and `dc_level` to be non-zero for the firmware values to be used. This is a conservative choice.
**Concern — should this be `||` instead of `&&`?** Consider a system where `ac_level` is valid (say 80) but `dc_level` is zero, or vice versa. With this patch, both firmware values are discarded even though the relevant one (based on `power_supply_is_system_supplied()`) might be perfectly valid. An alternative approach would be to only check the value actually being used:
```c
if (get_brightness_range(caps, &min, &max)) {
if (power_supply_is_system_supplied() > 0 && caps->ac_level > 0)
props.brightness = DIV_ROUND_CLOSEST(...ac_level...);
else if (caps->dc_level > 0)
props.brightness = DIV_ROUND_CLOSEST(...dc_level...);
else
/* fallback */
```
However, the current approach is simpler and more conservative — if the firmware is giving bogus zeros for one field, the other field may be suspect too. This is a reasonable engineering judgment.
**Fallback path sets `max_brightness` to `MAX_BACKLIGHT_LEVEL`:** When the new guard rejects zero levels, the fallback at line 5521 sets both `props.brightness` and `props.max_brightness` to `MAX_BACKLIGHT_LEVEL`. Previously this only happened when `get_brightness_range()` failed (i.e., `caps` was NULL). Now it also fires when caps exist but have zero AC/DC levels. In this case the firmware's min/max range is valid but unused — the backlight gets registered with `MAX_BACKLIGHT_LEVEL` as its range instead of the firmware-reported range. This seems acceptable as a safe default but is a behavioral change worth noting: user-space will see a different `max_brightness` on these affected systems than it would if only the initial brightness were corrected.
**`ac_level` and `dc_level` are `u8` (unsigned):** The `> 0` checks are correct; there's no sign issue. The values come from ACPI firmware (`amdgpu_acpi.c:400-401`) and represent percentages (0-100).
**Commit message nits:**
- Missing period at the end of "Only use the firmware brightness levels when both AC and DC values are non-zero" — minor style issue.
- The commit message could benefit from a `Fixes:` tag referencing the commit that introduced this brightness initialization logic, to help stable kernel backporting.
- No `Cc: stable@vger.kernel.org` tag — if this is intended as a bug fix for existing systems, it may be worth adding one.
**Overall:** The patch is simple, correct for the stated problem, and low-risk. Recommend adding a `Fixes:` tag and considering whether the fallback should preserve the firmware's `max_brightness` range even when it discards the initial brightness value.
---
Generated by Claude Code Patch Reviewer
prev parent reply other threads:[~2026-05-28 2:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-26 21:00 [PATCH] drm/amd/display: Avoid using zero AC/DC brightness levels Edson Juliano Drosdeck
2026-05-28 2:44 ` Claude review: " Claude Code Review Bot
2026-05-28 2:44 ` Claude Code Review Bot [this message]
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-patch1-20260526210048.1162477-1-edson.drosdeck@gmail.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