[PR #57] vbios_610: round FWSEC dmem_size up to 256 (fixes -EINVAL unlock abort on GA106 RTX 3060) #135

Open
opened 2026-10-26 16:41:06 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Zagitta/gpu-unlock/pull/57
Author: @536138283
Created: 10/24/2026
Status: 🔄 Open

Base: main ← Head: fix-ga106-dmem-align


📝 Commits (1)

  • 7e423f8 vbios_610: round FWSEC dmem_size up to 256 for GA106

📊 Changes

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

View changed files

📝 kernel/gpu_unlock/vbios_610.c (+10 -0)

📄 Description

Problem

On an RTX 3060 (GA106, 10de:2544) the unlock aborts with -EINVAL and leaves the
card unbindable, so nvidia then fails to probe it in a tight retry loop (593 times
in my boot) and the GPU is unusable until the machine is powered off:

pci 0000:01:00.0: FWSEC fuse: raw=0x3 version=2
gpu_unlock: FWSEC signature selection: versions=0xf fuse_version=2 sig_bytes=384
pci 0000:01:00.0: failure unlock_610.c:364 falcon_hs error=-22 last_mmio=0x8241e0 \
    value=0x3 valid=1 mapped=1 master=1 firmware_started=1 quiesced=0 pages=20606/20606
pci 0000:01:00.0: firmware did not stop; keeping its DMA buffers until power off
pci 0000:01:00.0: gpu_unlock: unlock failed (-22)
nvidia 0000:01:00.0: probe with driver nvidia failed with error -1

Note 0x2544 is already in supported_ids, so this is not a device-ID gap.

Root cause

falcon_dma_valid() requires every DMA size to be a multiple of 256, because the
falcon DMA engine moves 256-byte units (falcon_dma() advances done += 256):

return size && !((size | dest | mem_off | src) & 255) && ...

descriptor() rounds image_size up to 256:

fw.image_size = (stored + 255) & ~255u;

but passes dmem_size through verbatim:

fw.dmem_size = r32(rom + off + 32);

This board's FWSEC descriptor reports dmem_size = 0x980 (2432 = 9x256 + 128), which
is not 256-aligned, so falcon_hs() rejects its own arguments at unlock_610.c:364
and returns -EINVAL before falcon_reset(). The firmware therefore never runs at
all, but work->firmware_started has already been set by the caller and bus mastering
is on, so the module conservatively keeps the DMA buffers and the card stays claimed.

GA102 boards report dmem_size = 0x800 (already aligned) — which is exactly what
tests/test_vbios_610.c:108 asserts:

assert(fw.engine_mask == 0x400 && fw.imem_size == 0xda00 && fw.dmem_size == 0x800);

so this path is never exercised on the cards the unlock was developed against.

Fix

Round dmem_size up to 256 the same way image_size already is, with the same
overflow guard.

The rounded size stays in bounds on this board, exactly:

data_off + round_up(dmem_size) = 0xe300 + 0xa00 = 0xed00 = image_size

range(image_size, data_off, dmem_size) allows equality (bytes > length - off), and
memcpy(image, rom + fw.image_off, fw.image_size) has already copied the full rounded
image, so the extra 0x80 bytes the DMA covers are real ROM content already inside the
allocated buffer — not an out-of-bounds read. The three other dmem_size bounds checks
in descriptor() only become more permissive:

check value after rounding result
range(image_size, data_off, dmem_size) 0xe300 + 0xa00 = 0xed00 <= 0xed00 ok (exact)
range(dmem_size, pkc_off, 384) 0x724 + 0x180 = 0x8a4 <= 0xa00 ok
range(dmem_size, interface_off, 4) 0x20 <= 0xa00 ok

Verification

make test passes, including the C component tests. The GA102 assertion above is
unaffected because 0x800 is already aligned.

With the patch the unlock completes on this card:

gpu_unlock: FWSEC geometry: image_off=0x41af4 size=0xed00 imem=0xe300 va=0x0 pa=0x0 \
    dmem=0xa00 pa=0x0 pkc=0x724 interface=0x1c engine=0x400 ucode=9 signatures=4 \
    versions=0xf bytes=1536
pci 0000:01:00.0: Falcon DMA: base=0x110000 dest=0x0 offset=0x0 src=0xf8e4e300 size=0xa00 cmd=0x600
pci 0000:01:00.0: FWSEC result: scratch=0x0 expected_hi16=0
pci 0000:01:00.0: FWSEC WPR2: low=0x2ffee00 high=0x2fffc00 expected_page=0x2ffee0 end=0x2fffe0000
pci 0000:01:00.0: selector write: SS0=0x88888888
pci 0000:01:00.0: selector write: SS1=0x8
pci 0000:01:00.0: pre-FLR selectors: ss0=0x88888888 expected=0x88888888 ss1=0x8 expected=0x8
pci 0000:01:00.0: PCIe FLR returned: result=0
pci 0000:01:00.0: post-FLR SEC2 reset released, GSP halted, BME=0 pending=0 \
    WPR2=1ffffe00:00000000 SS0=88888888 SS1=00000008
pci 0000:01:00.0: gpu_unlock: unlocked

nvidia then binds normally (0 probe failures), and the card is fully usable.

Scope of what I verified: the unlock path completes, both speed selectors hold
their unlocked values across the FLR, and the card works normally afterwards. I have
not benchmarked FP16/BF16/TF32 throughput on this box (no PyTorch installed), so I
am not claiming a TFLOPS figure here — only that the -EINVAL abort is fixed and the
selectors are written as intended.

Test system

GPU ASUS RTX 3060 12GB, 10de:2544 rev a1, subsystem 1043:8a8f
VBIOS 94.06.54.00.2F
Chip (reported) 0xb76000a1
OS Ubuntu 25.04, kernel 6.14.0-37-generic
Driver NVIDIA 580.95.05
Base af28cbb

Happy to gather more data or test revisions on this card if useful. Other GA106 boards
reporting a non-aligned dmem_size should be fixed by the same change, but 0x2544 is
the only one I can test.


🔄 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/57 **Author:** [@536138283](https://github.com/536138283) **Created:** 10/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix-ga106-dmem-align` --- ### 📝 Commits (1) - [`7e423f8`](https://github.com/Zagitta/gpu-unlock/commit/7e423f87992f74c13b1a8e393ff6d67b762eaa04) vbios_610: round FWSEC dmem_size up to 256 for GA106 ### 📊 Changes **1 file changed** (+10 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `kernel/gpu_unlock/vbios_610.c` (+10 -0) </details> ### 📄 Description ## Problem On an RTX 3060 (GA106, `10de:2544`) the unlock aborts with `-EINVAL` and leaves the card unbindable, so `nvidia` then fails to probe it in a tight retry loop (593 times in my boot) and the GPU is unusable until the machine is powered off: ``` pci 0000:01:00.0: FWSEC fuse: raw=0x3 version=2 gpu_unlock: FWSEC signature selection: versions=0xf fuse_version=2 sig_bytes=384 pci 0000:01:00.0: failure unlock_610.c:364 falcon_hs error=-22 last_mmio=0x8241e0 \ value=0x3 valid=1 mapped=1 master=1 firmware_started=1 quiesced=0 pages=20606/20606 pci 0000:01:00.0: firmware did not stop; keeping its DMA buffers until power off pci 0000:01:00.0: gpu_unlock: unlock failed (-22) nvidia 0000:01:00.0: probe with driver nvidia failed with error -1 ``` Note `0x2544` is already in `supported_ids`, so this is not a device-ID gap. ## Root cause `falcon_dma_valid()` requires every DMA size to be a multiple of 256, because the falcon DMA engine moves 256-byte units (`falcon_dma()` advances `done += 256`): ```c return size && !((size | dest | mem_off | src) & 255) && ... ``` `descriptor()` rounds `image_size` up to 256: ```c fw.image_size = (stored + 255) & ~255u; ``` but passes `dmem_size` through verbatim: ```c fw.dmem_size = r32(rom + off + 32); ``` This board's FWSEC descriptor reports `dmem_size = 0x980` (2432 = 9x256 + 128), which is **not** 256-aligned, so `falcon_hs()` rejects its own arguments at `unlock_610.c:364` and returns `-EINVAL` *before* `falcon_reset()`. The firmware therefore never runs at all, but `work->firmware_started` has already been set by the caller and bus mastering is on, so the module conservatively keeps the DMA buffers and the card stays claimed. GA102 boards report `dmem_size = 0x800` (already aligned) — which is exactly what `tests/test_vbios_610.c:108` asserts: ```c assert(fw.engine_mask == 0x400 && fw.imem_size == 0xda00 && fw.dmem_size == 0x800); ``` so this path is never exercised on the cards the unlock was developed against. ## Fix Round `dmem_size` up to 256 the same way `image_size` already is, with the same overflow guard. The rounded size stays in bounds on this board, exactly: ``` data_off + round_up(dmem_size) = 0xe300 + 0xa00 = 0xed00 = image_size ``` `range(image_size, data_off, dmem_size)` allows equality (`bytes > length - off`), and `memcpy(image, rom + fw.image_off, fw.image_size)` has already copied the full rounded image, so the extra `0x80` bytes the DMA covers are real ROM content already inside the allocated buffer — not an out-of-bounds read. The three other `dmem_size` bounds checks in `descriptor()` only become more permissive: | check | value after rounding | result | | --- | --- | --- | | `range(image_size, data_off, dmem_size)` | `0xe300 + 0xa00 = 0xed00 <= 0xed00` | ok (exact) | | `range(dmem_size, pkc_off, 384)` | `0x724 + 0x180 = 0x8a4 <= 0xa00` | ok | | `range(dmem_size, interface_off, 4)` | `0x20 <= 0xa00` | ok | ## Verification `make test` passes, including the C component tests. The GA102 assertion above is unaffected because `0x800` is already aligned. With the patch the unlock completes on this card: ``` gpu_unlock: FWSEC geometry: image_off=0x41af4 size=0xed00 imem=0xe300 va=0x0 pa=0x0 \ dmem=0xa00 pa=0x0 pkc=0x724 interface=0x1c engine=0x400 ucode=9 signatures=4 \ versions=0xf bytes=1536 pci 0000:01:00.0: Falcon DMA: base=0x110000 dest=0x0 offset=0x0 src=0xf8e4e300 size=0xa00 cmd=0x600 pci 0000:01:00.0: FWSEC result: scratch=0x0 expected_hi16=0 pci 0000:01:00.0: FWSEC WPR2: low=0x2ffee00 high=0x2fffc00 expected_page=0x2ffee0 end=0x2fffe0000 pci 0000:01:00.0: selector write: SS0=0x88888888 pci 0000:01:00.0: selector write: SS1=0x8 pci 0000:01:00.0: pre-FLR selectors: ss0=0x88888888 expected=0x88888888 ss1=0x8 expected=0x8 pci 0000:01:00.0: PCIe FLR returned: result=0 pci 0000:01:00.0: post-FLR SEC2 reset released, GSP halted, BME=0 pending=0 \ WPR2=1ffffe00:00000000 SS0=88888888 SS1=00000008 pci 0000:01:00.0: gpu_unlock: unlocked ``` `nvidia` then binds normally (0 probe failures), and the card is fully usable. **Scope of what I verified:** the unlock path completes, both speed selectors hold their unlocked values across the FLR, and the card works normally afterwards. I have **not** benchmarked FP16/BF16/TF32 throughput on this box (no PyTorch installed), so I am not claiming a TFLOPS figure here — only that the `-EINVAL` abort is fixed and the selectors are written as intended. ## Test system | | | | --- | --- | | GPU | ASUS RTX 3060 12GB, `10de:2544` rev a1, subsystem `1043:8a8f` | | VBIOS | `94.06.54.00.2F` | | Chip (reported) | `0xb76000a1` | | OS | Ubuntu 25.04, kernel 6.14.0-37-generic | | Driver | NVIDIA 580.95.05 | | Base | `af28cbb` | Happy to gather more data or test revisions on this card if useful. Other GA106 boards reporting a non-aligned `dmem_size` should be fixed by the same change, but `0x2544` is the only one I can test. --- <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#135
No description provided.