diff options
author | Jonathon Fernyhough | 2021-01-09 13:51:18 +0000 |
---|---|---|
committer | Jonathon Fernyhough | 2021-01-09 13:51:18 +0000 |
commit | 3e92eba28c07f8a3ecfaeee59535741462f4a588 (patch) | |
tree | e83d579dc0a6695de2a94dbd8b1a070ba865e732 | |
parent | 6e077bcdfab0605d63fc8c59fc0c934440cd99c2 (diff) | |
download | aur-3e92eba28c07f8a3ecfaeee59535741462f4a588.tar.gz |
Upstream 390.141
https://forums.developer.nvidia.com/t/linux-solaris-and-freebsd-driver-390-141-legacy-for-gf1xx-fermi-gpus/165427
-rw-r--r-- | .SRCINFO | 20 | ||||
-rw-r--r-- | PKGBUILD | 27 | ||||
-rw-r--r-- | kernel-5.8.patch | 109 | ||||
-rw-r--r-- | kernel-5.9.patch | 364 | ||||
-rw-r--r-- | uvm_common-415.18.c | 378 |
5 files changed, 13 insertions, 885 deletions
@@ -1,22 +1,18 @@ pkgbase = nvidia-390xx pkgdesc = NVIDIA drivers for linux, 390xx legacy branch - pkgver = 390.138 - pkgrel = 10 + pkgver = 390.141 + pkgrel = 1 url = https://www.nvidia.com/ arch = x86_64 license = custom - makedepends = nvidia-390xx-utils=390.138 + makedepends = nvidia-390xx-utils=390.141 makedepends = libglvnd makedepends = linux-headers conflicts = nvidia options = !strip - source = https://us.download.nvidia.com/XFree86/Linux-x86_64/390.138/NVIDIA-Linux-x86_64-390.138-no-compat32.run + source = https://us.download.nvidia.com/XFree86/Linux-x86_64/390.141/NVIDIA-Linux-x86_64-390.141-no-compat32.run source = kernel-4.16.patch - source = kernel-5.8.patch - source = kernel-5.9.patch - source = https://gitlab.com/herecura/packages/nvidia-390xx-dkms/-/raw/db83ed8ac2e0e0097d535a82e2fd4ee0f31873e3/kernel-5.10.patch - source = uvm_common-415.18.c - b2sums = bf56cef38d76accdf547b96cd444b0bd4288f604d44a1d274f3246c13310d6a59050b36f384280edb83938db81fa0544f7a2dc84ff6f440ff90b76ee62749fc1 + b2sums = fae33e5fcd8f0429f163ad40e58a07c42ff47260bd1b0f56989d6147d63294c475f33ddc02f06a16eaf8c8ea9f74a98dbcb32b5322c68661331ebf7dfe976770 b2sums = 1d21307640a3844752c92e8344518daf6ad62d846689bebe6eed4dcadbf7b2e742862f5c17c0faee7256662cb75e62e124d59e5a5617e87324e1f0658f2b748d b2sums = 3ea3b298db0af192eb79a67d2307c92229defefc4cf66d09e24b85015de03b64a57b420233ca5532c6f57f35e007bc982c27333f2fc43a016a84cc797f67b191 b2sums = 7358919041a3d5df1cac50f6519b282abe7a344f07b59d52ab95a022ce0af12e743a1c194fd838b5733f3900e68c7f0756a528ac32255775f2ba830a2f052dec @@ -26,15 +22,15 @@ pkgbase = nvidia-390xx pkgname = nvidia-390xx pkgdesc = NVIDIA drivers for linux, 390xx legacy branch depends = linux - depends = nvidia-390xx-utils=390.138 + depends = nvidia-390xx-utils=390.141 depends = libglvnd pkgname = nvidia-390xx-dkms pkgdesc = NVIDIA driver sources for linux, 390xx legacy branch depends = dkms - depends = nvidia-390xx-utils=390.138 + depends = nvidia-390xx-utils=390.141 depends = libglvnd - provides = nvidia-390xx=390.138 + provides = nvidia-390xx=390.141 conflicts = nvidia conflicts = nvidia-390xx @@ -9,8 +9,8 @@ pkgbase=nvidia-390xx pkgname=(nvidia-390xx nvidia-390xx-dkms) -pkgver=390.138 -pkgrel=10 +pkgver=390.141 +pkgrel=1 pkgdesc="NVIDIA drivers for linux, 390xx legacy branch" arch=('x86_64') url="https://www.nvidia.com/" @@ -20,12 +20,8 @@ license=('custom') options=('!strip') _pkg="NVIDIA-Linux-x86_64-${pkgver}-no-compat32" source=("https://us.download.nvidia.com/XFree86/Linux-x86_64/${pkgver}/${_pkg}.run" - 'kernel-4.16.patch' - 'kernel-5.8.patch' - 'kernel-5.9.patch' - 'https://gitlab.com/herecura/packages/nvidia-390xx-dkms/-/raw/db83ed8ac2e0e0097d535a82e2fd4ee0f31873e3/kernel-5.10.patch' - 'uvm_common-415.18.c') -b2sums=('bf56cef38d76accdf547b96cd444b0bd4288f604d44a1d274f3246c13310d6a59050b36f384280edb83938db81fa0544f7a2dc84ff6f440ff90b76ee62749fc1' + 'kernel-4.16.patch') +b2sums=('fae33e5fcd8f0429f163ad40e58a07c42ff47260bd1b0f56989d6147d63294c475f33ddc02f06a16eaf8c8ea9f74a98dbcb32b5322c68661331ebf7dfe976770' '1d21307640a3844752c92e8344518daf6ad62d846689bebe6eed4dcadbf7b2e742862f5c17c0faee7256662cb75e62e124d59e5a5617e87324e1f0658f2b748d' '3ea3b298db0af192eb79a67d2307c92229defefc4cf66d09e24b85015de03b64a57b420233ca5532c6f57f35e007bc982c27333f2fc43a016a84cc797f67b191' '7358919041a3d5df1cac50f6519b282abe7a344f07b59d52ab95a022ce0af12e743a1c194fd838b5733f3900e68c7f0756a528ac32255775f2ba830a2f052dec' @@ -36,23 +32,10 @@ prepare() { sh "${_pkg}.run" --extract-only cd "${_pkg}" - # Use GPL2/MIT code directly from 415.18 release - # https://www.nvidia.com/Download/driverResults.aspx/140282/en-us - install -m644 ../uvm_common-415.18.c kernel/nvidia-uvm/uvm_common.c - - # Restore phys_to_dma support (still needed for 396.18) (and still needed for 390.138) + # Restore phys_to_dma support (still needed for 390.138) # From loqs via https://bugs.archlinux.org/task/58074 patch -Np1 -i ../kernel-4.16.patch - # 5.8 Patch, Alberto Milone - patch -Np1 -i ../kernel-5.8.patch - - # 5.9 Patch, from loqs - patch -Np1 -i ../kernel-5.9.patch - - # 5.10 Patch, from xtrymind and BlackIkeEagle - patch -Np1 -i ../kernel-5.10.patch - cp -a kernel kernel-dkms cd kernel-dkms sed -i "s/__VERSION_STRING/${pkgver}/" dkms.conf diff --git a/kernel-5.8.patch b/kernel-5.8.patch deleted file mode 100644 index 5140e3471af5..000000000000 --- a/kernel-5.8.patch +++ /dev/null @@ -1,109 +0,0 @@ -From 6fe02b8d6b5d1a0400bf4f5f1e69327b138d4f8b Mon Sep 17 00:00:00 2001 -From: Alberto Milone <alberto.milone@canonical.com> -Date: Mon, 13 Jul 2020 14:04:41 +0200 -Subject: [PATCH 1/1] Add support for Linux 5.8 - ---- - kernel/common/inc/nv-linux.h | 4 ++++ - kernel/common/inc/nv-mm.h | 4 ++++ - kernel/conftest.sh | 38 ++++++++++++++++++++++++++++++++++++++ - kernel/nvidia/nvidia.Kbuild | 2 ++ - 4 files changed, 48 insertions(+) - -diff --git a/kernel/common/inc/nv-linux.h b/kernel/common/inc/nv-linux.h -index ac5bb95..3d2f0b7 100644 ---- a/kernel/common/inc/nv-linux.h -+++ b/kernel/common/inc/nv-linux.h -@@ -531,7 +531,11 @@ extern int nv_pat_mode; - - static inline void *nv_vmalloc(unsigned long size) - { -+#if defined(NV_VMALLOC_HAS_PGPROT_T_ARG) - void *ptr = __vmalloc(size, GFP_KERNEL, PAGE_KERNEL); -+#else -+ void *ptr = __vmalloc(size, GFP_KERNEL); -+#endif - if (ptr) - NV_MEMDBG_ADD(ptr, size); - return ptr; -diff --git a/kernel/common/inc/nv-mm.h b/kernel/common/inc/nv-mm.h -index 1270bf3..d2d7657 100644 ---- a/kernel/common/inc/nv-mm.h -+++ b/kernel/common/inc/nv-mm.h -@@ -29,6 +29,10 @@ - typedef int vm_fault_t; - #endif - -+#if defined(NV_MM_HAS_MMAP_LOCK) -+#define mmap_sem mmap_lock -+#endif -+ - /* get_user_pages - * - * The 8-argument version of get_user_pages was deprecated by commit -diff --git a/kernel/conftest.sh b/kernel/conftest.sh -index 7da7505..7793dd6 100755 ---- a/kernel/conftest.sh -+++ b/kernel/conftest.sh -@@ -4067,6 +4067,44 @@ compile_test() { - compile_check_conftest "$CODE" "NV_KTIME_GET_REAL_TS64_PRESENT" "" "functions" - ;; - -+ vmalloc_has_pgprot_t_arg) -+ # -+ # Determine if __vmalloc has the 'pgprot' argument. -+ # -+ # The third argument to __vmalloc, page protection -+ # 'pgprot_t prot', was removed by commit 88dca4ca5a93 -+ # (mm: remove the pgprot argument to __vmalloc) -+ # in v5.8-rc1 (2020-06-01). -+ CODE=" -+ #include <linux/vmalloc.h> -+ -+ void conftest_vmalloc_has_pgprot_t_arg(void) { -+ pgprot_t prot; -+ (void)__vmalloc(0, 0, prot); -+ }" -+ -+ compile_check_conftest "$CODE" "NV_VMALLOC_HAS_PGPROT_T_ARG" "" "types" -+ -+ ;; -+ -+ mm_has_mmap_lock) -+ # -+ # Determine if the 'mm_struct' structure has a 'mmap_lock' field. -+ # -+ # Kernel commit da1c55f1b272 ("mmap locking API: rename mmap_sem -+ # to mmap_lock") replaced the field 'mmap_sem' by 'mmap_lock' -+ # in v5.8-rc1 (2020-06-08). -+ CODE=" -+ #include <linux/mm_types.h> -+ -+ int conftest_mm_has_mmap_lock(void) { -+ return offsetof(struct mm_struct, mmap_lock); -+ }" -+ -+ compile_check_conftest "$CODE" "NV_MM_HAS_MMAP_LOCK" "" "types" -+ -+ ;; -+ - pci_dev_has_skip_bus_pm) - # - # Determine if skip_bus_pm flag is present in struct pci_dev. -diff --git a/kernel/nvidia/nvidia.Kbuild b/kernel/nvidia/nvidia.Kbuild -index 63e369f..656db7b 100644 ---- a/kernel/nvidia/nvidia.Kbuild -+++ b/kernel/nvidia/nvidia.Kbuild -@@ -192,7 +192,9 @@ NV_CONFTEST_TYPE_COMPILE_TESTS += iterate_dir - NV_CONFTEST_TYPE_COMPILE_TESTS += kstrtoull - NV_CONFTEST_TYPE_COMPILE_TESTS += backlight_properties_type - NV_CONFTEST_TYPE_COMPILE_TESTS += proc_ops -+NV_CONFTEST_TYPE_COMPILE_TESTS += vmalloc_has_pgprot_t_arg - NV_CONFTEST_TYPE_COMPILE_TESTS += timeval -+NV_CONFTEST_TYPE_COMPILE_TESTS += mm_has_mmap_lock - NV_CONFTEST_TYPE_COMPILE_TESTS += kmem_cache_has_kobj_remove_work - NV_CONFTEST_TYPE_COMPILE_TESTS += sysfs_slab_unlink - NV_CONFTEST_TYPE_COMPILE_TESTS += pci_dev_has_skip_bus_pm --- -2.25.1 - diff --git a/kernel-5.9.patch b/kernel-5.9.patch deleted file mode 100644 index d01eba7ab66d..000000000000 --- a/kernel-5.9.patch +++ /dev/null @@ -1,364 +0,0 @@ -diff --git a/kernel/common/inc/nv-linux.h b/kernel/common/inc/nv-linux.h -index ab06dbc..dd335b5 100644 ---- a/kernel/common/inc/nv-linux.h -+++ b/kernel/common/inc/nv-linux.h -@@ -159,7 +159,7 @@ static inline uid_t __kuid_val(kuid_t uid) - } - #endif - --#if defined(NVCPU_X86_64) && !defined(HAVE_COMPAT_IOCTL) -+#if defined(NVCPU_X86_64) && !defined(NV_FILE_OPERATIONS_HAS_COMPAT_IOCTL) - #include <linux/syscalls.h> /* sys_ioctl() */ - #include <linux/ioctl32.h> /* register_ioctl32_conversion() */ - #endif -diff --git a/kernel/common/inc/nv-mm.h b/kernel/common/inc/nv-mm.h -index d2d7657..a5325fe 100644 ---- a/kernel/common/inc/nv-mm.h -+++ b/kernel/common/inc/nv-mm.h -@@ -144,9 +144,13 @@ typedef int vm_fault_t; - flags |= FOLL_FORCE; - - #if defined(NV_GET_USER_PAGES_REMOTE_HAS_LOCKED_ARG) -- -+ #if defined (NV_GET_USER_PAGES_REMOTE_HAS_TSK_ARG) - return get_user_pages_remote(tsk, mm, start, nr_pages, flags, - pages, vmas, NULL); -+ #else -+ return get_user_pages_remote(mm, start, nr_pages, flags, -+ pages, vmas, NULL); -+ #endif - - #else - -@@ -159,7 +163,7 @@ typedef int vm_fault_t; - #endif - #else - #if defined(NV_GET_USER_PAGES_HAS_WRITE_AND_FORCE_ARGS) -- #define NV_GET_USER_PAGES_REMOTE NV_GET_USER_PAGES -+ #define NV_GET_USER_PAGES_REMOTE get_user_pages - #else - #include <linux/mm.h> - #include <linux/sched.h> -diff --git a/kernel/conftest.sh b/kernel/conftest.sh -index e900963..ef82dee 100755 ---- a/kernel/conftest.sh -+++ b/kernel/conftest.sh -@@ -3043,6 +3043,7 @@ compile_test() { - - if [ -f conftest$$.o ]; then - echo "#undef NV_GET_USER_PAGES_REMOTE_PRESENT" | append_conftest "functions" -+ echo "#undef NV_GET_USER_PAGES_REMOTE_HAS_TSK_ARG" | append_conftest "functions" - echo "#undef NV_GET_USER_PAGES_REMOTE_HAS_WRITE_AND_FORCE_ARGS" | append_conftest "functions" - echo "#undef NV_GET_USER_PAGES_REMOTE_HAS_LOCKED_ARG" | append_conftest "functions" - rm -f conftest$$.o -@@ -3070,14 +3071,20 @@ compile_test() { - rm -f conftest$$.c - - if [ -f conftest$$.o ]; then -+ echo "#define NV_GET_USER_PAGES_REMOTE_HAS_TSK_ARG" | append_conftest "functions" - echo "#define NV_GET_USER_PAGES_REMOTE_HAS_WRITE_AND_FORCE_ARGS" | append_conftest "functions" - echo "#undef NV_GET_USER_PAGES_REMOTE_HAS_LOCKED_ARG" | append_conftest "functions" - rm -f conftest$$.o - return - fi - -+ echo "#undef NV_GET_USER_PAGES_REMOTE_HAS_WRITE_AND_FORCE_ARGS" | append_conftest "functions" -+ -+ # - # conftest #3: check if get_user_pages_remote() has locked argument -- -+ # Return if these arguments are present. Fall through to conftest #4 -+ # if these args are absent. -+ # - echo "$CONFTEST_PREAMBLE - #include <linux/mm.h> - long get_user_pages_remote(struct task_struct *tsk, -@@ -3095,13 +3102,40 @@ compile_test() { - rm -f conftest$$.c - - if [ -f conftest$$.o ]; then -+ echo "#define NV_GET_USER_PAGES_REMOTE_HAS_TSK_ARG" | append_conftest "functions" -+ echo "#define NV_GET_USER_PAGES_REMOTE_HAS_LOCKED_ARG" | append_conftest "functions" -+ rm -f conftest$$.o -+ return -+ fi -+ -+ # -+ # conftest #4: check if get_user_pages_remote() does not take -+ # tsk argument. -+ # -+ echo "$CONFTEST_PREAMBLE -+ #include <linux/mm.h> -+ long get_user_pages_remote(struct mm_struct *mm, -+ unsigned long start, -+ unsigned long nr_pages, -+ unsigned int gup_flags, -+ struct page **pages, -+ struct vm_area_struct **vmas, -+ int *locked) { -+ return 0; -+ }" > conftest$$.c -+ -+ $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1 -+ rm -f conftest$$.c -+ -+ if [ -f conftest$$.o ]; then -+ echo "#undef NV_GET_USER_PAGES_REMOTE_HAS_TSK_ARG" | append_conftest "functions" - echo "#define NV_GET_USER_PAGES_REMOTE_HAS_LOCKED_ARG" | append_conftest "functions" - rm -f conftest$$.o - else -+ -+ echo "#define NV_GET_USER_PAGES_REMOTE_HAS_TSK_ARG" | append_conftest "functions" - echo "#undef NV_GET_USER_PAGES_REMOTE_HAS_LOCKED_ARG" | append_conftest "functions" - fi -- echo "#undef NV_GET_USER_PAGES_REMOTE_HAS_WRITE_AND_FORCE_ARGS" | append_conftest "functions" -- - ;; - - usleep_range) -@@ -4131,6 +4165,115 @@ compile_test() { - compile_check_conftest "$CODE" "NV_PCI_DEV_HAS_SKIP_BUS_PM" "" "types" - ;; - -+ drm_gem_object_put_unlocked) -+ # -+ # Determine if the function drm_gem_object_put_unlocked() is present. -+ # -+ # In v5.9-rc1, commit 2f4dd13d4bb8 ("drm/gem: add -+ # drm_gem_object_put helper") removes drm_gem_object_put_unlocked() -+ # function and replace its definition by transient macro. Commit -+ # ab15d56e27be ("drm: remove transient -+ # drm_gem_object_put_unlocked()") finally removes -+ # drm_gem_object_put_unlocked() macro. -+ # -+ CODE=" -+ #if defined(NV_DRM_DRMP_H_PRESENT) -+ #include <drm/drmP.h> -+ #endif -+ -+ #if defined(NV_DRM_DRM_GEM_H_PRESENT) -+ #include <drm/drm_gem.h> -+ #endif -+ void conftest_drm_gem_object_put_unlocked(void) { -+ drm_gem_object_put_unlocked(); -+ }" -+ -+ compile_check_conftest "$CODE" "NV_DRM_GEM_OBJECT_PUT_UNLOCK_PRESENT" "" "functions" -+ ;; -+ -+ drm_display_mode_has_vrefresh) -+ # -+ # Determine if the 'drm_display_mode' structure has a 'vrefresh' -+ # field. -+ # -+ # Removed by commit 0425662fdf05 ("drm: Nuke mode->vrefresh") in -+ # v5.9-rc1. -+ # -+ CODE=" -+ #include <drm/drm_modes.h> -+ -+ int conftest_drm_display_mode_has_vrefresh(void) { -+ return offsetof(struct drm_display_mode, vrefresh); -+ }" -+ -+ compile_check_conftest "$CODE" "NV_DRM_DISPLAY_MODE_HAS_VREFRESH" "types" -+ -+ ;; -+ -+ drm_driver_master_set_has_int_return_type) -+ # -+ # Determine if drm_driver::master_set() returns integer value -+ # -+ # Changed to void by commit 907f53200f98 ("drm: vmwgfx: remove -+ # drm_driver::master_set() return type") in v5.9-rc1. -+ # -+ CODE=" -+ #if defined(NV_DRM_DRMP_H_PRESENT) -+ #include <drm/drmP.h> -+ #endif -+ -+ #if defined(NV_DRM_DRM_DRV_H_PRESENT) -+ #include <drm/drm_drv.h> -+ #endif -+ -+ int conftest_drm_driver_master_set_has_int_return_type(struct drm_driver *drv, -+ struct drm_device *dev, struct drm_file *file_priv, bool from_open) { -+ -+ return drv->master_set(dev, file_priv, from_open); -+ }" -+ -+ compile_check_conftest "$CODE" "NV_DRM_DRIVER_SET_MASTER_HAS_INT_RETURN_TYPE" "" "types" -+ ;; -+ -+ drm_driver_has_gem_free_object) -+ # -+ # Determine if the 'drm_driver' structure has a 'gem_free_object' -+ # function pointer. -+ # -+ # drm_driver::gem_free_object is removed by commit 1a9458aeb8eb -+ # ("drm: remove drm_driver::gem_free_object") in v5.9-rc1. -+ # -+ CODE=" -+ #if defined(NV_DRM_DRMP_H_PRESENT) -+ #include <drm/drmP.h> -+ #endif -+ -+ #if defined(NV_DRM_DRM_DRV_H_PRESENT) -+ #include <drm/drm_drv.h> -+ #endif -+ -+ int conftest_drm_driver_has_gem_free_object(void) { -+ return offsetof(struct drm_driver, gem_free_object); -+ }" -+ -+ compile_check_conftest "$CODE" "NV_DRM_DRIVER_HAS_GEM_FREE_OBJECT" "" "types" -+ ;; -+ -+ vga_tryget) -+ # -+ # Determine if vga_tryget() is present -+ # -+ # vga_tryget() was removed by commit f369bc3f9096 ("vgaarb: mark -+ # vga_tryget static") in v5.9-rc1 (2020-08-01). -+ # -+ CODE=" -+ #include <linux/vgaarb.h> -+ void conftest_vga_tryget(void) { -+ vga_tryget(); -+ }" -+ -+ compile_check_conftest "$CODE" "NV_VGA_TRYGET_PRESENT" "" "functions" -+ ;; - esac - } - -diff --git a/kernel/nvidia-drm/nvidia-drm-drv.c b/kernel/nvidia-drm/nvidia-drm-drv.c -index 17e377d..85d9798 100644 ---- a/kernel/nvidia-drm/nvidia-drm-drv.c -+++ b/kernel/nvidia-drm/nvidia-drm-drv.c -@@ -466,8 +466,8 @@ static void nv_drm_unload(struct drm_device *dev) - - #if defined(NV_DRM_ATOMIC_MODESET_AVAILABLE) - --static int nv_drm_master_set(struct drm_device *dev, -- struct drm_file *file_priv, bool from_open) -+static int __nv_drm_master_set(struct drm_device *dev, -+ struct drm_file *file_priv, bool from_open) - { - struct nv_drm_device *nv_dev = to_nv_device(dev); - -@@ -478,6 +478,22 @@ static int nv_drm_master_set(struct drm_device *dev, - return 0; - } - -+#include <linux/version.h> -+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 9, 0) -+static int nv_drm_master_set(struct drm_device *dev, -+ struct drm_file *file_priv, bool from_open) -+{ -+ return __nv_drm_master_set(dev, file_priv, from_open); -+} -+#else -+static void nv_drm_master_set(struct drm_device *dev, -+ struct drm_file *file_priv, bool from_open) -+{ -+ WARN_ON(__nv_drm_master_set(dev, file_priv, from_open) != 0); -+} -+#endif -+ -+ - #if defined(NV_DRM_MASTER_DROP_HAS_FROM_RELEASE_ARG) - static - void nv_drm_master_drop(struct drm_device *dev, -@@ -677,7 +693,9 @@ static struct drm_driver nv_drm_driver = { - #endif - DRIVER_GEM | DRIVER_RENDER, - -+#if defined(NV_DRM_DRIVER_HAS_GEM_FREE_OBJECT) - .gem_free_object = nv_drm_gem_free, -+#endif - - .ioctls = nv_drm_ioctls, - .num_ioctls = ARRAY_SIZE(nv_drm_ioctls), -diff --git a/kernel/nvidia-drm/nvidia-drm-gem.h b/kernel/nvidia-drm/nvidia-drm-gem.h -index 5691a7a..18c50ca 100644 ---- a/kernel/nvidia-drm/nvidia-drm-gem.h -+++ b/kernel/nvidia-drm/nvidia-drm-gem.h -@@ -87,7 +87,13 @@ static inline void - nv_drm_gem_object_unreference_unlocked(struct nv_drm_gem_object *nv_gem) - { - #if defined(NV_DRM_GEM_OBJECT_GET_PRESENT) -+ -+#if defined(NV_DRM_GEM_OBJECT_PUT_UNLOCK_PRESENT) - drm_gem_object_put_unlocked(&nv_gem->base); -+#else -+ drm_gem_object_put(&nv_gem->base); -+#endif -+ - #else - drm_gem_object_unreference_unlocked(&nv_gem->base); - #endif -diff --git a/kernel/nvidia-drm/nvidia-drm-utils.c b/kernel/nvidia-drm/nvidia-drm-utils.c -index 8cb2d5e..e30b2b6 100644 ---- a/kernel/nvidia-drm/nvidia-drm-utils.c -+++ b/kernel/nvidia-drm/nvidia-drm-utils.c -@@ -103,7 +103,9 @@ void - nvkms_display_mode_to_drm_mode(const struct NvKmsKapiDisplayMode *displayMode, - struct drm_display_mode *mode) - { -+#if defined(NV_DRM_DISPLAY_MODE_HAS_VREFRESH) - mode->vrefresh = (displayMode->timings.refreshRate + 500) / 1000; /* In Hz */ -+#endif - - mode->clock = (displayMode->timings.pixelClockHz + 500) / 1000; /* In Hz */ - -@@ -189,7 +191,11 @@ bool drm_format_to_nvkms_format(u32 format, - void drm_mode_to_nvkms_display_mode(const struct drm_display_mode *src, - struct NvKmsKapiDisplayMode *dst) - { -+#if defined(NV_DRM_DISPLAY_MODE_HAS_VREFRESH) - dst->timings.refreshRate = src->vrefresh * 1000; -+#else -+ dst->timings.refreshRate = drm_mode_vrefresh(src) * 1000; -+#endif - - dst->timings.pixelClockHz = src->clock * 1000; /* In Hz */ - -diff --git a/kernel/nvidia-uvm/uvm8_tools.c b/kernel/nvidia-uvm/uvm8_tools.c -index 86dbb77..63d0b64 100644 ---- a/kernel/nvidia-uvm/uvm8_tools.c -+++ b/kernel/nvidia-uvm/uvm8_tools.c -@@ -190,7 +190,6 @@ static uvm_tools_event_tracker_t *tools_event_tracker(struct file *filp) - { - long event_tracker = atomic_long_read((atomic_long_t *)&filp->private_data); - -- smp_read_barrier_depends(); - return (uvm_tools_event_tracker_t *)event_tracker; - } - -diff --git a/kernel/nvidia-uvm/uvm8_va_range.h b/kernel/nvidia-uvm/uvm8_va_range.h -index 8cae357..6166cc8 100644 ---- a/kernel/nvidia-uvm/uvm8_va_range.h -+++ b/kernel/nvidia-uvm/uvm8_va_range.h -@@ -717,7 +717,6 @@ static uvm_va_block_t *uvm_va_range_block(uvm_va_range_t *va_range, size_t index - // make sure that any initialization of this block by the creating thread is - // visible to later accesses in this thread, which requires a data - // dependency barrier. -- smp_read_barrier_depends(); - return block; - } - -diff --git a/kernel/nvidia/nv.c b/kernel/nvidia/nv.c -index 15983f6..cfb2375 100644 ---- a/kernel/nvidia/nv.c -+++ b/kernel/nvidia/nv.c -@@ -3872,7 +3872,9 @@ nvidia_probe - - #if defined(CONFIG_VGA_ARB) && !defined(NVCPU_PPC64LE) - #if defined(VGA_DEFAULT_DEVICE) -+#if defined(NV_VGA_TRYGET_PRESENT) - vga_tryget(VGA_DEFAULT_DEVICE, VGA_RSRC_LEGACY_MASK); -+#endif - #endif - vga_set_legacy_decoding(dev, VGA_RSRC_NONE); - #endif diff --git a/uvm_common-415.18.c b/uvm_common-415.18.c deleted file mode 100644 index fe227514ca89..000000000000 --- a/uvm_common-415.18.c +++ /dev/null @@ -1,378 +0,0 @@ -/******************************************************************************* - Copyright (c) 2013-2018 NVIDIA Corporation - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*******************************************************************************/ - -/* - * This file contains code that is common to all variants of the (Linux) UVM - * kernel module. - */ - -#include "uvm_common.h" -#include "uvm_linux.h" - -// TODO: Bug 1766109: Remove this when the GPU event stubs are no longer needed -#include "nv_uvm_interface.h" - -#include "uvm8_init.h" -#include "uvm8_forward_decl.h" - -// TODO: Bug 1710855: Tweak this number through benchmarks -#define UVM_SPIN_LOOP_SCHEDULE_TIMEOUT_NS (10*1000ULL) -#define UVM_SPIN_LOOP_PRINT_TIMEOUT_SEC 30ULL - -static dev_t g_uvmBaseDev; -struct UvmOpsUvmEvents g_exportedUvmOps; - -static char* uvm_driver_mode = "8"; - -// There used to be other choices, but now there is only one driver mode: 8. -// If no more choices show up soon, we may just delete this module parameter -// entirely. -module_param(uvm_driver_mode, charp, S_IRUGO); -MODULE_PARM_DESC(uvm_driver_mode, - "Set the uvm kernel driver mode. Choices include: 8"); - -// Default to debug prints being enabled for debug and develop builds and -// disabled for release builds. -static int uvm_debug_prints = UVM_IS_DEBUG() || UVM_IS_DEVELOP(); - -// Make the module param writable so that prints can be enabled or disabled at -// any time by modifying the module parameter. -module_param(uvm_debug_prints, int, S_IRUGO|S_IWUSR); -MODULE_PARM_DESC(uvm_debug_prints, "Enable uvm debug prints."); - -bool uvm_debug_prints_enabled() -{ - return uvm_debug_prints != 0; -} - -typedef enum -{ - UVM_DRIVER_MODE_8, -} UvmDriverMode; - -static const char * uvm_driver_mode_to_string(UvmDriverMode uvmDriverMode) -{ - switch (uvmDriverMode) - { - case UVM_DRIVER_MODE_8: - return "8"; - } - return "invalid"; -} - -static UvmDriverMode uvm_get_mode(void) -{ - static NvBool bUvmDriverModeChecked = NV_FALSE; - static UvmDriverMode uvmDriverMode; - - if (!bUvmDriverModeChecked) - { - uvmDriverMode = UVM_DRIVER_MODE_8; - - bUvmDriverModeChecked = NV_TRUE; - } - - return uvmDriverMode; -} - -NV_STATUS uvm_api_initialize(UVM_INITIALIZE_PARAMS *params, struct file *filp) -{ - params->rmStatus = uvm8_initialize(params, filp); - return params->rmStatus; -} - -// This function serves to 'stub' out functionality by being a No-Op and -// returning NV_OK early. -NV_STATUS uvm_api_stub(void *pParams, struct file *filp) -{ - return NV_OK; -} - -// This function serves to identify functionality that isn't supported -// in this UVM driver, by returning NV_ERR_NOT_SUPPORTED early. -NV_STATUS uvm_api_unsupported(void *pParams, struct file *filp) -{ - return NV_ERR_NOT_SUPPORTED; -} - -// -// TODO: Bug 1766109: uvm8: delete UVM-Lite files and remove -lite mode -// ...just remove -lite mode, instead of the original to-do: which was: -// -static int __init uvm_init(void) -{ - NvBool allocated_dev = NV_FALSE; - - // The various helper init routines will create their own minor devices, so - // we only need to create space for them here. - int ret = alloc_chrdev_region(&g_uvmBaseDev, - 0, - NVIDIA_UVM_NUM_MINOR_DEVICES, - NVIDIA_UVM_DEVICE_NAME); - if (ret != 0) { - UVM_ERR_PRINT("alloc_chrdev_region failed: %d\n", ret); - goto error; - } - allocated_dev = NV_TRUE; - - ret = uvm8_init(g_uvmBaseDev); - - if (ret != 0) { - UVM_ERR_PRINT("uvm init failed: %d\n", ret); - goto error; - } - - pr_info("Loaded the UVM driver in %s mode, major device number %d\n", - uvm_driver_mode_to_string(uvm_get_mode()), MAJOR(g_uvmBaseDev)); - - if (uvm_enable_builtin_tests) - pr_info("Built-in UVM tests are enabled. This is a security risk.\n"); - - return 0; - -error: - if (allocated_dev) - unregister_chrdev_region(g_uvmBaseDev, NVIDIA_UVM_NUM_MINOR_DEVICES); - - return ret; -} - -static void __exit uvm_exit(void) -{ - uvm8_exit(); - - unregister_chrdev_region(g_uvmBaseDev, NVIDIA_UVM_NUM_MINOR_DEVICES); - - pr_info("Unloaded the UVM driver in %s mode\n", uvm_driver_mode_to_string(uvm_get_mode())); -} - -// -// Convert kernel errno codes to corresponding NV_STATUS -// -NV_STATUS errno_to_nv_status(int errnoCode) -{ - if (errnoCode < 0) - errnoCode = -errnoCode; - - switch (errnoCode) - { - case 0: - return NV_OK; - - case E2BIG: - case EINVAL: - return NV_ERR_INVALID_ARGUMENT; - - case EACCES: - return NV_ERR_INVALID_ACCESS_TYPE; - - case EADDRINUSE: - case EADDRNOTAVAIL: - return NV_ERR_UVM_ADDRESS_IN_USE; - - case EFAULT: - return NV_ERR_INVALID_ADDRESS; - - case EINTR: - case EBUSY: - return NV_ERR_BUSY_RETRY; - - case ENXIO: - case ENODEV: - return NV_ERR_MODULE_LOAD_FAILED; - - case ENOMEM: - return NV_ERR_NO_MEMORY; - - case EPERM: - return NV_ERR_INSUFFICIENT_PERMISSIONS; - - case ESRCH: - return NV_ERR_PID_NOT_FOUND; - - case ETIMEDOUT: - return NV_ERR_TIMEOUT; - - case EEXIST: - return NV_ERR_IN_USE; - - case ENOSYS: - return NV_ERR_NOT_SUPPORTED; - - case ENOENT: - return NV_ERR_NO_VALID_PATH; - - case EIO: - return NV_ERR_RC_ERROR; - - default: - return NV_ERR_GENERIC; - }; -} - -// Returns POSITIVE errno -int nv_status_to_errno(NV_STATUS status) -{ - switch (status) { - case NV_OK: - return 0; - - case NV_ERR_BUSY_RETRY: - return EBUSY; - - case NV_ERR_INSUFFICIENT_PERMISSIONS: - return EPERM; - - case NV_ERR_GPU_UUID_NOT_FOUND: - return ENODEV; - - case NV_ERR_INSUFFICIENT_RESOURCES: - case NV_ERR_NO_MEMORY: - return ENOMEM; - - case NV_ERR_INVALID_ACCESS_TYPE: - return EACCES; - - case NV_ERR_INVALID_ADDRESS: - return EFAULT; - - case NV_ERR_INVALID_ARGUMENT: - case NV_ERR_INVALID_DEVICE: - case NV_ERR_INVALID_PARAMETER: - case NV_ERR_INVALID_REQUEST: - case NV_ERR_INVALID_STATE: - return EINVAL; - - case NV_ERR_NOT_SUPPORTED: - return ENOSYS; - - case NV_ERR_MODULE_LOAD_FAILED: - return ENXIO; - - case NV_ERR_OVERLAPPING_UVM_COMMIT: - case NV_ERR_UVM_ADDRESS_IN_USE: - return EADDRINUSE; - - case NV_ERR_PID_NOT_FOUND: - return ESRCH; - - case NV_ERR_TIMEOUT: - case NV_ERR_TIMEOUT_RETRY: - return ETIMEDOUT; - - case NV_ERR_IN_USE: - return EEXIST; - - case NV_ERR_NO_VALID_PATH: - return ENOENT; - - case NV_ERR_RC_ERROR: - case NV_ERR_ECC_ERROR: - return EIO; - - default: - UVM_ASSERT_MSG(0, "No errno conversion set up for NV_STATUS %s\n", nvstatusToString(status)); - return EINVAL; - } -} - -// -// This routine retrieves the process ID of current, but makes no attempt to -// refcount or lock the pid in place, because that capability is only available -// to GPL-licenses device drivers. -// -// TODO: Bug 1483843: Use the GPL-protected routines if and when we are able to -// change over to a dual MIT/GPL license. -// -unsigned uvm_get_stale_process_id(void) -{ - return (unsigned) current->tgid; -} - -unsigned uvm_get_stale_thread_id(void) -{ - return (unsigned) current->pid; -} - -// -// A simple security rule for allowing access to UVM user space memory: if you -// are the same user as the owner of the memory, or if you are root, then you -// are granted access. The idea is to allow debuggers and profilers to work, but -// without opening up any security holes. -// -NvBool uvm_user_id_security_check(uid_t euidTarget) -{ - return (NV_CURRENT_EUID() == euidTarget) || - (UVM_ROOT_UID == euidTarget); -} - -void on_uvm_assert(void) -{ - (void)NULL; -} - -NV_STATUS uvm_spin_loop(uvm_spin_loop_t *spin) -{ - NvU64 curr = NV_GETTIME(); - - // This schedule() is required for functionality, not just system - // performance. It allows RM to run and unblock the UVM driver: - // - // - UVM must service faults in order for RM to idle/preempt a context - // - RM must service interrupts which stall UVM (SW methods, stalling CE - // interrupts, etc) in order for UVM to service faults - // - // Even though UVM's bottom half is preemptable, we have encountered cases - // in which a user thread running in RM won't preempt the UVM driver's - // thread unless the UVM driver thread gives up its timeslice. This is also - // theoretically possible if the RM thread has a low nice priority. - // - // TODO: Bug 1710855: Look into proper prioritization of these threads as a longer-term - // solution. - if (curr - spin->start_time_ns >= UVM_SPIN_LOOP_SCHEDULE_TIMEOUT_NS && NV_MAY_SLEEP()) { - schedule(); - curr = NV_GETTIME(); - } - - cpu_relax(); - - // TODO: Bug 1710855: Also check fatal_signal_pending() here if the caller can handle it. - - if (curr - spin->print_time_ns >= 1000*1000*1000*UVM_SPIN_LOOP_PRINT_TIMEOUT_SEC) { - spin->print_time_ns = curr; - return NV_ERR_TIMEOUT_RETRY; - } - - return NV_OK; -} - -module_init(uvm_init); -module_exit(uvm_exit); - -// This parameter allows a program in user mode to call the kernel tests -// defined in this module. This parameter should only be used for testing and -// must not be set to true otherwise since it breaks security when it is -// enabled. By default and for safety reasons this parameter is set to false. -int uvm_enable_builtin_tests = 0; -module_param(uvm_enable_builtin_tests, int, S_IRUGO); -MODULE_PARM_DESC(uvm_enable_builtin_tests, - "Enable the UVM built-in tests. (This is a security risk)"); - -MODULE_LICENSE("Dual MIT/GPL"); -MODULE_INFO(supported, "external"); |