Your GeForce runs AI at half speed. This fixes it for 20/30/40 series cards. Up to 2× FP16 / BF16 / TF32 tensor throughput
C
Various fixes
Zagitta6081407b312a
diff --git a/.github/ci/module.sh b/.github/ci/module.shindex c8a245f..cbb43e3 100755--- a/.github/ci/module.sh+++ b/.github/ci/module.sh@@ -1,7 +1,7 @@#!/bin/sh# SPDX-License-Identifier: GPL-2.0-only-# Build the module against the distribution kernel headers of this-# container, with warnings as errors. Run from the repository root.+# Build the module against every set of distribution kernel headers this+# container offers, with warnings as errors. Run from the repository root.set -eu. /etc/os-releasecase "$ID" in@@ -10,20 +10,31 @@ debian)apt-get install -qy --no-install-recommends make gcc linux-headers-amd64 ;;ubuntu)apt-get update -q- apt-get install -qy --no-install-recommends make gcc linux-headers-generic ;;+ apt-get install -qy --no-install-recommends make gcc linux-headers-generic+ # The hardware enablement kernel, where the release has one.+ apt-get install -qy --no-install-recommends "linux-headers-generic-hwe-$VERSION_ID" || :+ # Its headers do not pull in the gcc it was built with.+ apt-get install -qy --no-install-recommends $(grep -h '^CONFIG_CC_VERSION_TEXT=' \+ /usr/src/linux-headers-*/.config | grep -o 'gcc-[0-9]*' | sort -u) ;;fedora)dnf install -qy make gcc kernel-devel ;;arch)- pacman -Syu --noconfirm --needed make gcc linux-headers ;;+ pacman -Syu --noconfirm --needed make gcc linux-headers linux-lts-headers ;;*)echo "unknown distribution: $ID" >&2exit 1 ;;esac+# The same headers can show up under more than one of these paths.+built=for kdir in /usr/src/linux-headers-*-amd64 /usr/src/linux-headers-*-generic \/usr/src/kernels/* /usr/lib/modules/*/build; do- [ -f "$kdir/Makefile" ] && break+ [ -f "$kdir/Makefile" ] || continue+ kdir=$(realpath "$kdir")+ case " $built " in *" $kdir "*) continue ;; esac+ echo "Building against $kdir"+ make -C kernel/gpu_unlock KDIR="$kdir" clean+ make -C kernel/gpu_unlock KDIR="$kdir" KCFLAGS=-Werror+ test -f kernel/gpu_unlock/gpu_unlock.ko+ built="$built $kdir"done-[ -f "$kdir/Makefile" ] || { echo "no kernel headers found" >&2; exit 1; }-echo "Building against $kdir"-make -C kernel/gpu_unlock KDIR="$kdir" KCFLAGS=-Werror-test -f kernel/gpu_unlock/gpu_unlock.ko+[ -n "$built" ] || { echo "no kernel headers found" >&2; exit 1; }diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 4ad8c72..6c2f644 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -13,8 +13,8 @@ concurrency:group: ${{ github.workflow }}-${{ github.ref }}cancel-in-progress: true-# The pinned NVIDIA/CachyOS inputs (about 340 MB) are fetched once per-# manifest change into .inputs and shared by every job through the cache.+# The pinned NVIDIA inputs are fetched once per change of the list in+# fetch_artifacts.py into .inputs and shared by every job through the cache.jobs:inputs:runs-on: ubuntu-24.04@@ -24,28 +24,12 @@ jobs:uses: actions/cache@v4with:path: .inputs- key: inputs-${{ hashFiles('firmware/artifacts-*.json') }}+ key: inputs-${{ hashFiles('firmware/fetch_artifacts.py') }}- if: steps.cache.outputs.cache-hit != 'true'run: make inputs INPUTS=.inputs- name: Verify the inputsrun: python3 firmware/fetch_artifacts.py --offline .inputs- # With the generated firmware the tests also run the whole unlock against- # mocked hardware, not only the components.- test:- needs: inputs- runs-on: ubuntu-24.04- steps:- - uses: actions/checkout@v5- - run: sudo apt-get update -q && sudo apt-get install -qy zstd- - uses: actions/cache/restore@v4- with:- path: .inputs- key: inputs-${{ hashFiles('firmware/artifacts-*.json') }}- fail-on-cache-miss: true- - run: make firmware INPUTS=.inputs ASSETS="$RUNNER_TEMP/assets"- - run: make test ASSETS="$RUNNER_TEMP/assets"-module:name: module (${{ matrix.image }})runs-on: ubuntu-24.04@@ -54,15 +38,21 @@ jobs:fail-fast: falsematrix:include:- - image: debian:12 # 6.1+ - image: debian:12 # 6.1setup: apt-get update -q && apt-get install -qy --no-install-recommends ca-certificates git- - image: ubuntu:24.04 # 6.8+ - image: debian:13 # 6.12setup: apt-get update -q && apt-get install -qy --no-install-recommends ca-certificates git- - image: debian:13 # 6.12+ - image: ubuntu:22.04 # 5.15, 6.8 HWEsetup: apt-get update -q && apt-get install -qy --no-install-recommends ca-certificates git- - image: fedora:latest+ - image: ubuntu:24.04 # 6.8, 7.0 HWE+ setup: apt-get update -q && apt-get install -qy --no-install-recommends ca-certificates git+ - image: ubuntu:26.04 # 7.0+ setup: apt-get update -q && apt-get install -qy --no-install-recommends ca-certificates git+ - image: fedora:43 # 7.2setup: dnf install -qy git- - image: archlinux:latest+ - image: fedora:latest # 7.2+ setup: dnf install -qy git+ - image: archlinux:latest # 7.2, 6.18 LTSsetup: pacman -Syu --noconfirm --needed gitsteps:# Without git the checkout is a GitHub archive, which leaves out@@ -80,8 +70,18 @@ jobs:fail-fast: falsematrix:include:+ - image: debian:12+ setup: apt-get update -q && apt-get install -qy --no-install-recommends ca-certificates git make xz-utils zstd- image: debian:13setup: apt-get update -q && apt-get install -qy --no-install-recommends ca-certificates git make xz-utils zstd+ - image: ubuntu:22.04+ setup: apt-get update -q && apt-get install -qy --no-install-recommends ca-certificates git make xz-utils zstd+ - image: ubuntu:24.04+ setup: apt-get update -q && apt-get install -qy --no-install-recommends ca-certificates git make xz-utils zstd+ - image: ubuntu:26.04+ setup: apt-get update -q && apt-get install -qy --no-install-recommends ca-certificates git make xz-utils zstd+ - image: fedora:43+ setup: dnf install -qy git make xz zstd rpm-build dnf-plugins-core- image: fedora:latestsetup: dnf install -qy git make xz zstd rpm-build dnf-plugins-core- image: archlinux:latest@@ -94,6 +94,7 @@ jobs:- uses: actions/cache/restore@v4with:path: .inputs- key: inputs-${{ hashFiles('firmware/artifacts-*.json') }}+ key: inputs-${{ hashFiles('firmware/fetch_artifacts.py') }}fail-on-cache-miss: true- run: INPUTS=.inputs sh .github/ci/package.sh+ - run: sh tests/packaging/install.shdiff --git a/Makefile b/Makefileindex a37ef9c..7cc7219 100644--- a/Makefile+++ b/Makefile@@ -29,7 +29,8 @@ DEBS := $(foreach p,dkms firmware,$(DEBDIR)/gpu-unlock-$(p)_$(VERSION)_all.de.PHONY: all dist inputs firmware assets install-dkms install-firmware \install-mkinitcpio install-initramfs-tools install-dracut \- install-licenses arch deb rpm install install-arch install-deb install-rpm+ install-licenses arch deb rpm install install-arch install-deb install-rpm \+ test-module test-packagesall:@@ -70,7 +71,7 @@ install-firmware:install -Dm644 $(ASSETS)/NVIDIA-LICENSE $(DESTDIR)$(LICENSEDIR)/gpu-unlock-firmware/NVIDIA-LICENSEinstall -Dm644 firmware/NOTICE.md $(DESTDIR)$(LICENSEDIR)/gpu-unlock-firmware/NOTICE.md-# One file per initramfs generator: include gpu_unlock and its firmware in+# Per initramfs generator: include gpu_unlock and its firmware in# the image so it runs before an nvidia module loaded from the initramfs.install-mkinitcpio:install -Dm644 packaging/boot/mkinitcpio.conf $(DESTDIR)/etc/mkinitcpio.conf.d/zz-gpu-unlock.conf@@ -78,6 +79,8 @@ install-mkinitcpio:install-initramfs-tools:install -Dm644 packaging/boot/initramfs-tools.conf \$(DESTDIR)/usr/share/initramfs-tools/modules.d/gpu-unlock.conf+ install -Dm755 packaging/boot/initramfs-tools-init-top \+ $(DESTDIR)/usr/share/initramfs-tools/scripts/init-top/gpu-unlockinstall-dracut:install -Dm644 packaging/boot/dracut.conf $(DESTDIR)/usr/lib/dracut/dracut.conf.d/gpu-unlock.conf@@ -137,4 +140,12 @@ install-rpm:sudo dnf install -y rpm-buildsudo dnf builddep -y packaging/rpm/gpu-unlock.spec$(MAKE) rpm- sudo dnf install -y $(RPMDIR)/RPMS/noarch/gpu-unlock-*-$(VERSION)-*.noarch.rpm\ No newline at end of file+ sudo dnf install -y $(RPMDIR)/RPMS/noarch/gpu-unlock-*-$(VERSION)-*.noarch.rpm++# Build the module, or build, install and remove the packages, in a+# container of each distribution.+test-module:+ tests/docker.sh module++test-packages:+ INPUTS=$(INPUTS) tests/docker.sh packagediff --git a/debian/gpu-unlock-dkms.install b/debian/gpu-unlock-dkms.installindex a11e6c7..1bdde78 100644--- a/debian/gpu-unlock-dkms.install+++ b/debian/gpu-unlock-dkms.install@@ -1,3 +1,4 @@usr/srcusr/share/initramfs-tools+usr/lib/dracutusr/share/doc/gpu-unlockdiff --git a/debian/rules b/debian/rulesindex 299630a..918e350 100755--- a/debian/rules+++ b/debian/rules@@ -17,4 +17,4 @@ override_dh_auto_build:override_dh_auto_install:$(MAKE) DESTDIR=$(CURDIR)/debian/tmp ASSETS="$(ASSETS)" \- install-dkms install-firmware install-initramfs-tools+ install-dkms install-firmware install-initramfs-tools install-dracutdiff --git a/kernel/gpu_unlock/unlock_610.c b/kernel/gpu_unlock/unlock_610.cindex fe91abc..153c463 100644--- a/kernel/gpu_unlock/unlock_610.c+++ b/kernel/gpu_unlock/unlock_610.c@@ -5,7 +5,12 @@* FLR so the stock driver starts from a clean, halted GSP. After resume from* suspend it runs again on the card nvidia has suspended, before nvidia resumes it.*/+#include <linux/version.h>+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 0, 0)#include <linux/aperture.h>+#else+#include <linux/fb.h>+#endif#include <linux/delay.h>#include <linux/dma-mapping.h>#include <linux/firmware.h>@@ -1390,7 +1395,12 @@ static int unlock_transaction_reset(struct unlock_transaction_work *work)* does nothing on a card without one. After resume nvidia-drm already has.*/if (!work->resume) {+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 0, 0)ret = aperture_remove_conflicting_pci_devices(work->pdev, "gpu_unlock");+#else+ /* Before 6.0 the fbdev helper does the same. */+ ret = remove_conflicting_pci_framebuffers(work->pdev, "gpu_unlock");+#endifif (ret)return GU_RESULT(ret);}diff --git a/packaging/arch/PKGBUILD b/packaging/arch/PKGBUILDindex 0378b84..9da90b3 100644--- a/packaging/arch/PKGBUILD+++ b/packaging/arch/PKGBUILD@@ -50,7 +50,7 @@ package_gpu-unlock-dkms() {replaces=('gpu-unlock-mkinitcpio')install=gpu-unlock.installcd $pkgbase- make DESTDIR="$pkgdir" install-dkms install-mkinitcpio+ make DESTDIR="$pkgdir" install-dkms install-mkinitcpio install-dracutmake DESTDIR="$pkgdir" PKG=$pkgname install-licenses}diff --git a/packaging/boot/initramfs-tools-init-top b/packaging/boot/initramfs-tools-init-topnew file mode 100755index 0000000..1efc5e6--- /dev/null+++ b/packaging/boot/initramfs-tools-init-top@@ -0,0 +1,10 @@+#!/bin/sh+# Load gpu_unlock before init-top/udev starts the coldplug, which would+# load nvidia for the card first; modules.d only loads it after that. It+# does nothing unless gpu_unlock.targets= is on the kernel command line.+PREREQ=""+prereqs() { echo "$PREREQ"; }+case $1 in+prereqs) prereqs; exit 0 ;;+esac+modprobe -q gpu_unlock || truediff --git a/packaging/boot/mkinitcpio.conf b/packaging/boot/mkinitcpio.confindex a7027d8..1fcf6f9 100644--- a/packaging/boot/mkinitcpio.conf+++ b/packaging/boot/mkinitcpio.conf@@ -4,13 +4,18 @@# before any nvidia loaded from the root filesystem. Named to be read after# every other drop-in. It does nothing unless gpu_unlock.targets= is on the# kernel command line.-[[ ${MODULES@a} == *a* ]] || read -ra MODULES <<<"$MODULES"-_gu_modules=()-for _gu_module in "${MODULES[@]}"; do- [[ ${_gu_module%\?} == gpu_unlock ]] && continue- [[ ${_gu_module%\?} == nvidia ]] && _gu_modules+=(gpu_unlock?)- _gu_modules+=("$_gu_module")-done-[[ " ${_gu_modules[*]} " == *' gpu_unlock? '* ]] || _gu_modules+=(gpu_unlock?)-MODULES=("${_gu_modules[@]}")-unset _gu_modules _gu_module+# The name is plain, not gpu_unlock?: the systemd hook copies MODULES as is+# into modules-load.d, which does not know the ?. A kernel without a build+# of the module gets nothing, so its image still builds.+if modinfo -k "$KERNELVERSION" gpu_unlock &>/dev/null; then+ [[ ${MODULES@a} == *a* ]] || read -ra MODULES <<<"$MODULES"+ _gu_modules=()+ for _gu_module in "${MODULES[@]}"; do+ [[ ${_gu_module%\?} == gpu_unlock ]] && continue+ [[ ${_gu_module%\?} == nvidia ]] && _gu_modules+=(gpu_unlock)+ _gu_modules+=("$_gu_module")+ done+ [[ " ${_gu_modules[*]} " == *' gpu_unlock '* ]] || _gu_modules+=(gpu_unlock)+ MODULES=("${_gu_modules[@]}")+ unset _gu_modules _gu_module+fidiff --git a/tests/docker.sh b/tests/docker.shnew file mode 100755index 0000000..688bf98--- /dev/null+++ b/tests/docker.sh@@ -0,0 +1,56 @@+#!/bin/sh+# SPDX-License-Identifier: GPL-2.0-only+# Run a CI job of the working tree in a fresh container of each+# distribution: "module" builds the module against the distribution+# kernels, "package" builds, installs and removes the native packages.+# Run from the repository root; the arguments after the job pick the+# images, all of them by default.+set -eu+job=${1:?usage: tests/docker.sh module|package [image...]}+shift+INPUTS=${INPUTS:-$HOME/.cache/gpu-unlock/inputs}+mounts=+if [ "$job" = package ]; then+ make inputs INPUTS="$INPUTS"+ mounts="-v $(realpath "$INPUTS"):/inputs:ro"+fi+commit=$(packaging/snapshot.sh)+[ $# -gt 0 ] || set -- debian:12 debian:13 ubuntu:22.04 ubuntu:24.04 \+ ubuntu:26.04 fedora:43 fedora:latest archlinux:latest++# The same setup as the CI jobs. The job runs on a clone so that nothing+# in the checkout ends up owned by root.+script='+. /etc/os-release+case "$ID" in+debian|ubuntu)+ apt-get update -q+ apt-get install -qy --no-install-recommends ca-certificates git make xz-utils zstd ;;+fedora)+ dnf install -qy git make xz zstd rpm-build dnf-plugins-core ;;+arch)+ pacman -Syu --noconfirm --needed base-devel git zstd ;;+esac+git config --global --add safe.directory "*"+git clone -q --shared /src /work+cd /work+git checkout -q "$1"+case "$2" in+module)+ sh .github/ci/module.sh ;;+package)+ cp -r /inputs /tmp/inputs+ INPUTS=/tmp/inputs sh .github/ci/package.sh+ sh tests/packaging/install.sh ;;+esac+'++failed=+for image; do+ echo "==> $image"+ # shellcheck disable=SC2086+ docker run --rm -v "$PWD:/src:ro" $mounts "$image" \+ sh -euc "$script" sh "$commit" "$job" || failed="$failed $image"+done+[ -z "$failed" ] || { echo "failed:$failed" >&2; exit 1; }+echo "$job passed on all images"diff --git a/tests/integration/shim/linux/version.h b/tests/integration/shim/linux/version.hnew file mode 100644index 0000000..59cacba--- /dev/null+++ b/tests/integration/shim/linux/version.h@@ -0,0 +1,3 @@+/* SPDX-License-Identifier: GPL-2.0-only */+#define KERNEL_VERSION(a, b, c) (((a) << 16) + ((b) << 8) + (c))+#define LINUX_VERSION_CODE KERNEL_VERSION(6, 0, 0)diff --git a/tests/packaging/install.sh b/tests/packaging/install.shnew file mode 100755index 0000000..e540b42--- /dev/null+++ b/tests/packaging/install.sh@@ -0,0 +1,42 @@+#!/bin/sh+# SPDX-License-Identifier: GPL-2.0-only+# Install the packages .github/ci/package.sh built, check what they put on+# disk, then remove them again. Run as root from the repository root.+set -eu+version=$(cat VERSION)+src=/usr/src/gpu-unlock-$version+fw=/usr/lib/firmware/gpu-unlock/610.43.03+dracut=/usr/lib/dracut/dracut.conf.d/gpu-unlock.conf+. /etc/os-release+case "$ID" in+debian|ubuntu)+ install="apt-get install -qy --no-install-recommends ./build/deb/*.deb"+ remove="apt-get purge -qy"+ boot=/usr/share/initramfs-tools/scripts/init-top/gpu-unlock ;;+fedora)+ install="dnf install -qy build/rpm/RPMS/noarch/*.rpm"+ remove="dnf remove -qy"+ boot=$dracut ;;+arch)+ install="pacman -U --noconfirm packaging/arch/*.pkg.tar.zst"+ remove="pacman -Rns --noconfirm"+ boot=/etc/mkinitcpio.conf.d/zz-gpu-unlock.conf ;;+*)+ echo "unknown distribution: $ID" >&2+ exit 1 ;;+esac++$install+test -f "$src/dkms.conf"+test -f "$src/main.c"+test -f "$fw/gsp_ga10x.bin"+test -f "$fw/booter_load_ga102.bin"+test -f "$dracut"+test -f "$boot"++$remove gpu-unlock-dkms gpu-unlock-firmware+test ! -e "$src"+test ! -e "$fw"+test ! -e "$dracut"+test ! -e "$boot"+echo "packages install and remove cleanly"