Skip to content

drm/apple: fix two brightness floor edge cases on wake and M4 default - #4412

Open
RyanTheTide wants to merge 1 commit into
mainfrom
fix/dcp-backlight-floor-edges
Open

RyanTheTide wants to merge 1 commit into
mainfrom
fix/dcp-backlight-floor-edges

Conversation

@RyanTheTide

Copy link
Copy Markdown
Contributor

What: Fix both apple,min-brightness edge cases in the DCP backlight policy: keep a loader-inherited level below the floor across the firmware-27 wake/resume sequence, and raise an uninherited default (such as the M4 120-nit default) to the floor before its first present. Fixes #3579

Tested: At head bbf2f71c50a8:

  • make ARCH=arm64 LLVM=1 W=1 drivers/gpu/drm/apple/dcp_backlight.o drivers/gpu/drm/apple/dcp_backlight_test.o: 0 errors, 0 warnings
  • python3 tools/testing/selftests/drivers/gpu/apple-dcp/run.py --source . --group all: 104/104 passed
  • Standalone host C run of all new dcp_backlight.h floor assertions (clang -Wall -Wextra -Werror): passed
  • scripts/checkpatch.pl --strict --git HEAD~1..HEAD: 0 errors, 0 warnings, 0 checks

Risk: two-way door · Apple panels with apple,min-brightness configured in DT (no tree sets it on main yet; runtime no-op for panels with minimum == 0)

Not yet: Hardware row on a panel with apple,min-brightness set (e.g. K114s once #3181 lands, and an M4 panel with a configured floor above 120 nits)

Details
  1. Firmware 27 wake path (dcp_backlight.h, dcp_backlight.c): dcp_backlight_wake_lit() previously cleared core_blank and suspended before the backlight core resumed, so the matching resume callback arrived with unchanged blank/suspend flags and dcp_bl_request() treated it as a new user brightness request (raising a loader level below minimum). Move the state transition into dcp_bl_wake_lit() and record wake_resume_pending when core_blank || suspended was set; dcp_bl_request() consumes wake_resume_pending once on the matching unblanked resume notification, while any subsequent user write (or a wake_lit while already unblanked) enforces the floor as before.
  2. Uninherited M4 default (dcp_backlight.h): In dcp_bl_set_minimum(), when !state->level_known && !state->controlled && state->target < minimum, raise target, level, and actual to minimum immediately so dcp_backlight_configure()'s dcp_bl_jump() on M4 never presents 120 nits below a higher floor. Loader-inherited levels (level_known == true) and late loader hints via dcp_bl_report() remain unaffected.
  3. KUnit coverage (dcp_backlight_test.c): Extended backlight_floor_test() with cases for firmware-27 wake + resume (both full suspend and v27_keep_level=1), already-unblanked wake_lit, M4 default clamping below a 150-nit floor, and late loader hints below the floor.
Evidence
  • make ARCH=arm64 LLVM=1 W=1 O=... drivers/gpu/drm/apple/dcp_backlight.o drivers/gpu/drm/apple/dcp_backlight_test.o: clean build (0 warnings, 0 errors)
  • tools/testing/selftests/drivers/gpu/apple-dcp/run.py --source . --group all: 1..104 all ok
  • scripts/checkpatch.pl --strict --git HEAD~1..HEAD: total: 0 errors, 0 warnings, 0 checks, 164 lines checked

Fix the two edge cases tracked in #3579 for panels that set
apple,min-brightness:

1. Firmware 27 wake path (dcp_backlight_wake_lit()): clearing core_blank
   and suspended before the backlight core's resume callback meant the
   subsequent resume notification arrived with unchanged flags and was
   mistaken for a user request, raising a loader-inherited level below
   the floor. Move the state update into dcp_bl_wake_lit() and record
   wake_resume_pending when blank or suspend was active so the matching
   resume notification preserves the loader level while any subsequent
   user request still enforces the floor.

2. M4 default presentation: dcp_bl_set_minimum() left an uninherited
   registration default untouched, so an M4 panel configured with a
   120-nit default and a higher floor presented 120 nits on its initial
   dcp_bl_jump() before the floor took effect. Raise an uninherited,
   uncontrolled default in dcp_bl_set_minimum() while keeping loader-
   inherited levels and late loader hints below the floor intact.

Add KUnit cases in dcp_backlight_test.c covering both edge cases,
v27_keep_level=1 (core_blank only), already-unblanked wake_lit, M4
default clamping, and late loader hints below the floor.

Closes: #3579
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide
RyanTheTide requested review from a team as code owners December 5, 2026 04:42

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: MERGE at bbf2f71

Checked: Replayed the exact backlight-only test routines using the exact inline implementation. GCC and Clang each passed 724 assertions under UBSan. Verified the wake marker preserves the inherited level through the matching resume callback, the next unchanged brightness request applies the floor, and the uninherited default is clamped before its first present. The configured-floor hardware row remains open.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Code-owner notice for @aurora-silicon/core @aurora-silicon/omarchy-mac @aurora-silicon/aurora-maintainers: approved by aurora-silicon-review at bbf2f71c50, CI running, hardware row queued.

@github-actions github-actions Bot added area:display Area from CODEOWNERS (bot) door:two-way Revertible or not, from Merge risk (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Dec 5, 2026
@github-actions

github-actions Bot commented Dec 5, 2026

Copy link
Copy Markdown

Merge readiness at bbf2f71c: not ready yet

Check Detail
CI at head running running: apple-build, host-tests, KUnit plan
Review no approved by aurora-silicon-review, but GitHub does not count it yet (code owner from Core, Omarchy Mac or Aurora Maintainers needed, or approval went stale)
Requested changes ok none
Hardware row at head no no line with the head SHA bbf2f71c, a Mac and a result in the PR body or a comment
Conflicts ok none
PR text ok Risk: two-way · Apple panels with apple,min-brightness configured in DT (no tree sets it on main yet; runtime no-op for panels with minimum == 0)

Areas: area:display

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:display Area from CODEOWNERS (bot) door:two-way Revertible or not, from Merge risk (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

drm/apple brightness floor (#3105): two edge cases once a tree sets apple,min-brightness

1 participant