Merge pull request #5602 from heitbaum/kernel11

NVIDIA updates for kernel 5.14
This commit is contained in:
CvH 2021-09-11 15:44:56 +02:00 committed by GitHub
commit 40f26afea2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 337 additions and 4 deletions

View File

@ -0,0 +1,231 @@
diff -Naur NVIDIA-Linux-x86_64-340.108-old/kernel/conftest.sh NVIDIA-Linux-x86_64-340.108-new/kernel/conftest.sh
--- NVIDIA-Linux-x86_64-340.108-old/kernel/conftest.sh 2021-05-24 20:08:18.743742335 +0200
+++ NVIDIA-Linux-x86_64-340.108-new/kernel/conftest.sh 2021-05-24 20:13:18.019314390 +0200
@@ -1578,21 +1578,21 @@
#include <drm/drm_drv.h>
#endif
- #if defined(NV_DRM_DRM_PRIME_H_PRESENT)
- #include <drm/drm_prime.h>
- #endif
-
#if !defined(CONFIG_DRM) && !defined(CONFIG_DRM_MODULE)
#error DRM not enabled
#endif
+
void conftest_drm_available(void) {
struct drm_driver drv;
- drv.gem_prime_pin = 0;
- drv.gem_prime_get_sg_table = 0;
- drv.gem_prime_vmap = 0;
- drv.gem_prime_vunmap = 0;
- (void)drm_gem_prime_import;
- (void)drm_gem_prime_export;
+
+ /* 2013-10-02 1bb72532ac260a2d3982b40bdd4c936d779d0d16 */
+ (void)drm_dev_alloc;
+
+ /* 2013-10-02 c22f0ace1926da399d9a16dfaf09174c1b03594c */
+ (void)drm_dev_register;
+
+ /* 2013-10-02 c3a49737ef7db0bdd4fcf6cf0b7140a883e32b2a */
+ (void)drm_dev_unregister;
}"
compile_check_conftest "$CODE" "NV_DRM_AVAILABLE" "" "generic"
diff -Naur NVIDIA-Linux-x86_64-340.108-old/kernel/nv-drm.c NVIDIA-Linux-x86_64-340.108-new/kernel/nv-drm.c
--- NVIDIA-Linux-x86_64-340.108-old/kernel/nv-drm.c 2021-05-24 20:08:18.779739237 +0200
+++ NVIDIA-Linux-x86_64-340.108-new/kernel/nv-drm.c 2021-05-24 20:42:13.443288819 +0200
@@ -52,7 +52,9 @@
#define nv_drm_pci_exit drm_legacy_pci_exit
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0)
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 7, 0)
+#include "linux/dma-buf.h"
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 7, 0) && LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0)
#include <drm/drm_agpsupport.h>
struct drm_agp_mem {
@@ -168,8 +170,10 @@
/* No locking needed since shadow-attach is single-threaded since it may
* only be called from the per-driver module init hook. */
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 10, 0)
if (drm_core_check_feature(dev, DRIVER_LEGACY))
list_add_tail(&dev->legacy_dev_list, &driver->legacy_dev_list);
+#endif
return 0;
@@ -193,8 +197,10 @@
if (WARN_ON(!(driver->driver_features & DRIVER_LEGACY)))
return -EINVAL;
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 10, 0)
/* If not using KMS, fall back to stealth mode manual scanning. */
INIT_LIST_HEAD(&driver->legacy_dev_list);
+#endif
for (i = 0; pdriver->id_table[i].vendor != 0; i++) {
pid = &pdriver->id_table[i];
@@ -219,7 +219,9 @@
/* stealth mode requires a manual probe */
pci_dev_get(pdev);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0)
drm_get_pci_dev(pdev, pid, driver);
+#endif
}
}
return 0;
@@ -227,11 +233,13 @@
if (!(driver->driver_features & DRIVER_LEGACY)) {
WARN_ON(1);
} else {
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 10, 0)
list_for_each_entry_safe(dev, tmp, &driver->legacy_dev_list,
legacy_dev_list) {
list_del(&dev->legacy_dev_list);
drm_put_dev(dev);
}
+#endif
}
DRM_INFO("Module unloaded\n");
}
@@ -254,6 +262,8 @@
{
nv_linux_state_t *nvl;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0)
+ /* dev->pdev is no longer avaialble in 5.14 */
for (nvl = nv_linux_devices; nvl != NULL; nvl = nvl->next)
{
if (nvl->dev == dev->pdev)
@@ -262,6 +272,7 @@
return 0;
}
}
+#endif
return -ENODEV;
}
@@ -278,6 +289,8 @@
{
nv_linux_state_t *nvl;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0)
+ /* dev->pdev is no longer avaialble in 5.14 */
for (nvl = nv_linux_devices; nvl != NULL; nvl = nvl->next)
{
if (nvl->dev == dev->pdev)
@@ -287,6 +300,7 @@
return 0;
}
}
+#endif
return -ENODEV;
}
@@ -359,6 +373,39 @@
.llseek = noop_llseek,
};
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0)
+struct sg_table *nv_drm_gem_prime_get_sg_table(struct drm_gem_object *gem)
+{
+ return nv_gem_prime_get_sg_table(gem);
+}
+
+static int nv_drm_gem_vmap(struct drm_gem_object *gem,
+ struct dma_buf_map *map)
+{
+ map->vaddr = nv_gem_prime_vmap(gem);
+ if (map->vaddr == NULL) {
+ return -ENOMEM;
+ }
+ map->is_iomem = true;
+ return 0;
+}
+
+static void nv_drm_gem_vunmap(struct drm_gem_object *gem,
+ struct dma_buf_map *map)
+{
+ nv_gem_prime_vunmap(gem, map->vaddr);
+ map->vaddr = NULL;
+}
+
+static struct drm_gem_object_funcs nv_drm_gem_object_funcs = {
+ .free = nv_gem_free,
+ .export = drm_gem_prime_export,
+ .get_sg_table = nv_drm_gem_prime_get_sg_table,
+ .vmap = nv_drm_gem_vmap,
+ .vunmap = nv_drm_gem_vunmap,
+};
+#endif
+
static struct drm_driver nv_drm_driver = {
.driver_features = DRIVER_GEM
@@ -377,17 +424,19 @@
.set_busid = drm_pci_set_busid,
#endif
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 9, 0)
- .gem_free_object_unlocked = nv_gem_free,
-#else
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 8, 0)
.gem_free_object = nv_gem_free,
+#elif LINUX_VERSION_CODE <= KERNEL_VERSION(5, 10, 0)
+ .gem_free_object_unlocked = nv_gem_free,
#endif
.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 10, 0)
.gem_prime_export = drm_gem_prime_export,
.gem_prime_get_sg_table = nv_gem_prime_get_sg_table,
.gem_prime_vmap = nv_gem_prime_vmap,
.gem_prime_vunmap = nv_gem_prime_vunmap,
+#endif
.name = "nvidia-drm",
.desc = "NVIDIA DRM driver",
diff -Naur NVIDIA-Linux-x86_64-340.108-old/kernel/nv-linux.h NVIDIA-Linux-x86_64-340.108-new/kernel/nv-linux.h
--- NVIDIA-Linux-x86_64-340.108-old/kernel/nv-linux.h 2021-05-24 20:08:18.775739581 +0200
+++ NVIDIA-Linux-x86_64-340.108-new/kernel/nv-linux.h 2021-05-24 20:09:18.748287771 +0200
@@ -119,7 +119,9 @@
#include <asm/tlbflush.h> /* flush_tlb(), flush_tlb_all() */
#include <linux/cpu.h> /* CPU hotplug support */
#endif
-#include <asm/kmap_types.h> /* page table entry lookup */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0)
+ #include <asm/kmap_types.h> /* page table entry lookup */
+#endif
#include <linux/pci.h> /* pci_find_class, etc */
#include <linux/interrupt.h> /* tasklets, interrupt helpers */
diff -Naur NVIDIA-Linux-x86_64-340.108-old/kernel/uvm/nvidia_uvm_linux.h NVIDIA-Linux-x86_64-340.108-new/kernel/uvm/nvidia_uvm_linux.h
--- NVIDIA-Linux-x86_64-340.108-old/kernel/uvm/nvidia_uvm_linux.h 2021-05-24 20:08:18.775739581 +0200
+++ NVIDIA-Linux-x86_64-340.108-new/kernel/uvm/nvidia_uvm_linux.h 2021-05-24 20:09:18.749287739 +0200
@@ -141,7 +141,9 @@
#if !defined(NV_VMWARE)
#include <asm/tlbflush.h> /* flush_tlb(), flush_tlb_all() */
#endif
-#include <asm/kmap_types.h> /* page table entry lookup */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0)
+ #include <asm/kmap_types.h> /* page table entry lookup */
+#endif
#include <linux/interrupt.h> /* tasklets, interrupt helpers */
#include <linux/timer.h>
--- a/kernel/os-interface.c 2021-09-04 22:01:56.175807486 +1000
+++ b/kernel/os-interface.c 2021-09-04 22:01:56.175807486 +1000
@@ -549,7 +549,7 @@
// the requested timeout has expired, loop until less
// than a jiffie of the desired delay remains.
//
- current->state = TASK_INTERRUPTIBLE;
+ current->__state = TASK_INTERRUPTIBLE;
do
{
schedule_timeout(jiffies);

View File

@ -6,8 +6,8 @@ PKG_NAME="xf86-video-nvidia"
# Remember to run "python3 packages/x11/driver/xf86-video-nvidia/scripts/make_nvidia_udev.py" and commit changes to
# "packages/x11/driver/xf86-video-nvidia/udev.d/96-nvidia.rules" whenever bumping version.
# Host may require installation of python3-lxml and python3-requests packages.
PKG_VERSION="460.67"
PKG_SHA256="a19253cf805f913a3b53098587d557fb21c9b57b1568cb630e128ebb3276c10e"
PKG_VERSION="460.91.03"
PKG_SHA256="448156cfcef182ed6997c2754c472fd681bf7139b821d2adce1d847220c6c933"
PKG_ARCH="x86_64"
PKG_LICENSE="nonfree"
PKG_SITE="http://www.nvidia.com/"

View File

@ -0,0 +1,63 @@
From f18c541edc5e122b06b0c1e65d0a422f0b8109e7 Mon Sep 17 00:00:00 2001
From: Joan Bruguera <joanbrugueram@gmail.com>
Date: Fri, 2 Jul 2021 02:09:58 +0200
Subject: [PATCH] Tentative fix for NVIDIA 465.31 driver for Linux 5.14-rc1
---
kernel/common/inc/nv-time.h | 6 ++++++
kernel/nvidia-drm/nvidia-drm-drv.c | 4 ++++
2 files changed, 10 insertions(+)
diff --git a/kernel/common/inc/nv-time.h b/kernel/common/inc/nv-time.h
index dc80806..cc343a5 100644
--- a/kernel/common/inc/nv-time.h
+++ b/kernel/common/inc/nv-time.h
@@ -23,6 +23,7 @@
#ifndef __NV_TIME_H__
#define __NV_TIME_H__
+#include <linux/version.h>
#include "conftest.h"
#include <linux/sched.h>
#include <linux/delay.h>
@@ -205,7 +206,12 @@ static inline NV_STATUS nv_sleep_ms(unsigned int ms)
// the requested timeout has expired, loop until less
// than a jiffie of the desired delay remains.
//
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0))
current->state = TASK_INTERRUPTIBLE;
+#else
+ // Rel. commit "sched: Change task_struct::state" (Peter Zijlstra, Jun 11 2021)
+ WRITE_ONCE(current->__state, TASK_INTERRUPTIBLE);
+#endif
do
{
schedule_timeout(jiffies);
diff --git a/kernel/nvidia-drm/nvidia-drm-drv.c b/kernel/nvidia-drm/nvidia-drm-drv.c
index 84d4479..99ea552 100644
--- a/kernel/nvidia-drm/nvidia-drm-drv.c
+++ b/kernel/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"
@@ -903,9 +904,12 @@ static void nv_drm_register_drm_device(const nv_gpu_info_t *gpu_info)
dev->dev_private = nv_dev;
nv_dev->dev = dev;
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0))
+ // Rel. commit "drm: Remove pdev field from struct drm_device" (Thomas Zimmermann, 3 May 2021)
if (device->bus == &pci_bus_type) {
dev->pdev = to_pci_dev(device);
}
+#endif
/* Register DRM device to DRM sub-system */
--
2.32.0

View File

@ -40,7 +40,12 @@ for version in sys.argv[1:]:
for version in versions:
url = 'http://us.download.nvidia.com/XFree86/Linux-x86_64/' + version + '/README/supportedchips.html'
page = requests.get(url)
headers = {
'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:15.0) Gecko/20100101 Firefox/15.0.1',
}
page = requests.get(url, headers=headers)
tree = html.fromstring(page.content)
# These are the tables we want to use (gpu's supported by the current driver)

View File

@ -20,7 +20,12 @@ for line in open(__package__, 'r'):
break
url = 'http://us.download.nvidia.com/XFree86/Linux-x86_64/' + __version__ + '/README/supportedchips.html'
page = requests.get(url)
headers = {
'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:15.0) Gecko/20100101 Firefox/15.0.1',
}
page = requests.get(url, headers=headers)
tree = html.fromstring(page.content)
# These are the tables we want to use (gpu's supported by the current driver)

View File

@ -239,6 +239,7 @@ ATTR{device}=="0x1df6", GOTO="configure_nvidia"
ATTR{device}=="0x1e02", GOTO="configure_nvidia"
ATTR{device}=="0x1e04", GOTO="configure_nvidia"
ATTR{device}=="0x1e07", GOTO="configure_nvidia"
ATTR{device}=="0x1e09", GOTO="configure_nvidia"
ATTR{device}=="0x1e30", GOTO="configure_nvidia"
ATTR{device}=="0x1e36", GOTO="configure_nvidia"
ATTR{device}=="0x1e78", GOTO="configure_nvidia"
@ -291,14 +292,20 @@ ATTR{device}=="0x1f99", GOTO="configure_nvidia"
ATTR{device}=="0x1f9c", GOTO="configure_nvidia"
ATTR{device}=="0x1f9d", GOTO="configure_nvidia"
ATTR{device}=="0x1fb0", GOTO="configure_nvidia"
ATTR{device}=="0x1fb1", GOTO="configure_nvidia"
ATTR{device}=="0x1fb2", GOTO="configure_nvidia"
ATTR{device}=="0x1fb8", GOTO="configure_nvidia"
ATTR{device}=="0x1fb9", GOTO="configure_nvidia"
ATTR{device}=="0x1fba", GOTO="configure_nvidia"
ATTR{device}=="0x1fbb", GOTO="configure_nvidia"
ATTR{device}=="0x1fbc", GOTO="configure_nvidia"
ATTR{device}=="0x1fdd", GOTO="configure_nvidia"
ATTR{device}=="0x1ff9", GOTO="configure_nvidia"
ATTR{device}=="0x20b0", GOTO="configure_nvidia"
ATTR{device}=="0x20b1", GOTO="configure_nvidia"
ATTR{device}=="0x20b2", GOTO="configure_nvidia"
ATTR{device}=="0x20b6", GOTO="configure_nvidia"
ATTR{device}=="0x20b7", GOTO="configure_nvidia"
ATTR{device}=="0x20f1", GOTO="configure_nvidia"
ATTR{device}=="0x2182", GOTO="configure_nvidia"
ATTR{device}=="0x2184", GOTO="configure_nvidia"
@ -311,17 +318,39 @@ ATTR{device}=="0x21c4", GOTO="configure_nvidia"
ATTR{device}=="0x21d1", GOTO="configure_nvidia"
ATTR{device}=="0x2204", GOTO="configure_nvidia"
ATTR{device}=="0x2206", GOTO="configure_nvidia"
ATTR{device}=="0x2208", GOTO="configure_nvidia"
ATTR{device}=="0x2216", GOTO="configure_nvidia"
ATTR{device}=="0x2230", GOTO="configure_nvidia"
ATTR{device}=="0x2231", GOTO="configure_nvidia"
ATTR{device}=="0x2235", GOTO="configure_nvidia"
ATTR{device}=="0x2236", GOTO="configure_nvidia"
ATTR{device}=="0x2237", GOTO="configure_nvidia"
ATTR{device}=="0x2482", GOTO="configure_nvidia"
ATTR{device}=="0x2484", GOTO="configure_nvidia"
ATTR{device}=="0x2486", GOTO="configure_nvidia"
ATTR{device}=="0x2488", GOTO="configure_nvidia"
ATTR{device}=="0x2489", GOTO="configure_nvidia"
ATTR{device}=="0x249c", GOTO="configure_nvidia"
ATTR{device}=="0x249d", GOTO="configure_nvidia"
ATTR{device}=="0x24b0", GOTO="configure_nvidia"
ATTR{device}=="0x24b6", GOTO="configure_nvidia"
ATTR{device}=="0x24b7", GOTO="configure_nvidia"
ATTR{device}=="0x24b8", GOTO="configure_nvidia"
ATTR{device}=="0x24dc", GOTO="configure_nvidia"
ATTR{device}=="0x24dd", GOTO="configure_nvidia"
ATTR{device}=="0x2503", GOTO="configure_nvidia"
ATTR{device}=="0x2504", GOTO="configure_nvidia"
ATTR{device}=="0x2520", GOTO="configure_nvidia"
ATTR{device}=="0x2523", GOTO="configure_nvidia"
ATTR{device}=="0x2560", GOTO="configure_nvidia"
ATTR{device}=="0x2563", GOTO="configure_nvidia"
ATTR{device}=="0x25a0", GOTO="configure_nvidia"
ATTR{device}=="0x25a2", GOTO="configure_nvidia"
ATTR{device}=="0x25a5", GOTO="configure_nvidia"
ATTR{device}=="0x25b8", GOTO="configure_nvidia"
ATTR{device}=="0x25e0", GOTO="configure_nvidia"
ATTR{device}=="0x25e2", GOTO="configure_nvidia"
ATTR{device}=="0x25e5", GOTO="configure_nvidia"
GOTO="configure_nvidia-legacy"
LABEL="configure_nvidia"