Skip to content

Instantly share code, notes, and snippets.

@joanbm
Last active March 12, 2024 20:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joanbm/24f4d4f4ec69f0c37038a6cc9d132b43 to your computer and use it in GitHub Desktop.
Save joanbm/24f4d4f4ec69f0c37038a6cc9d132b43 to your computer and use it in GitHub Desktop.
Tentative fix for NVIDIA 470.223.02 driver for Linux 6.8-rc3
From a23d8d2c592028bc49570a6d3dcf75ee4aa0dde0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Joan=20Bruguera=20Mic=C3=B3?= <joanbrugueram@gmail.com>
Date: Fri, 2 Feb 2024 19:19:04 +0000
Subject: [PATCH] Tentative fix for NVIDIA 470.223.02 driver for Linux 6.8-rc3
---
nvidia-drm/nvidia-drm-drv.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/nvidia-drm/nvidia-drm-drv.c b/nvidia-drm/nvidia-drm-drv.c
index 5ef557c..d271551 100644
--- a/nvidia-drm/nvidia-drm-drv.c
+++ b/nvidia-drm/nvidia-drm-drv.c
@@ -60,6 +60,7 @@
#include <drm/drm_ioctl.h>
#endif
+#include <linux/version.h>
#include <linux/pci.h>
/*
@@ -741,6 +742,13 @@ static const struct file_operations nv_drm_fops = {
.llseek = noop_llseek,
};
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 8, 0)
+// Rel. commit. "drm: Remove locking for legacy ioctls and DRM_UNLOCKED" (Thomas Zimmermann, 22 Nov 2023)
+// Mock this flag, which was already useless on any recent kernel, since it
+// only did something if the driver set DRIVER_LEGACY in driver_features.
+static const enum drm_ioctl_flags DRM_UNLOCKED = 0;
+#endif
+
static const struct drm_ioctl_desc nv_drm_ioctls[] = {
#if defined(NV_DRM_ATOMIC_MODESET_AVAILABLE)
DRM_IOCTL_DEF_DRV(NVIDIA_GEM_IMPORT_NVKMS_MEMORY,
--
2.43.0
@joanbm
Copy link
Author

joanbm commented Feb 2, 2024

Currently on Torvalds' master (almost -rc3), no workarounds are needed to avoid GPL'd symbols, so I've updated the patch. If you want to build old versions for some reason, check this Gist's revision history.

However it should be noted that now the same commit that caused GPL issues in 6.8-rc1 and rc2 is now in stable 6.1, 6.6 and 6.7 so there's some breakage there, see: https://github.com/gentoo/gentoo/blob/c64caf53/x11-drivers/nvidia-drivers/files/nvidia-drivers-470.223.02-gpl-pfn_valid.patch

FWIW the related kernel mainline commits are:

  • commit 5ec8e8ea8b77 "mm/sparsemem: fix race in accessing memory_section->usage" caused GPL symbol issues in pfn_valid
  • commit f6564fce256a "mm, kmsan: fix infinite recursion due to RCU critical section" fixed GPL symbol issues in pfn_valid

EDIT 2024-02-17: Kernels from the 6.1.x, 6.6.x, 6.7.x and 6.8.x branches now include the two commits so the driver builds everywhere without any workarounds.

@philmmanjaro
Copy link

This patch seems not to work with 470.239.06 and the final 6.8 kernel ...

@joanbm
Copy link
Author

joanbm commented Mar 12, 2024

@philmmanjaro I believe the NVIDIA 470.239.06 driver should build and work out of the box with Linux 6.8, i.e. you do not need any patch. This patch was only needed for older driver versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment