diff --git a/srcpkgs/nvidia470/patches/disable-objtool-override.patch b/srcpkgs/nvidia470/patches/disable-objtool-override.patch new file mode 100644 index 00000000000000..6068b4a2c7fda7 --- /dev/null +++ b/srcpkgs/nvidia470/patches/disable-objtool-override.patch @@ -0,0 +1,41 @@ +From 77af76b80b3dea6df69af616d45e4c6a1d26bf4c Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Joan=20Bruguera=20Mic=C3=B3?= +Date: Mon, 16 Feb 2026 01:07:18 +0000 +Subject: [PATCH] Disable final processing of .o files with binary blobs + +Due to the fact that the driver is unmaintained, and can't be adapted +to the current Linux kernel security standards (e.g. IBT), as it has a +proprietary blob; as this is likely to be an ever-growing security risk: +Use at your own risk; no warranty of any kind is provided. +--- + Kbuild | 14 ++++++++++++++ + 1 file changed, 14 insertions(+) + +diff --git a/kernel/Kbuild b/kernel/Kbuild +index f333e0b..9381ab1 100644 +--- a/kernel/Kbuild ++++ b/kernel/Kbuild +@@ -55,6 +55,20 @@ ifeq ($(NV_UNDEF_BEHAVIOR_SANITIZER),1) + UBSAN_SANITIZE := y + endif + ++# This is an *ugly* hack to disable objtool during the final processing of the ++# objects that embed the proprietary blobs. Objtool can't process them, as they ++# do not follow the requirements of current kernels, including support for ++# critical security features. In Ubuntu 26.04+, this causes a build error. ++# Disable it at your own risk. Note that the MIT license applies: ++# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ++# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ++# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ++# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ++# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ++# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE ++# SOFTWARE. ++nvidia.o nvidia-modeset.o: override objtool-enabled = ++ + $(foreach _module, $(NV_KERNEL_MODULES), \ + $(eval include $(src)/$(_module)/$(_module).Kbuild)) + +-- +2.53.0 + diff --git a/srcpkgs/nvidia470/patches/enable-drm-modeset-by-default.patch b/srcpkgs/nvidia470/patches/enable-drm-modeset-by-default.patch new file mode 100644 index 00000000000000..9f64e13809fd51 --- /dev/null +++ b/srcpkgs/nvidia470/patches/enable-drm-modeset-by-default.patch @@ -0,0 +1,27 @@ +From aa59e5d9b1ed0f8d4012d2773573c15008286a4d Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Joan=20Bruguera=20Mic=C3=B3?= +Date: Sun, 31 Aug 2025 14:09:49 +0000 +Subject: [PATCH] Enable nvidia-drm.modeset=1 by default + +--- + nvidia-drm/nvidia-drm-linux.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/kernel/nvidia-drm/nvidia-drm-linux.c b/kernel/nvidia-drm/nvidia-drm-linux.c +index 2319640..55de3e3 100644 +--- a/kernel/nvidia-drm/nvidia-drm-linux.c ++++ b/kernel/nvidia-drm/nvidia-drm-linux.c +@@ -41,8 +41,8 @@ + + MODULE_PARM_DESC( + modeset, +- "Enable atomic kernel modesetting (1 = enable, 0 = disable (default))"); +-bool nv_drm_modeset_module_param = false; ++ "Enable atomic kernel modesetting (1 = enable (default), 0 = disable)"); ++bool nv_drm_modeset_module_param = true; + module_param_named(modeset, nv_drm_modeset_module_param, bool, 0400); + + void *nv_drm_calloc(size_t nmemb, size_t size) +-- +2.51.0 + diff --git a/srcpkgs/nvidia470/patches/nvidia-470xx-fix-gcc-15.patch b/srcpkgs/nvidia470/patches/nvidia-470xx-fix-gcc-15.patch new file mode 100644 index 00000000000000..1509c6d7f17e30 --- /dev/null +++ b/srcpkgs/nvidia470/patches/nvidia-470xx-fix-gcc-15.patch @@ -0,0 +1,32 @@ +From 3d51f7abf1c591dfd47d0070e2b6942ef91301af Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Joan=20Bruguera=20Mic=C3=B3?= +Date: Sun, 1 Jun 2025 22:14:13 +0000 +Subject: [PATCH] Fix for NVIDIA 470.256.02 driver for GCC 15 + +conftest.sh invokes GCC on its own, without going through the usual +kernel Makefile that would add the proper CFLAGS (e.g. -std=gnu11). + +This means that it builds with the default of GCC, which in GCC 15 +has changed to -std=gnu23 which and has backwards incompatible changes +that the kernel does not support. Force it to -std=gnu17 instead. +--- + conftest.sh | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/kernel/conftest.sh b/kernel/conftest.sh +index 70c91e5..dc40d3a 100755 +--- a/kernel/conftest.sh ++++ b/kernel/conftest.sh +@@ -205,6 +205,9 @@ build_cflags() { + CFLAGS="$CFLAGS -mfentry -DCC_USING_FENTRY" + fi + fi ++ ++ # Specify the C standard, instead of defaulting to the compiler's ++ CFLAGS="$CFLAGS -std=gnu17" + } + + CONFTEST_PREAMBLE="#include \"conftest/headers.h\" +-- +2.49.0 + diff --git a/srcpkgs/nvidia470/patches/nvidia-470xx-fix-linux-6.13.patch b/srcpkgs/nvidia470/patches/nvidia-470xx-fix-linux-6.13.patch new file mode 100644 index 00000000000000..8a16d8aadec15e --- /dev/null +++ b/srcpkgs/nvidia470/patches/nvidia-470xx-fix-linux-6.13.patch @@ -0,0 +1,58 @@ +From 9f91b171f680648647580c163bbc9cc1641e3920 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Joan=20Bruguera=20Mic=C3=B3?= +Date: Sat, 16 Nov 2024 22:45:21 +0000 +Subject: [PATCH] Tentative fix for NVIDIA 470.256.02 driver for Linux 6.13-rc1 + +--- + nvidia-modeset/nvidia-modeset.Kbuild | 8 +++++--- + nvidia/nvidia.Kbuild | 8 +++++--- + 2 files changed, 10 insertions(+), 6 deletions(-) + +diff --git a/kernel/nvidia-modeset/nvidia-modeset.Kbuild b/kernel/nvidia-modeset/nvidia-modeset.Kbuild +index a7d84e0..d417c28 100644 +--- a/kernel/nvidia-modeset/nvidia-modeset.Kbuild ++++ b/kernel/nvidia-modeset/nvidia-modeset.Kbuild +@@ -40,13 +40,15 @@ NV_KERNEL_MODULE_TARGETS += $(NVIDIA_MODESET_KO) + NVIDIA_MODESET_BINARY_OBJECT := $(src)/nvidia-modeset/nv-modeset-kernel.o_binary + NVIDIA_MODESET_BINARY_OBJECT_O := nvidia-modeset/nv-modeset-kernel.o + +-quiet_cmd_symlink = SYMLINK $@ +-cmd_symlink = ln -sf $< $@ ++# Rel. commit 80f289101690 "kbuild: change working directory to external module directory with M=" (Masahiro Yamada, 10 Nov 2024) ++# Ensure `$<` is absolute, since the link target is resolved relative to its path, not from where `ln` is run from. ++quiet_cmd_symlinkabs = SYMLINK $@ ++ cmd_symlinkabs = ln -sf $(abspath $<) $@ + + targets += $(NVIDIA_MODESET_BINARY_OBJECT_O) + + $(obj)/$(NVIDIA_MODESET_BINARY_OBJECT_O): $(NVIDIA_MODESET_BINARY_OBJECT) FORCE +- $(call if_changed,symlink) ++ $(call if_changed,symlinkabs) + + nvidia-modeset-y += $(NVIDIA_MODESET_BINARY_OBJECT_O) + +diff --git a/kernel/nvidia/nvidia.Kbuild b/kernel/nvidia/nvidia.Kbuild +index 31a6f92..62689f6 100644 +--- a/kernel/nvidia/nvidia.Kbuild ++++ b/kernel/nvidia/nvidia.Kbuild +@@ -40,13 +40,15 @@ NVIDIA_KO = nvidia/nvidia.ko + NVIDIA_BINARY_OBJECT := $(src)/nvidia/nv-kernel.o_binary + NVIDIA_BINARY_OBJECT_O := nvidia/nv-kernel.o + +-quiet_cmd_symlink = SYMLINK $@ +- cmd_symlink = ln -sf $< $@ ++# Rel. commit 80f289101690 "kbuild: change working directory to external module directory with M=" (Masahiro Yamada, 10 Nov 2024) ++# Ensure `$<` is absolute, since the link target is resolved relative to its path, not from where `ln` is run from. ++quiet_cmd_symlinkabs = SYMLINK $@ ++ cmd_symlinkabs = ln -sf $(abspath $<) $@ + + targets += $(NVIDIA_BINARY_OBJECT_O) + + $(obj)/$(NVIDIA_BINARY_OBJECT_O): $(NVIDIA_BINARY_OBJECT) FORCE +- $(call if_changed,symlink) ++ $(call if_changed,symlinkabs) + + nvidia-y += $(NVIDIA_BINARY_OBJECT_O) + +-- +2.47.0 diff --git a/srcpkgs/nvidia470/patches/nvidia-470xx-fix-linux-6.14.patch b/srcpkgs/nvidia470/patches/nvidia-470xx-fix-linux-6.14.patch new file mode 100644 index 00000000000000..ed74d13a403802 --- /dev/null +++ b/srcpkgs/nvidia470/patches/nvidia-470xx-fix-linux-6.14.patch @@ -0,0 +1,26 @@ +From bee3ff1153f7b42491d2a0552d6f9a66a307ec1a Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Joan=20Bruguera=20Mic=C3=B3?= +Date: Sun, 15 Dec 2024 17:56:03 +0000 +Subject: [PATCH] Tentative fix for NVIDIA 470.256.02 driver for Linux 6.14-rc1 + +--- + nvidia-drm/nvidia-drm-drv.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/kernel/nvidia-drm/nvidia-drm-drv.c b/kernel/nvidia-drm/nvidia-drm-drv.c +index 0b1181d..b50b17a 100644 +--- a/kernel/nvidia-drm/nvidia-drm-drv.c ++++ b/kernel/nvidia-drm/nvidia-drm-drv.c +@@ -882,7 +882,10 @@ static struct drm_driver nv_drm_driver = { + .name = "nvidia-drm", + + .desc = "NVIDIA DRM driver", ++#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 14, 0) ++ // Rel. commit. "drm: remove driver date from struct drm_driver and all drivers" (Jani Nikula, 4 Dec 2024) + .date = "20160202", ++#endif + + #if defined(NV_DRM_DRIVER_HAS_DEVICE_LIST) + .device_list = LIST_HEAD_INIT(nv_drm_driver.device_list), +-- +2.48.1 diff --git a/srcpkgs/nvidia470/patches/nvidia-470xx-fix-linux-6.15.patch b/srcpkgs/nvidia470/patches/nvidia-470xx-fix-linux-6.15.patch new file mode 100644 index 00000000000000..3a2ffca6e7c4a5 --- /dev/null +++ b/srcpkgs/nvidia470/patches/nvidia-470xx-fix-linux-6.15.patch @@ -0,0 +1,354 @@ +From c9a877ea48935bb40597cc2e7d88b0035a27e6f2 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Joan=20Bruguera=20Mic=C3=B3?= +Date: Sat, 12 Apr 2025 22:46:59 +0000 +Subject: [PATCH] Tentative fix for NVIDIA 470.256.02 driver for Linux 6.15-rc1 + +The trickier part of this patch is that vm_flags_set and vm_flags_clear +depend on a GPL-only symbol (__vma_start_write) since Linux >=6.15. + +In some situations (mainly nvidia_mmap_helper), we can replace it by +vm_flags_reset as the VMA gets locked by other previous calls. +In some other code paths that I have not been able to trigger, I don't +believe the VMA is locked, so it returns -ENOTSUPP instead for now. + +Replacing EXTRA_CFLAGS with ccflags-y is rel. commit "kbuild: remove +EXTRA_*FLAGS support" (Masahiro Yamada, 6 Feb 2025), according to which +they have been deprecated since 2007, so no need to add any fallback. + +Thanks to Willy Frissen and Satadru Pramanik, who shared patches for +various of the necessary changes. +--- + Kbuild | 25 +++++++++---------------- + common/inc/nv-mm.h | 18 ++++++++++++++++++ + common/inc/nv-timer.h | 1 + + nvidia-drm/nvidia-drm-connector.c | 8 ++++++++ + nvidia-drm/nvidia-drm-gem-user-memory.c | 9 +++++++++ + nvidia-drm/nvidia-drm-gem.c | 5 +++++ + nvidia-drm/nvidia-drm-linux.c | 1 + + nvidia-modeset/nvidia-modeset-linux.c | 5 +++-- + nvidia-uvm/uvm.c | 10 ++++++++++ + nvidia/nv-frontend.c | 1 + + nvidia/nv-mmap.c | 6 ++++++ + nvidia/nv.c | 4 ++-- + 12 files changed, 73 insertions(+), 20 deletions(-) + +diff --git a/kernel/Kbuild b/kernel/Kbuild +index eadd8b2..f333e0b 100644 +--- a/kernel/Kbuild ++++ b/kernel/Kbuild +@@ -59,27 +59,20 @@ $(foreach _module, $(NV_KERNEL_MODULES), \ + $(eval include $(src)/$(_module)/$(_module).Kbuild)) + + +-# +-# Define CFLAGS that apply to all the NVIDIA kernel modules. EXTRA_CFLAGS +-# is deprecated since 2.6.24 in favor of ccflags-y, but we need to support +-# older kernels which do not have ccflags-y. Newer kernels append +-# $(EXTRA_CFLAGS) to ccflags-y for compatibility. +-# +- +-EXTRA_CFLAGS += -I$(src)/common/inc +-EXTRA_CFLAGS += -I$(src) +-EXTRA_CFLAGS += -Wall -MD $(DEFINES) $(INCLUDES) -Wno-cast-qual -Wno-error -Wno-format-extra-args +-EXTRA_CFLAGS += -D__KERNEL__ -DMODULE -DNVRM -DNV_VERSION_STRING=\"470.256.02\" -Wno-unused-function -Wuninitialized -fno-strict-aliasing -mno-red-zone -mcmodel=kernel -DNV_UVM_ENABLE +-EXTRA_CFLAGS += $(call cc-option,-Werror=undef,) +-EXTRA_CFLAGS += -DNV_SPECTRE_V2=$(NV_SPECTRE_V2) +-EXTRA_CFLAGS += -DNV_KERNEL_INTERFACE_LAYER ++ccflags-y += -I$(src)/common/inc ++ccflags-y += -I$(src) ++ccflags-y += -Wall -MD $(DEFINES) $(INCLUDES) -Wno-cast-qual -Wno-error -Wno-format-extra-args ++ccflags-y += -D__KERNEL__ -DMODULE -DNVRM -DNV_VERSION_STRING=\"470.256.02\" -Wno-unused-function -Wuninitialized -fno-strict-aliasing -mno-red-zone -mcmodel=kernel -DNV_UVM_ENABLE ++ccflags-y += $(call cc-option,-Werror=undef,) ++ccflags-y += -DNV_SPECTRE_V2=$(NV_SPECTRE_V2) ++ccflags-y += -DNV_KERNEL_INTERFACE_LAYER + + # + # Detect SGI UV systems and apply system-specific optimizations. + # + + ifneq ($(wildcard /proc/sgi_uv),) +- EXTRA_CFLAGS += -DNV_CONFIG_X86_UV ++ ccflags-y += -DNV_CONFIG_X86_UV + endif + + +@@ -107,7 +100,7 @@ NV_CONFTEST_CMD := /bin/sh $(NV_CONFTEST_SCRIPT) \ + + NV_CFLAGS_FROM_CONFTEST := $(shell $(NV_CONFTEST_CMD) build_cflags) + +-NV_CONFTEST_CFLAGS = $(NV_CFLAGS_FROM_CONFTEST) $(EXTRA_CFLAGS) -fno-pie ++NV_CONFTEST_CFLAGS = $(NV_CFLAGS_FROM_CONFTEST) $(ccflags-y) -fno-pie + + NV_CONFTEST_COMPILE_TEST_HEADERS := $(obj)/conftest/macros.h + NV_CONFTEST_COMPILE_TEST_HEADERS += $(obj)/conftest/functions.h +diff --git a/kernel/common/inc/nv-mm.h b/kernel/common/inc/nv-mm.h +index da5065d..094cd8a 100644 +--- a/kernel/common/inc/nv-mm.h ++++ b/kernel/common/inc/nv-mm.h +@@ -31,6 +31,7 @@ typedef int vm_fault_t; + + #include + #include ++#include + /* get_user_pages + * + * The 8-argument version of get_user_pages was deprecated by commit +@@ -248,12 +249,29 @@ static inline struct rw_semaphore *nv_mmap_get_lock(struct mm_struct *mm) + #if defined(NV_VM_AREA_STRUCT_HAS_CONST_VM_FLAGS) + static inline void nv_vm_flags_set(struct vm_area_struct *vma, vm_flags_t flags) + { ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 15, 0) ++ // Rel. commit "mm: uninline the main body of vma_start_write()" (Suren Baghdasaryan, 13 Feb 2025) ++ // Since Linux 6.15, vm_flags_set and vm_flags_clear call a GPL-only symbol ++ // for locking (__vma_start_write), which can't be called from non-GPL code. ++ // However, it appears all uses on the driver are on VMAs being initially ++ // mapped and which are already locked by previous calls over that VMA, ++ // so we can use vm_flags_reset, which doesn't lock the VMA, but rather just ++ // asserts it is already write-locked. ++ vm_flags_reset(vma, vma->vm_flags | flags); ++#else + vm_flags_set(vma, flags); ++#endif + } + + static inline void nv_vm_flags_clear(struct vm_area_struct *vma, vm_flags_t flags) + { ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 15, 0) ++ // Rel. commit "mm: uninline the main body of vma_start_write()" (Suren Baghdasaryan, 13 Feb 2025) ++ // See above ++ vm_flags_reset(vma, vma->vm_flags & ~flags); ++#else + vm_flags_clear(vma, flags); ++#endif + } + #else + static inline void nv_vm_flags_set(struct vm_area_struct *vma, unsigned long flags) +diff --git a/kernel/common/inc/nv-timer.h b/kernel/common/inc/nv-timer.h +index 18df6ea..396e121 100644 +--- a/kernel/common/inc/nv-timer.h ++++ b/kernel/common/inc/nv-timer.h +@@ -25,6 +25,7 @@ + + #include + #include // For container_of ++#include + + #include "conftest.h" + +diff --git a/kernel/nvidia-drm/nvidia-drm-connector.c b/kernel/nvidia-drm/nvidia-drm-connector.c +index fe838ef..c35c9ec 100644 +--- a/kernel/nvidia-drm/nvidia-drm-connector.c ++++ b/kernel/nvidia-drm/nvidia-drm-connector.c +@@ -44,6 +44,8 @@ + #include + #include + ++#include ++ + static void nv_drm_connector_destroy(struct drm_connector *connector) + { + struct nv_drm_connector *nv_connector = to_nv_connector(connector); +@@ -302,8 +304,14 @@ static int nv_drm_connector_get_modes(struct drm_connector *connector) + return count; + } + ++// Rel. commit. "drm/connector: make mode_valid take a const struct drm_display_mode" (Dmitry Baryshkov, 14 Dec 2024) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 15, 0) ++static int nv_drm_connector_mode_valid(struct drm_connector *connector, ++ const struct drm_display_mode *mode) ++#else + static int nv_drm_connector_mode_valid(struct drm_connector *connector, + struct drm_display_mode *mode) ++#endif + { + struct drm_device *dev = connector->dev; + struct nv_drm_device *nv_dev = to_nv_device(dev); +diff --git a/kernel/nvidia-drm/nvidia-drm-gem-user-memory.c b/kernel/nvidia-drm/nvidia-drm-gem-user-memory.c +index 6de9dd9..e56efb0 100644 +--- a/kernel/nvidia-drm/nvidia-drm-gem-user-memory.c ++++ b/kernel/nvidia-drm/nvidia-drm-gem-user-memory.c +@@ -36,6 +36,8 @@ + #include "linux/mm.h" + #include "nv-mm.h" + ++#include ++ + static inline + void __nv_drm_gem_user_memory_free(struct nv_drm_gem_object *nv_gem) + { +@@ -92,6 +94,13 @@ static int __nv_drm_gem_user_memory_mmap(struct nv_drm_gem_object *nv_gem, + return -EINVAL; + } + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 15, 0) ++ // Rel. commit "mm: uninline the main body of vma_start_write()" (Suren Baghdasaryan, 13 Feb 2025) ++ printk(KERN_WARNING "[NVIDIA] Unable to call vm_flags_(set|clear) on " ++ "%s on Linux >=6.15, for more information see %s.\n", __func__, ++ "https://gist.github.com/joanbm/def2bf57ed7a799c1d84a67606459314"); ++ return -ENOTSUPP; ++#endif + nv_vm_flags_clear(vma, VM_PFNMAP); + nv_vm_flags_clear(vma, VM_IO); + nv_vm_flags_set(vma, VM_MIXEDMAP); +diff --git a/kernel/nvidia-drm/nvidia-drm-gem.c b/kernel/nvidia-drm/nvidia-drm-gem.c +index f7b4b3f..22ec4bf 100644 +--- a/kernel/nvidia-drm/nvidia-drm-gem.c ++++ b/kernel/nvidia-drm/nvidia-drm-gem.c +@@ -49,6 +49,8 @@ + + #include "nv-mm.h" + ++#include ++ + void nv_drm_gem_free(struct drm_gem_object *gem) + { + struct nv_drm_gem_object *nv_gem = to_nv_gem_object(gem); +@@ -297,6 +299,9 @@ int nv_drm_mmap(struct file *file, struct vm_area_struct *vma) + ret = -EINVAL; + goto done; + } ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 15, 0) ++ #error "Not expecting to compile the vm_flags_clear call in nv_drm_mmap" ++#endif + nv_vm_flags_clear(vma, VM_MAYWRITE); + } + #endif +diff --git a/kernel/nvidia-drm/nvidia-drm-linux.c b/kernel/nvidia-drm/nvidia-drm-linux.c +index 94e463e..2319640 100644 +--- a/kernel/nvidia-drm/nvidia-drm-linux.c ++++ b/kernel/nvidia-drm/nvidia-drm-linux.c +@@ -182,6 +182,7 @@ static void __exit nv_linux_drm_exit(void) + module_init(nv_linux_drm_init); + module_exit(nv_linux_drm_exit); + ++MODULE_DESCRIPTION("NVIDIA GPU DRM kernel module"); + #if defined(MODULE_LICENSE) + + +diff --git a/kernel/nvidia-modeset/nvidia-modeset-linux.c b/kernel/nvidia-modeset/nvidia-modeset-linux.c +index de0c748..f6810d2 100644 +--- a/kernel/nvidia-modeset/nvidia-modeset-linux.c ++++ b/kernel/nvidia-modeset/nvidia-modeset-linux.c +@@ -718,7 +718,7 @@ static void nvkms_kthread_q_callback(void *arg) + * pending timers and than waiting for workqueue callbacks. + */ + if (timer->kernel_timer_created) { +- del_timer_sync(&timer->kernel_timer); ++ timer_delete_sync(&timer->kernel_timer); + } + + /* +@@ -1740,7 +1740,7 @@ restart: + * completion, and we wait for queue completion with + * nv_kthread_q_stop below. + */ +- if (del_timer_sync(&timer->kernel_timer) == 1) { ++ if (timer_delete_sync(&timer->kernel_timer) == 1) { + /* We've deactivated timer so we need to clean after it */ + list_del(&timer->timers_list); + +@@ -1778,6 +1778,7 @@ restart: + module_init(nvkms_init); + module_exit(nvkms_exit); + ++MODULE_DESCRIPTION("NVIDIA GPU modeset kernel module"); + #if defined(MODULE_LICENSE) + + +diff --git a/kernel/nvidia-uvm/uvm.c b/kernel/nvidia-uvm/uvm.c +index 73ceb70..321a411 100644 +--- a/kernel/nvidia-uvm/uvm.c ++++ b/kernel/nvidia-uvm/uvm.c +@@ -36,6 +36,8 @@ + #include "uvm_hmm.h" + #include "uvm_mem.h" + ++#include ++ + #define NVIDIA_UVM_DEVICE_NAME "nvidia-uvm" + + static dev_t g_uvm_base_dev; +@@ -812,6 +814,13 @@ static int uvm_mmap(struct file *filp, struct vm_area_struct *vma) + // Using VM_DONTCOPY would be nice, but madvise(MADV_DOFORK) can reset that + // so we have to handle vm_open on fork anyway. We could disable MADV_DOFORK + // with VM_IO, but that causes other mapping issues. ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 15, 0) ++ // Rel. commit "mm: uninline the main body of vma_start_write()" (Suren Baghdasaryan, 13 Feb 2025) ++ printk(KERN_WARNING "[NVIDIA] Unable to call vm_flags_(set|clear) on " ++ "%s on Linux >=6.15, for more information see %s.\n", __func__, ++ "https://gist.github.com/joanbm/def2bf57ed7a799c1d84a67606459314"); ++ return -ENOTSUPP; ++#endif + nv_vm_flags_set(vma, VM_MIXEDMAP | VM_DONTEXPAND); + + vma->vm_ops = &uvm_vm_ops_managed; +@@ -1129,6 +1138,7 @@ static void __exit uvm_exit_entry(void) + module_init(uvm_init_entry); + module_exit(uvm_exit_entry); + ++MODULE_DESCRIPTION("NVIDIA GPU UVM kernel module"); + MODULE_LICENSE("Dual MIT/GPL"); + MODULE_INFO(supported, "external"); + +diff --git a/kernel/nvidia/nv-frontend.c b/kernel/nvidia/nv-frontend.c +index 4d6d8af..ad82d6b 100644 +--- a/kernel/nvidia/nv-frontend.c ++++ b/kernel/nvidia/nv-frontend.c +@@ -13,6 +13,7 @@ + #include "nv-reg.h" + #include "nv-frontend.h" + ++MODULE_DESCRIPTION("NVIDIA GPU frontend kernel module"); + #if defined(MODULE_LICENSE) + + +diff --git a/kernel/nvidia/nv-mmap.c b/kernel/nvidia/nv-mmap.c +index 9e1eb5d..81bd7a6 100644 +--- a/kernel/nvidia/nv-mmap.c ++++ b/kernel/nvidia/nv-mmap.c +@@ -15,6 +15,8 @@ + #include "nv-ibmnpu.h" + #include "nv_speculation_barrier.h" + ++#include ++ + /* + * The 'struct vm_operations' open() callback is called by the Linux + * kernel when the parent VMA is split or copied, close() when the +@@ -448,7 +450,11 @@ static int nvidia_mmap_numa( + } + + // Needed for the linux kernel for mapping compound pages ++#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 15, 0) ++ // Rel. commit "mm: uninline the main body of vma_start_write()" (Suren Baghdasaryan, 13 Feb 2025) ++ // This call isn't necessary because vm_insert_page already sets VM_MIXEDMAP + nv_vm_flags_set(vma, VM_MIXEDMAP); ++#endif + + for (i = 0, addr = mmap_context->page_array[0]; i < pages; + addr = mmap_context->page_array[++i], start += PAGE_SIZE) +diff --git a/kernel/nvidia/nv.c b/kernel/nvidia/nv.c +index 9d7da39..57b5024 100644 +--- a/kernel/nvidia/nv.c ++++ b/kernel/nvidia/nv.c +@@ -3838,7 +3838,7 @@ int NV_API_CALL nv_stop_rc_timer( + + nv_printf(NV_DBG_INFO, "NVRM: stopping rc timer\n"); + nv->rc_timer_enabled = 0; +- del_timer_sync(&nvl->rc_timer.kernel_timer); ++ timer_delete_sync(&nvl->rc_timer.kernel_timer); + nv_printf(NV_DBG_INFO, "NVRM: rc timer stopped\n"); + + return 0; +@@ -3882,7 +3882,7 @@ void NV_API_CALL nv_stop_snapshot_timer(void) + NV_SPIN_UNLOCK_IRQRESTORE(&nvl->snapshot_timer_lock, flags); + + if (timer_active) +- del_timer_sync(&nvl->snapshot_timer.kernel_timer); ++ timer_delete_sync(&nvl->snapshot_timer.kernel_timer); + } + + void NV_API_CALL nv_flush_snapshot_timer(void) +-- +2.49.0 + diff --git a/srcpkgs/nvidia470/patches/nvidia-470xx-fix-linux-6.17.patch b/srcpkgs/nvidia470/patches/nvidia-470xx-fix-linux-6.17.patch new file mode 100644 index 00000000000000..65b6b0bf5e9452 --- /dev/null +++ b/srcpkgs/nvidia470/patches/nvidia-470xx-fix-linux-6.17.patch @@ -0,0 +1,98 @@ +From fd52e276f587394b9ae3ba7013b6a44cbdd526f2 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Joan=20Bruguera=20Mic=C3=B3?= +Date: Sat, 26 Jul 2025 21:19:03 +0000 +Subject: [PATCH] Tentative fix for NVIDIA 470.256.02 driver for Linux 6.17-rc1 + +--- + nvidia-drm/nvidia-drm-drv.c | 8 ++++++++ + nvidia-drm/nvidia-drm-fb.c | 9 +++++++++ + nvidia-drm/nvidia-drm-fb.h | 6 ++++++ + 3 files changed, 23 insertions(+) + +diff --git a/kernel/nvidia-drm/nvidia-drm-drv.c b/kernel/nvidia-drm/nvidia-drm-drv.c +index b50b17a..9da3294 100644 +--- a/kernel/nvidia-drm/nvidia-drm-drv.c ++++ b/kernel/nvidia-drm/nvidia-drm-drv.c +@@ -140,6 +140,10 @@ static void nv_drm_output_poll_changed(struct drm_device *dev) + static struct drm_framebuffer *nv_drm_framebuffer_create( + struct drm_device *dev, + struct drm_file *file, ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 17, 0) ++ // Rel. commit. "drm: Pass the format info to .fb_create()" (Ville Syrjälä, 1 Jul 2025) ++ const struct drm_format_info *info, ++#endif + #if defined(NV_DRM_HELPER_MODE_FILL_FB_STRUCT_HAS_CONST_MODE_CMD_ARG) + const struct drm_mode_fb_cmd2 *cmd + #else +@@ -155,6 +159,10 @@ static struct drm_framebuffer *nv_drm_framebuffer_create( + fb = nv_drm_internal_framebuffer_create( + dev, + file, ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 17, 0) ++ // Rel. commit. "drm: Allow the caller to pass in the format info to drm_helper_mode_fill_fb_struct()" (Ville Syrjälä, 1 Jul 2025) ++ info, ++#endif + &local_cmd); + + #if !defined(NV_DRM_HELPER_MODE_FILL_FB_STRUCT_HAS_CONST_MODE_CMD_ARG) +diff --git a/kernel/nvidia-drm/nvidia-drm-fb.c b/kernel/nvidia-drm/nvidia-drm-fb.c +index d119e7c..b84e026 100644 +--- a/kernel/nvidia-drm/nvidia-drm-fb.c ++++ b/kernel/nvidia-drm/nvidia-drm-fb.c +@@ -33,6 +33,7 @@ + #include "nvidia-drm-format.h" + + #include ++#include + + static void __nv_drm_framebuffer_free(struct nv_drm_framebuffer *nv_fb) + { +@@ -184,6 +185,10 @@ static int nv_drm_framebuffer_init(struct drm_device *dev, + struct drm_framebuffer *nv_drm_internal_framebuffer_create( + struct drm_device *dev, + struct drm_file *file, ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 17, 0) ++ // Rel. commit. "drm: Allow the caller to pass in the format info to drm_helper_mode_fill_fb_struct()" (Ville Syrjälä, 1 Jul 2025) ++ const struct drm_format_info *info, ++#endif + struct drm_mode_fb_cmd2 *cmd) + { + struct nv_drm_device *nv_dev = to_nv_device(dev); +@@ -237,6 +242,10 @@ struct drm_framebuffer *nv_drm_internal_framebuffer_create( + dev, + #endif + &nv_fb->base, ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 17, 0) ++ // Rel. commit. "drm: Allow the caller to pass in the format info to drm_helper_mode_fill_fb_struct()" (Ville Syrjälä, 1 Jul 2025) ++ info, ++#endif + cmd); + + /* +diff --git a/kernel/nvidia-drm/nvidia-drm-fb.h b/kernel/nvidia-drm/nvidia-drm-fb.h +index cf477cc..b61b309 100644 +--- a/kernel/nvidia-drm/nvidia-drm-fb.h ++++ b/kernel/nvidia-drm/nvidia-drm-fb.h +@@ -35,6 +35,8 @@ + #include + #endif + ++#include ++ + #include "nvidia-drm-gem-nvkms-memory.h" + #include "nvkms-kapi.h" + +@@ -59,6 +61,10 @@ static inline struct nv_drm_framebuffer *to_nv_framebuffer( + struct drm_framebuffer *nv_drm_internal_framebuffer_create( + struct drm_device *dev, + struct drm_file *file, ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 17, 0) ++ // Rel. commit. "drm: Allow the caller to pass in the format info to drm_helper_mode_fill_fb_struct()" (Ville Syrjälä, 1 Jul 2025) ++ const struct drm_format_info *info, ++#endif + struct drm_mode_fb_cmd2 *cmd); + + #endif /* NV_DRM_ATOMIC_MODESET_AVAILABLE */ +-- +2.50.1 + diff --git a/srcpkgs/nvidia470/patches/nvidia-470xx-fix-linux-6.19-part1.patch b/srcpkgs/nvidia470/patches/nvidia-470xx-fix-linux-6.19-part1.patch new file mode 100644 index 00000000000000..3ad97519e94694 --- /dev/null +++ b/srcpkgs/nvidia470/patches/nvidia-470xx-fix-linux-6.19-part1.patch @@ -0,0 +1,487 @@ +From 509447266ca6cca596cbd6a6bf01175a6189ccb8 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Joan=20Bruguera=20Mic=C3=B3?= +Date: Sun, 26 Oct 2025 11:24:50 +0000 +Subject: [PATCH 1/2] Tentative fix for NVIDIA 470.256.02 driver for Linux + 6.19-rc1 (part 1: DRM state pointer cleanup) + +In commit 'drm/atomic: Change state pointers to a more meaningful name' +(Maxime Ripard, 8 Oct 2025), 'state' is renamed to 'state_to_destroy'. + +Don't work around it, rather clean up usages of the deprecated macros. +--- + nvidia-drm/nvidia-drm-crtc.c | 6 +- + nvidia-drm/nvidia-drm-drv.c | 4 +- + nvidia-drm/nvidia-drm-helper.c | 137 -------------------------------- + nvidia-drm/nvidia-drm-helper.h | 121 ---------------------------- + nvidia-drm/nvidia-drm-modeset.c | 42 ++++------ + 5 files changed, 22 insertions(+), 288 deletions(-) + +diff --git a/kernel/nvidia-drm/nvidia-drm-crtc.c b/kernel/nvidia-drm/nvidia-drm-crtc.c +index 20a3158..69db1cb 100644 +--- a/kernel/nvidia-drm/nvidia-drm-crtc.c ++++ b/kernel/nvidia-drm/nvidia-drm-crtc.c +@@ -310,7 +310,7 @@ static int nv_drm_plane_atomic_check(struct drm_plane *plane, + goto done; + } + +- nv_drm_for_each_crtc_in_state(plane_state->state, crtc, crtc_state, i) { ++ for_each_new_crtc_in_state(plane_state->state, crtc, crtc_state, i) { + struct nv_drm_crtc_state *nv_crtc_state = to_nv_crtc_state(crtc_state); + struct NvKmsKapiHeadRequestedConfig *head_req_config = + &nv_crtc_state->req_config; +@@ -634,8 +634,8 @@ static int nv_drm_crtc_atomic_check(struct drm_crtc *crtc, + + req_config->flags.displaysChanged = NV_TRUE; + +- nv_drm_for_each_connector_in_state(crtc_state->state, +- connector, connector_state, j) { ++ for_each_new_connector_in_state(crtc_state->state, ++ connector, connector_state, j) { + if (connector_state->crtc != crtc) { + continue; + } +diff --git a/kernel/nvidia-drm/nvidia-drm-drv.c b/kernel/nvidia-drm/nvidia-drm-drv.c +index 9da3294..1b6e2be 100644 +--- a/kernel/nvidia-drm/nvidia-drm-drv.c ++++ b/kernel/nvidia-drm/nvidia-drm-drv.c +@@ -616,13 +616,13 @@ void nv_drm_master_drop(struct drm_device *dev, struct drm_file *file_priv) + + drm_modeset_lock_all(dev); + +- if ((err = nv_drm_atomic_helper_disable_all( ++ if ((err = drm_atomic_helper_disable_all( + dev, + dev->mode_config.acquire_ctx)) != 0) { + + NV_DRM_DEV_LOG_ERR( + nv_dev, +- "nv_drm_atomic_helper_disable_all failed with error code %d !", ++ "drm_atomic_helper_disable_all failed with error code %d !", + err); + } + +diff --git a/kernel/nvidia-drm/nvidia-drm-helper.c b/kernel/nvidia-drm/nvidia-drm-helper.c +index 8fc8620..f91f522 100644 +--- a/kernel/nvidia-drm/nvidia-drm-helper.c ++++ b/kernel/nvidia-drm/nvidia-drm-helper.c +@@ -64,141 +64,4 @@ static void __nv_drm_framebuffer_put(struct drm_framebuffer *fb) + + } + +-/* +- * drm_atomic_helper_disable_all() has been added by commit +- * 1494276000db789c6d2acd85747be4707051c801, which is Signed-off-by: +- * Thierry Reding +- * Daniel Vetter +- * +- * drm_atomic_helper_disable_all() is copied from +- * linux/drivers/gpu/drm/drm_atomic_helper.c and modified to use +- * nv_drm_for_each_crtc instead of drm_for_each_crtc to loop over all crtcs, +- * use nv_drm_for_each_*_in_state instead of for_each_connector_in_state to loop +- * over all modeset object states, and use drm_atomic_state_free() if +- * drm_atomic_state_put() is not available. +- * +- * drm_atomic_helper_disable_all() is copied from +- * linux/drivers/gpu/drm/drm_atomic_helper.c @ +- * 49d70aeaeca8f62b72b7712ecd1e29619a445866, which has the following +- * copyright and license information: +- * +- * Copyright (C) 2014 Red Hat +- * Copyright (C) 2014 Intel Corp. +- * +- * Permission is hereby granted, free of charge, to any person obtaining a +- * copy of this software and associated documentation files (the "Software"), +- * to deal in the Software without restriction, including without limitation +- * the rights to use, copy, modify, merge, publish, distribute, sublicense, +- * and/or sell copies of the Software, and to permit persons to whom the +- * Software is furnished to do so, subject to the following conditions: +- * +- * The above copyright notice and this permission notice shall be included in +- * all copies or substantial portions of the Software. +- * +- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +- * OTHER DEALINGS IN THE SOFTWARE. +- * +- * Authors: +- * Rob Clark +- * Daniel Vetter +- */ +-int nv_drm_atomic_helper_disable_all(struct drm_device *dev, +- struct drm_modeset_acquire_ctx *ctx) +-{ +- struct drm_atomic_state *state; +- struct drm_connector_state *conn_state; +- struct drm_connector *conn; +- struct drm_plane_state *plane_state; +- struct drm_plane *plane; +- struct drm_crtc_state *crtc_state; +- struct drm_crtc *crtc; +- unsigned plane_mask = 0; +- int ret, i; +- +- state = drm_atomic_state_alloc(dev); +- if (!state) +- return -ENOMEM; +- +- state->acquire_ctx = ctx; +- +- nv_drm_for_each_crtc(crtc, dev) { +- crtc_state = drm_atomic_get_crtc_state(state, crtc); +- if (IS_ERR(crtc_state)) { +- ret = PTR_ERR(crtc_state); +- goto free; +- } +- +- crtc_state->active = false; +- +- ret = drm_atomic_set_mode_prop_for_crtc(crtc_state, NULL); +- if (ret < 0) +- goto free; +- +- ret = drm_atomic_add_affected_planes(state, crtc); +- if (ret < 0) +- goto free; +- +- ret = drm_atomic_add_affected_connectors(state, crtc); +- if (ret < 0) +- goto free; +- } +- +- nv_drm_for_each_connector_in_state(state, conn, conn_state, i) { +- ret = drm_atomic_set_crtc_for_connector(conn_state, NULL); +- if (ret < 0) +- goto free; +- } +- +- nv_drm_for_each_plane_in_state(state, plane, plane_state, i) { +- ret = drm_atomic_set_crtc_for_plane(plane_state, NULL); +- if (ret < 0) +- goto free; +- +- drm_atomic_set_fb_for_plane(plane_state, NULL); +- plane_mask |= NVBIT(drm_plane_index(plane)); +- plane->old_fb = plane->fb; +- } +- +- ret = drm_atomic_commit(state); +-free: +- if (plane_mask) { +- drm_for_each_plane_mask(plane, dev, plane_mask) { +- if (ret == 0) { +- plane->fb = NULL; +- plane->crtc = NULL; +- +- WARN_ON(plane->state->fb); +- WARN_ON(plane->state->crtc); +- +- if (plane->old_fb) +- __nv_drm_framebuffer_put(plane->old_fb); +- } +- plane->old_fb = NULL; +- } +- } +- +-#if defined(NV_DRM_ATOMIC_STATE_REF_COUNTING_PRESENT) +- drm_atomic_state_put(state); +-#else +- if (ret != 0) { +- drm_atomic_state_free(state); +- } else { +- /* +- * In case of success, drm_atomic_commit() takes care to cleanup and +- * free @state. +- * +- * Comment placed above drm_atomic_commit() says: The caller must not +- * free or in any other way access @state. If the function fails then +- * the caller must clean up @state itself. +- */ +- } +-#endif +- return ret; +-} +- + #endif /* NV_DRM_ATOMIC_MODESET_AVAILABLE */ +diff --git a/kernel/nvidia-drm/nvidia-drm-helper.h b/kernel/nvidia-drm/nvidia-drm-helper.h +index 1ce4fba..dc92948 100644 +--- a/kernel/nvidia-drm/nvidia-drm-helper.h ++++ b/kernel/nvidia-drm/nvidia-drm-helper.h +@@ -156,127 +156,6 @@ nv_drm_prime_pages_to_sg(struct drm_device *dev, + #include + #include + +-int nv_drm_atomic_helper_disable_all(struct drm_device *dev, +- struct drm_modeset_acquire_ctx *ctx); +- +-/* +- * for_each_connector_in_state(), for_each_crtc_in_state() and +- * for_each_plane_in_state() were added by kernel commit +- * df63b9994eaf942afcdb946d27a28661d7dfbf2a which was Signed-off-by: +- * Ander Conselvan de Oliveira +- * Daniel Vetter +- * +- * for_each_connector_in_state(), for_each_crtc_in_state() and +- * for_each_plane_in_state() were copied from +- * include/drm/drm_atomic.h @ +- * 21a01abbe32a3cbeb903378a24e504bfd9fe0648 +- * which has the following copyright and license information: +- * +- * Copyright (C) 2014 Red Hat +- * Copyright (C) 2014 Intel Corp. +- * +- * Permission is hereby granted, free of charge, to any person obtaining a +- * copy of this software and associated documentation files (the "Software"), +- * to deal in the Software without restriction, including without limitation +- * the rights to use, copy, modify, merge, publish, distribute, sublicense, +- * and/or sell copies of the Software, and to permit persons to whom the +- * Software is furnished to do so, subject to the following conditions: +- * +- * The above copyright notice and this permission notice shall be included in +- * all copies or substantial portions of the Software. +- * +- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +- * OTHER DEALINGS IN THE SOFTWARE. +- * +- * Authors: +- * Rob Clark +- * Daniel Vetter +- */ +- +-/** +- * nv_drm_for_each_connector_in_state - iterate over all connectors in an +- * atomic update +- * @__state: &struct drm_atomic_state pointer +- * @connector: &struct drm_connector iteration cursor +- * @connector_state: &struct drm_connector_state iteration cursor +- * @__i: int iteration cursor, for macro-internal use +- * +- * This iterates over all connectors in an atomic update. Note that before the +- * software state is committed (by calling drm_atomic_helper_swap_state(), this +- * points to the new state, while afterwards it points to the old state. Due to +- * this tricky confusion this macro is deprecated. +- */ +-#if !defined(for_each_connector_in_state) +-#define nv_drm_for_each_connector_in_state(__state, \ +- connector, connector_state, __i) \ +- for ((__i) = 0; \ +- (__i) < (__state)->num_connector && \ +- ((connector) = (__state)->connectors[__i].ptr, \ +- (connector_state) = (__state)->connectors[__i].state, 1); \ +- (__i)++) \ +- for_each_if (connector) +-#else +-#define nv_drm_for_each_connector_in_state(__state, \ +- connector, connector_state, __i) \ +- for_each_connector_in_state(__state, connector, connector_state, __i) +-#endif +- +- +-/** +- * nv_drm_for_each_crtc_in_state - iterate over all CRTCs in an atomic update +- * @__state: &struct drm_atomic_state pointer +- * @crtc: &struct drm_crtc iteration cursor +- * @crtc_state: &struct drm_crtc_state iteration cursor +- * @__i: int iteration cursor, for macro-internal use +- * +- * This iterates over all CRTCs in an atomic update. Note that before the +- * software state is committed (by calling drm_atomic_helper_swap_state(), this +- * points to the new state, while afterwards it points to the old state. Due to +- * this tricky confusion this macro is deprecated. +- */ +-#if !defined(for_each_crtc_in_state) +-#define nv_drm_for_each_crtc_in_state(__state, crtc, crtc_state, __i) \ +- for ((__i) = 0; \ +- (__i) < (__state)->dev->mode_config.num_crtc && \ +- ((crtc) = (__state)->crtcs[__i].ptr, \ +- (crtc_state) = (__state)->crtcs[__i].state, 1); \ +- (__i)++) \ +- for_each_if (crtc_state) +-#else +-#define nv_drm_for_each_crtc_in_state(__state, crtc, crtc_state, __i) \ +- for_each_crtc_in_state(__state, crtc, crtc_state, __i) +-#endif +- +-/** +- * nv_drm_for_each_plane_in_state - iterate over all planes in an atomic update +- * @__state: &struct drm_atomic_state pointer +- * @plane: &struct drm_plane iteration cursor +- * @plane_state: &struct drm_plane_state iteration cursor +- * @__i: int iteration cursor, for macro-internal use +- * +- * This iterates over all planes in an atomic update. Note that before the +- * software state is committed (by calling drm_atomic_helper_swap_state(), this +- * points to the new state, while afterwards it points to the old state. Due to +- * this tricky confusion this macro is deprecated. +- */ +-#if !defined(for_each_plane_in_state) +-#define nv_drm_for_each_plane_in_state(__state, plane, plane_state, __i) \ +- for ((__i) = 0; \ +- (__i) < (__state)->dev->mode_config.num_total_plane && \ +- ((plane) = (__state)->planes[__i].ptr, \ +- (plane_state) = (__state)->planes[__i].state, 1); \ +- (__i)++) \ +- for_each_if (plane_state) +-#else +-#define nv_drm_for_each_plane_in_state(__state, plane, plane_state, __i) \ +- for_each_plane_in_state(__state, plane, plane_state, __i) +-#endif +- + static inline struct drm_crtc *nv_drm_crtc_find(struct drm_device *dev, + uint32_t id) + { +diff --git a/kernel/nvidia-drm/nvidia-drm-modeset.c b/kernel/nvidia-drm/nvidia-drm-modeset.c +index 123a126..640b341 100644 +--- a/kernel/nvidia-drm/nvidia-drm-modeset.c ++++ b/kernel/nvidia-drm/nvidia-drm-modeset.c +@@ -86,9 +86,9 @@ void nv_drm_atomic_state_free(struct drm_atomic_state *state) + * is swapped into current state. + */ + static bool __will_generate_flip_event(struct drm_crtc *crtc, +- struct drm_crtc_state *old_crtc_state) ++ struct drm_crtc_state *old_crtc_state, ++ struct drm_crtc_state *new_crtc_state) + { +- struct drm_crtc_state *new_crtc_state = crtc->state; + struct nv_drm_crtc_state *nv_new_crtc_state = + to_nv_crtc_state(new_crtc_state); + struct drm_plane_state *old_plane_state = NULL; +@@ -107,7 +107,7 @@ static bool __will_generate_flip_event(struct drm_crtc *crtc, + } + + /* Find out whether primary & overlay flip done events will be generated. */ +- nv_drm_for_each_plane_in_state(old_crtc_state->state, ++ for_each_old_plane_in_state(old_crtc_state->state, + plane, old_plane_state, i) { + if (old_plane_state->crtc != crtc) { + continue; +@@ -166,13 +166,13 @@ static int __nv_drm_get_syncpt_data( + struct nv_drm_device *nv_dev, + struct drm_crtc *crtc, + struct drm_crtc_state *old_crtc_state, ++ struct drm_crtc_state *new_crtc_state, + struct NvKmsKapiRequestedModeSetConfig *requested_config, + struct NvKmsKapiModeSetReplyConfig *reply_config) + { + struct nv_drm_crtc *nv_crtc = to_nv_crtc(crtc); + struct NvKmsKapiHeadReplyConfig *head_reply_config; + struct nv_drm_plane_state *plane_state; +- struct drm_crtc_state *new_crtc_state = crtc->state; + struct drm_plane_state *old_plane_state = NULL; + struct drm_plane_state *new_plane_state = NULL; + struct drm_plane *plane = NULL; +@@ -188,14 +188,12 @@ static int __nv_drm_get_syncpt_data( + + head_reply_config = &reply_config->headReplyConfig[nv_crtc->head]; + +- nv_drm_for_each_plane_in_state(old_crtc_state->state, plane, old_plane_state, i) { ++ for_each_oldnew_plane_in_state(old_crtc_state->state, plane, old_plane_state, new_plane_state, i) { + + if (plane->type == DRM_PLANE_TYPE_CURSOR || old_plane_state->crtc != crtc) { + continue; + } + +- new_plane_state = plane->state; +- + if (new_plane_state->crtc != crtc) { + continue; + } +@@ -262,21 +260,14 @@ nv_drm_atomic_apply_modeset_config(struct drm_device *dev, + &(to_nv_atomic_state(state)->config); + struct NvKmsKapiModeSetReplyConfig reply_config = { }; + struct drm_crtc *crtc; +- struct drm_crtc_state *crtc_state; ++ struct drm_crtc_state *old_crtc_state, *new_crtc_state; + int i; + int ret; + + memset(requested_config, 0, sizeof(*requested_config)); + + /* Loop over affected crtcs and construct NvKmsKapiRequestedModeSetConfig */ +- nv_drm_for_each_crtc_in_state(state, crtc, crtc_state, i) { +- /* +- * When committing a state, the new state is already stored in +- * crtc->state. When checking a proposed state, the proposed state is +- * stored in crtc_state. +- */ +- struct drm_crtc_state *new_crtc_state = +- commit ? crtc->state : crtc_state; ++ for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) { + struct nv_drm_crtc *nv_crtc = to_nv_crtc(crtc); + + requested_config->headRequestedConfig[nv_crtc->head] = +@@ -285,7 +276,6 @@ nv_drm_atomic_apply_modeset_config(struct drm_device *dev, + requested_config->headsMask |= 1 << nv_crtc->head; + + if (commit) { +- struct drm_crtc_state *old_crtc_state = crtc_state; + struct nv_drm_crtc_state *nv_new_crtc_state = + to_nv_crtc_state(new_crtc_state); + +@@ -297,7 +287,7 @@ nv_drm_atomic_apply_modeset_config(struct drm_device *dev, + * If flip event will be generated by hardware + * then defer flip object processing to flip event from hardware. + */ +- if (__will_generate_flip_event(crtc, old_crtc_state)) { ++ if (__will_generate_flip_event(crtc, old_crtc_state, new_crtc_state)) { + nv_drm_crtc_enqueue_flip(nv_crtc, + nv_new_crtc_state->nv_flip); + +@@ -322,10 +312,12 @@ nv_drm_atomic_apply_modeset_config(struct drm_device *dev, + } + + if (commit && nv_dev->supportsSyncpts) { +- nv_drm_for_each_crtc_in_state(state, crtc, crtc_state, i) { ++ for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, ++ new_crtc_state, i) { + /*! loop over affected crtcs and get NvKmsKapiModeSetReplyConfig */ +- ret = __nv_drm_get_syncpt_data( +- nv_dev, crtc, crtc_state, requested_config, &reply_config); ++ ret = __nv_drm_get_syncpt_data(nv_dev, crtc, ++ old_crtc_state, new_crtc_state, ++ requested_config, &reply_config); + if (ret != 0) { + return ret; + } +@@ -410,7 +402,7 @@ int nv_drm_atomic_commit(struct drm_device *dev, + + int i; + struct drm_crtc *crtc = NULL; +- struct drm_crtc_state *crtc_state = NULL; ++ struct drm_crtc_state *new_crtc_state = NULL; + struct nv_drm_device *nv_dev = to_nv_device(dev); + + /* +@@ -420,7 +412,7 @@ int nv_drm_atomic_commit(struct drm_device *dev, + * updates to complete. + */ + if (nonblock) { +- nv_drm_for_each_crtc_in_state(state, crtc, crtc_state, i) { ++ for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) { + struct nv_drm_crtc *nv_crtc = to_nv_crtc(crtc); + + /* +@@ -494,10 +486,10 @@ int nv_drm_atomic_commit(struct drm_device *dev, + goto done; + } + +- nv_drm_for_each_crtc_in_state(state, crtc, crtc_state, i) { ++ for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) { + struct nv_drm_crtc *nv_crtc = to_nv_crtc(crtc); + struct nv_drm_crtc_state *nv_new_crtc_state = +- to_nv_crtc_state(crtc->state); ++ to_nv_crtc_state(new_crtc_state); + + /* + * If nv_drm_atomic_apply_modeset_config() hasn't consumed the flip +-- +2.51.2 + diff --git a/srcpkgs/nvidia470/patches/nvidia-470xx-fix-linux-6.19-part2.patch b/srcpkgs/nvidia470/patches/nvidia-470xx-fix-linux-6.19-part2.patch new file mode 100644 index 00000000000000..06f6d10b7c3041 --- /dev/null +++ b/srcpkgs/nvidia470/patches/nvidia-470xx-fix-linux-6.19-part2.patch @@ -0,0 +1,151 @@ +From 5abaa0e1f22d528d0e1ac9e72ce70e788a7a3b39 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Joan=20Bruguera=20Mic=C3=B3?= +Date: Sun, 7 Dec 2025 20:35:30 +0000 +Subject: [PATCH 2/2] Tentative fix for NVIDIA 470.256.02 driver for Linux + 6.19-rc1 (part 2: rest of fixes) + +--- + common/inc/nv-memdbg.h | 5 +++-- + common/inc/nv-time.h | 10 ++++++++-- + conftest.sh | 11 ++++++++++- + nvidia-drm/nvidia-drm-priv.h | 3 +++ + nvidia/nv-dma.c | 7 +++++++ + nvidia/os-interface.c | 2 +- + 6 files changed, 32 insertions(+), 6 deletions(-) + +diff --git a/kernel/common/inc/nv-memdbg.h b/kernel/common/inc/nv-memdbg.h +index c618ead..8212d44 100644 +--- a/kernel/common/inc/nv-memdbg.h ++++ b/kernel/common/inc/nv-memdbg.h +@@ -28,8 +28,9 @@ void nv_memdbg_exit(void); + + #else + +-#define NV_MEMDBG_ADD(ptr, size) +-#define NV_MEMDBG_REMOVE(ptr, size) ++// NB: Using while(0) to avoid -Wempty-body warnings ++#define NV_MEMDBG_ADD(ptr, size) while(0) ++#define NV_MEMDBG_REMOVE(ptr, size) while(0) + + #endif /* NV_MEM_LOGGER */ + +diff --git a/kernel/common/inc/nv-time.h b/kernel/common/inc/nv-time.h +index 0133383..584633f 100644 +--- a/kernel/common/inc/nv-time.h ++++ b/kernel/common/inc/nv-time.h +@@ -31,6 +31,12 @@ + + #include + ++#include ++#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0) ++// Rel. commit "treewide: Remove in_irq()" (Matthew Wilcox, 24 Oct 2025) ++#define in_hardirq in_irq ++#endif ++ + #define NV_MAX_ISR_DELAY_US 20000 + #define NV_MAX_ISR_DELAY_MS (NV_MAX_ISR_DELAY_US / 1000) + #define NV_NSECS_TO_JIFFIES(nsec) ((nsec) * HZ / 1000000000) +@@ -141,7 +147,7 @@ static inline NV_STATUS nv_sleep_us(unsigned int us) + ktime_get_real_ts64(&tm1); + #endif + +- if (in_irq() && (us > NV_MAX_ISR_DELAY_US)) ++ if (in_hardirq() && (us > NV_MAX_ISR_DELAY_US)) + return NV_ERR_GENERIC; + + mdelay_safe_msec = us / 1000; +@@ -187,7 +193,7 @@ static inline NV_STATUS nv_sleep_ms(unsigned int ms) + tm_start = tm_aux; + #endif + +- if (in_irq() && (ms > NV_MAX_ISR_DELAY_MS)) ++ if (in_hardirq() && (ms > NV_MAX_ISR_DELAY_MS)) + { + return NV_ERR_GENERIC; + } +diff --git a/kernel/conftest.sh b/kernel/conftest.sh +index 263a404..294d6e5 100755 +--- a/kernel/conftest.sh ++++ b/kernel/conftest.sh +@@ -208,6 +208,11 @@ build_cflags() { + + # Specify the C standard, instead of defaulting to the compiler's + CFLAGS="$CFLAGS -std=gnu17" ++ ++ # Rel. commit "Kbuild: enable -fms-extensions" (Rasmus Villemoes, 20 Oct 2025) ++ # Enable the flags since the Linux headers use those extensions in some structs ++ # See https://www.phoronix.com/news/Linux-6.19-Patch-Would-MS-Ext ++ CFLAGS="$CFLAGS -fms-extensions" + } + + CONFTEST_PREAMBLE="#include \"conftest/headers.h\" +@@ -5013,7 +5018,11 @@ compile_test() { + CODE=" + #include + int conftest_vm_area_struct_has_const_vm_flags(void) { +- return offsetof(struct vm_area_struct, __vm_flags); ++ // Rel. commit 'mm: introduce VMA flags bitmap type' (Lorenzo Stoakes, 14 Nov 2025) ++ // Check for the const-ness of vm_flags directly: If vm_flags ++ // is not const, _Generic doesn't match and the build fails) ++ struct vm_area_struct vma; ++ return _Generic(&vma.vm_flags, const typeof(vma.vm_flags) *: 1); + }" + + compile_check_conftest "$CODE" "NV_VM_AREA_STRUCT_HAS_CONST_VM_FLAGS" "" "types" +diff --git a/kernel/nvidia-drm/nvidia-drm-priv.h b/kernel/nvidia-drm/nvidia-drm-priv.h +index dce6a53..ac932f9 100644 +--- a/kernel/nvidia-drm/nvidia-drm-priv.h ++++ b/kernel/nvidia-drm/nvidia-drm-priv.h +@@ -39,6 +39,9 @@ + #include + #endif + ++// Rel. commit "drm/mm: replace drm_print.h include with a forward declaration" (Jani Nikula, 29 Oct 2025) ++#include ++ + #include "nvidia-drm-os-interface.h" + + #include "nvkms-kapi.h" +diff --git a/kernel/nvidia/nv-dma.c b/kernel/nvidia/nv-dma.c +index 9f1ea11..e08d7c8 100644 +--- a/kernel/nvidia/nv-dma.c ++++ b/kernel/nvidia/nv-dma.c +@@ -12,6 +12,7 @@ + + #include "os-interface.h" + #include "nv-linux.h" ++#include + + #define NV_DMA_DEV_PRINTF(debuglevel, dma_dev, format, ... ) \ + nv_printf(debuglevel, "NVRM: %s: " format, \ +@@ -764,7 +765,13 @@ static NvBool nv_dma_is_map_resource_implemented + #endif + } + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 19, 0) ++ // Rel. commit "dma-mapping: remove unused mapping resource callbacks" (Leon Romanovsky, 15 Oct 2025) ++ // https://lore.kernel.org/all/20251015-remove-map-page-v5-0-3bbfe3a25cdf@kernel.org/ ++ return (ops->map_phys != NULL); ++#else + return (ops->map_resource != NULL); ++#endif + #else + return NV_FALSE; + #endif +diff --git a/kernel/nvidia/os-interface.c b/kernel/nvidia/os-interface.c +index e7c1f9d..7379965 100644 +--- a/kernel/nvidia/os-interface.c ++++ b/kernel/nvidia/os-interface.c +@@ -229,7 +229,7 @@ NvBool NV_API_CALL os_semaphore_may_sleep(void) + + NvBool NV_API_CALL os_is_isr(void) + { +- return (in_irq()); ++ return (in_hardirq()); + } + + // return TRUE if the caller is the super-user +-- +2.52.0 + diff --git a/srcpkgs/nvidia470/patches/nvidia-470xx-fix-linux-7.0.patch b/srcpkgs/nvidia470/patches/nvidia-470xx-fix-linux-7.0.patch new file mode 100644 index 00000000000000..d9ad92a0ae66a6 --- /dev/null +++ b/srcpkgs/nvidia470/patches/nvidia-470xx-fix-linux-7.0.patch @@ -0,0 +1,98 @@ +From d1fd3bcac1ef7da7cd9624f87d8d6ab2768880f1 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Joan=20Bruguera=20Mic=C3=B3?= +Date: Sun, 15 Feb 2026 11:31:28 +0000 +Subject: [PATCH] Tentative fix for NVIDIA 470.256.02 driver for Linux 7.0-rc1 + +--- + common/inc/nv-linux.h | 3 +++ + nvidia-drm/nvidia-dma-fence-helper.h | 7 ++++--- + nvidia/nv.c | 23 +++++++++++++++-------- + 3 files changed, 22 insertions(+), 11 deletions(-) + +diff --git a/kernel/common/inc/nv-linux.h b/kernel/common/inc/nv-linux.h +index e095a89..2ab5074 100644 +--- a/kernel/common/inc/nv-linux.h ++++ b/kernel/common/inc/nv-linux.h +@@ -223,6 +223,9 @@ static inline uid_t __kuid_val(uid_t uid) + + #include /* fb_info struct */ + #include /* screen_info */ ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 20, 0) ++#include /* sysfb_primary_display */ ++#endif + + #if !defined(CONFIG_PCI) + #warning "Attempting to build driver for a platform with no PCI support!" +diff --git a/kernel/nvidia-drm/nvidia-dma-fence-helper.h b/kernel/nvidia-drm/nvidia-dma-fence-helper.h +index a09ab76..6221bf2 100644 +--- a/kernel/nvidia-drm/nvidia-dma-fence-helper.h ++++ b/kernel/nvidia-drm/nvidia-dma-fence-helper.h +@@ -89,11 +89,12 @@ nv_dma_fence_default_wait(nv_dma_fence_t *fence, + #endif + } + +-static inline int nv_dma_fence_signal(nv_dma_fence_t *fence) { ++// Rel. commit "dma-buf/dma-fence: Remove return code of signaling-functions" (Philipp Stanner, 1 Dec 2025) ++static inline void nv_dma_fence_signal(nv_dma_fence_t *fence) { + #if defined(NV_LINUX_FENCE_H_PRESENT) +- return fence_signal(fence); ++ fence_signal(fence); + #else +- return dma_fence_signal(fence); ++ dma_fence_signal(fence); + #endif + } + +diff --git a/kernel/nvidia/nv.c b/kernel/nvidia/nv.c +index 57b5024..ef7dde6 100644 +--- a/kernel/nvidia/nv.c ++++ b/kernel/nvidia/nv.c +@@ -5639,8 +5639,15 @@ void NV_API_CALL nv_get_screen_info( + * After commit b8466fe82b79 ("efi: move screen_info into efi init code") + * in v6.7, 'screen_info' is exported as GPL licensed symbol for ARM64. + */ ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 20, 0) ++ // Rel. commit "sysfb: Replace screen_info with sysfb_primary_display" (Thomas Zimmermann, 26 Nov 2025) ++ const struct screen_info *si = &sysfb_primary_display.screen; ++#elif NV_CHECK_EXPORT_SYMBOL(screen_info) ++ const struct screen_info *si = &screen_info; ++#endif + +-#if NV_CHECK_EXPORT_SYMBOL(screen_info) ++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 20, 0)) || \ ++ NV_CHECK_EXPORT_SYMBOL(screen_info) + /* + * If there is not a framebuffer console, return 0 size. + * +@@ -5648,21 +5655,21 @@ void NV_API_CALL nv_get_screen_info( + * initialization, and then will be set to a value, such as + * VIDEO_TYPE_VLFB or VIDEO_TYPE_EFI if an fbdev console is used. + */ +- if (screen_info.orig_video_isVGA > 1) ++ if (si->orig_video_isVGA > 1) + { +- NvU64 physAddr = screen_info.lfb_base; ++ NvU64 physAddr = si->lfb_base; + #if defined(VIDEO_CAPABILITY_64BIT_BASE) +- physAddr |= (NvU64)screen_info.ext_lfb_base << 32; ++ physAddr |= (NvU64)si->ext_lfb_base << 32; + #endif + + /* Make sure base address is mapped to GPU BAR */ + if (NV_IS_CONSOLE_MAPPED(nv, physAddr)) + { + *pPhysicalAddress = physAddr; +- *pFbWidth = screen_info.lfb_width; +- *pFbHeight = screen_info.lfb_height; +- *pFbDepth = screen_info.lfb_depth; +- *pFbPitch = screen_info.lfb_linelength; ++ *pFbWidth = si->lfb_width; ++ *pFbHeight = si->lfb_height; ++ *pFbDepth = si->lfb_depth; ++ *pFbPitch = si->lfb_linelength; + *pFbSize = (NvU64)(*pFbHeight) * (NvU64)(*pFbPitch); + } + } +-- +2.53.0 + diff --git a/srcpkgs/nvidia470/template b/srcpkgs/nvidia470/template index 0b649c5b91dd0c..08790de1de91b8 100644 --- a/srcpkgs/nvidia470/template +++ b/srcpkgs/nvidia470/template @@ -4,7 +4,7 @@ _desc="NVIDIA drivers (GKxxx “Kepler”)" pkgname=nvidia470 version=470.256.02 -revision=2 +revision=3 maintainer="Andrew Benson " license="custom:NVIDIA Proprietary" homepage="https://www.nvidia.com/en-us/drivers/unix/"