-
-
Save joanbm/dfe8dc59af1c83e2530a1376b77be8ba to your computer and use it in GitHub Desktop.
From 0ca9614e5b074d3dd01e95f47b3555f48e74f622 Mon Sep 17 00:00:00 2001 | |
From: =?UTF-8?q?Joan=20Bruguera=20Mic=C3=B3?= <[email protected]> | |
Date: Wed, 17 May 2023 21:54:08 +0000 | |
Subject: [PATCH] Tentative fix for NVIDIA 470.182.03 driver for Linux 6.5-rc1 | |
--- | |
common/inc/nv-mm.h | 45 +++++++++++++++++++++++++++++++++++++++++++-- | |
1 file changed, 43 insertions(+), 2 deletions(-) | |
diff --git a/common/inc/nv-mm.h b/common/inc/nv-mm.h | |
index 54f6f60..25333e8 100644 | |
--- a/common/inc/nv-mm.h | |
+++ b/common/inc/nv-mm.h | |
@@ -23,6 +23,7 @@ | |
#ifndef __NV_MM_H__ | |
#define __NV_MM_H__ | |
+#include <linux/version.h> | |
#include "conftest.h" | |
#if !defined(NV_VM_FAULT_T_IS_PRESENT) | |
@@ -47,7 +48,27 @@ typedef int vm_fault_t; | |
* | |
*/ | |
-#if defined(NV_GET_USER_PAGES_HAS_TASK_STRUCT) | |
+// Rel. commit. "mm/gup: remove unused vmas parameter from get_user_pages()" (Lorenzo Stoakes, 14 May 2023) | |
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 5, 0) | |
+#include <linux/mm.h> | |
+ | |
+static inline long NV_GET_USER_PAGES(unsigned long start, | |
+ unsigned long nr_pages, | |
+ int write, | |
+ int force, | |
+ struct page **pages, | |
+ struct vm_area_struct **vmas) | |
+{ | |
+ unsigned int flags = 0; | |
+ | |
+ if (write) | |
+ flags |= FOLL_WRITE; | |
+ if (force) | |
+ flags |= FOLL_FORCE; | |
+ | |
+ return get_user_pages(start, nr_pages, flags, pages); | |
+} | |
+#elif defined(NV_GET_USER_PAGES_HAS_TASK_STRUCT) | |
#if defined(NV_GET_USER_PAGES_HAS_WRITE_AND_FORCE_ARGS) | |
#define NV_GET_USER_PAGES(start, nr_pages, write, force, pages, vmas) \ | |
get_user_pages(current, current->mm, start, nr_pages, write, force, pages, vmas) | |
@@ -130,7 +151,27 @@ typedef int vm_fault_t; | |
* | |
*/ | |
-#if defined(NV_GET_USER_PAGES_REMOTE_PRESENT) | |
+// Rel. commit. "mm/gup: remove unused vmas parameter from get_user_pages_remote()" (Lorenzo Stoakes, 14 May 2023) | |
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 5, 0) | |
+static inline long NV_GET_USER_PAGES_REMOTE(struct task_struct *tsk, | |
+ struct mm_struct *mm, | |
+ unsigned long start, | |
+ unsigned long nr_pages, | |
+ int write, | |
+ int force, | |
+ struct page **pages, | |
+ struct vm_area_struct **vmas) | |
+{ | |
+ unsigned int flags = 0; | |
+ | |
+ if (write) | |
+ flags |= FOLL_WRITE; | |
+ if (force) | |
+ flags |= FOLL_FORCE; | |
+ | |
+ return get_user_pages_remote(mm, start, nr_pages, flags, pages, NULL); | |
+} | |
+#elif defined(NV_GET_USER_PAGES_REMOTE_PRESENT) | |
#if defined(NV_GET_USER_PAGES_REMOTE_HAS_WRITE_AND_FORCE_ARGS) | |
#define NV_GET_USER_PAGES_REMOTE get_user_pages_remote | |
#else | |
-- | |
2.41.0 | |
blastwave
commented
Oct 21, 2023
@joanbm thank you for quick reply, i have kali with kernel 6.5 and have Nvidia 720m with no driver now (390xx) , @AntonioTrindade said the patch 470xx work with 390xx can you confirm ? And what you propose ? The guide you give, I'm already tried and i had some errors. Have a nice day.
@Abdou-St-009 Honestly, you're probably going to have a much easier time if you either switch to the Nouveau open source driver, or switch to a more stable distribution (like Ubuntu 22.04 or Debian Bullseye) which provides official packages for the 390xx driver branch. Using the somewhat-abandoned 390xx driver with a rolling release distribution is most likely going to be a PITA.
If you want to try to do it anyway, there's an AUR package for Arch for nvidia-390xx (https://aur.archlinux.org/packages/nvidia-390xx-dkms) which has various patches to make the driver work up to Linux 6.5, see https://aur.archlinux.org/cgit/aur.git/tree/?h=nvidia-390xx-utils. But as I said, it's probably going to be painful to get and keep such a setup working.
@blastwave Yeah, looks like somehow you ran into a NULL pointer reference somewhere in the UVM code... not sure what this is about since the driver doesn't need any changes to the UVM code to build on Linux 6.5, but it's still possible that something has changed in Linux that indirectly breaks the UVM part of the driver nonetheless.
I ran some simple CUDA sample using UVM on my card and it worked fine, so it's probably something related to your specific setup & application. So if you want to try to look into it, the first step would be to try to find a minimal reproducer (simple small application, single card if possible), though there's no guarantee at all that we can figure out what the problem is since most of the drivers are closed source.
Though TBH, if you want to do scientific computing / advanced CUDA use, it's probably better that you stay on the officially supported versions of the kernel by the NVIDIA driver, as (hopefully) NVIDIA has tested and validated their driver with those, while these patches are provided on a "best effort" basis and have no real testing besides checking that very basic desktop / gaming / CUDA use cases work.
@joanbm thank you for quick reply, i have kali with kernel 6.5 and have Nvidia 720m with no driver now (390xx) , @AntonioTrindade said the patch 470xx work with 390xx can you confirm ? And what you propose ? The guide you give, I'm already tried and i had some errors. Have a nice day.
@Abdou-St-009 Honestly, you're probably going to have a much easier time if you either switch to the Nouveau open source driver, or switch to a more stable distribution (like Ubuntu 22.04 or Debian Bullseye) which provides official packages for the 390xx driver branch. Using the somewhat-abandoned 390xx driver with a rolling release distribution is most likely going to be a PITA.
If you want to try to do it anyway, there's an AUR package for Arch for nvidia-390xx (https://aur.archlinux.org/packages/nvidia-390xx-dkms) which has various patches to make the driver work up to Linux 6.5, see https://aur.archlinux.org/cgit/aur.git/tree/?h=nvidia-390xx-utils. But as I said, it's probably going to be painful to get and keep such a setup working.
I am grateful and will take your advice into consideration.
@blastwave FWIW there's a new driver version in the 470xx branch that builds up to Linux 6.6 without third-party patches, you may want to try it: https://www.nvidia.com/download/driverResults.aspx/215840/en-us/
@joanbm thank you for quick reply, i have kali with kernel 6.5 and have Nvidia 720m with no driver now (390xx) , @AntonioTrindade said the patch 470xx work with 390xx can you confirm ? And what you propose ? The guide you give, I'm already tried and i had some errors. Have a nice day.
Honestly I do not remember if I used the 470xx patch as is or not. I patched the files manually and created a patch file for myself and have had no problems since I reported the compilation problem, even after several kernel upgrades.
@joanbm thank you for quick reply, i have kali with kernel 6.5 and have Nvidia 720m with no driver now (390xx) , @AntonioTrindade said the patch 470xx work with 390xx can you confirm ? And what you propose ? The guide you give, I'm already tried and i had some errors. Have a nice day.
Honestly I do not remember if I used the 470xx patch as is or not. I patched the files manually and created a patch file for myself and have had no problems since I reported the compilation problem, even after several kernel upgrades.
Hey @AntonioTrindade
Can you please help me to find the driver 390.x for my Debian and i have old Gpu Nvidia gt720m and my kernel is 6.5 and no official driver from Nvidia site for this kernel yet and i got very tired to find it.
Have a good day
@Abdou-St-009, If you are using Debian Sid, just install nvidia-legacy-390xx-driver.
If you are using Debian stable, change your apt.sources.list to Sid, run "apt update; apt install nvidia-legacy-390xx-driver" and change back the apt.sources.list to your Debian version and rerun "apt update".
WARNING: after editing apt.sources.list to Sid DO NOT RUN "apt upgrade"!