Repository navigation
drm: apple: complete the H17P display driver for the MacBook Neo - #203
Merged
Merged
Conversation
The H17P callback dispatcher only accepts callbacks whose record lengths appear in the startup observations. Every other callback that has a handler is treated as unqualified and marks the coprocessor as crashed, which stops all presents until the next reboot. Twenty-six handled callbacks are missing from those observations because they arrive only after startup: present notifications, swap aborts, the backlight re-send request, the wall-clock and clock-rate queries, and several acknowledgements. A long session that sees any of them loses the internal panel even though the driver knows how to answer. Record, for each of them, the input its handler reads and the reply it writes, and accept any record at least that large. The dispatcher already zeroes the whole reply before the handler runs, so a longer reply carries zeroes beyond the handler's fields. The measured startup tuples stay exact, and tags without a handler are still answered with a zeroed reply as before. Add a KUnit case that every installed handler has bounds and that the exact and bounded rules hold. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
The prepare callback maps a physical display register range for the coprocessor. Its size arrives from the firmware as a 64-bit value but is rounded into an int, so a large size wraps negative. The window check then compares a wrapped end address, and dma_map_resource() receives the sign-extended size. The descriptor ID is also taken from find_first_zero_bit() without checking for a full table, so a mapping requested while all 128 descriptors are in use writes past the array. A failed DMA mapping is only warned about and returned as the device address. Keep the size in 64 bits, refuse a zero size or a range that wraps, refuse when no descriptor is free, and refuse a failed DMA mapping before claiming a descriptor. Each refusal is the existing all-zero reply already used for addresses outside the display windows. A valid request is mapped and answered exactly as before. H17P accepts this callback at runtime from now on, which makes the bounds matter there too. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
H17P reports an aborted present through its abort callback and never sends a completion for it. The driver only traced the callback, so the present stayed pending: the outbound queue waited until its ten-second timeout declared the coprocessor crashed, and the page-flip event was never signalled. Track the abort in the present state. After the submit reply, an abort ends the present like a rejected submission: the brightness reservation is retried, framebuffers displaced by the present are unarmed and stay retained for the next completed present, and the DRM event is signalled. An abort that arrives before the submit reply is recorded, and the reply then fails the present instead of waiting for a completion. An abort naming a present that is not in flight is only logged. Older firmware still only traces the callback. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
The enable-backlight-message callback asks the AP to send the panel level again. On H17P the level travels only inside a present, so the existing handler, which sets the older firmware's update flag, sends nothing: the brightness policy sees no pending change and the queued brightness transaction returns without presenting. On the measured H17P profile, mark the effective level dirty and let the update worker queue a brightness present, which re-presents the retained scanout as for any other level change. A blanked panel is re-sent at zero and keeps its restore target. Nothing is sent before Linux controls the level, while a present already carries it, or more than once a second, so a request repeated after every brightness present cannot keep the queue busy. The receive path only schedules the worker; it never queues a transaction itself. Older firmware keeps its existing handling. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
The H17P backlight is commanded in nits, and the firmware converts them with its own tables up to the panel ceiling from the device tree, 525 nits on J700. Takeover still clamps the exposed range to 509 nits, the end of the older firmware's DAC interpolation table, which H17P never uses. The top of the panel's range is therefore unreachable, and a loader level reported above 509 nits rejects the takeover hint, which leaves the backlight unregistered until a later report falls below it. Use the panel ceiling as the H17P maximum, and clamp a powerlog report above it to the ceiling instead of rejecting it. The present encoding already writes the same ceiling into every present. Older firmware keeps its existing range. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
H17P never publishes the panel level. The driver registers its backlight only when the system endpoint forwards a powerlog report with the loader's level. That report is optional: when it does not arrive, or arrives in a form the parser does not accept, no backlight device is ever registered and desktops offer no brightness control. Two seconds after the first pipe enable, register the backlight anyway if no report has configured it. Expose the middle of the panel range as the current level, but present nothing: the policy starts clean, so the panel keeps the loader's level until userspace writes one. A report that arrives later is ignored, as are reports after a hint-based registration. The worker is cancelled with the other backlight work on unbind and shutdown. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
H17P keeps its pipe and display domains running across system sleep, and blanks the panel with a brightness present instead. The DRM and backlight suspend handlers only queue that present: the serialized IOMFB queue sends it, and finishes it when the firmware reports the completion. The DCP suspend handler returned without waiting, so the blanking present could still be in flight when interrupts are suspended, leaving the panel lit through the sleep and the transaction stalled until resume. Before the DCP suspends, flush the brightness worker and wait up to half a second for the queue to go idle, twice, since a completed present can schedule one more brightness present. A crashed or stopped queue counts as idle. If the queue does not drain, log it and continue suspending. Older firmware does not use the queue and is unaffected. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
When the H17P firmware crashes, the driver marks the coprocessor failed and reports the connector disconnected. A present in flight at that moment never completes, so its page-flip event is only released by the DRM core's flip timeout, and the compositor stalls on it first. Schedule the existing delayed vblank work from the crash handler on H17P so the pending event is signalled. Framebuffers stay retained, since the display engine may still be reading the last surface. H17P has no in-place restart, so also log that a reboot is needed to restore the display. Older firmware keeps its existing crash handling. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
…abled The display subsystem builds its component match from every available DCP node and binds only when all of them have bound. The T8140 external DCP runs firmware this driver cannot drive yet: its node falls back to the generic DCP match, which has no firmware profile for it. Its probe then either fails, leaving the component master waiting forever, or selects an older firmware interface from the loader's properties. Enabling that node in a device tree would therefore take the internal panel down with it. Leave T8140 external DCP nodes out of the component match and the pipeline scan, and refuse them in the DCP probe with an informational message, so they are never touched. Other SoCs are unaffected. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
The H17P crash handler schedules the delayed vblank work, so that a present in flight at the time of the crash completes its page-flip event. That work dereferences dcp->crtc, which is set only when the display subsystem links the pipeline. RTKit is already running before that: component binding wakes the coprocessor before the DRM device creates its CRTCs, and a pipeline whose CRTC setup failed stays bound with no CRTC at all. A firmware crash in either state then oopses the workqueue on a NULL CRTC. Schedule the work from the crash handler only once a CRTC is linked, and make the delayed vblank work itself return early without one, which also covers its other callers. Publish the CRTC with WRITE_ONCE() to match the lockless readers. Also limit the crash-time completion to the measured H17P profile, as every other H17P change in this series is. The H17G profile (T8142) keeps its existing crash handling. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
When the backlight class device cannot be registered, the worker zeroes the panel maximum so that older firmware stops encoding brightness. On H17P the brightness policy is already active by then, and the present path needs that maximum for the ceiling it writes into every present: with it zeroed, every present is refused and the panel freezes on its last frame. Registration is attempted on every H17P boot now, so this error path is always reachable. Keep the maximum while the H17P policy is active. Presents keep their ceiling and the policy keeps applying DPMS and the firmware's requests; only the sysfs control is missing. Log the error code in either case. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
Without a loader brightness report, the H17P backlight is registered with a mid-range default that is only reported to userspace; the panel keeps the loader's level. Registration also marks the policy as controlled, which is the only condition the firmware's re-send request checked. A re-send request before userspace writes a level therefore presented the default and moved the panel from the loader's level to mid-range, contrary to the intent of the re-send and fallback registration changes. Track whether the level the panel shows is known: the loader's reported level, or one a completed present carried. Require it for a re-send, so a re-send request now leaves a panel showing an unknown level alone. A rejected present does not make a level known. A DPMS blank and wake, or a suspend and resume, after a fallback registration still has to light the panel at some level and uses the reported default. The panel keeps the loader's level only until the first such transition or userspace write. Also reject powerlog reports above twice the panel ceiling instead of clamping them, so a corrupt sample cannot become a known level. Add a KUnit case for the fallback registration, the re-send request, rejected and completed presents, and the DPMS wake level. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
The H17P abort callback is handled as "this present never completes", but no capture confirms that. If the firmware still completes an aborted present, the completion matches no present in flight and the driver declares the coprocessor crashed, turning the first real abort into a dead display. Remember the most recently aborted present. A completion for it is logged and otherwise ignored: its displaced framebuffers were already unarmed and its DRM event signalled when it was aborted, and it does not disturb a later present in flight. Also settle the swap watchdog when an accepted present is aborted. Otherwise a Type-C output would report a missing completion and retrain one second later. Rate-limit the abort messages, so that a firmware that aborts every frame cannot flood the log. Extend the KUnit present-state case with stale completions. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
The sleep drain waited for the IOMFB queue to go idle, but a rejected blanking present leaves the queue idle with a delayed retry scheduled. The drain then returned, and the retry ran after the coprocessor's mailbox had suspended, leaving the panel lit through sleep. Run a pending brightness retry immediately in each drain pass, and keep draining while the brightness policy still has a level to send. Four passes cover the first attempt and the policy's three retries, each bounded as before; a level that is still pending after them is logged. Also queue the fallback backlight registration on the freezable system workqueue, so that it cannot register a class device in the middle of a suspend that starts within two seconds of the first pipe enable. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
The runtime callbacks accepted within reply bounds are validated against what their handlers read and write, because no capture of their record lengths exists. A longer record is accepted silently, so a layout that differs from the handler's assumption, for instance a status word at another offset, would go unnoticed. The first time each of these callbacks arrives with lengths other than its handler's, log the lengths seen next to the handler's. Each tag is reported at most once per boot, and the measured startup callbacks are unchanged. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
RyanTheTide
added a commit
that referenced
this pull request
Oct 8, 2026
…a dead DCP, seeded backlight level, DCP node references drm: apple: #203 follow-ups: sleep drain on a dead DCP, seeded backlight level, DCP node references
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This series completes the display driver for the MacBook Neo (J700, T8140, H17P display firmware) on top of
aurora-wip. It builds on the DART fix already inaurora-wip(2bad3dba632f, "keep inherited firmware translations visible before attach"), which lets the internal display coprocessor bind.What's included (15 commits)
Testing
Builds:
drivers/gpu/drm/apple/with W=1, with no new warnings, including the KUnit objects.aurora-wip.Static checks:
checkpatch --strictreports only theAssisted-byformat warning.KUnit on arm64 QEMU covers:
Hardware (J700) runs used a kernel combining this series, the DT hand-off series and
aurora-wip, with the loader's display hand-off. The first nine commits had the full run below. The follow-up fixes had one re-verification boot of the series merged into currentaurora-wip, which passed:Not exercised on hardware (KUnit and review only):
How it was written
All code is newly written for this series, following the existing driver's conventions.
🤖 Generated with Claude Code