[PR #272] gpu_unlock: contain a late failure with the success path's FLR instead of keeping the card until power off #277

Open
opened 2026-11-07 17:54:46 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Zagitta/gpu-unlock/pull/272
Author: @jontyler21
Created: 10/30/2026
Status: 🔄 Open

Base: main ← Head: contain-late-failure


📝 Commits (1)

  • 7eca70a gpu_unlock: contain a late failure with the success path's FLR instead of keeping the card until power off

📊 Changes

1 file changed (+29 additions, -10 deletions)

View changed files

📝 kernel/gpu_unlock/unlock_610.c (+29 -10)

📄 Description

What

A failure after firmware has started (FWSEC, a Booter launch or its readback, a pre-FLR check) currently retains the card: BME off, BAR0 and the DMA buffers held until power off, and the stock driver can't bind. On a card that also drives the display, that's a black screen until a cold boot. Behind a LUKS root it's a blank passphrase prompt too, because the FLR path has already removed simpledrm/efifb by then.

This PR runs the same FLR and post-FLR checks a successful unlock uses, once, before giving up. The card is only quiesced and handed to the stock driver (at stock speed) when every existing check passes: config identity and BARs restored, GFW halted, SEC2 reset, no pending transactions, WPR2 down. If any check fails, the card stays retained exactly as today. The original error is still returned, so card->unlocked stays false and nothing is reported as unlocked.

This isn't the unconditional cleanup #43 warns against. Memory is only released after the FLR has disposed of the firmware's execution, which is the same proof the success path already relies on.

How

  • unlock_transaction_reset(work, contain): in contain mode it skips the "selectors must be unlocked" pre/post checks and also accepts GU_ALLOCATED (FWSEC failed before publish). It logs stage=contain ….
  • flr_attempted makes sure the FLR is tried at most once: a failure inside the success path's own post-FLR checks is not retried.
  • It runs after restore_stock_signature(), so the stock signature is in place before the FLR.

Testing

  • Compile-tested only: kernel 7.2.8 (Arch/Omarchy), no warnings. Also builds merged with #252, without conflicts.
  • Not run on hardware. I haven't forced a late failure on a real card. If there's a fault-injection setup for this path (the 1.x emulator suite, or the harness from #43), this needs to run there before merging. Opening as a draft for that reason.

Open question for the maintainers

Is there any late-failure state where an FLR itself is unsafe? For example, a Booter that never halted while holding something the FLR can't reset. If so, contain mode could be limited to failures with invocation_halted (or FWSEC proven halted), which would still cover the common readback-mismatch case.

🤖 Generated with Claude Code

https://claude.ai/code/session_013LhtwTLXMR7uvVCcq1xbrM


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Zagitta/gpu-unlock/pull/272 **Author:** [@jontyler21](https://github.com/jontyler21) **Created:** 10/30/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `contain-late-failure` --- ### 📝 Commits (1) - [`7eca70a`](https://github.com/Zagitta/gpu-unlock/commit/7eca70ac3c281bd3a2a484685caa0c66f3c58dc5) gpu_unlock: contain a late failure with the success path's FLR instead of keeping the card until power off ### 📊 Changes **1 file changed** (+29 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `kernel/gpu_unlock/unlock_610.c` (+29 -10) </details> ### 📄 Description ## What A failure after firmware has started (FWSEC, a Booter launch or its readback, a pre-FLR check) currently retains the card: BME off, BAR0 and the DMA buffers held until power off, and the stock driver can't bind. On a card that also drives the display, that's a black screen until a cold boot. Behind a LUKS root it's a blank passphrase prompt too, because the FLR path has already removed simpledrm/efifb by then. This PR runs the same FLR and post-FLR checks a successful unlock uses, once, before giving up. The card is only quiesced and handed to the stock driver (at stock speed) when every existing check passes: config identity and BARs restored, GFW halted, SEC2 reset, no pending transactions, WPR2 down. If any check fails, the card stays retained exactly as today. The original error is still returned, so `card->unlocked` stays false and nothing is reported as unlocked. This isn't the unconditional cleanup #43 warns against. Memory is only released after the FLR has disposed of the firmware's execution, which is the same proof the success path already relies on. ## How - `unlock_transaction_reset(work, contain)`: in contain mode it skips the "selectors must be unlocked" pre/post checks and also accepts `GU_ALLOCATED` (FWSEC failed before publish). It logs `stage=contain …`. - `flr_attempted` makes sure the FLR is tried at most once: a failure inside the success path's own post-FLR checks is not retried. - It runs after `restore_stock_signature()`, so the stock signature is in place before the FLR. ## Testing - **Compile-tested only:** kernel 7.2.8 (Arch/Omarchy), no warnings. Also builds merged with #252, without conflicts. - **Not run on hardware.** I haven't forced a late failure on a real card. If there's a fault-injection setup for this path (the 1.x emulator suite, or the harness from #43), this needs to run there before merging. Opening as a draft for that reason. ## Open question for the maintainers Is there any late-failure state where an FLR itself is unsafe? For example, a Booter that never halted while holding something the FLR can't reset. If so, contain mode could be limited to failures with `invocation_halted` (or FWSEC proven halted), which would still cover the common readback-mismatch case. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_013LhtwTLXMR7uvVCcq1xbrM --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Zagitta/gpu-unlock#277
No description provided.