[PR #113] Load gpu_unlock from init-top on initramfs-tools, before udev coldplug #116

Open
opened 2026-10-31 06:56:32 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/JustAResearcher/gpu-unlock-ada/pull/113
Author: @steppergg
Created: 10/29/2026
Status: 🔄 Open

Base: main ← Head: initramfs-tools-init-top


📝 Commits (1)

  • f19bcb5 Load gpu_unlock from init-top on initramfs-tools, before udev coldplug

📊 Changes

4 files changed (+78 additions, -1 deletions)

View changed files

📝 Makefile (+2 -0)
📝 README.md (+5 -1)
➕ packaging/boot/initramfs-tools-init-top (+30 -0)
📝 tests/test_packaging.py (+41 -0)

📄 Description

Fixes #112.

Problem

On initramfs-tools hosts where nvidia.ko is in the image (Ubuntu's framebuffer-nvidia hook copies it), every boot logs gpu_unlock: unlock failed (-16). /init runs run_scripts /scripts/init-top (line 222 in current initramfs-tools) before load_modules (line 227), and init-top/udev coldplugs the GPU. nvidia autoloads by its PCI alias and binds the card before the modules.d list is read. mkinitcpio and dracut load their lists before coldplug, so they aren't affected.

Change

The Debian package also installs /usr/share/initramfs-tools/scripts/init-top/00-gpu-unlock, which runs modprobe gpu_unlock. The modules.d list already loads the module on every boot; this only loads it earlier. Targets set on the command line or in modprobe.d behave as before, and without targets it does nothing. A failed modprobe is logged to kmsg and never stops the boot.

Ordering: mkinitramfs calls cache_run_scripts from hook-functions, which writes the init-top ORDER file from get_prereq_pairs | tsort. That code is the same in Debian upstream and in Ubuntu 24.04's 0.142ubuntu25.8 (hook-functions lines 954–982). Both GNU tsort and uutils tsort (the default tsort on Ubuntu 25.10+) emit scripts without prerequisites in name order, so 00-gpu-unlock (no prereqs) runs ahead of udev. The modules.d drop-in stays, since it is what puts the module and its firmware in the image.

No softdep, in line with the README: the order still comes from the initramfs.

Testing

  • New tests in tests/test_packaging.py:
    • installed path and mode (mkinitramfs skips scripts that aren't executable);
    • sh -n passes and prereqs prints nothing;
    • tsort order against a typical Ubuntu init-top puts 00-gpu-unlock first;
    • the script loads gpu_unlock and exits 0 even when modprobe fails.
  • I also ran the real set_initlist and get_prereq_pairs from current initramfs-tools (b6795cf) against an installed tree with udev, plymouth (PREREQ=udev) and keymap. The order came out 00-gpu-unlock keymap udev plymouth.
  • Boot-tested by @Hotcooler on the #112 box (AD103 10de:2705, Ubuntu 24.04.5, initramfs-tools 0.142ubuntu25.8, kernel 7.2.13, driver 615.78.08), with their modprobe.d softdep workaround removed first and a full cold boot (comment): lsinitramfs lists scripts/init-top/00-gpu-unlock, ORDER puts it first and before udev, dmesg shows gpu_unlock: unlocked before nvidia loads, unlock failed count 0, read_sm_rates.py reads fmla32: 0, and mma_bench shows FP32-accumulate at full rate.

🤖 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/JustAResearcher/gpu-unlock-ada/pull/113 **Author:** [@steppergg](https://github.com/steppergg) **Created:** 10/29/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `initramfs-tools-init-top` --- ### 📝 Commits (1) - [`f19bcb5`](https://github.com/JustAResearcher/gpu-unlock-ada/commit/f19bcb5ac8981913d05264943406ffe8f99ce081) Load gpu_unlock from init-top on initramfs-tools, before udev coldplug ### 📊 Changes **4 files changed** (+78 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `Makefile` (+2 -0) 📝 `README.md` (+5 -1) ➕ `packaging/boot/initramfs-tools-init-top` (+30 -0) 📝 `tests/test_packaging.py` (+41 -0) </details> ### 📄 Description Fixes #112. ## Problem On initramfs-tools hosts where `nvidia.ko` is in the image (Ubuntu's `framebuffer-nvidia` hook copies it), every boot logs `gpu_unlock: unlock failed (-16)`. `/init` runs `run_scripts /scripts/init-top` (line 222 in current initramfs-tools) before `load_modules` (line 227), and `init-top/udev` coldplugs the GPU. nvidia autoloads by its PCI alias and binds the card before the `modules.d` list is read. mkinitcpio and dracut load their lists before coldplug, so they aren't affected. ## Change The Debian package also installs `/usr/share/initramfs-tools/scripts/init-top/00-gpu-unlock`, which runs `modprobe gpu_unlock`. The `modules.d` list already loads the module on every boot; this only loads it earlier. Targets set on the command line or in `modprobe.d` behave as before, and without targets it does nothing. A failed modprobe is logged to kmsg and never stops the boot. Ordering: `mkinitramfs` calls `cache_run_scripts` from `hook-functions`, which writes the init-top `ORDER` file from `get_prereq_pairs | tsort`. That code is the same in Debian upstream and in Ubuntu 24.04's `0.142ubuntu25.8` (`hook-functions` lines 954–982). Both GNU tsort and uutils tsort (the default `tsort` on Ubuntu 25.10+) emit scripts without prerequisites in name order, so `00-gpu-unlock` (no prereqs) runs ahead of `udev`. The `modules.d` drop-in stays, since it is what puts the module and its firmware in the image. No softdep, in line with the README: the order still comes from the initramfs. ## Testing - New tests in `tests/test_packaging.py`: - installed path and mode (mkinitramfs skips scripts that aren't executable); - `sh -n` passes and `prereqs` prints nothing; - tsort order against a typical Ubuntu init-top puts `00-gpu-unlock` first; - the script loads `gpu_unlock` and exits 0 even when modprobe fails. - I also ran the real `set_initlist` and `get_prereq_pairs` from current initramfs-tools (`b6795cf`) against an installed tree with `udev`, `plymouth` (PREREQ=udev) and `keymap`. The order came out `00-gpu-unlock keymap udev plymouth`. - **Boot-tested by @Hotcooler** on the #112 box (AD103 `10de:2705`, Ubuntu 24.04.5, initramfs-tools 0.142ubuntu25.8, kernel 7.2.13, driver 615.78.08), with their `modprobe.d` softdep workaround removed first and a full cold boot ([comment](https://github.com/JustAResearcher/gpu-unlock-ada/pull/113#issuecomment-6510931592)): `lsinitramfs` lists `scripts/init-top/00-gpu-unlock`, `ORDER` puts it first and before `udev`, dmesg shows `gpu_unlock: unlocked` before nvidia loads, `unlock failed` count 0, `read_sm_rates.py` reads `fmla32: 0`, and `mma_bench` shows FP32-accumulate at full rate. 🤖 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>
Sign in to join this conversation.
No labels
pull-request
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
JustAResearcher/gpu-unlock-ada#116
No description provided.