-
-
Save joanbm/beaccedd729589df98332d70a1754e9a to your computer and use it in GitHub Desktop.
From 0c3e4c40305e78fd6d9899e43af6f0544a02fa6e Mon Sep 17 00:00:00 2001 | |
From: Joan Bruguera <joanbrugueram@gmail.com> | |
Date: Mon, 26 Oct 2020 04:44:33 +0100 | |
Subject: [PATCH] Tentative fix for NVIDIA 455.28 driver for Linux 5.10-rc1 | |
NOTE: This does not fix the licensing problem with nvidia-uvm which also affects Linux 5.9 | |
--- | |
common/inc/nv-linux.h | 6 ++++++ | |
nvidia-drm/nvidia-drm-gem-user-memory.c | 7 +++++++ | |
2 files changed, 13 insertions(+) | |
diff --git a/common/inc/nv-linux.h b/common/inc/nv-linux.h | |
index 09d1e50..630f80b 100644 | |
--- a/common/inc/nv-linux.h | |
+++ b/common/inc/nv-linux.h | |
@@ -11,6 +11,7 @@ | |
#ifndef _NV_LINUX_H_ | |
#define _NV_LINUX_H_ | |
+#include <linux/version.h> | |
#include "nvstatus.h" | |
#include "nv-misc.h" | |
#include "nv.h" | |
@@ -169,6 +170,11 @@ static inline uid_t __kuid_val(uid_t uid) | |
#include <linux/pagemap.h> | |
#include <linux/dma-mapping.h> | |
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0)) | |
+// dma-mapping.h has been split on commit 0a0f0d8be76dcd4390ff538e7060fda34db79717,, | |
+// so this needs to be incldued now for the build to work | |
+#include <linux/dma-map-ops.h> | |
+#endif | |
#if defined(CONFIG_SWIOTLB) && defined(NVCPU_AARCH64) | |
#include <linux/swiotlb.h> | |
diff --git a/nvidia-drm/nvidia-drm-gem-user-memory.c b/nvidia-drm/nvidia-drm-gem-user-memory.c | |
index 737d84c..082fc11 100644 | |
--- a/nvidia-drm/nvidia-drm-gem-user-memory.c | |
+++ b/nvidia-drm/nvidia-drm-gem-user-memory.c | |
@@ -20,6 +20,7 @@ | |
* DEALINGS IN THE SOFTWARE. | |
*/ | |
+#include <linux/version.h> | |
#include "nvidia-drm-conftest.h" | |
#if defined(NV_DRM_AVAILABLE) | |
@@ -60,8 +61,14 @@ static struct sg_table *__nv_drm_gem_user_memory_prime_get_sg_table( | |
{ | |
struct nv_drm_gem_user_memory *nv_user_memory = to_nv_user_memory(nv_gem); | |
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0)) | |
+ // New parameter to drm_prime_pages_to_sg (commit 707d561f77b5e2a6f90c9786bee44ee7a8dedc7e) | |
+ return drm_prime_pages_to_sg(nv_gem->nv_dev->dev, nv_user_memory->pages, | |
+ nv_user_memory->pages_count); | |
+#else | |
return drm_prime_pages_to_sg(nv_user_memory->pages, | |
nv_user_memory->pages_count); | |
+#endif | |
} | |
static void *__nv_drm_gem_user_memory_prime_vmap( | |
-- | |
2.29.1 |
many thanks for your effort in giving a look!!
I will try tomorrow your fix and report.. although I expect driver to work, as you expose seems a build only issue..
Thanks for your efforts. I am confirming that your fix worked on Ubuntu I had the same problem as @oscarbg (ubuntu groovy x86_64). the -generic /script modlule.lds.s is just a symlink to the plain /usr/src/linux-headers-5.10.0-051000rc2/script/module.lds.S. Copying that to -generic/script directory and editing per your instruction allowed build to finish and the drivers to load.
yep confirmed working.. thanks..
Great, glad it worked!
By the way, I took a look to see if this was actually a problem with the NVIDIA driver and I'm fairly sure this is a problem with the kernel or the Ubuntu package. Building other different out-of-tree kernel modules also fails with this error.
Looking at torvalds/linux@596b047 the problem seems to be that module.lds
is neither shipped with the kernel headers .deb package (they removed it from scripts/package/builddeb
) but it's also not generated on-demand by the other modules:
target in the Makefile
which is used when building out-of-tree modules. I guess it's supposed to be generated on-the-fly when building out-of-tree modules but it doesn't look like a simple one line fix. In Arch Linux I think they ignore scripts/package/builddeb
so that's why I still have a generated modules.lds
file around.
Interesting, I just set up a Ubuntu 20.04 VM and tried to build the driver and I get the same problem.
I found a workaround which is to copy
/usr/src/linux-headers-5.10.0-051000rc2-generic/scripts/module.lds.S
to/usr/src/linux-headers-5.10.0-051000rc2-generic/scripts/module.lds
and then remove the last line (an #include). With this the module builds. I couldn't load it since this was a just a simple VM, so it'd be nice if you could try it and report back.In my Arch Linux install, it works since the linux-mainline-headers I have includes the
module.lds
file. So I'm not sure if this is a packaging problem in Ubuntu. It's definitely looks related to 5.10 changes, commit: torvalds/linux@596b047