From a15bc76711a1d50ed38a4e93af99be5e819ac53a Mon Sep 17 00:00:00 2001 From: taz Date: Sat, 24 Jul 2021 11:29:04 +0200 Subject: [PATCH] update 5.11 patch for recent kernels --- 0005-kernel-5.11.patch | 169 ++++++++++++++++++++++++++++++++++++++--- PKGBUILD | 3 +- 2 files changed, 161 insertions(+), 11 deletions(-) diff --git a/0005-kernel-5.11.patch b/0005-kernel-5.11.patch index f401d98..382d7d3 100644 --- a/0005-kernel-5.11.patch +++ b/0005-kernel-5.11.patch @@ -1,25 +1,174 @@ - +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 + #endif + +- #if defined(NV_DRM_DRM_PRIME_H_PRESENT) +- #include +- #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 +@@ -60,6 +60,8 @@ + #else + #include + ++#include "linux/dma-buf.h" ++ + struct nv_drm_agp_head { + struct agp_kern_info agp_info; + struct list_head memory; +@@ -210,8 +212,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; + +@@ -239,8 +243,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]; + +@@ -273,11 +279,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"); + } +@@ -402,6 +410,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 +@@ -420,17 +461,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-02-23 20:01:52.429999710 +0100 -+++ NVIDIA-Linux-x86_64-340.108-new/kernel/nv-linux.h 2021-02-23 14:48:00.163333638 +0100 -@@ -119,7 +119,7 @@ +--- 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 /* flush_tlb(), flush_tlb_all() */ #include /* CPU hotplug support */ #endif -#include /* page table entry lookup */ -+//#include /* page table entry lookup */ ++#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0) ++ #include /* page table entry lookup */ ++#endif #include /* pci_find_class, etc */ #include /* tasklets, interrupt helpers */ ---- a/kernel/uvm/nvidia_uvm_linux.h 2019-12-11 17:04:24.000000000 -0500 -+++ b/kernel/uvm/nvidia_uvm_linux.h 2021-02-24 06:26:26.237367942 -0500 -@@ -141,7 +141,7 @@ +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 /* flush_tlb(), flush_tlb_all() */ #endif -#include /* page table entry lookup */ -+//#include /* page table entry lookup */ ++#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0) ++ #include /* page table entry lookup */ ++#endif #include /* tasklets, interrupt helpers */ #include - diff --git a/PKGBUILD b/PKGBUILD index face377..bd4b384 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -29,7 +29,8 @@ b2sums=('6538bbec53b10f8d20977f9b462052625742e9709ef06e24cf2e55de5d0c55f1620a4bb 'b436095b89d6e294995651a3680ff18b5af5e91582c3f1ec9b7b63be9282497f54f9bf9be3997a5af30eec9b8548f25ec5235d969ac00a667a9cddece63d8896' '947cb1f149b2db9c3c4f973f285d389790f73fc8c8a6865fc5b78d6a782f49513aa565de5c82a81c07515f1164e0e222d26c8212a14cf016e387bcc523e3fcb1' '665bf0e1fa22119592e7c75ff40f265e919955f228a3e3e3ebd76e9dffa5226bece5eb032922eb2c009572b31b28e80cd89656f5d0a4ad592277edd98967e68f' - 'bbea70e129f5a51a06a0c341f731be360f39f6b31a88df39e97c2d8f2daa87dd6c4b3a8becc57f25ad2a26ad567c69208546d907e7334c320796c4140fc78a15') +# 'bbea70e129f5a51a06a0c341f731be360f39f6b31a88df39e97c2d8f2daa87dd6c4b3a8becc57f25ad2a26ad567c69208546d907e7334c320796c4140fc78a15') + '344cd3a9888a9a61941906c198d3a480ce230119c96c72c72a74b711d23face2a7b1e53b9b4639465809b84762cdc53f38210e740318866705241bc4216e4f35') _pkg="NVIDIA-Linux-x86_64-${pkgver}-no-compat32" # default is 'linux' substitute custom name here