-
-
Save joanbm/7a034ac4b79396c3841040e410ef7e91 to your computer and use it in GitHub Desktop.
From a2963d47c009bcbdc98907f70717d9d49425f6db Mon Sep 17 00:00:00 2001 | |
From: Joan Bruguera <[email protected]> | |
Date: Mon, 1 Mar 2021 17:25:15 +0100 | |
Subject: [PATCH] Tentative fix for NVIDIA 460.56 driver for Linux 5.12-rc1 | |
--- | |
nvidia-drm/nvidia-drm-drv.c | 12 ++++++++++++ | |
1 file changed, 12 insertions(+) | |
diff --git a/nvidia-drm/nvidia-drm-drv.c b/nvidia-drm/nvidia-drm-drv.c | |
index 9582531..c23a338 100644 | |
--- a/nvidia-drm/nvidia-drm-drv.c | |
+++ b/nvidia-drm/nvidia-drm-drv.c | |
@@ -20,6 +20,7 @@ | |
* DEALINGS IN THE SOFTWARE. | |
*/ | |
+#include <linux/version.h> | |
#include "nvidia-drm-conftest.h" /* NV_DRM_AVAILABLE and NV_DRM_DRM_GEM_H_PRESENT */ | |
#include "nvidia-drm-priv.h" | |
@@ -796,6 +797,13 @@ static struct drm_driver nv_drm_driver = { | |
#endif | |
}; | |
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0)) | |
+// Reimport trivial forwarder function deleted in commit "drm: Don't export the drm_gem_dumb_destroy() function" (file drivers/gpu/drm/drm_gem.c) | |
+static int nv_drm_gem_dumb_destroy(struct drm_file *file, struct drm_device *dev, u32 handle) | |
+{ | |
+ return drm_gem_handle_delete(file, handle); | |
+} | |
+#endif | |
/* | |
* Update the global nv_drm_driver for the intended features. | |
@@ -819,7 +827,11 @@ static void nv_drm_update_drm_driver_features(void) | |
nv_drm_driver.dumb_create = nv_drm_dumb_create; | |
nv_drm_driver.dumb_map_offset = nv_drm_dumb_map_offset; | |
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 12, 0)) | |
nv_drm_driver.dumb_destroy = drm_gem_dumb_destroy; | |
+#else | |
+ nv_drm_driver.dumb_destroy = nv_drm_gem_dumb_destroy; | |
+#endif | |
#endif /* NV_DRM_ATOMIC_MODESET_AVAILABLE */ | |
} | |
-- | |
2.30.1 | |
No worries, nice you figured out the fix yourself 😉!
Hi Joan,
thanks for your patches helping me to get along with NVIDIA GPUs on Linux ;-)
I had a build error using Linux 5.12-rc2, because nv-interface.o wasn't linked. I wonder how it works for you. The target "always" was renamed to "always-y", see commit 5f2fb52fac15a. The patch below fixes the issue for me.
Have fun
Berny
--- a/Kbuild 2021-03-07 21:13:47.560599117 +0100
+++ b/Kbuild 2021-03-07 21:12:10.017289150 +0100
@@ -48,7 +48,7 @@
# - Append to 'obj-m', to indicate the kernel module that should be built.
# - Define the object files that should get built to produce the kernel module.
# - Tie into conftest (see the description below).
-# - Add any items that should always be built to $(always)
+# - Add any items that should always be built to $(always-y)
#
NV_UNDEF_BEHAVIOR_SANITIZER ?=
@@ -56,7 +56,7 @@
UBSAN_SANITIZE := y
endif
-always :=
+always-y :=
$(foreach _module, $(NV_KERNEL_MODULES), \
$(eval include $(src)/$(_module)/$(_module).Kbuild))
--- a/nvidia/nvidia.Kbuild 2021-03-07 21:14:29.124305993 +0100
+++ b/nvidia/nvidia.Kbuild 2021-03-07 21:11:24.401612989 +0100
@@ -84,7 +84,7 @@
NVIDIA_INTERFACE := nvidia/nv-interface.o
-always += $(NVIDIA_INTERFACE)
+always-y += $(NVIDIA_INTERFACE)
$(obj)/$(NVIDIA_INTERFACE): $(addprefix $(obj)/,$(NVIDIA_OBJECTS))
$(LD) -r -o $@ $^
--- a/nvidia-modeset/nvidia-modeset.Kbuild 2021-03-07 22:03:27.960835988 +0100
+++ b/nvidia-modeset/nvidia-modeset.Kbuild 2021-03-07 22:03:45.732734138 +0100
@@ -69,7 +69,7 @@
NVIDIA_MODESET_INTERFACE := nvidia-modeset/nv-modeset-interface.o
-always += $(NVIDIA_MODESET_INTERFACE)
+always-y += $(NVIDIA_MODESET_INTERFACE)
$(obj)/$(NVIDIA_MODESET_INTERFACE): $(addprefix $(obj)/,$(NVIDIA_MODESET_OBJECTS))
$(LD) -r -o $@ $^
Update: I have done patching with patch -p1 < nvidia-fix-linux-5.12.patch command. It is now installed , but wayland is dead both in Gnome and Plasma, it was running on 5.11
Hi Joan,
I am trying to patch this Nvidia 460.56 for Fedora 35 5.12 rc2 kernel, it will be my first experience on Nvidia patching. I tried FredC88's way, by running this ./NVIDIA-Linux-x86_64-460.56.run --apply-patch nvidia-fix-linux-5.12.patch , however, it asks which file to patch:
Verifying archive integrity... OK
Uncompressing NVIDIA Accelerated Graphics Driver for Linux-x86_64 460.56...............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
can't find file to patch at input line 14
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
|From a2963d47c009bcbdc98907f70717d9d49425f6db Mon Sep 17 00:00:00 2001
|From: Joan Bruguera [email protected]
|Date: Mon, 1 Mar 2021 17:25:15 +0100
|Subject: [PATCH] Tentative fix for NVIDIA 460.56 driver for Linux 5.12-rc1
|
|---
| nvidia-drm/nvidia-drm-drv.c | 12 ++++++++++++
| 1 file changed, 12 insertions(+)
|
|diff --git a/nvidia-drm/nvidia-drm-drv.c b/nvidia-drm/nvidia-drm-drv.c
|index 9582531..c23a338 100644
|--- a/nvidia-drm/nvidia-drm-drv.c
|+++ b/nvidia-drm/nvidia-drm-drv.c
File to patch:
I had added patch to /NVIDIA-Linux-x86_64-460.56/kernel folder
@berny156: Thanks for the contribution, I did not run into this problem, but this may be because I build and apply the patch by adding it on top of the Arch Linux's nvidia-dkms package rather than running the installer, so maybe it does something differently. Thinking about this, I should test the patch before release using a more conventional Debian+NVIDIA-Installer setup so I catch those problems more often. Commit 5f2fb52fac15a seems to be quite old and has been in the kernel sources for some versions so I don't think it's the problem though, but rather maybe other more recent changes.
@dogansan: I didn't know there was an --apply-patch
option, but it doesn't seem to be compatible with the way I set up the directory structure for the patch, which is rather set up so I can easily apply the patch automatically using DKMS.
Anyway, if I remember correctly, you should be able to apply the patch by extracting the installer and manually running patch over the kernel
folder after being extracted, like so:
$ sh NVIDIA-Linux-x86_64-460.56.run --extract-only
$ cd NVIDIA-Linux-x86_64-460.56/kernel/
$ patch -Np1 -i ../../nvidia-fix-linux-5.12.patch
$ cd ..
$ sudo ./nvidia-installer
Hi Joan, I forgot to mention that my way of installation is certainly not the standard one. I'm actually using the RPMs provided for openSUSE's Tumbleweed. The module build uses the Kbuild system requiring the "always-y" targets.
Looks like at least the line numbers have changed in the meantime.
Hence, the patch for nvidia-drm-drv.c
had to be updated in order to allow the patches to be applied:
@@ -20,6 +20,7 @@
* DEALINGS IN THE SOFTWARE.
*/
+#include <linux/version.h>
#include "nvidia-drm-conftest.h" /* NV_DRM_AVAILABLE and NV_DRM_DRM_GEM_H_PRESENT */
#include "nvidia-drm-priv.h"
@@ -700,10 +701,10 @@
.num_ioctls = ARRAY_SIZE(nv_drm_ioctls),
.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
- .gem_prime_export = nv_drm_gem_prime_export,
- .gem_prime_get_sg_table = nv_drm_gem_prime_get_sg_table,
- .gem_prime_vmap = nv_drm_gem_prime_vmap,
- .gem_prime_vunmap = nv_drm_gem_prime_vunmap,
+/* .gem_prime_export = nv_drm_gem_prime_export, */
+/* .gem_prime_get_sg_table = nv_drm_gem_prime_get_sg_table, */
+/* .gem_prime_vmap = nv_drm_gem_prime_vmap, */
+/* .gem_prime_vunmap = nv_drm_gem_prime_vunmap, */
#if defined(NV_DRM_DRIVER_HAS_GEM_PRIME_RES_OBJ)
.gem_prime_res_obj = nv_drm_gem_prime_res_obj,
@@ -730,10 +731,17 @@
#if defined(NV_DRM_DRIVER_HAS_LEGACY_DEV_LIST)
.legacy_dev_list = LIST_HEAD_INIT(nv_drm_driver.legacy_dev_list),
#else
- .device_list = LIST_HEAD_INIT(nv_drm_driver.device_list),
+ /* .device_list = LIST_HEAD_INIT(nv_drm_driver.device_list),*/
#endif
};
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0))
+// Reimport trivial forwarder function deleted in commit "drm: Don't export the drm_gem_dumb_destroy() function" (file drivers/gpu/drm/drm_gem.c)
+static int nv_drm_gem_dumb_destroy(struct drm_file *file, struct drm_device *dev, u32 handle)
+{
+ return drm_gem_handle_delete(file, handle);
+}
+#endif
/*
* Update the global nv_drm_driver for the intended features.
@@ -757,9 +765,12 @@
nv_drm_driver.dumb_create = nv_drm_dumb_create;
nv_drm_driver.dumb_map_offset = nv_drm_dumb_map_offset;
- nv_drm_driver.dumb_destroy = drm_gem_dumb_destroy;
-
- nv_drm_driver.gem_vm_ops = &nv_drm_gem_vma_ops;
+ #if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 12, 0))
+ nv_drm_driver.dumb_destroy = drm_gem_dumb_destroy;
+ #else
+ nv_drm_driver.dumb_destroy = nv_drm_gem_dumb_destroy;
+ #endif
+ /* nv_drm_driver.gem_vm_ops = &nv_drm_gem_vma_ops; */
#endif /* NV_DRM_ATOMIC_MODESET_AVAILABLE */
}
** I found the solution(Sorry, Linux Patch Newbie here)! -> I need to "copy the patch inside NVIDIA-Linux-x86_64-460.56/kernel and run sudo patch < 5.12.patch) Everything works now! Thank you very much!!!
Hi Joanbm:
Thank you so much for your sharing and effort!! Really save me and(allow me to say)thousands of Nvidia card owners! However, when I run this patch, I always got the following error, don't know what went wrong... Please help! (Kernel 5.12 rc2, Geforce 460.56), Thank you so so much!!
fred@fred-2F:/media/RamDisk/NVIDIA-Linux-x86_64-460.56$ sudo patch p1 -i 5.12.patch
[sudo] password for fred:
patching file p1
Hunk #1 FAILED at 20.
Hunk #2 FAILED at 796.
Hunk #3 FAILED at 819.
3 out of 3 hunks FAILED -- saving rejects to file p1.rej
patch: **** Can't reopen file p1 : No such file or directory
Also, Error here:
fred@fred-2F:/media/RamDisk$ sudo patch < 5.12.patch
can't find file to patch at input line 14
Perhaps you should have used the -p or --strip option?
The text leading up to this was:
|From a2963d47c009bcbdc98907f70717d9d49425f6db Mon Sep 17 00:00:00 2001
|From: Joan Bruguera [email protected]
|Date: Mon, 1 Mar 2021 17:25:15 +0100
|Subject: [PATCH] Tentative fix for NVIDIA 460.56 driver for Linux 5.12-rc1
|
|---
| nvidia-drm/nvidia-drm-drv.c | 12 ++++++++++++
| 1 file changed, 12 insertions(+)
|
|diff --git a/nvidia-drm/nvidia-drm-drv.c b/nvidia-drm/nvidia-drm-drv.c
|index 9582531..c23a338 100644
|--- a/nvidia-drm/nvidia-drm-drv.c
|+++ b/nvidia-drm/nvidia-drm-drv.c
File to patch: