Repository navigation
nvme-apple: let post-M4 reset recovery finish while I/O is frozen (reworked) - #31
Merged
Merged
Conversation
After the I/O queue is re-created, reset_work unquiesces the I/O queues and waits in nvme_wait_freeze() for the requests that entered before the reset, while holding disable_lock. If one of them times out while the controller is CONNECTING, the timeout handler marks the reset aborted and queues recovery_work, which needs disable_lock to stop the controller and cancel the request, so neither side can proceed. A timeout during removal and apple_nvme_shutdown() also stop the controller under this lock, so they wait behind reset_work as well. Release disable_lock while waiting and take it again before resizing the tag set and publishing LIVE. If the reset was aborted, or the controller was removed or quarantined meanwhile, unfreeze and take the reset failure path. Releasing the lock alone does not let the wait finish. recovery_work stops the controller without unquiescing the queues, and the requests it cancels, which are retryable, are requeued onto the quiesced queues. An aborted initialization gets no follow-up reset, so after its stop, unquiesce the queues under the same lock: the requeued requests then reach the disabled queues and fail with BLK_STS_IOERR, as the PCI driver lets them fail after a timeout while connecting. The failure path removes the controller, so these requests could not have completed anyway. A controller whose stop fails is quarantined and keeps its requests until reboot, so the wait could still never finish. Wait in steps of the I/O timeout, and stop waiting once the controller is quarantined or the reset aborted. The failure path then stops the controller, or leaves a quarantined one as it is. Removing a controller that cannot be stopped still hangs: the quarantine keeps its requests, and del_gendisk() waits for them. That needs a separate decision. Legacy controllers are unchanged. Compile-tested only; not run on hardware. Fixes: 7296c58 ("nvme-apple: Serialize post-M4 disable, timeout recovery and reset") Assisted-by: LLM checkpatch sparse Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
reset_work publishes LIVE and then calls nvme_start_ctrl() with disable_lock held. When the controller reports supported asynchronous events in OAES, nvme_start_ctrl() sends Set Features (Asynchronous Event Configuration) and waits for it. If that command times out, the controller is LIVE, so the timeout handler moves it to RESETTING and queues recovery_work, which blocks on disable_lock while reset_work waits for the command that recovery_work would cancel. A timeout during removal blocks on the lock the same way. This driver has no submit_async_event() callback, so a controller that reported asynchronous events would also fault in nvme_async_event_work(). The OAES field of the post-M4 controllers has not been read here, though, so do not rely on the command never being sent: release disable_lock once LIVE has been published, before nvme_start_ctrl(). Nothing in nvme_start_ctrl() programs the controller, which is what the lock keeps apart from a stop. After the lock is released, a recovery can stop the controller before nvme_start_ctrl() unquiesces the I/O queues. The unquiesce then undoes the stop's quiesce, and requests fail on the stopped queues until the next reset instead of waiting for it. The PCI driver has the same window. A request can time out in it only while nvme_start_ctrl() waits for the command above: the requests that entered before the reset have completed by then, and later ones have been in flight for less than the I/O timeout. Legacy controllers never take disable_lock and are unchanged. Compile-tested only; not run on hardware. Fixes: 7296c58 ("nvme-apple: Serialize post-M4 disable, timeout recovery and reset") Assisted-by: LLM checkpatch sparse Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
RyanTheTide
force-pushed
the
series/neo-ans-freeze-recovery-20260926
branch
from
September 25, 2026 17:07
bd0b97a to
f5be53a
Compare
RyanTheTide
marked this pull request as ready for review
September 25, 2026 17:07
This was referenced Nov 15, 2026
knalekar
added a commit
to knalekar/linux
that referenced
this pull request
Nov 19, 2026
14.7 firmware on the T6030 ProMotion panel completes swaps every second refresh: with the swap record's presentation timing words all zero, swaps complete 16.7 ms apart even though the panel scans out at 120 Hz, so compositors pace everything at 60 fps (omacom/linux-aurora aurora-silicon#31). Set the existing per-board .swap_timestamps flag on the T6030 record. dcp_v14_swap_locked() then stamps the three presentation timing words (offsets 0x00, 0x08 and 0x30, as on the 12.x/13.x/26.6 paths) through dcp_v14_swap_timestamps(). With the target long past, the firmware presents each swap at the next refresh, i.e. at 120 Hz. Report an internal panel's flip before dcp_v14_present() instead of after it. dcp_v14_swap() blocks until the firmware completes the swap, so the compositor could not start its next frame until then. The next commit still waits for this swap (v14->lock and the CRTC commit dependencies), and displaced framebuffers stay pinned until the swap completes, so nothing is freed while the firmware may still scan it. A 3-buffer swapchain renders into the buffer from two flips back, which is already off screen. This is not board-specific and now applies to every internal 14.x panel; external processors keep their present path. On j514s (MacBook Pro 14", M3 Pro, T6030) with GNOME/mutter 50.6, stock paces everything at ~60 fps while the panel reports 120 Hz; with these changes UFO tester and visual checks confirm ~120 fps, stable across several boots with no GPU faults, flip failures or display errors. The swap timestamps were also validated on j516s (omacom/linux-aurora aurora-silicon#31). The early flip has only been tested on T6030. Assisted-by: LLM
DjDeveloperr
pushed a commit
to knalekar/linux
that referenced
this pull request
Nov 25, 2026
14.7 firmware on the T6030 ProMotion panel completes swaps every second refresh: with the swap record's presentation timing words all zero, swaps complete 16.7 ms apart even though the panel scans out at 120 Hz, so compositors pace everything at 60 fps (omacom/linux-aurora aurora-silicon#31). Set the existing per-board .swap_timestamps flag on the T6030 record. dcp_v14_swap_locked() then stamps the three presentation timing words (offsets 0x00, 0x08 and 0x30, as on the 12.x/13.x/26.6 paths) through dcp_v14_swap_timestamps(). With the target long past, the firmware presents each swap at the next refresh, i.e. at 120 Hz. Report an internal panel's flip before dcp_v14_present() instead of after it. dcp_v14_swap() blocks until the firmware completes the swap, so the compositor could not start its next frame until then. The next commit still waits for this swap (v14->lock and the CRTC commit dependencies), and displaced framebuffers stay pinned until the swap completes, so nothing is freed while the firmware may still scan it. A 3-buffer swapchain renders into the buffer from two flips back, which is already off screen. This is not board-specific and now applies to every internal 14.x panel; external processors keep their present path. On j514s (MacBook Pro 14", M3 Pro, T6030) with GNOME/mutter 50.6, stock paces everything at ~60 fps while the panel reports 120 Hz; with these changes UFO tester and visual checks confirm ~120 fps, stable across several boots with no GPU faults, flip failures or display errors. The swap timestamps were also validated on j516s (omacom/linux-aurora aurora-silicon#31). The early flip has only been tested on T6030. Signed-off-by: Dj <43033058+DjDeveloperr@users.noreply.github.com>
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.
Fixes the post-M4 reset deadlock around the I/O freeze and makes the fix sufficient, reworked after review. Two commits on
aurora-wip(671ad267c), bothFixes: 7296c5865423.What changed since the reviewed head (bd0b97a00c4d)
The freeze can now finish after an aborted reset. Dropping
disable_lockacross the freeze wait (the original change, kept) was necessary but not enough:recovery_workstopped the controller without unquiescing the queues.reset_workhung without the lock instead of deadlocking with it.Now, after the stop for a CONNECTING abort,
recovery_workunquiesces the queues under the same lock. The requeued requests fail on the disabled queues, as in pci.c after a timeout while connecting. The failure path removes the controller afterwards, so they could not have completed anyway.The wait is bounded. It runs in steps of the I/O timeout and gives up once the reset is aborted or the controller is quarantined. A quarantined controller keeps its requests, so the wait could otherwise never end; the quarantined re-check after the wait is now reachable. The wait does not give up on removal alone: removal drains I/O through the live controller, and the removal-time timeout branch stops the controller if a request stalls.
New commit: the lock is released before
nvme_start_ctrl(). If the controller advertises asynchronous events,nvme_start_ctrl()sends Set Features and waits. A timeout of that command on the live controller used to blockrecovery_work, or a removal, on the lock. The lock is now released once LIVE is published. The remaining window is documented in the code and the message: a stop that lands before the unquiesce innvme_start_ctrl()loses its quiesce, which pci.c's reset has too. It is reachable only while that Set Features is outstanding.The unlock and relock share one condition. The redundant state test in the re-check is dropped, so the re-check matches the one after Create SQ.
Subject prefix
nvme-apple:,Assisted-by: LLM checkpatch sparse,Co-authored-by: Claude Opus 5.5.Still open, stated in the message: removing a controller that cannot be stopped hangs in
del_gendisk(), because the quarantine keeps its requests. That needs a policy decision. A second removal hang, whereremove()waited on areset_workparked behind quiesced requests, is closed by this series.Checks:
W=1 C=1compile with LLVM and upstream sparse ofapple.o(andmacsmc-power.o). No new warnings; the one sparse warning, about the non-staticflush_interval, predates the series.checkpatch --stricton each patch file: 0 errors. The only warnings are the known ones: theAssisted-byformat,Co-authored-by, and "Unknown commit id" when run outside a git directory.Compile-tested only; not run on hardware in this form. Before relying on it:
fio;CONFIG_FAIL_IO_TIMEOUT,io-timeout-fail, one-shotfail_io_timeout). Expect "Reset failure status: -125", the controller removed, and no hang or lockdep report;nvme id-ctrlto read OAES;The J700 roots on this disk, so boot from USB for the destructive steps.
🤖 Generated with Claude Code