Skip to content

Instantly share code, notes, and snippets.

@joanbm
Last active November 5, 2020 13:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joanbm/beaccedd729589df98332d70a1754e9a to your computer and use it in GitHub Desktop.
Save joanbm/beaccedd729589df98332d70a1754e9a to your computer and use it in GitHub Desktop.
Tentative fix for NVIDIA 455.28 driver for Linux 5.10-rc1
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
@joanbm
Copy link
Author

joanbm commented Nov 5, 2020

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.

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