[PR #6] [MERGED] Claim cards on older kernels and behind BME-setting firmware #122

Closed
opened 2026-10-26 16:40:56 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Zagitta/gpu-unlock/pull/6
Author: @foureight84
Created: 10/22/2026
Status: ✅ Merged
Merged: 10/22/2026
Merged by: @Zagitta

Base: main ← Head: fix-pre-driver-claim


📝 Commits (1)

  • d04f5a0 Claim cards on older kernels and behind BME-setting firmware

📊 Changes

4 files changed (+37 additions, -11 deletions)

View changed files

📝 README.md (+5 -3)
📝 kernel/gpu_unlock/unlock_610.c (+16 -3)
📝 tests/test_unlock_adapter.c (+15 -5)
📝 tests/unlock_shim/compat.h (+1 -0)

📄 Description

Fixes #3. Fixes #5.

Two checks in unlock_transaction_claim() refused every card on a Supermicro X11SPi-TF running Ubuntu 24.04 (6.8.0-31-generic):

  1. current_state is PCI_UNKNOWN (5) on older kernels (#3: also seen on 6.14). No driver has enabled the card yet, so the kernel hasn't recorded a power state. Now PCI_UNKNOWN is accepted only when pm_cap is present, so the existing PMCSR read still confirms the card is in D0. Without a PM capability, the claim still refuses (-EOPNOTSUPP).
  2. The firmware leaves BME set (#5). The UEFI shell shows command 0x0147 before Linux starts, even with the slot's OPROM and the BIOS's "Bus Master Enable" option both disabled. The claim now clears BME, reads it back, and saves the cleared value as original_cmd. A card whose BME won't clear is still refused with -EBUSY, and the WPR2 check still refuses a card a driver has initialised.

The README sentence about skipping bus-mastering cards is updated to match.

Tests

Four new full-transaction scenarios in test_unlock_adapter.c, with PCI_UNKNOWN added to the shim:

  • power-unknown: PCI_UNKNOWN with a PM capability → unlocks
  • power-unknown-no-pm: PCI_UNKNOWN without one → -EOPNOTSUPP, nothing allocated
  • firmware-bme: command 0x6 at claim → BME cleared, unlocks
  • firmware-bme-stuck: BME won't clear → -EBUSY, nothing allocated, card left as found

python3 -m unittest discover -s tests passes 5/5 with the installed 610.43.03 firmware, including the full mocked transaction. The module builds against 6.8.0-31-generic.

Hardware

4x RTX 3090 (10de:2204) behind a PLX switch, VBIOS 94.02.59.00.94 x3 and 94.02.59.00.DD x1, NVIDIA open 610.57.04, cold boot with gpu_unlock.targets=all. All four log gpu_unlock: unlocked with SS0 0x88888888 after the FLR. BF16 per SM clock went from ~0.043 to ~0.082 TFLOPS/MHz. The before/after table is in #5.

The hardware run used an earlier version of change 1 that didn't have the pm_cap condition, and change 2 without the 0xffff readback check. On these cards (pm_cap=0x60, real readback) the code paths are the same.

🤖 Generated with Claude Code


🔄 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/6 **Author:** [@foureight84](https://github.com/foureight84) **Created:** 10/22/2026 **Status:** ✅ Merged **Merged:** 10/22/2026 **Merged by:** [@Zagitta](https://github.com/Zagitta) **Base:** `main` ← **Head:** `fix-pre-driver-claim` --- ### 📝 Commits (1) - [`d04f5a0`](https://github.com/Zagitta/gpu-unlock/commit/d04f5a00f30d9bceec7069868a7504fd925dc7ad) Claim cards on older kernels and behind BME-setting firmware ### 📊 Changes **4 files changed** (+37 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `README.md` (+5 -3) 📝 `kernel/gpu_unlock/unlock_610.c` (+16 -3) 📝 `tests/test_unlock_adapter.c` (+15 -5) 📝 `tests/unlock_shim/compat.h` (+1 -0) </details> ### 📄 Description Fixes #3. Fixes #5. Two checks in `unlock_transaction_claim()` refused every card on a Supermicro X11SPi-TF running Ubuntu 24.04 (6.8.0-31-generic): 1. **`current_state` is `PCI_UNKNOWN` (5) on older kernels** (#3: also seen on 6.14). No driver has enabled the card yet, so the kernel hasn't recorded a power state. Now `PCI_UNKNOWN` is accepted only when `pm_cap` is present, so the existing PMCSR read still confirms the card is in D0. Without a PM capability, the claim still refuses (`-EOPNOTSUPP`). 2. **The firmware leaves BME set** (#5). The UEFI shell shows command `0x0147` before Linux starts, even with the slot's OPROM and the BIOS's "Bus Master Enable" option both disabled. The claim now clears BME, reads it back, and saves the cleared value as `original_cmd`. A card whose BME won't clear is still refused with `-EBUSY`, and the WPR2 check still refuses a card a driver has initialised. The README sentence about skipping bus-mastering cards is updated to match. ### Tests Four new full-transaction scenarios in `test_unlock_adapter.c`, with `PCI_UNKNOWN` added to the shim: - `power-unknown`: PCI_UNKNOWN with a PM capability → unlocks - `power-unknown-no-pm`: PCI_UNKNOWN without one → `-EOPNOTSUPP`, nothing allocated - `firmware-bme`: command `0x6` at claim → BME cleared, unlocks - `firmware-bme-stuck`: BME won't clear → `-EBUSY`, nothing allocated, card left as found `python3 -m unittest discover -s tests` passes 5/5 with the installed 610.43.03 firmware, including the full mocked transaction. The module builds against 6.8.0-31-generic. ### Hardware 4x RTX 3090 (10de:2204) behind a PLX switch, VBIOS 94.02.59.00.94 x3 and 94.02.59.00.DD x1, NVIDIA open 610.57.04, cold boot with `gpu_unlock.targets=all`. All four log `gpu_unlock: unlocked` with SS0 `0x88888888` after the FLR. BF16 per SM clock went from ~0.043 to ~0.082 TFLOPS/MHz. The before/after table is in #5. The hardware run used an earlier version of change 1 that didn't have the `pm_cap` condition, and change 2 without the `0xffff` readback check. On these cards (`pm_cap=0x60`, real readback) the code paths are the same. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-26 16:40:56 +07:00
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#122
No description provided.