From a9f671fe945c5cff4f44cfbf7c5e01b7e85c37c9 Mon Sep 17 00:00:00 2001 From: Tk-Glitch Date: Thu, 26 Mar 2020 13:52:57 +0100 Subject: [PATCH] nvidia-all: 440.66.04 - previous index was here: https://github.com/Tk-Glitch/PKGBUILDS/tree/master/nvidia-all --- PKGBUILD | 1082 +++++++++++++++++ README.md | 27 + customization.cfg | 41 + patches/01-ipmi-vm.diff | 55 + patches/02-ipmi-vm.diff | 16 + patches/5.6-ioremap.diff | 55 + patches/5.6-legacy-includes.diff | 28 + patches/GFP_RETRY_MAYFAIL-test.diff | 23 + patches/kernel-4.16.patch | 33 + patches/kernel-4.19.patch | 75 ++ patches/kernel-5.0.patch | 646 ++++++++++ patches/kernel-5.1.patch | 98 ++ patches/kernel-5.2.patch | 57 + patches/kernel-5.3.patch | 53 + patches/kernel-5.4-prime.diff | 110 ++ patches/kernel-5.4-symver.diff | 13 + patches/kernel-5.4.patch | 51 + patches/kernel-5.5.patch | 380 ++++++ patches/kernel-5.6.patch | 405 ++++++ patches/linux-version.diff | 166 +++ patches/list_is_first.diff | 39 + system/10-nvidia-drm-outputclass.conf | 15 + system/20-nvidia.conf | 4 + .../egl-wayland/licenses/egl-wayland/COPYING | 20 + .../pkgconfig/wayland-eglstream-protocols.pc | 8 + .../pkgconfig/wayland-eglstream.pc | 12 + .../wayland-eglstream-controller.xml | 87 ++ .../wayland-eglstream/wayland-eglstream.xml | 161 +++ system/nvidia-tkg.install | 54 + system/nvidia-utils-tkg.install | 14 + system/nvidia-utils-tkg.sysusers | 1 + 31 files changed, 3829 insertions(+) create mode 100644 PKGBUILD create mode 100644 README.md create mode 100644 customization.cfg create mode 100644 patches/01-ipmi-vm.diff create mode 100644 patches/02-ipmi-vm.diff create mode 100644 patches/5.6-ioremap.diff create mode 100644 patches/5.6-legacy-includes.diff create mode 100644 patches/GFP_RETRY_MAYFAIL-test.diff create mode 100644 patches/kernel-4.16.patch create mode 100644 patches/kernel-4.19.patch create mode 100644 patches/kernel-5.0.patch create mode 100644 patches/kernel-5.1.patch create mode 100644 patches/kernel-5.2.patch create mode 100644 patches/kernel-5.3.patch create mode 100644 patches/kernel-5.4-prime.diff create mode 100644 patches/kernel-5.4-symver.diff create mode 100644 patches/kernel-5.4.patch create mode 100644 patches/kernel-5.5.patch create mode 100644 patches/kernel-5.6.patch create mode 100644 patches/linux-version.diff create mode 100644 patches/list_is_first.diff create mode 100644 system/10-nvidia-drm-outputclass.conf create mode 100644 system/20-nvidia.conf create mode 100644 system/egl-wayland/licenses/egl-wayland/COPYING create mode 100644 system/egl-wayland/pkgconfig/wayland-eglstream-protocols.pc create mode 100644 system/egl-wayland/pkgconfig/wayland-eglstream.pc create mode 100644 system/egl-wayland/wayland-eglstream/wayland-eglstream-controller.xml create mode 100644 system/egl-wayland/wayland-eglstream/wayland-eglstream.xml create mode 100644 system/nvidia-tkg.install create mode 100644 system/nvidia-utils-tkg.install create mode 100644 system/nvidia-utils-tkg.sysusers diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 0000000..f80c58c --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,1082 @@ +# Created by: Tk-Glitch +# Originally based on https://aur.archlinux.org/packages/nvidia-beta-all/ + +# Includes DKMS support, libglvnd compat, 32-bit libs and building for all kernels currently installed + +plain ' .---.` `.---.' +plain ' `/syhhhyso- -osyhhhys/`' +plain ' .syNMdhNNhss/``.---.``/sshNNhdMNys.' +plain ' +sdMh.`+MNsssssssssssssssNM+`.hMds+' +plain ' :syNNdhNNhssssssssssssssshNNhdNNys:' +plain ' /ssyhhhysssssssssssssssssyhhhyss/' +plain ' .ossssssssssssssssssssssssssssso.' +plain ' :sssssssssssssssssssssssssssssssss:' +plain ' /sssssssssssssssssssssssssssssssssss/' +plain ' :sssssssssssssoosssssssoosssssssssssss:' +plain ' osssssssssssssoosssssssoossssssssssssso' +plain ' osssssssssssyyyyhhhhhhhyyyyssssssssssso' +plain ' /yyyyyyhhdmmmmNNNNNNNNNNNmmmmdhhyyyyyy/' +plain ' smmmNNNNNNNNNNNNNNNNNNNNNNNNNNNNNmmms' +plain ' /dNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNd/' +plain ' `:sdNNNNNNNNNNNNNNNNNNNNNNNNNds:`' +plain ' `-+shdNNNNNNNNNNNNNNNdhs+-`' +plain ' `.-:///////:-.`' +plain '' + +where=$PWD # track basedir as different Arch based distros are moving srcdir around +source "$where"/customization.cfg + +# Load external configuration file if present. Available variable values will overwrite customization.cfg ones. +if [ -e "$_EXT_CONFIG_PATH" ]; then + source "$_EXT_CONFIG_PATH" && msg2 "External configuration file $_EXT_CONFIG_PATH will be used to override customization.cfg values." && msg2 "" +fi + +# Auto-add kernel userpatches to source +_autoaddpatch="false" + +# Some people seem to believe making blank headers is a good idea +if [ $(pacman -Qs linux-headers | head -c1 | wc -c) -eq 0 ]; then + error "A (correctly made?) linux-headers package can't be found." + plain "If you're sure it's installed, blame your kernel maintainer." + read -p " Press enter to proceed anyway..." +fi + +# Package type selector +if [ -z "$_driver_version" ] || [ -z "$_driver_branch" ] && [ ! -e options ]; then + warning "440.48.02 has been unstable for some, so 440.43.02 is recommended for vulkan dev (using \"Custom version\" option)\n" + read -p " What driver version do you want?`echo $'\n > 1.Vulkan dev: 440.66.04\n 2.440 series: 440.64\n 3.435 series: 435.21\n 4.430 series: 430.64\n 5.418 series: 418.113\n 6.415 series: 415.27\n 7.410 series: 410.104\n 8.396 series: 396.54\n 9.Custom version (396.xx series or higher)\n choice[1-9?]: '`" CONDITION; + if [ "$CONDITION" == "2" ]; then + echo '_driver_version=440.64' > options + echo '_md5sum=ba746d5b5f50369139bbed47da04aa74' >> options + echo '_driver_branch=regular' >> options + elif [ "$CONDITION" == "3" ]; then + echo '_driver_version=435.21' > options + echo '_md5sum=050acb0aecc93ba15d1fc609ee82bebe' >> options + echo '_driver_branch=regular' >> options + elif [ "$CONDITION" == "4" ]; then + echo '_driver_version=430.64' > options + echo '_md5sum=a4ea35bf913616c71f104f15092df714' >> options + echo '_driver_branch=regular' >> options + elif [ "$CONDITION" == "5" ]; then + echo '_driver_version=418.113' > options + echo '_md5sum=0b21dbabaa25beed46c20a177e59642e' >> options + echo '_driver_branch=regular' >> options + elif [ "$CONDITION" == "6" ]; then + echo '_driver_version=415.27' > options + echo '_md5sum=f4777691c4673c808d82e37695367f6d' >> options + echo '_driver_branch=regular' >> options + elif [ "$CONDITION" == "7" ]; then + echo '_driver_version=410.104' > options + echo '_md5sum=4f3219b5fad99465dea399fc3f4bb866' >> options + echo '_driver_branch=regular' >> options + elif [ "$CONDITION" == "8" ]; then + echo '_driver_version=396.54' > options + echo '_md5sum=195afa93d400bdbb9361ede6cef95143' >> options + echo '_driver_branch=regular' >> options + elif [ "$CONDITION" == "9" ]; then + echo '_driver_version=custom' > options + read -p "What branch do you want?`echo $'\n> 1.Stable or regular beta\n 2.Vulkan dev\nchoice[1-2?]: '`" CONDITION; + if [ "$CONDITION" == "2" ]; then + echo '_driver_branch=vulkandev' >> options + read -p "Type the desired version number (examples: 415.18.02, 396.54.09): " _driver_version; + else + echo '_driver_branch=regular' >> options + read -p "Type the desired version number (examples: 410.57, 396.51): " _driver_version; + fi + echo "_md5sum='SKIP'" >> options + echo "_driver_version=$_driver_version" >> options + else + echo '_driver_version=440.66.04' > options + echo '_md5sum=127ce8a8e5a7271bf8e1b5f862fe034f' >> options + echo '_driver_branch=vulkandev' >> options + fi +# Package type selector + if [ -z "$_dkms" ]; then + read -p "Build the dkms package or the regular one?`echo $'\n> 1.dkms\n 2.regular\nchoice[1-2?]: '`" CONDITION; + if [ "$CONDITION" == "2" ]; then + echo '_dkms="false"' >> options + else + echo '_dkms="true"' >> options + fi + fi +else + _md5sum='SKIP' +fi + +if [ -e options ]; then + source options +fi + +_pkgname_array=() + +if [ "$_driver_branch" == "vulkandev" ]; then + _branchname="nvidia-dev" +else + _branchname="nvidia" +fi + +# packages +if [ "$_dkms" == "full" ]; then + _pkgname_array+=("$_branchname-dkms-tkg") + _pkgname_array+=("$_branchname-tkg") +elif [ "$_dkms" == "true" ]; then + _pkgname_array+=("$_branchname-dkms-tkg") +else + _pkgname_array+=("$_branchname-tkg") +fi + +_pkgname_array+=("$_branchname-utils-tkg") + +if [ "$_lib32" == "true" ]; then + _pkgname_array+=("lib32-$_branchname-utils-tkg") +fi + +if [ "$_opencl" == "true" ]; then + _pkgname_array+=("opencl-$_branchname-tkg") + if [ "$_lib32" == "true" ]; then + _pkgname_array+=("lib32-opencl-$_branchname-tkg") + fi +fi + +if [ "$_eglwayland" == "true" ]; then + _pkgname_array+=("$_branchname-egl-wayland-tkg") +fi + +pkgname=("${_pkgname_array[@]}") +pkgver=$_driver_version +pkgrel=101 +arch=('x86_64') +url="http://www.nvidia.com/" +license=('custom:NVIDIA') +optdepends=('linux-headers' 'linux-lts-headers: Build the module for LTS Arch kernel') +options=('!strip') + +cp "$where"/patches/* "$where" && cp -r "$where"/system/* "$where" + +# Installer name +_pkg="NVIDIA-Linux-x86_64-$pkgver" + +# Source +if [ "$_driver_branch" == "vulkandev" ]; then + if [[ $pkgver == 396* ]]; then + _source_name="NVIDIA-Linux-x86_64-$pkgver.run::https://developer.nvidia.com/linux-${pkgver//.}" + else + _source_name="NVIDIA-Linux-x86_64-$pkgver.run::https://developer.nvidia.com/vulkan-beta-${pkgver//.}-linux" + fi +else + _source_name="http://us.download.nvidia.com/XFree86/Linux-x86_64/$pkgver/NVIDIA-Linux-x86_64-$pkgver.run" +fi + +source=($_source_name + '10-nvidia-drm-outputclass.conf' + '20-nvidia.conf' + 'nvidia-utils-tkg.sysusers' + 'linux-version.diff' # include linux version + '01-ipmi-vm.diff' # ipmi & vm patch for older than 415.22 releases (2018.12.7) (396.xx) + '02-ipmi-vm.diff' # ipmi & vm patch for older than 415.22 releases (2018.12.7) (addon for 410+) + 'list_is_first.diff' # fix for "redefinition of ‘list_is_first’" on <418.56 drivers when used on 5.1+ + 'kernel-4.16.patch' # 4.16 workaround + 'kernel-4.19.patch' # 4.19 workaround + 'kernel-5.0.patch' # 5.0 workaround + 'kernel-5.1.patch' # 5.1 workaround + 'kernel-5.2.patch' # 5.2 workaround + 'kernel-5.3.patch' # 5.3 workaround + 'kernel-5.4.patch' # 5.4 workaround + 'kernel-5.4-symver.diff' # 5.4 symver fix only + 'kernel-5.4-prime.diff' # 5.4+ PRIME fixing attempt + 'kernel-5.5.patch' # 5.5 workaround + 'kernel-5.6.patch' # 5.6 workaround + '5.6-legacy-includes.diff' # 5.6 includes needed for <440.59(stable) and <440.58.01(vk dev) + '5.6-ioremap.diff' # 5.6 additional ioremap workaround (<440.64) +) + +msg2 "Selected driver integrity check behavior (md5sum or SKIP): $_md5sum" # If the driver is "known", return md5sum. If it isn't, return SKIP + +md5sums=("$_md5sum" + '768a64259f7e8d8a46a13b876d6c443c' + '2640eac092c220073f0668a7aaff61f7' + '3d2894e71d81570bd00bce416d3e547d' + '7a825f41ada7e106c8c0b713a49b3bfa' + 'd961d1dce403c15743eecfe3201e4b6a' + '14460615a9d4e247c8d9bcae8776ed48' + '401859ea7bb4a9864af24ecd67abf34c' + 'adb83cede754daf5adb001f077b1ff67' + '58d058367934813d29d38328bc3b4dcd' + '6cff80c311debfdb6b543e575a81820a' + 'a3ce8ebab6506f556f4b222e2372ce87' + '98b67a671ece0a796f9767793c209c93' + '6f9a62ef76ac86f299b0174f44488987' + '8bf41d705afdf9aad7d934be06a7b12b' + '0d9aa49647cc73a4522246cc22ae15e1' + 'e6270c2d19afd982efc92bdecd9f48f0' + '1c1966d6ee6f3cd381ebcc92f1488c68' + 'c44e43638e1ab708fbdd6d7aa76afcf2' + '84dc2d2eff2846b2f961388b153e2a89' + '1f11f5c765e42c471b202e630e3cd407') + +if [ $_autoaddpatch == "true" ]; then + # Auto-add *.patch files from $startdir to source=() + for _patch in $(find "$startdir" -maxdepth 1 -name '*.patch' -printf "%f\n"); do + # Don't duplicate already listed ones + if [[ ! " ${source[@]} " =~ " $_patch " ]]; then # https://stackoverflow.com/a/15394738/1821548 + source+=("$_patch") + md5sums+=('SKIP') + fi + done +fi + +_create_links() { + # create missing soname links + for _lib in $(find "$pkgdir" -name '*.so*' | grep -v 'xorg/'); do + # Get soname/base name + _soname=$(dirname "$_lib")/$(readelf -d "$_lib" | grep -Po 'SONAME.*: \[\K[^]]*' || true) + _base=$(echo "$_soname" | sed -r 's/(.*).so.*/\1.so/') + + # Create missing links + [ -e "$_soname" ] || ln -s $(basename "$_lib") "$_soname" + [ -e "$_base" ] || ln -s $(basename "$_soname") "$_base" + done +} + +prepare() { + # Remove previous builds + [ -d "$_pkg" ] && rm -rf $_pkg + + # Use custom compiler paths if defined + if [ -n "${CUSTOM_GCC_PATH}" ]; then + PATH=${CUSTOM_GCC_PATH}/bin:${CUSTOM_GCC_PATH}/lib:${CUSTOM_GCC_PATH}/include:${PATH} + fi + + # Extract + msg2 "Self-Extracting $_pkg.run..." + sh $_pkg.run -x + cd $_pkg + + # linux-rt fix for newer drivers. This just passes the same value regardless of kernel type as a bypass. This was stolen from https://gitlab.manjaro.org/packages/community/realtime-kernels/linux416-rt-extramodules/blob/master/nvidia/PKGBUILD - Thanks Muhownage <3 + sed -i -e 's|PREEMPT_RT_PRESENT=1|PREEMPT_RT_PRESENT=0|g' kernel/conftest.sh + + # non-english locale workaround for 440.26 + if [[ $pkgver = 440.26 ]]; then + sed -i -e 's|$CC $CFLAGS -c conftest_headers$$.c|LC_ALL=C $CC $CFLAGS -c conftest_headers$$.c|g' kernel/conftest.sh + fi + + # 440.58.01 Unfrogging + if [[ $pkgver = 440.58.01 ]]; then + sed -i -e '/bug/d' nvidia-application-profiles-440.58.01-rc + fi + + cp -a kernel kernel-dkms + cd kernel-dkms + sed -i "s/__VERSION_STRING/${pkgver}/" dkms.conf + sed -i 's/__JOBS/`nproc`/' dkms.conf + sed -i 's/__DKMS_MODULES//' dkms.conf + sed -i '$iBUILT_MODULE_NAME[0]="nvidia"\ +DEST_MODULE_LOCATION[0]="/kernel/drivers/video"\ +BUILT_MODULE_NAME[1]="nvidia-uvm"\ +DEST_MODULE_LOCATION[1]="/kernel/drivers/video"\ +BUILT_MODULE_NAME[2]="nvidia-modeset"\ +DEST_MODULE_LOCATION[2]="/kernel/drivers/video"\ +BUILT_MODULE_NAME[3]="nvidia-drm"\ +DEST_MODULE_LOCATION[3]="/kernel/drivers/video"' dkms.conf + + # Gift for linux-rt guys + sed -i 's/NV_EXCLUDE_BUILD_MODULES/IGNORE_PREEMPT_RT_PRESENCE=1 NV_EXCLUDE_BUILD_MODULES/' dkms.conf + + cd ../ + bsdtar -xf nvidia-persistenced-init.tar.bz2 + + if [[ $pkgver = 396* ]] || [[ $pkgver = 410* ]] || [[ $pkgver = 415* ]] || [[ $pkgver = 418* ]] || [[ $pkgver = 430* ]]; then + sed -i 's/__NV_VK_ICD__/libGLX_nvidia.so.0/' nvidia_icd.json.template + fi + + # Loop kernels (4.15.0-1-ARCH, 4.14.5-1-ck, ...) + local -a _kernels + mapfile -t _kernels < <(find /usr/lib/modules/*/build/version -exec cat {} +) + for _kernel in "${_kernels[@]}"; do + # Use separate source directories + cp -r kernel kernel-$_kernel + + cd "$srcdir"/"$_pkg"/kernel-$_kernel + msg2 "Applying linux-version.diff for $_kernel..." + patch -p2 -i "$srcdir"/linux-version.diff + cd .. + + ## kernel version variables, quirks & driver patch whitelists + + # https://bugs.archlinux.org/task/62142 + if [ "$_62142_fix" == "true" ]; then + sed -i 's/return (ops->map_resource != NULL);/return (ops \&\& ops->map_resource);/' "$srcdir/$_pkg/kernel-$_kernel/nvidia/nv-dma.c" && msg2 "Applied fix for https://bugs.archlinux.org/task/62142" + fi + + # 4.16 + if (( $(vercmp "$_kernel" "4.16") >= 0 )); then + _kernel416="1" + _whitelist416=( 396* 410* 415* 418.3* 418.4* 418.52.0* 418.52.10 418.52.14 ) + fi + + # 4.19 + if (( $(vercmp "$_kernel" "4.19") >= 0 )); then + _kernel419="1" + _whitelist419=( 396* ) + fi + + # 4.20 + if (( $(vercmp "$_kernel" "4.20") >= 0 )); then + # Fix for "unknown type name 'ipmi_user_t'" (required for older than 2018.12.7 drivers when used on 4.20+) + if [[ $pkgver = 396* ]] || [[ $pkgver = 410.5* ]] || [[ $pkgver = 410.6* ]] || [[ $pkgver = 410.7* ]] || [[ $pkgver = 415.1* ]]; then + _oldstuff="1" + cd "$srcdir"/"$_pkg"/kernel-$_kernel + msg2 "Applying 01-ipmi-vm.diff for $_kernel..." + patch -p2 -i "$srcdir"/01-ipmi-vm.diff + if [[ $pkgver != 396* ]]; then + _youngeryetoldstuff="1" + msg2 "Applying 02-ipmi-vm.diff for $_kernel..." + patch -p2 -i "$srcdir"/02-ipmi-vm.diff + fi + cd .. + else + msg2 "Skipping ipmi-vm fixes (not needed for this driver/kernel combination)" + fi + fi + + # 5.0 + if (( $(vercmp "$_kernel" "5.0") >= 0 )); then + _kernel50="1" + _whitelist50=( 396* 410.5* 410.6* 410.7* 410.9* 415* ) + fi + + # 5.1 + if (( $(vercmp "$_kernel" "5.1") >= 0 )); then + _kernel51="1" + _whitelist51=( 396* 410* 415* 418.3* 418.4* 418.52.0* 418.52.10 ) + if [[ $pkgver != 430* ]]; then + sed -i "s/static int nv_drm_vma_fault(struct vm_fault \*vmf)/#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 1, 0)\nstatic int nv_drm_vma_fault(struct vm_fault \*vmf)\n#else\nstatic vm_fault_t nv_drm_vma_fault(struct vm_fault \*vmf)\n#endif/g" "$srcdir/$_pkg/kernel-$_kernel/nvidia-drm/nvidia-drm-gem-nvkms-memory.c" + if [[ $pkgver = 396* ]] || [[ $pkgver = 410* ]] || [[ $pkgver = 415* ]] || [[ $pkgver = 418.3* ]] || [[ $pkgver = 418.4* ]]; then + _low418="1" + cd "$srcdir"/"$_pkg"/kernel-$_kernel + msg2 "Applying list_is_first.diff for $_kernel..." + # Use sed for the moving parts of the patch - Fix for "redefinition of ‘list_is_first’" (required for older than 418.56 drivers when used on 5.1+) + sed -i "s/static inline int list_is_first(const struct list_head \*list,/#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 1, 0)\nstatic inline int list_is_first(const struct list_head \*list,/g" "$srcdir/$_pkg/kernel-$_kernel/common/inc/nv-list-helpers.h" + sed -i "s/ const struct list_head \*head)/ const struct list_head \*head)\n#else\nstatic inline int nv_list_is_first(const struct list_head \*list,\n const struct list_head \*head)\n#endif/g" "$srcdir/$_pkg/kernel-$_kernel/common/inc/nv-list-helpers.h" + patch -Np2 -i "$srcdir"/list_is_first.diff + cd .. + else + msg2 "Skipping list_is_first fixes (not needed for this driver/kernel combination)" + fi + fi + fi + + # 5.2 + if (( $(vercmp "$_kernel" "5.2") >= 0 )); then + _kernel52="1" + _whitelist52=( 396* 410* 415* 418.3* 418.4* 418.56 418.7* 418.52.0* 418.52.10 418.52.14 ) + fi + + # 5.3 + if (( $(vercmp "$_kernel" "5.3") >= 0 )); then + _kernel53="1" + _whitelist53=( 396* 410* 415* 418.3* 418.4* 418.5* 418.7* 418.8* ) + fi + + # 5.4 + if (( $(vercmp "$_kernel" "5.4") >= 0 )); then + _kernel54="1" + _whitelist54=( 396* 410* 415* 418.3* 418.4* 418.5* 418.7* 418.8* 430.0* 430.1* 430.2* 430.3* 430.4* 430.5* 435.1* 435.21* 435.24* 435.27.01 ) + if [[ $pkgver = 435.27.02 ]] || [[ $pkgver = 435.27.03 ]] || [[ $pkgver = 435.27.06 ]] || [[ $pkgver = 435.27.07 ]] || [[ $pkgver = 435.27.08 ]] || [[ $pkgver = 440.26 ]]; then + cd "$srcdir"/"$_pkg"/kernel-$_kernel + msg2 "Applying kernel-5.4-symver.diff for $_kernel..." + patch -Np2 -i "$srcdir"/kernel-5.4-symver.diff + cd .. + fi + if [[ $pkgver = 396* ]] || [[ $pkgver = 410* ]] || [[ $pkgver = 415* ]] || [[ $pkgver = 418.* ]] || [[ $pkgver = 430.0* ]] || [[ $pkgver = 435.* ]] || [[ $pkgver = 440.2* ]] || [[ $pkgver = 440.3* ]] || [[ $pkgver = 440.43.* ]] || [[ $pkgver = 440.44 ]] && [ "$_54_prime_fixing_attempt" == "true" ]; then + _54_prime="true" + cd "$srcdir"/"$_pkg"/kernel-$_kernel + msg2 "Applying kernel-5.4-prime.diff for $_kernel..." + patch -Np2 -i "$srcdir"/kernel-5.4-prime.diff + cd .. + fi + fi + + # 5.5 + if (( $(vercmp "$_kernel" "5.5") >= 0 )); then + _kernel55="1" + _whitelist55=( 396* 410* 415* 418* 430* 435* 440.2* 440.3* 440.43.01 440.44 ) + fi + + # 5.6 + if (( $(vercmp "$_kernel" "5.6") >= 0 )); then + _kernel56="1" + _whitelist56=( 396* 410* 415* 418* 430* 435* 440.2* 440.3* 440.4* 440.5* 440.6* ) + if [[ $pkgver = 396* ]] || [[ $pkgver = 410* ]] || [[ $pkgver = 415* ]] || [[ $pkgver = 418.* ]] || [[ $pkgver = 430.0* ]] || [[ $pkgver = 435.* ]] || [[ $pkgver = 440.2* ]] || [[ $pkgver = 440.3* ]] || [[ $pkgver = 440.4* ]]; then + cd "$srcdir"/"$_pkg"/kernel-$_kernel + msg2 "Applying 5.6-legacy-includes.diff for $_kernel..." + patch -Np2 -i "$srcdir"/5.6-legacy-includes.diff + msg2 "Applying 5.6-ioremap.diff for $_kernel..." + patch -Np2 -i "$srcdir"/5.6-ioremap.diff + cd .. + elif [[ $pkgver = 440.5* ]]; then + cd "$srcdir"/"$_pkg"/kernel-$_kernel + msg2 "Applying 5.6-ioremap.diff for $_kernel..." + patch -Np2 -i "$srcdir"/5.6-ioremap.diff + cd .. + fi + fi + + # Loop patches (linux-4.15.patch, lol.patch, ...) + for _p in $(printf -- '%s\n' ${source[@]} | grep .patch); do # https://stackoverflow.com/a/21058239/1821548 + # Patch version (4.15, "", ...) + _patch=$(echo $_p | grep -Po "\d+\.\d+") + + # Cd in place + cd "$srcdir"/"$_pkg"/kernel-$_kernel + + if [ "$_patch" == "4.16" ]; then + _whitelist=(${_whitelist416[@]}) + fi + if [ "$_patch" == "4.19" ]; then + _whitelist=(${_whitelist419[@]}) + fi + if [ "$_patch" == "5.0" ]; then + _whitelist=(${_whitelist50[@]}) + fi + if [ "$_patch" == "5.1" ]; then + _whitelist=(${_whitelist51[@]}) + fi + if [ "$_patch" == "5.2" ]; then + _whitelist=(${_whitelist52[@]}) + fi + if [ "$_patch" == "5.3" ]; then + _whitelist=(${_whitelist53[@]}) + fi + if [ "$_patch" == "5.4" ]; then + _whitelist=(${_whitelist54[@]}) + fi + if [ "$_patch" == "5.5" ]; then + _whitelist=(${_whitelist55[@]}) + fi + if [ "$_patch" == "5.6" ]; then + _whitelist=(${_whitelist56[@]}) + fi + + patchy=0 + if (( $(vercmp "$_kernel" "$_patch") >= 0 )); then + for yup in "${_whitelist[@]}"; do + [[ $pkgver = $yup ]] && patchy=1 + done + + if [ "$patchy" == "1" ]; then + msg2 "Applying $_p for $_kernel..." + patch -p2 -i "$srcdir"/$_p + else + msg2 "Skipping $_p as it doesn't apply to this driver version..." + fi + fi + done + + cd .. + + done + + # dkms patches + if [ "$_dkms" == "true" ]; then + + # https://bugs.archlinux.org/task/62142 + if [ "$_62142_fix" == "true" ]; then + sed -i 's/return (ops->map_resource != NULL);/return (ops \&\& ops->map_resource);/' "$srcdir/$_pkg/kernel-dkms/nvidia/nv-dma.c" && msg2 "Applied fix for https://bugs.archlinux.org/task/62142" + fi + + msg2 "Applying linux-version.diff for dkms..." + patch -Np1 -i "$srcdir"/linux-version.diff + + # 4.16 + if [ "$_kernel416" == "1" ]; then + patchy=0 + for yup in "${_whitelist416[@]}"; do + [[ $pkgver = $yup ]] && patchy=1 + done + if [ "$patchy" == "1" ]; then + msg2 "Applying kernel-4.16.patch for dkms..." + patch -Np1 -i "$srcdir"/kernel-4.16.patch + else + msg2 "Skipping kernel-4.16.patch as it doesn't apply to this driver version..." + fi + fi + + # 4.19 + if [ "$_kernel419" == "1" ]; then + patchy=0 + for yup in "${_whitelist419[@]}"; do + [[ $pkgver = $yup ]] && patchy=1 + done + if [ "$patchy" == "1" ]; then + msg2 "Applying kernel-4.19.patch for dkms..." + patch -Np1 -i "$srcdir"/kernel-4.19.patch + else + msg2 "Skipping kernel-4.19.patch as it doesn't apply to this driver version..." + fi + fi + + # 5.0 + if [ "$_kernel50" == "1" ]; then + patchy=0 + for yup in "${_whitelist50[@]}"; do + [[ $pkgver = $yup ]] && patchy=1 + done + if [ "$patchy" == "1" ]; then + msg2 "Applying kernel-5.0.patch for dkms..." + patch -Np1 -i "$srcdir"/kernel-5.0.patch + else + msg2 "Skipping kernel-5.0.patch as it doesn't apply to this driver version..." + fi + fi + + # 5.1 + if [ "$_kernel51" == "1" ]; then + patchy=0 + for yup in "${_whitelist51[@]}"; do + [[ $pkgver = $yup ]] && patchy=1 + done + if [ "$patchy" == "1" ]; then + msg2 "Applying kernel-5.1.patch for dkms..." + patch -Np1 -i "$srcdir"/kernel-5.1.patch + sed -i "s/static int nv_drm_vma_fault(struct vm_fault \*vmf)/#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 1, 0)\nstatic int nv_drm_vma_fault(struct vm_fault \*vmf)\n#else\nstatic vm_fault_t nv_drm_vma_fault(struct vm_fault \*vmf)\n#endif/g" "$srcdir/$_pkg/kernel-dkms/nvidia-drm/nvidia-drm-gem-nvkms-memory.c" + else + msg2 "Skipping kernel-5.1.patch as it doesn't apply to this driver version..." + fi + if [ "$_low418" == "1" ]; then + msg2 "Applying list_is_first.patch for dkms..." + # Use sed for the moving parts of the patch - Fix for "redefinition of ‘list_is_first’" (required for older than 418.56 drivers when used on 5.1+) + sed -i "s/static inline int list_is_first(const struct list_head \*list,/#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 1, 0)\nstatic inline int list_is_first(const struct list_head \*list,/g" "$srcdir/$_pkg/kernel-dkms/common/inc/nv-list-helpers.h" + sed -i "s/ const struct list_head \*head)/ const struct list_head \*head)\n#else\nstatic inline int nv_list_is_first(const struct list_head \*list,\n const struct list_head \*head)\n#endif/g" "$srcdir/$_pkg/kernel-dkms/common/inc/nv-list-helpers.h" + patch -Np1 -i "$srcdir"/list_is_first.diff + fi + fi + + # 5.2 + if [ "$_kernel52" == "1" ]; then + patchy=0 + for yup in "${_whitelist52[@]}"; do + [[ $pkgver = $yup ]] && patchy=1 + done + if [ "$patchy" == "1" ]; then + msg2 "Applying kernel-5.2.patch for dkms..." + patch -Np1 -i "$srcdir"/kernel-5.2.patch + else + msg2 "Skipping kernel-5.2.patch as it doesn't apply to this driver version..." + fi + fi + + # 5.3 + if [ "$_kernel53" == "1" ]; then + patchy=0 + for yup in "${_whitelist53[@]}"; do + [[ $pkgver = $yup ]] && patchy=1 + done + if [ "$patchy" == "1" ]; then + msg2 "Applying kernel-5.3.patch for dkms..." + patch -Np1 -i "$srcdir"/kernel-5.3.patch + else + msg2 "Skipping kernel-5.3.patch as it doesn't apply to this driver version..." + fi + fi + + # 5.4 + if [ "$_kernel54" == "1" ]; then + patchy=0 + for yup in "${_whitelist54[@]}"; do + [[ $pkgver = $yup ]] && patchy=1 + done + if [ "$patchy" == "1" ]; then + msg2 "Applying kernel-5.4.patch for dkms..." + patch -Np1 -i "$srcdir"/kernel-5.4.patch + else + msg2 "Skipping kernel-5.4.patch as it doesn't apply to this driver version..." + fi + if [[ $pkgver = 435.27.02 ]] || [[ $pkgver = 435.27.03 ]] || [[ $pkgver = 435.27.06 ]] || [[ $pkgver = 435.27.07 ]] || [[ $pkgver = 435.27.08 ]] || [[ $pkgver = 440.26 ]]; then + patch -Np1 -i "$srcdir"/kernel-5.4-symver.diff + fi + fi + + # 5.5 + if [ "$_kernel55" == "1" ]; then + patchy=0 + for yup in "${_whitelist55[@]}"; do + [[ $pkgver = $yup ]] && patchy=1 + done + if [ "$patchy" == "1" ]; then + msg2 "Applying kernel-5.5.patch for dkms..." + patch -Np1 -i "$srcdir"/kernel-5.5.patch + else + msg2 "Skipping kernel-5.5.patch as it doesn't apply to this driver version..." + fi + fi + + # 5.6 + if [ "$_kernel56" == "1" ]; then + patchy=0 + for yup in "${_whitelist56[@]}"; do + [[ $pkgver = $yup ]] && patchy=1 + done + if [ "$patchy" == "1" ]; then + msg2 "Applying kernel-5.6.patch for dkms..." + patch -Np1 -i "$srcdir"/kernel-5.6.patch + else + msg2 "Skipping kernel-5.6.patch as it doesn't apply to this driver version..." + fi + if [[ $pkgver = 396* ]] || [[ $pkgver = 410* ]] || [[ $pkgver = 415* ]] || [[ $pkgver = 418.* ]] || [[ $pkgver = 430.0* ]] || [[ $pkgver = 435.* ]] || [[ $pkgver = 440.2* ]] || [[ $pkgver = 440.3* ]] || [[ $pkgver = 440.4* ]]; then + msg2 "Applying 5.6-legacy-includes.diff for dkms..." + patch -Np1 -i "$srcdir"/5.6-legacy-includes.diff + msg2 "Applying 5.6-ioremap.diff for dkms..." + patch -Np1 -i "$srcdir"/5.6-ioremap.diff + elif [[ $pkgver = 440.5* ]]; then + msg2 "Applying 5.6-ioremap.diff for dkms..." + patch -Np1 -i "$srcdir"/5.6-ioremap.diff + fi + fi + + # Legacy quirks + if [ "$_oldstuff" == "1" ]; then + msg2 "Applying 01-ipmi-vm.diff for dkms..." + patch -Np1 -i "$srcdir"/01-ipmi-vm.diff + fi + if [ "$_youngeryetoldstuff" == "1" ]; then + msg2 "Applying 02-ipmi-vm.diff for dkms..." + patch -Np1 -i "$srcdir"/02-ipmi-vm.diff + fi + if [[ $pkgver = 396* ]] || [[ $pkgver = 410* ]] || [[ $pkgver = 415* ]] || [[ $pkgver = 418.* ]] || [[ $pkgver = 430.0* ]] || [[ $pkgver = 435.* ]] || [[ $pkgver = 440.2* ]] || [[ $pkgver = 440.3* ]] || [[ $pkgver = 440.43.* ]] || [[ $pkgver = 440.44 ]] && [ "$_54_prime" == "true" ]; then + msg2 "Applying kernel-5.4-prime.diff for dkms..." + patch -Np1 -i "$srcdir"/kernel-5.4-prime.diff + fi + fi +} + +build() { + if [ "$_dkms" != "true" ]; then + # Build for all kernels + local _kernel + local -a _kernels + mapfile -t _kernels < <(find /usr/lib/modules/*/build/version -exec cat {} +) + + for _kernel in "${_kernels[@]}"; do + cd "$srcdir"/$_pkg/kernel-$_kernel + + # Build module + msg2 "Building Nvidia module for $_kernel..." + make SYSSRC=/usr/lib/modules/$_kernel/build modules + done + fi +} + +opencl-nvidia-tkg() { + pkgdesc="NVIDIA's OpenCL implemention for 'nvidia-utils-tkg'" + depends=('zlib') + optdepends=('opencl-headers: headers necessary for OpenCL development') + provides=("opencl-nvidia=$pkgver" "opencl-nvidia-tkg=$pkgver" 'opencl-driver') + conflicts=('opencl-nvidia') + cd $_pkg + + # OpenCL + install -Dm644 nvidia.icd "$pkgdir"/etc/OpenCL/vendors/nvidia.icd + install -Dm755 libnvidia-compiler.so.$pkgver "$pkgdir"/usr/lib/libnvidia-compiler.so.$pkgver + install -Dm755 libnvidia-opencl.so.$pkgver "$pkgdir"/usr/lib/libnvidia-opencl.so.$pkgver + + # create missing soname links + _create_links + + # License (link) + install -d "$pkgdir"/usr/share/licenses/ + ln -s nvidia/ "$pkgdir"/usr/share/licenses/opencl-nvidia +} +package_opencl-nvidia-tkg() { + opencl-nvidia-tkg +} +package_opencl-nvidia-dev-tkg() { + opencl-nvidia-tkg +} + +nvidia-egl-wayland-tkg() { + if [[ $pkgver == 396* ]]; then + _eglwver="1.0.3" + elif [[ $pkgver == 410* ]] || [[ $pkgver == 415* ]]; then + _eglwver="1.1.0" + elif [[ $pkgver == 418* ]] || [[ $pkgver == 430* ]]; then + _eglwver="1.1.2" + elif [[ $pkgver == 435* ]]; then + _eglwver="1.1.3" + else + _eglwver="1.1.4" + fi + pkgdesc="NVIDIA EGL Wayland library (libnvidia-egl-wayland.so.$_eglwver) for 'nvidia-utils-tkg'" + depends=('nvidia-utils-tkg') + provides=("egl-wayland" "nvidia-egl-wayland-tkg") + conflicts=('egl-wayland') + cd $_pkg + + install -Dm755 libnvidia-egl-wayland.so."${_eglwver}" "${pkgdir}"/usr/lib/libnvidia-egl-wayland.so."${_eglwver}" + ln -s libnvidia-egl-wayland.so."${_eglwver}" "${pkgdir}"/usr/lib/libnvidia-egl-wayland.so.1 + ln -s libnvidia-egl-wayland.so.1 "${pkgdir}"/usr/lib/libnvidia-egl-wayland.so + + install -Dm755 10_nvidia_wayland.json "${pkgdir}"/usr/share/egl/egl_external_platform.d/10_nvidia_wayland.json + install -Dm755 "$where"/egl-wayland/licenses/egl-wayland/COPYING "${pkgdir}"/usr/share/licenses/egl-wayland/COPYING + install -Dm755 "$where"/egl-wayland/pkgconfig/wayland-eglstream-protocols.pc "${pkgdir}"/usr/share/pkgconfig/wayland-eglstream-protocols.pc + install -Dm755 "$where"/egl-wayland/pkgconfig/wayland-eglstream.pc "${pkgdir}"/usr/share/pkgconfig/wayland-eglstream.pc + install -Dm755 "$where"/egl-wayland/wayland-eglstream/wayland-eglstream-controller.xml "${pkgdir}"/usr/share/wayland-eglstream/wayland-eglstream-controller.xml + install -Dm755 "$where"/egl-wayland/wayland-eglstream/wayland-eglstream.xml "${pkgdir}"/usr/share/wayland-eglstream/wayland-eglstream.xml + + sed -i "s/Version:.*/Version: $_eglwver/g" "${pkgdir}"/usr/share/pkgconfig/wayland-eglstream-protocols.pc + sed -i "s/Version:.*/Version: $_eglwver/g" "${pkgdir}"/usr/share/pkgconfig/wayland-eglstream.pc +} +package_nvidia-egl-wayland-tkg() { + nvidia-egl-wayland-tkg +} +package_nvidia-dev-egl-wayland-tkg() { + nvidia-egl-wayland-tkg +} + +nvidia-utils-tkg() { + pkgdesc="NVIDIA driver utilities and libraries for 'nvidia-tkg'" + depends=('xorg-server' 'libglvnd' 'mesa>=17.0.2-2' 'vulkan-icd-loader') + optdepends=('gtk2: nvidia-settings (GTK+ v2)' + 'gtk3: nvidia-settings (GTK+ v3)' + 'opencl-nvidia-tkg: OpenCL support' + 'xorg-server-devel: nvidia-xconfig' + 'egl-wayland-git: for alternative, more advanced Wayland library (libnvidia-egl-wayland.so)') + provides=("nvidia-utils=$pkgver" "nvidia-utils-tkg=$pkgver" "nvidia-settings=$pkgver" 'vulkan-driver' 'opengl-driver' 'nvidia-libgl') + conflicts=('nvidia-utils' 'nvidia-settings' 'nvidia-libgl') + backup=('etc/X11/xorg.conf.d/20-nvidia.conf') + install=nvidia-utils-tkg.install + cd $_pkg + + # X driver + install -D -m755 nvidia_drv.so "${pkgdir}/usr/lib/xorg/modules/drivers/nvidia_drv.so" + + if [[ $pkgver == 396* ]]; then + # GLX extension module for X + install -D -m755 "libglx.so.${pkgver}" "${pkgdir}/usr/lib/nvidia/xorg/libglx.so.${pkgver}" + ln -s "libglx.so.${pkgver}" "${pkgdir}/usr/lib/nvidia/xorg/libglx.so.1" # X doesn't find glx otherwise + ln -s "libglx.so.${pkgver}" "${pkgdir}/usr/lib/nvidia/xorg/libglx.so" # X doesn't find glx otherwise + else + # GLX extension module for X + install -D -m755 "libglxserver_nvidia.so.${pkgver}" "${pkgdir}/usr/lib/nvidia/xorg/libglxserver_nvidia.so.${pkgver}" + # Ensure that X finds glx + ln -s "libglxserver_nvidia.so.${pkgver}" "${pkgdir}/usr/lib/nvidia/xorg/libglxserver_nvidia.so.1" + ln -s "libglxserver_nvidia.so.${pkgver}" "${pkgdir}/usr/lib/nvidia/xorg/libglxserver_nvidia.so" + fi + + if [[ $pkgver != 396* ]] && [[ $pkgver != 410* ]] && [[ $pkgver != 415* ]]; then + # optical flow + install -D -m755 "libnvidia-opticalflow.so.${pkgver}" "${pkgdir}/usr/lib/libnvidia-opticalflow.so.${pkgver}" + else + # X wrapped software rendering + install -D -m755 "libnvidia-wfb.so.${pkgver}" "${pkgdir}/usr/lib/libnvidia-wfb.so.${pkgver}" + fi + + install -D -m755 "libGLX_nvidia.so.${pkgver}" "${pkgdir}/usr/lib/libGLX_nvidia.so.${pkgver}" + + # OpenGL libraries + install -D -m755 "libEGL_nvidia.so.${pkgver}" "${pkgdir}/usr/lib/libEGL_nvidia.so.${pkgver}" + install -D -m755 "libGLESv1_CM_nvidia.so.${pkgver}" "${pkgdir}/usr/lib/libGLESv1_CM_nvidia.so.${pkgver}" + install -D -m755 "libGLESv2_nvidia.so.${pkgver}" "${pkgdir}/usr/lib/libGLESv2_nvidia.so.${pkgver}" + install -D -m644 "10_nvidia.json" "${pkgdir}/usr/share/glvnd/egl_vendor.d/10_nvidia.json" + + # OpenGL core library + install -D -m755 "libnvidia-glcore.so.${pkgver}" "${pkgdir}/usr/lib/libnvidia-glcore.so.${pkgver}" + install -D -m755 "libnvidia-eglcore.so.${pkgver}" "${pkgdir}/usr/lib/libnvidia-eglcore.so.${pkgver}" + install -D -m755 "libnvidia-glsi.so.${pkgver}" "${pkgdir}/usr/lib/libnvidia-glsi.so.${pkgver}" + + # misc + install -D -m755 "libnvidia-ifr.so.${pkgver}" "${pkgdir}/usr/lib/libnvidia-ifr.so.${pkgver}" + install -D -m755 "libnvidia-fbc.so.${pkgver}" "${pkgdir}/usr/lib/libnvidia-fbc.so.${pkgver}" + install -D -m755 "libnvidia-encode.so.${pkgver}" "${pkgdir}/usr/lib/libnvidia-encode.so.${pkgver}" + install -D -m755 "libnvidia-cfg.so.${pkgver}" "${pkgdir}/usr/lib/libnvidia-cfg.so.${pkgver}" + install -D -m755 "libnvidia-ml.so.${pkgver}" "${pkgdir}/usr/lib/libnvidia-ml.so.${pkgver}" + install -D -m755 "libnvidia-glvkspirv.so.${pkgver}" "${pkgdir}/usr/lib/libnvidia-glvkspirv.so.${pkgver}" + + # Allocator library + if [[ -e libnvidia-allocator.so.${pkgver} ]]; then + install -D -m755 "libnvidia-allocator.so.${pkgver}" "${pkgdir}/usr/lib/libnvidia-allocator.so.${pkgver}" + fi + + if [[ $pkgver != 396* ]]; then + # Ray tracing + install -D -m755 "libnvoptix.so.${pkgver}" "${pkgdir}/usr/lib/libnvoptix.so.${pkgver}" + install -D -m755 "libnvidia-rtcore.so.${pkgver}" "${pkgdir}/usr/lib/libnvidia-rtcore.so.${pkgver}" + install -D -m755 "libnvidia-cbl.so.${pkgver}" "${pkgdir}/usr/lib/libnvidia-cbl.so.${pkgver}" + fi + + # Vulkan ICD + if [[ $pkgver != 396* ]] && [[ $pkgver != 410* ]] && [[ $pkgver != 415* ]] && [[ $pkgver != 418* ]] && [[ $pkgver != 430* ]]; then + install -D -m644 "nvidia_icd.json" "${pkgdir}/usr/share/vulkan/icd.d/nvidia_icd.json" + else + install -D -m644 "nvidia_icd.json.template" "${pkgdir}/usr/share/vulkan/icd.d/nvidia_icd.json" + fi + if [ -e nvidia_layers.json ]; then + install -D -m644 "nvidia_layers.json" "${pkgdir}/usr/share/vulkan/explicit_layer.d/nvidia_layers.json" + fi + + # VDPAU + install -D -m755 "libvdpau_nvidia.so.${pkgver}" "${pkgdir}/usr/lib/vdpau/libvdpau_nvidia.so.${pkgver}" + + # nvidia-tls library + install -D -m755 "libnvidia-tls.so.${pkgver}" "${pkgdir}/usr/lib/libnvidia-tls.so.${pkgver}" + + if [[ $pkgver == 396* ]] || [[ $pkgver == 410* ]]; then + install -D -m755 "tls/libnvidia-tls.so.${pkgver}" "${pkgdir}/usr/lib/tls/libnvidia-tls.so.${pkgver}" + fi + + # CUDA + install -D -m755 "libcuda.so.${pkgver}" "${pkgdir}/usr/lib/libcuda.so.${pkgver}" + install -D -m755 "libnvcuvid.so.${pkgver}" "${pkgdir}/usr/lib/libnvcuvid.so.${pkgver}" + + # PTX JIT Compiler (Parallel Thread Execution (PTX) is a pseudo-assembly language for CUDA) + install -D -m755 "libnvidia-ptxjitcompiler.so.${pkgver}" "${pkgdir}/usr/lib/libnvidia-ptxjitcompiler.so.${pkgver}" + + # Fat (multiarchitecture) binary loader + install -D -m755 "libnvidia-fatbinaryloader.so.${pkgver}" "${pkgdir}/usr/lib/libnvidia-fatbinaryloader.so.${pkgver}" + + # DEBUG + install -D -m755 nvidia-debugdump "${pkgdir}/usr/bin/nvidia-debugdump" + + # nvidia-xconfig + install -D -m755 nvidia-xconfig "${pkgdir}/usr/bin/nvidia-xconfig" + install -D -m644 nvidia-xconfig.1.gz "${pkgdir}/usr/share/man/man1/nvidia-xconfig.1.gz" + + # nvidia-bug-report + install -D -m755 nvidia-bug-report.sh "${pkgdir}/usr/bin/nvidia-bug-report.sh" + + # nvidia-smi + install -D -m755 nvidia-smi "${pkgdir}/usr/bin/nvidia-smi" + install -D -m644 nvidia-smi.1.gz "${pkgdir}/usr/share/man/man1/nvidia-smi.1.gz" + + # nvidia-cuda-mps + install -D -m755 nvidia-cuda-mps-server "${pkgdir}/usr/bin/nvidia-cuda-mps-server" + install -D -m755 nvidia-cuda-mps-control "${pkgdir}/usr/bin/nvidia-cuda-mps-control" + install -D -m644 nvidia-cuda-mps-control.1.gz "${pkgdir}/usr/share/man/man1/nvidia-cuda-mps-control.1.gz" + + # nvidia-modprobe + # This should be removed if nvidia fixed their uvm module! + install -D -m4755 nvidia-modprobe "${pkgdir}/usr/bin/nvidia-modprobe" + install -D -m644 nvidia-modprobe.1.gz "${pkgdir}/usr/share/man/man1/nvidia-modprobe.1.gz" + + # nvidia-persistenced + install -D -m755 nvidia-persistenced "${pkgdir}/usr/bin/nvidia-persistenced" + install -D -m644 nvidia-persistenced.1.gz "${pkgdir}/usr/share/man/man1/nvidia-persistenced.1.gz" + install -D -m644 nvidia-persistenced-init/systemd/nvidia-persistenced.service.template "${pkgdir}/usr/lib/systemd/system/nvidia-persistenced.service" + sed -i 's/__USER__/nvidia-persistenced/' "${pkgdir}/usr/lib/systemd/system/nvidia-persistenced.service" + + # application profiles + install -D -m644 nvidia-application-profiles-${pkgver}-rc "${pkgdir}/usr/share/nvidia/nvidia-application-profiles-${pkgver}-rc" + install -D -m644 nvidia-application-profiles-${pkgver}-key-documentation "${pkgdir}/usr/share/nvidia/nvidia-application-profiles-${pkgver}-key-documentation" + + install -D -m644 LICENSE "${pkgdir}/usr/share/licenses/nvidia-utils/LICENSE" + install -D -m644 README.txt "${pkgdir}/usr/share/doc/nvidia/README" + install -D -m644 NVIDIA_Changelog "${pkgdir}/usr/share/doc/nvidia/NVIDIA_Changelog" + cp -r html "${pkgdir}/usr/share/doc/nvidia/" + ln -s nvidia "${pkgdir}/usr/share/doc/nvidia-utils" + + # GTK+ for nvidia-settings + install -D -m755 "libnvidia-gtk2.so.${pkgver}" "${pkgdir}/usr/lib/libnvidia-gtk2.so.${pkgver}" + install -D -m755 "libnvidia-gtk3.so.${pkgver}" "${pkgdir}/usr/lib/libnvidia-gtk3.so.${pkgver}" + + # GUI for configuring the driver + install -Dm755 nvidia-settings "$pkgdir"/usr/bin/nvidia-settings + install -Dm644 nvidia-settings.1.gz "$pkgdir"/usr/share/man/man1/nvidia-settings.1.gz + install -Dm644 nvidia-settings.png "$pkgdir"/usr/share/pixmaps/nvidia-settings.png + install -Dm644 nvidia-settings.desktop "$pkgdir"/usr/share/applications/nvidia-settings.desktop + sed -e 's:__UTILS_PATH__:/usr/bin:' \ + -e 's:__PIXMAP_PATH__:/usr/share/pixmaps:' \ + -i "$pkgdir"/usr/share/applications/nvidia-settings.desktop + + # Coolbits + if [ -n "$_coolbits" ]; then + sed -i "/.*\"NoLogo\" \"True\".*/a \ Option \"Coolbits\" \"$_coolbits\"" "$srcdir"/20-nvidia.conf + fi + + # Disable logo splash + install -Dm644 "$srcdir"/20-nvidia.conf "$pkgdir"/etc/X11/xorg.conf.d/20-nvidia.conf + + # Distro-specific files must be installed in /usr/share/X11/xorg.conf.d + if [ "$_PRIME_render_offload" == "true" ]; then + sed -i '/Option "PrimaryGPU" "yes"/d' "$srcdir"/10-nvidia-drm-outputclass.conf + fi + install -Dm644 "$srcdir"/10-nvidia-drm-outputclass.conf "$pkgdir"/usr/share/X11/xorg.conf.d/10-nvidia-drm-outputclass.conf + + install -Dm644 "$srcdir"/nvidia-utils-tkg.sysusers "$pkgdir"/usr/lib/sysusers.d/$pkgname.conf + + _create_links +} +package_nvidia-utils-tkg() { + nvidia-utils-tkg +} +package_nvidia-dev-utils-tkg() { + nvidia-utils-tkg +} + +if [ "$_dkms" == "false" ] || [ "$_dkms" == "full" ]; then + nvidia-tkg() { + pkgdesc="Full NVIDIA drivers' package for all kernels on the system (drivers and shared utilities and libraries)" + depends=("nvidia-utils-tkg>=$pkgver" 'libglvnd') + provides=("nvidia=$pkgver" "nvidia-tkg>=$pkgver") + conflicts=('nvidia-96xx' 'nvidia-173xx' 'nvidia') + install=nvidia-tkg.install + + # Install for all kernels + local _kernel + local -a _kerndels + mapfile -t _kernels < <(find /usr/lib/modules/*/build/version -exec cat {} +) + + for _kernel in "${_kernels[@]}"; do + install -D -m644 "${_pkg}/kernel-${_kernel}/"nvidia{,-drm,-modeset,-uvm}.ko -t "${pkgdir}/usr/lib/modules/${_kernel}/extramodules" + find "$pkgdir" -name '*.ko' -exec gzip -n {} + + done + + # Blacklist Nouveau + mkdir -p "${pkgdir}/usr/lib/modprobe.d" + echo -e "blacklist nouveau\nblacklist nvidiafb" > "${pkgdir}/usr/lib/modprobe.d/${pkgname}.conf" + } + package_nvidia-tkg() { + nvidia-tkg + } + package_nvidia-dev-tkg() { + nvidia-tkg + } +fi + +lib32-opencl-nvidia-tkg() { + pkgdesc="NVIDIA's OpenCL implemention for 'lib32-nvidia-utils-tkg' " + depends=('lib32-zlib' 'lib32-gcc-libs') + optdepends=('opencl-headers: headers necessary for OpenCL development') + provides=("lib32-opencl-nvidia=$pkgver" "lib32-opencl-nvidia-tkg=$pkgver" 'lib32-opencl-driver') + conflicts=('lib32-opencl-nvidia') + cd $_pkg/32 + + # OpenCL + install -D -m755 libnvidia-compiler.so.$pkgver "$pkgdir"/usr/lib32/libnvidia-compiler.so.$pkgver + install -D -m755 libnvidia-opencl.so.$pkgver "$pkgdir"/usr/lib32/libnvidia-opencl.so.$pkgver + + # create missing soname links + _create_links + + # License (link) + install -d "$pkgdir"/usr/share/licenses/ + ln -s nvidia-utils/ "$pkgdir"/usr/share/licenses/lib32-opencl-nvidia +} +package_lib32-opencl-nvidia-tkg() { + lib32-opencl-nvidia-tkg +} +package_lib32-opencl-nvidia-dev-tkg() { + lib32-opencl-nvidia-tkg +} + +lib32-nvidia-utils-tkg() { + pkgdesc="NVIDIA driver utilities and libraries for 'nvidia-tkg' (32-bit)" + depends=('lib32-zlib' 'lib32-gcc-libs' 'nvidia-utils-tkg' 'lib32-libglvnd' 'lib32-mesa>=17.0.2-1' 'lib32-vulkan-icd-loader') + optdepends=('lib32-opencl-nvidia-tkg: OpenCL support') + provides=("lib32-nvidia-utils=$pkgver" "lib32-nvidia-utils-tkg=$pkgver" 'lib32-vulkan-driver' 'lib32-opengl-driver' 'lib32-nvidia-libgl') + conflicts=('lib32-nvidia-utils' 'lib32-nvidia-libgl') + cd $_pkg/32 + + install -D -m755 "libGLX_nvidia.so.${pkgver}" "${pkgdir}/usr/lib32/libGLX_nvidia.so.${pkgver}" + + # OpenGL libraries + install -D -m755 "libEGL_nvidia.so.${pkgver}" "${pkgdir}/usr/lib32/libEGL_nvidia.so.${pkgver}" + install -D -m755 "libGLESv1_CM_nvidia.so.${pkgver}" "${pkgdir}/usr/lib32/libGLESv1_CM_nvidia.so.${pkgver}" + install -D -m755 "libGLESv2_nvidia.so.${pkgver}" "${pkgdir}/usr/lib32/libGLESv2_nvidia.so.${pkgver}" + + # OpenGL core library + install -D -m755 "libnvidia-glcore.so.${pkgver}" "${pkgdir}/usr/lib32/libnvidia-glcore.so.${pkgver}" + install -D -m755 "libnvidia-eglcore.so.${pkgver}" "${pkgdir}/usr/lib32/libnvidia-eglcore.so.${pkgver}" + install -D -m755 "libnvidia-glsi.so.${pkgver}" "${pkgdir}/usr/lib32/libnvidia-glsi.so.${pkgver}" + + # Allocator library + if [[ -e libnvidia-allocator.so.${pkgver} ]]; then + install -D -m755 "libnvidia-allocator.so.${pkgver}" "${pkgdir}/usr/lib32/libnvidia-allocator.so.${pkgver}" + fi + + # misc + install -D -m755 "libnvidia-ifr.so.${pkgver}" "${pkgdir}/usr/lib32/libnvidia-ifr.so.${pkgver}" + install -D -m755 "libnvidia-fbc.so.${pkgver}" "${pkgdir}/usr/lib32/libnvidia-fbc.so.${pkgver}" + install -D -m755 "libnvidia-encode.so.${pkgver}" "${pkgdir}/usr/lib32/libnvidia-encode.so.${pkgver}" + install -D -m755 "libnvidia-ml.so.${pkgver}" "${pkgdir}/usr/lib32/libnvidia-ml.so.${pkgver}" + install -D -m755 "libnvidia-glvkspirv.so.${pkgver}" "${pkgdir}/usr/lib32/libnvidia-glvkspirv.so.${pkgver}" + + # VDPAU + install -D -m755 "libvdpau_nvidia.so.${pkgver}" "${pkgdir}/usr/lib32/vdpau/libvdpau_nvidia.so.${pkgver}" + + # nvidia-tls library + install -D -m755 "libnvidia-tls.so.${pkgver}" "${pkgdir}/usr/lib32/libnvidia-tls.so.${pkgver}" + + if [[ $pkgver == 396* ]] || [[ $pkgver == 410* ]]; then + install -D -m755 "tls/libnvidia-tls.so.${pkgver}" "${pkgdir}/usr/lib32/tls/libnvidia-tls.so.${pkgver}" + fi + + # CUDA + install -D -m755 "libcuda.so.${pkgver}" "${pkgdir}/usr/lib32/libcuda.so.${pkgver}" + install -D -m755 "libnvcuvid.so.${pkgver}" "${pkgdir}/usr/lib32/libnvcuvid.so.${pkgver}" + + # PTX JIT Compiler (Parallel Thread Execution (PTX) is a pseudo-assembly language for CUDA) + install -D -m755 "libnvidia-ptxjitcompiler.so.${pkgver}" "${pkgdir}/usr/lib32/libnvidia-ptxjitcompiler.so.${pkgver}" + + # Fat (multiarchitecture) binary loader + install -D -m755 "libnvidia-fatbinaryloader.so.${pkgver}" "${pkgdir}/usr/lib32/libnvidia-fatbinaryloader.so.${pkgver}" + + _create_links + + rm -rf "${pkgdir}"/usr/{include,share,bin} + mkdir -p "${pkgdir}/usr/share/licenses" + ln -s nvidia-utils/ "${pkgdir}/usr/share/licenses/${pkgname}" +} +package_lib32-nvidia-utils-tkg() { + lib32-nvidia-utils-tkg +} +package_lib32-nvidia-dev-utils-tkg() { + lib32-nvidia-utils-tkg +} + +if [ "$_dkms" == "true" ] || [ "$_dkms" == "full" ]; then + nvidia-dkms-tkg() { + pkgdesc="NVIDIA kernel module sources (DKMS)" + depends=('dkms' "nvidia-utils-tkg>=${pkgver}" 'nvidia-libgl') + provides=("nvidia=${pkgver}" 'nvidia-dkms' "nvidia-dkms-tkg=${pkgver}") + conflicts=('nvidia') + + cd ${_pkg} + install -dm 755 "${pkgdir}"/usr/{lib/modprobe.d,src} + cp -dr --no-preserve='ownership' kernel-dkms "${pkgdir}/usr/src/nvidia-${pkgver}" + + # Blacklist Nouveau + mkdir -p "${pkgdir}/usr/lib/modprobe.d" + echo -e "blacklist nouveau\nblacklist nvidiafb" > "${pkgdir}/usr/lib/modprobe.d/${pkgname}.conf" + + install -Dt "${pkgdir}/usr/share/licenses/${pkgname}" -m644 "${srcdir}/${_pkg}/LICENSE" + } + package_nvidia-dkms-tkg() { + nvidia-dkms-tkg + } + package_nvidia-dev-dkms-tkg() { + nvidia-dkms-tkg + } +fi + +function exit_cleanup { + # Sanitization + rm -f "${where}"/options + rm -f "${where}"/*.conf + rm -f "${where}"/*.install + rm -f "${where}"/*.patch + rm -f "${where}"/*.diff + rm -f "${where}"/nvidia-utils-tkg.sysusers + rm -rf "${where}"/egl-wayland + rm -rf "${where}"/src/* + + # Put the built packages in a versioned dir - overwrite if needed + if [ "$_local_package_storing" == "true" ]; then + rm -rf "${where}/${pkgver}-packages" && mkdir -p "${where}/${pkgver}-packages" && mv "${where}/"*.pkg.* "${where}/${pkgver}-packages"/ >/dev/null 2>&1 + fi + + remove_deps + + msg2 'exit cleanup done' +} + +trap exit_cleanup EXIT diff --git a/README.md b/README.md new file mode 100644 index 0000000..4500c90 --- /dev/null +++ b/README.md @@ -0,0 +1,27 @@ +# Nvidia driver 440/435/430/418/415/410/396 series AIO installer + +LIBGLVND compatible, with 32 bit libs and DKMS enabled out of the box (you will still be asked if you want to use the regular package). Installs for all currently installed kernels. Comes with custom patches to enhance kernel compatibility, dynamically applied when you're requesting a driver that's not compatible OOTB with your currently installed kernel(s). +Unwanted packages can be disabled with switches in the PKGBUILD. Defaults to complete installation. + +You may need/want to add a pacman hook for nvidia depending on your setup : https://wiki.archlinux.org/index.php/NVIDIA#DRM_kernel_mode_setting + +Vulkan dev drivers : https://developer.nvidia.com/vulkan-driver + +Regular drivers : https://www.nvidia.com/object/unix.html + +## My DKMS driver installed with kernel X.1 doesn't work/build anymore after I upgraded to kernel X.2! Help! +- Simply rebuild the packages so the script can detect your currently installed kernel(s) and patch your driver accordingly to fix compatibility issues. + +# How to generate a package for a driver that isn't listed (390 and lower branches are not supported) : +- When you are prompted for driver version, select "custom" (choice 9). +- You'll then be asked the branch group. Select either "Vulkan dev" (choice 2) for Vulkan dev drivers or "stable or regular beta" (choice 1) for every other driver. +- Now you have to enter the version number of the desired driver. Vulkan dev drivers version is usually formatted as `mainbranch.version.subversion` (i.e.: 415.22.01) while the stable or regular beta drivers version is usually `mainbranch.version` (i.e.: 415.25) +- To finish, you'll be asked if you want dkms(recommended) or regular modules, similarly to the usual drivers versions. + +# Optimus users : +- A great tool exists for you and works with these nvidia-all packages: https://github.com/Askannz/optimus-manager +- 435.17 beta has introduced PRIME render offload support. You can learn more about the needed setup here: http://us.download.nvidia.com/XFree86/Linux-x86_64/435.17/README/primerenderoffload.html + +# Mostlyportable-gcc users : +- For non-dkms nvidia-all packages, setting your `CUSTOM_GCC_PATH` in .cfg is enough. +- For dkms nvidia-all packages, you'll need to make DKMS aware of your mostlyportable-gcc build. See: https://github.com/Tk-Glitch/PKGBUILDS/issues/334#issuecomment-537197636 diff --git a/customization.cfg b/customization.cfg new file mode 100644 index 0000000..8001370 --- /dev/null +++ b/customization.cfg @@ -0,0 +1,41 @@ +# nvidia-all config file + + +#### OPTIONS #### + +# External config file to use - If the given file exists in path, it will override default config (customization.cfg) - Default is ~/.config/frogminer/nvidia-all.cfg +_EXT_CONFIG_PATH=~/.config/frogminer/nvidia-all.cfg + +# Custom compiler root dirs - For non-dkms builds (see readme to use this with dkms) - Leave empty to use system compilers +# ! If your kernel was built with mostlyportable GCC, you need to use the exact same build here or module compilation will fail ! +# Example: CUSTOM_GCC_PATH="/home/frog/PKGBUILDS/mostlyportable-gcc/gcc-mostlyportable-9.2.0" +CUSTOM_GCC_PATH="" + +# Put the built packages in a versioned dir in the same folder as the nvidia-all PKGBUILD on exit - Will fail to install if running makepkg with -i option +_local_package_storing="false" + +# If you want to ignore some packages, set them to "false". Default is all set to "true" for a complete installation. +_lib32="true" +_opencl="true" +_eglwayland="true" + +# Set to "true" to unset Option "PrimaryGPU" "yes" in outputclass for PRIME Render offloading setups +_PRIME_render_offload="false" + +# Attempt at fixing PRIME sync on kernel 5.4 and 5.5rc - https://devtalk.nvidia.com/default/topic/1068045/linux/5-4-kernel-breaks-prime-synchronization-/post/5416631/#5416631 +_54_prime_fixing_attempt="false" + +# Coolbits value - Enables fan control & overclocking from nvidia-settings - A value of 31 enables all features +_coolbits="31" + +# Fix for https://bugs.archlinux.org/task/62142 affecting SLi configs +_62142_fix="true" + +# Either "vulkandev" for vulkan developer drivers or "regular" for all others +_driver_branch="" + +# Desired driver version - !! needs to be available from the selected branch above !! +_driver_version="" + +# Set to "true" to use DKMS or "false" to use regular modules. You can also use "full" to build both dkms and regular packages (don't use it if you don't know you need it!). +_dkms="" diff --git a/patches/01-ipmi-vm.diff b/patches/01-ipmi-vm.diff new file mode 100644 index 0000000..553289e --- /dev/null +++ b/patches/01-ipmi-vm.diff @@ -0,0 +1,55 @@ +diff --git a/kernel-dkms/conftest.sh b/kernel-dkms/conftest.sh +index e8de161..04d6683 100755 +--- a/kernel-dkms/conftest.sh ++++ b/kernel-dkms/conftest.sh +@@ -1780,11 +1780,14 @@ compile_test() { + # Determine if atomic64_t and associated functions are defined + CODE=" + #include ++ #include + void conftest_atomic64(void) { + atomic64_t data; + atomic64_read(&data); + atomic64_set(&data, 0); ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0) + atomic64_inc(&data); ++#endif + }" + + compile_check_conftest "$CODE" "NV_ATOMIC64_PRESENT" "" "types" +diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-gem-nvkms-memory.c b/kernel-dkms/nvidia-drm/nvidia-drm-gem-nvkms-memory.c +index 1db7777..863bb77 100644 +--- a/kernel-dkms/nvidia-drm/nvidia-drm-gem-nvkms-memory.c ++++ b/kernel-dkms/nvidia-drm/nvidia-drm-gem-nvkms-memory.c +@@ -345,7 +347,11 @@ static int __nv_drm_vma_fault(struct vm_area_struct *vma, + + page_offset = vmf->pgoff - drm_vma_node_start(&gem->vma_node); + ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 19, 0) + ret = vm_insert_pfn(vma, address, pfn + page_offset); ++#else ++ ret = vmf_insert_pfn(vma, address, pfn + page_offset); ++#endif + + switch (ret) { + case 0: +--- a/kernel-dkms/nvidia/os-interface.c 2018-11-15 21:56:59.000000000 -0600 ++++ b/kernel-dkms/nvidia/os-interface.c 2018-11-26 21:53:39.970635906 -0600 +@@ -1670,7 +1670,7 @@ + + struct nv_ipmi_softc + { +- ipmi_user_t p_user; // ptr to ipmi_msghandler user structure ++ struct ipmi_user *p_user; + spinlock_t msg_lock; + struct list_head msgs; + NvU32 seqNum; //request sequence number +@@ -1679,7 +1679,7 @@ + static inline int + nv_ipmi_set_my_address + ( +- ipmi_user_t user, ++ struct ipmi_user *user, + unsigned char address + ) + { diff --git a/patches/02-ipmi-vm.diff b/patches/02-ipmi-vm.diff new file mode 100644 index 0000000..35d0801 --- /dev/null +++ b/patches/02-ipmi-vm.diff @@ -0,0 +1,16 @@ +diff --git a/kernel-dkms/nvidia/linux_nvswitch.c b/kernel-dkms/nvidia/linux_nvswitch.c +index 75b5598..9841775 100644 +--- a/kernel-dkms/nvidia/linux_nvswitch.c ++++ b/kernel-dkms/nvidia/linux_nvswitch.c +@@ -1582,7 +1582,11 @@ nvswitch_os_snprintf_time + struct tm t; + NvS32 date_end; + ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 19, 0) + time_to_tm(time_nsec / NVSWITCH_NSEC_PER_SEC, 0, &t); ++#else ++ time64_to_tm(time_nsec / NVSWITCH_NSEC_PER_SEC, 0, &t); ++#endif + + date_end = snprintf(date, + date_len, diff --git a/patches/5.6-ioremap.diff b/patches/5.6-ioremap.diff new file mode 100644 index 0000000..fbf73c8 --- /dev/null +++ b/patches/5.6-ioremap.diff @@ -0,0 +1,55 @@ +diff --git a/kernel-dkms/common/inc/nv-linux.h b/kernel-dkms/common/inc/nv-linux.h +index e235842..805e525 100644 +--- a/kernel-dkms/common/inc/nv-linux.h ++++ b/kernel-dkms/common/inc/nv-linux.h +@@ -531,7 +531,11 @@ static inline void *nv_ioremap(NvU64 phys, NvU64 size) + + static inline void *nv_ioremap_nocache(NvU64 phys, NvU64 size) + { ++#if defined(NV_IOREMAP_NOCACHE_PRESENT) + void *ptr = ioremap_nocache(phys, size); ++#else ++ void *ptr = ioremap(phys, size); ++#endif + if (ptr) + NV_MEMDBG_ADD(ptr, size); + return ptr; +diff --git a/kernel-dkms/nvidia/nvidia.Kbuild b/kernel-dkms/nvidia/nvidia.Kbuild +index 5ec3e65..2897e31 100644 +--- a/kernel-dkms/nvidia/nvidia.Kbuild ++++ b/kernel-dkms/nvidia/nvidia.Kbuild +@@ -104,6 +104,7 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += set_memory_array_uc + NV_CONFTEST_FUNCTION_COMPILE_TESTS += acquire_console_sem + NV_CONFTEST_FUNCTION_COMPILE_TESTS += console_lock + NV_CONFTEST_FUNCTION_COMPILE_TESTS += ioremap_cache ++NV_CONFTEST_FUNCTION_COMPILE_TESTS += ioremap_nocache + NV_CONFTEST_FUNCTION_COMPILE_TESTS += ioremap_wc + NV_CONFTEST_FUNCTION_COMPILE_TESTS += acpi_walk_namespace + NV_CONFTEST_FUNCTION_COMPILE_TESTS += sg_alloc_table +diff --git a/kernel-dkms/conftest.sh b/kernel-dkms/conftest.sh +index 57d85a4..4902248 100755 +--- a/kernel-dkms/conftest.sh ++++ b/kernel-dkms/conftest.sh +@@ -780,6 +780,22 @@ compile_test() { + compile_check_conftest "$CODE" "NV_IOREMAP_CACHE_PRESENT" "" "functions" + ;; + ++ ioremap_nocache) ++ # ++ # Determine if the ioremap_nocache() function is present. ++ # ++ # Removed by commit 4bdc0d676a64 ("remove ioremap_nocache and ++ # devm_ioremap_nocache") in v5.6 (2020-01-06) ++ # ++ CODE=" ++ #include ++ void conftest_ioremap_nocache(void) { ++ ioremap_nocache(); ++ }" ++ ++ compile_check_conftest "$CODE" "NV_IOREMAP_NOCACHE_PRESENT" "" "functions" ++ ;; ++ + ioremap_wc) + # + # Determine if the ioremap_wc() function is present. diff --git a/patches/5.6-legacy-includes.diff b/patches/5.6-legacy-includes.diff new file mode 100644 index 0000000..6c73d0d --- /dev/null +++ b/patches/5.6-legacy-includes.diff @@ -0,0 +1,28 @@ +diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-gem-nvkms-memory.c b/kernel-dkms/nvidia-drm/nvidia-drm-gem-nvkms-memory.c +index b9cdaae..c73ed43 100644 +--- a/kernel-dkms/nvidia-drm/nvidia-drm-gem-nvkms-memory.c ++++ b/kernel-dkms/nvidia-drm/nvidia-drm-gem-nvkms-memory.c +@@ -31,6 +31,8 @@ + #include + #endif + ++#include ++ + #include "nv-mm.h" + + static void __nv_drm_gem_nvkms_memory_free(struct nv_drm_gem_object *nv_gem) +diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-linux.c b/kernel-dkms/nvidia-drm/nvidia-drm-linux.c +index 650b96d..1d3e658 100644 +--- a/kernel-dkms/nvidia-drm/nvidia-drm-linux.c ++++ b/kernel-dkms/nvidia-drm/nvidia-drm-linux.c +@@ -35,6 +35,8 @@ + #include + #endif + ++#include ++ + #include "nv-mm.h" + + MODULE_PARM_DESC( + + diff --git a/patches/GFP_RETRY_MAYFAIL-test.diff b/patches/GFP_RETRY_MAYFAIL-test.diff new file mode 100644 index 0000000..6399aa3 --- /dev/null +++ b/patches/GFP_RETRY_MAYFAIL-test.diff @@ -0,0 +1,23 @@ +From 681303f341929adacb8fd493c501f3864716ae9c Mon Sep 17 00:00:00 2001 +From: Tk-Glitch +Date: Mon, 9 Sep 2019 12:05:43 +0200 +Subject: nv-vm: Replace __GFP_NORETRY flag by __GFP_RETRY_MAYFAIL +This is a test for DXVK issue #1100, suggested by NVIDIA. +https://github.com/doitsujin/dxvk/issues/1100 + + +diff --git a/kernel-dkms/nvidia/nv-vm.c b/kernel-dkms/nvidia/nv-vm.c +index 09cd39bda..e1fd7cfd2 100644 +--- a/kernel-dkms/nvidia/nv-vm.c ++++ b/kernel-dkms/nvidia/nv-vm.c +@@ -235,8 +235,8 @@ static unsigned int nv_compute_gfp_mask( + gfp_mask = NV_GFP_DMA32; + } + } +-#if defined(__GFP_NORETRY) +- gfp_mask |= __GFP_NORETRY; ++#if defined(__GFP_RETRY_MAYFAIL) ++ gfp_mask |= __GFP_RETRY_MAYFAIL; + #endif + #if defined(__GFP_ZERO) + if (at->flags & NV_ALLOC_TYPE_ZEROED) diff --git a/patches/kernel-4.16.patch b/patches/kernel-4.16.patch new file mode 100644 index 0000000..2498444 --- /dev/null +++ b/patches/kernel-4.16.patch @@ -0,0 +1,33 @@ +diff --git a/kernel-dkms/common/inc/nv-linux.h b/kernel-dkms/common/inc/nv-linux.h +index 10fc418..22ef968 100644 +--- a/kernel-dkms/common/inc/nv-linux.h ++++ b/kernel-dkms/common/inc/nv-linux.h +@@ -175,7 +175,11 @@ static inline uid_t __kuid_val(kuid_t uid) + + #if defined(NV_VM_INSERT_PAGE_PRESENT) + #include ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0) + #include ++#else ++#include ++#endif + #endif + + #if defined(CONFIG_SWIOTLB) && defined(NVCPU_AARCH64) +diff --git a/kernel-dkms/conftest.sh b/kernel-dkms/conftest.sh +index b23dbb4..42dc576 100755 +--- a/kernel-dkms/conftest.sh ++++ b/kernel-dkms/conftest.sh +@@ -1906,7 +1906,12 @@ compile_test() { + # Determine if the phys_to_dma function is present. + # + CODE=" ++ #include ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0) + #include ++#else ++ #include ++#endif + void conftest_phys_to_dma(void) { + phys_to_dma(); + }" diff --git a/patches/kernel-4.19.patch b/patches/kernel-4.19.patch new file mode 100644 index 0000000..f632f63 --- /dev/null +++ b/patches/kernel-4.19.patch @@ -0,0 +1,75 @@ +diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-connector.c b/kernel-dkms/nvidia-drm/nvidia-drm-connector.c +index dbda66d..99333d9 100644 +--- a/kernel-dkms/nvidia-drm/nvidia-drm-connector.c ++++ b/kernel-dkms/nvidia-drm/nvidia-drm-connector.c +@@ -226,7 +228,11 @@ static int nv_drm_connector_get_modes(struct drm_connector *connector) + + + if (nv_connector->edid != NULL) { ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,19,0) + drm_mode_connector_update_edid_property( ++#else ++ drm_connector_update_edid_property( ++#endif + connector, nv_connector->edid); + } + +diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-encoder.c b/kernel-dkms/nvidia-drm/nvidia-drm-encoder.c +index 3dc2400..e8b4aad 100644 +--- a/kernel-dkms/nvidia-drm/nvidia-drm-encoder.c ++++ b/kernel-dkms/nvidia-drm/nvidia-drm-encoder.c +@@ -216,7 +218,11 @@ nv_drm_add_encoder(struct drm_device *dev, NvKmsKapiDisplay hDisplay) + + /* Attach encoder and connector */ + ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,19,0) + ret = drm_mode_connector_attach_encoder(connector, encoder); ++#else ++ ret = drm_connector_attach_encoder(connector, encoder); ++#endif + + if (ret != 0) { + NV_DRM_DEV_LOG_ERR( +diff --git a/kernel-dkms/conftest.sh b/kernel-dkms/conftest.sh +index dd61566..30c88a1 100755 +--- a/kernel-dkms/conftest.sh ++++ b/kernel-dkms/conftest.sh +@@ -2363,17 +2363,22 @@ compile_test() { + + ;; + +- drm_mode_connector_list_update_has_merge_type_bits_arg) ++ drm_connector_list_update_has_merge_type_bits_arg) + # +- # Detect if drm_mode_connector_list_update() has a ++ # Detect if drm_connector_list_update() has a + # 'merge_type_bits' second argument. This argument was + # remove by: + # 2015-12-03 6af3e6561243f167dabc03f732d27ff5365cd4a4 + # + CODE=" + #include +- void conftest_drm_mode_connector_list_update_has_merge_type_bits_arg(void) { ++ #include ++ void conftest_drm_connector_list_update_has_merge_type_bits_arg(void) { ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,19,0) + drm_mode_connector_list_update( ++#else ++ drm_connector_list_update( ++#endif + NULL, /* struct drm_connector *connector */ + true); /* bool merge_type_bits */ + }" +diff --git a/kernel-dkms/nvidia-drm/nvidia-drm.Kbuild b/kernel-dkms/nvidia-drm/nvidia-drm.Kbuild +index b4a45a7..3b7f3a1 100644 +--- a/kernel-dkms/nvidia-drm/nvidia-drm.Kbuild ++++ b/kernel-dkms/nvidia-drm/nvidia-drm.Kbuild +@@ -74,7 +74,7 @@ NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_has_legacy_dev_list + NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_has_set_busid + NV_CONFTEST_TYPE_COMPILE_TESTS += drm_crtc_state_has_connectors_changed + NV_CONFTEST_TYPE_COMPILE_TESTS += drm_init_function_args +-NV_CONFTEST_TYPE_COMPILE_TESTS += drm_mode_connector_list_update_has_merge_type_bits_arg ++NV_CONFTEST_TYPE_COMPILE_TESTS += drm_connector_list_update_has_merge_type_bits_arg + NV_CONFTEST_TYPE_COMPILE_TESTS += drm_helper_mode_fill_fb_struct + NV_CONFTEST_TYPE_COMPILE_TESTS += drm_master_drop_has_from_release_arg + NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_unload_has_int_return_type diff --git a/patches/kernel-5.0.patch b/patches/kernel-5.0.patch new file mode 100644 index 0000000..975afaf --- /dev/null +++ b/patches/kernel-5.0.patch @@ -0,0 +1,646 @@ +From 11adcf1e8d2fbebeb614390832de08388a46bcda Mon Sep 17 00:00:00 2001 +From: Tk-Glitch +Date: Mon, 28 Jan 2019 18:21:34 +0100 +Subject: kernel 5.0 patch + + +diff --git a/kernel-dkms/common/inc/nv.h b/kernel-dkms/common/inc/nv.h +index d52c2a1ef..f6dc2dc32 100644 +--- a/kernel-dkms/common/inc/nv.h ++++ b/kernel-dkms/common/inc/nv.h +@@ -603,6 +605,7 @@ typedef NV_STATUS (*nvPmaEvictRangeCallback)(void *, NvU64, NvU64); + #define NV_MAX_ISR_DELAY_US 20000 + #define NV_MAX_ISR_DELAY_MS (NV_MAX_ISR_DELAY_US / 1000) + ++#if LINUX_VERSION_CODE < KERNEL_VERSION(5,0,0) + #define NV_TIMERCMP(a, b, CMP) \ + (((a)->tv_sec == (b)->tv_sec) ? \ + ((a)->tv_usec CMP (b)->tv_usec) : ((a)->tv_sec CMP (b)->tv_sec)) +@@ -630,6 +633,35 @@ typedef NV_STATUS (*nvPmaEvictRangeCallback)(void *, NvU64, NvU64); + } + + #define NV_TIMEVAL_TO_US(tv) ((NvU64)(tv).tv_sec * 1000000 + (tv).tv_usec) ++#else ++#define NV_TIMERCMP(a, b, CMP) \ ++ (((a)->tv_sec == (b)->tv_sec) ? \ ++ ((a)->tv_nsec CMP (b)->tv_nsec) : ((a)->tv_sec CMP (b)->tv_sec)) ++ ++#define NV_TIMERADD(a, b, result) \ ++ { \ ++ (result)->tv_sec = (a)->tv_sec + (b)->tv_sec; \ ++ (result)->tv_nsec = (a)->tv_nsec + (b)->tv_nsec; \ ++ if ((result)->tv_nsec >= NSEC_PER_SEC) \ ++ { \ ++ ++(result)->tv_sec; \ ++ (result)->tv_nsec -= NSEC_PER_SEC; \ ++ } \ ++ } ++ ++#define NV_TIMERSUB(a, b, result) \ ++ { \ ++ (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ ++ (result)->tv_nsec = (a)->tv_nsec - (b)->tv_nsec; \ ++ if ((result)->tv_nsec < 0) \ ++ { \ ++ --(result)->tv_sec; \ ++ (result)->tv_nsec += NSEC_PER_SEC; \ ++ } \ ++ } ++ ++#define NV_TIMEVAL_TO_US(tv) ((NvU64)(tv).tv_sec * USEC_PER_SEC + (tv).tv_nsec/NSEC_PER_USEC) ++#endif + + #ifndef NV_ALIGN_UP + #define NV_ALIGN_UP(v,g) (((v) + ((g) - 1)) & ~((g) - 1)) +diff --git a/kernel-dkms/conftest.sh b/kernel-dkms/conftest.sh +index 0ae7a2662..9a71ae7b3 100755 +--- a/kernel-dkms/conftest.sh ++++ b/kernel-dkms/conftest.sh +@@ -1653,6 +1653,24 @@ compile_test() { + compile_check_conftest "$CODE" "NV_DRM_AVAILABLE" "" "generic" + ;; + ++ drm_dev_put) ++ # ++ # Determine if drm_dev_put() is present. ++ # ++ CODE=" ++ #include ++ #if defined(NV_DRM_DRMP_H_PRESENT) ++ #include ++ #endif ++#if LINUX_VERSION_CODE => KERNEL_VERSION(5,0,0) ++ void conftest_drm_dev_put(void) { ++ drm_dev_put(); ++ } ++#endif" ++ ++ compile_check_conftest "$CODE" "NV_DRM_DEV_PUT_PRESENT" "" "functions" ++ ;; ++ + drm_dev_unref) + # + # Determine if drm_dev_unref() is present. +diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-gem.h b/kernel-dkms/nvidia-drm/nvidia-drm-gem.h +index f276588db..7cbdbe632 100644 +--- a/kernel-dkms/nvidia-drm/nvidia-drm-gem.h ++++ b/kernel-dkms/nvidia-drm/nvidia-drm-gem.h +@@ -79,7 +81,11 @@ static inline int nv_drm_gem_handle_create_drop_reference( + + /* drop reference from allocate - handle holds it now */ + ++#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0) + drm_gem_object_unreference_unlocked(&nv_gem->base); ++#else ++ drm_gem_object_put_unlocked(&nv_gem->base); ++#endif + + return ret; + } +@@ -148,13 +154,21 @@ static inline struct nv_drm_gem_object *nv_drm_gem_object_lookup( + static inline void + nv_drm_gem_object_unreference_unlocked(struct nv_drm_gem_object *nv_gem) + { ++#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0) + drm_gem_object_unreference_unlocked(&nv_gem->base); ++#else ++ drm_gem_object_put_unlocked(&nv_gem->base); ++#endif + } + + static inline void + nv_drm_gem_object_unreference(struct nv_drm_gem_object *nv_gem) + { ++#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0) + drm_gem_object_unreference(&nv_gem->base); ++#else ++ drm_gem_object_put(&nv_gem->base); ++#endif + } + + static inline int nv_drm_gem_handle_create(struct drm_file *filp, +diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-helper.c b/kernel-dkms/nvidia-drm/nvidia-drm-helper.c +index 4ccf81929..7fb59bbb3 100644 +--- a/kernel-dkms/nvidia-drm/nvidia-drm-helper.c ++++ b/kernel-dkms/nvidia-drm/nvidia-drm-helper.c +@@ -149,12 +151,20 @@ void nv_drm_atomic_clean_old_fb(struct drm_device *dev, + if (ret == 0) { + struct drm_framebuffer *new_fb = plane->state->fb; + if (new_fb) ++#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0) + drm_framebuffer_reference(new_fb); ++#else ++ drm_framebuffer_get(new_fb); ++#endif + plane->fb = new_fb; + plane->crtc = plane->state->crtc; + + if (plane->old_fb) ++#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0) + drm_framebuffer_unreference(plane->old_fb); ++#else ++ drm_framebuffer_put(plane->old_fb); ++#endif + } + plane->old_fb = NULL; + } +diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-helper.h b/kernel-dkms/nvidia-drm/nvidia-drm-helper.h +index efecc4ad7..2a0c3bbca 100644 +--- a/kernel-dkms/nvidia-drm/nvidia-drm-helper.h ++++ b/kernel-dkms/nvidia-drm/nvidia-drm-helper.h +@@ -36,7 +36,9 @@ + */ + static inline void nv_drm_dev_free(struct drm_device *dev) + { +-#if defined(NV_DRM_DEV_UNREF_PRESENT) ++#if defined(NV_DRM_DEV_PUT_PRESENT) ++ drm_dev_put(dev); ++#elif defined(NV_DRM_DEV_UNREF_PRESENT) + drm_dev_unref(dev); + #else + drm_dev_free(dev); +diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-linux.c b/kernel-dkms/nvidia-drm/nvidia-drm-linux.c +index 5a2bbc18c..133d8fe64 100644 +--- a/kernel-dkms/nvidia-drm/nvidia-drm-linux.c ++++ b/kernel-dkms/nvidia-drm/nvidia-drm-linux.c +@@ -151,11 +153,19 @@ void nv_drm_vunmap(void *address) + + uint64_t nv_drm_get_time_usec(void) + { ++#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0) + struct timeval tv; + + do_gettimeofday(&tv); + + return (((uint64_t)tv.tv_sec) * 1000000) + tv.tv_usec; ++#else ++ struct timespec64 ts; ++ ++ ktime_get_real_ts64(&ts); ++ ++ return (((uint64_t)ts.tv_sec) * USEC_PER_SEC) + (((uint64_t)ts.tv_nsec) / NSEC_PER_USEC); ++#endif + } + + #endif /* NV_DRM_AVAILABLE */ +diff --git a/kernel-dkms/nvidia-drm/nvidia-drm.Kbuild b/kernel-dkms/nvidia-drm/nvidia-drm.Kbuild +index 466b51528..bcf8aff10 100644 +--- a/kernel-dkms/nvidia-drm/nvidia-drm.Kbuild ++++ b/kernel-dkms/nvidia-drm/nvidia-drm.Kbuild +@@ -53,6 +53,7 @@ NV_CONFTEST_GENERIC_COMPILE_TESTS += drm_atomic_modeset_nonblocking_commit_avail + NV_CONFTEST_GENERIC_COMPILE_TESTS += is_export_symbol_gpl_refcount_inc + NV_CONFTEST_GENERIC_COMPILE_TESTS += is_export_symbol_gpl_refcount_dec_and_test + ++NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_dev_put + NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_dev_unref + NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_reinit_primary_mode_group + NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_atomic_set_mode_for_crtc +diff --git a/kernel-dkms/nvidia-modeset/nvidia-modeset-linux.c b/kernel-dkms/nvidia-modeset/nvidia-modeset-linux.c +index 1b9148ee7..4c1bd3617 100644 +--- a/kernel-dkms/nvidia-modeset/nvidia-modeset-linux.c ++++ b/kernel-dkms/nvidia-modeset/nvidia-modeset-linux.c +@@ -210,11 +212,19 @@ void NVKMS_API_CALL nvkms_usleep(NvU64 usec) + + NvU64 NVKMS_API_CALL nvkms_get_usec(void) + { ++#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0) + struct timeval tv; + + do_gettimeofday(&tv); + + return (((NvU64)tv.tv_sec) * 1000000) + tv.tv_usec; ++#else ++ struct timespec64 ts; ++ ++ ktime_get_real_ts64(&ts); ++ ++ return (((NvU64)ts.tv_sec) * 1000000) + ts.tv_nsec/NSEC_PER_USEC; ++#endif + } + + int NVKMS_API_CALL nvkms_copyin(void *kptr, NvU64 uaddr, size_t n) +diff --git a/kernel-dkms/nvidia-uvm/uvm_linux.h b/kernel-dkms/nvidia-uvm/uvm_linux.h +index 8707ac070..990cefbd4 100644 +--- a/kernel-dkms/nvidia-uvm/uvm_linux.h ++++ b/kernel-dkms/nvidia-uvm/uvm_linux.h +@@ -320,12 +322,21 @@ static inline uint64_t NV_DIV64(uint64_t dividend, uint64_t divisor, uint64_t *r + /* Return a nanosecond-precise value */ + static inline NvU64 NV_GETTIME(void) + { ++#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0) + struct timespec ts = {0}; + + getrawmonotonic(&ts); + + /* Wraps around every 583 years */ + return (ts.tv_sec * 1000000000ULL + ts.tv_nsec); ++#else ++ struct timespec64 ts = {0}; ++ ++ ktime_get_raw_ts64(&ts); ++ ++ /* Wraps around every 583 years */ ++ return (ts.tv_sec * NSEC_PER_SEC + ts.tv_nsec); ++#endif + } + #else + /* We can only return a microsecond-precise value with the +@@ -334,9 +345,15 @@ static inline NvU64 NV_GETTIME(void) + { + struct timeval tv = {0}; + ++#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0) + do_gettimeofday(&tv); + + return (tv.tv_sec * 1000000000ULL + tv.tv_usec * 1000ULL); ++#else ++ ktime_get_real_ts64(&tv); ++ ++ return (tv.tv_sec * 1000000000ULL + (tv.tv_nsec/NSEC_PER_USEC) * 1000ULL); ++#endif + } + #endif + +diff --git a/kernel-dkms/nvidia/nvlink_linux.c b/kernel-dkms/nvidia/nvlink_linux.c +index c13b72515..db691679c 100644 +--- a/kernel-dkms/nvidia/nvlink_linux.c ++++ b/kernel-dkms/nvidia/nvlink_linux.c +@@ -500,6 +502,7 @@ void * NVLINK_API_CALL nvlink_memcpy(void *dest, void *src, NvLength size) + return memcpy(dest, src, size); + } + ++#if LINUX_VERSION_CODE < KERNEL_VERSION(5,0,0) + static NvBool nv_timer_less_than + ( + const struct timeval *a, +@@ -610,6 +613,118 @@ void NVLINK_API_CALL nvlink_sleep(unsigned int ms) + udelay(us); + } + } ++#else ++static NvBool nv_timer_less_than ++( ++ const struct timespec64 *a, ++ const struct timespec64 *b ++) ++{ ++ return (a->tv_sec == b->tv_sec) ? (a->tv_nsec < b->tv_nsec) ++ : (a->tv_sec < b->tv_sec); ++} ++ ++static void nv_timeradd ++( ++ const struct timespec64 *a, ++ const struct timespec64 *b, ++ struct timespec64 *result ++) ++{ ++ result->tv_sec = a->tv_sec + b->tv_sec; ++ result->tv_nsec = a->tv_nsec + b->tv_nsec; ++ while (result->tv_nsec >= NSEC_PER_SEC) ++ { ++ ++result->tv_sec; ++ result->tv_nsec -= NSEC_PER_SEC; ++ } ++} ++ ++static void nv_timersub ++( ++ const struct timespec64 *a, ++ const struct timespec64 *b, ++ struct timespec64 *result ++) ++{ ++ result->tv_sec = a->tv_sec - b->tv_sec; ++ result->tv_nsec = a->tv_nsec - b->tv_nsec; ++ while (result->tv_nsec < 0) ++ { ++ --(result->tv_sec); ++ result->tv_nsec += NSEC_PER_SEC; ++ } ++} ++ ++/* ++ * Sleep for specified milliseconds. Yields the CPU to scheduler. ++ */ ++void NVLINK_API_CALL nvlink_sleep(unsigned int ms) ++{ ++ unsigned long us; ++ unsigned long jiffies; ++ unsigned long mdelay_safe_msec; ++ struct timespec64 ts_end, ts_aux; ++ ++ ktime_get_real_ts64(&ts_aux); ++ ++ if (in_irq() && (ms > NV_MAX_ISR_DELAY_MS)) ++ { ++ return; ++ } ++ ++ if (irqs_disabled() || in_interrupt() || in_atomic()) ++ { ++ mdelay(ms); ++ return; ++ } ++ ++ us = ms * 1000; ++ ts_end.tv_nsec = us*NSEC_PER_USEC; ++ ts_end.tv_sec = 0; ++ nv_timeradd(&ts_aux, &ts_end, &ts_end); ++ ++ /* do we have a full jiffie to wait? */ ++ jiffies = NV_USECS_TO_JIFFIES(us); ++ ++ if (jiffies) ++ { ++ // ++ // If we have at least one full jiffy to wait, give up ++ // up the CPU; since we may be rescheduled before ++ // the requested timeout has expired, loop until less ++ // than a jiffie of the desired delay remains. ++ // ++ current->state = TASK_INTERRUPTIBLE; ++ do ++ { ++ schedule_timeout(jiffies); ++ ktime_get_real_ts64(&ts_aux); ++ if (nv_timer_less_than(&ts_aux, &ts_end)) ++ { ++ nv_timersub(&ts_end, &ts_aux, &ts_aux); ++ us = ts_aux.tv_nsec/NSEC_PER_USEC + ts_aux.tv_sec * USEC_PER_SEC; ++ } ++ else ++ { ++ us = 0; ++ } ++ } ++ while ((jiffies = NV_USECS_TO_JIFFIES(us)) != 0); ++ } ++ ++ if (us > 1000) ++ { ++ mdelay_safe_msec = us / USEC_PER_MSEC; ++ mdelay(mdelay_safe_msec); ++ us %= 1000; ++ } ++ if (us) ++ { ++ udelay(us); ++ } ++} ++#endif + + void NVLINK_API_CALL nvlink_assert(int cond) + { +diff --git a/kernel-dkms/nvidia/os-interface.c b/kernel-dkms/nvidia/os-interface.c +index d1c889f69..88c57b2da 100644 +--- a/kernel-dkms/nvidia/os-interface.c ++++ b/kernel-dkms/nvidia/os-interface.c +@@ -426,6 +428,7 @@ NV_STATUS NV_API_CALL os_get_current_time( + NvU32 *seconds, + NvU32 *useconds + ) ++#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0) + { + struct timeval tm; + +@@ -608,6 +611,190 @@ NV_STATUS NV_API_CALL os_delay(NvU32 MilliSeconds) + + return NV_OK; + } ++#else ++{ ++ struct timespec64 ts; ++ ++ ktime_get_real_ts64(&ts); ++ ++ *seconds = ts.tv_sec; ++ *useconds = ((uint64_t)(ts.tv_nsec / NSEC_PER_USEC)); ++ ++ return NV_OK; ++} ++ ++#if BITS_PER_LONG >= 64 ++ ++void NV_API_CALL os_get_current_tick(NvU64 *nseconds) ++{ ++ struct timespec64 ts; ++ ++ jiffies_to_timespec64(jiffies, &ts); ++ ++ *nseconds = ((NvU64)ts.tv_sec * NSEC_PER_SEC + (NvU64)ts.tv_nsec); ++} ++ ++#else ++ ++void NV_API_CALL os_get_current_tick(NvU64 *nseconds) ++{ ++ /* ++ * 'jiffies' overflows regularly on 32-bit builds (unsigned long is 4 bytes ++ * instead of 8 bytes), so it's unwise to build a tick counter on it, since ++ * the rest of the Resman assumes the 'tick' returned from this function is ++ * monotonically increasing and never overflows. ++ * ++ * Instead, use the previous implementation that we've lived with since the ++ * beginning, which uses system clock time to calculate the tick. This is ++ * subject to problems if the system clock time changes dramatically ++ * (more than a second or so) while the Resman is actively tracking a ++ * timeout. ++ */ ++ NvU32 seconds, useconds; ++ ++ (void) os_get_current_time(&seconds, &useconds); ++ ++ *nseconds = ((NvU64)seconds * NSEC_PER_SEC + ++ (NvU64)useconds * NSEC_PER_USEC); ++} ++ ++#endif ++ ++//--------------------------------------------------------------------------- ++// ++// Misc services. ++// ++//--------------------------------------------------------------------------- ++ ++#define NV_MSECS_PER_JIFFIE (1000 / HZ) ++#define NV_MSECS_TO_JIFFIES(msec) ((msec) * HZ / 1000) ++#define NV_USECS_PER_JIFFIE (1000000 / HZ) ++#define NV_USECS_TO_JIFFIES(usec) ((usec) * HZ / 1000000) ++ ++// #define NV_CHECK_DELAY_ACCURACY 1 ++ ++/* ++ * It is generally a bad idea to use udelay() to wait for more than ++ * a few milliseconds. Since the caller is most likely not aware of ++ * this, we use mdelay() for any full millisecond to be safe. ++ */ ++ ++NV_STATUS NV_API_CALL os_delay_us(NvU32 MicroSeconds) ++{ ++ unsigned long mdelay_safe_msec; ++ unsigned long usec; ++ ++#ifdef NV_CHECK_DELAY_ACCURACY ++ struct timespec64 ts1, ts2; ++ ++ ktime_get_real_ts64(&ts1); ++#endif ++ ++ if (in_irq() && (MicroSeconds > NV_MAX_ISR_DELAY_US)) ++ return NV_ERR_GENERIC; ++ ++ mdelay_safe_msec = MicroSeconds / 1000; ++ if (mdelay_safe_msec) ++ mdelay(mdelay_safe_msec); ++ ++ usec = MicroSeconds % 1000; ++ if (usec) ++ udelay(usec); ++ ++#ifdef NV_CHECK_DELAY_ACCURACY ++ ktime_get_real_ts64(&ts2); ++ nv_printf(NV_DBG_ERRORS, "NVRM: osDelayUs %d: 0x%x 0x%x\n", ++ MicroSeconds, ts2.tv_sec - ts1.tv_sec, (ts2.tv_nsec - ts1.tv_nsec) / NSEC_PER_USEC); ++#endif ++ ++ return NV_OK; ++} ++ ++/* ++ * On Linux, a jiffie represents the time passed in between two timer ++ * interrupts. The number of jiffies per second (HZ) varies across the ++ * supported platforms. On i386, where HZ is 100, a timer interrupt is ++ * generated every 10ms; the resolution is a lot better on ia64, where ++ * HZ is 1024. NV_MSECS_TO_JIFFIES should be accurate independent of ++ * the actual value of HZ; any partial jiffies will be 'floor'ed, the ++ * remainder will be accounted for with mdelay(). ++ */ ++ ++NV_STATUS NV_API_CALL os_delay(NvU32 MilliSeconds) ++{ ++ unsigned long MicroSeconds; ++ unsigned long jiffies; ++ unsigned long mdelay_safe_msec; ++ struct timespec64 ts_end, ts_aux; ++#ifdef NV_CHECK_DELAY_ACCURACY ++ struct timespec64 ts_start; ++#endif ++ ++ ktime_get_real_ts64(&ts_aux); ++#ifdef NV_CHECK_DELAY_ACCURACY ++ ts_start = ts_aux; ++#endif ++ ++ if (in_irq() && (MilliSeconds > NV_MAX_ISR_DELAY_MS)) ++ return NV_ERR_GENERIC; ++ ++ if (!NV_MAY_SLEEP()) ++ { ++ mdelay(MilliSeconds); ++ return NV_OK; ++ } ++ ++ MicroSeconds = MilliSeconds * USEC_PER_MSEC; ++ ts_end.tv_nsec = MicroSeconds * NSEC_PER_USEC; ++ ts_end.tv_sec = 0; ++ NV_TIMERADD(&ts_aux, &ts_end, &ts_end); ++ ++ /* do we have a full jiffie to wait? */ ++ jiffies = NV_USECS_TO_JIFFIES(MicroSeconds); ++ ++ if (jiffies) ++ { ++ // ++ // If we have at least one full jiffy to wait, give up ++ // up the CPU; since we may be rescheduled before ++ // the requested timeout has expired, loop until less ++ // than a jiffie of the desired delay remains. ++ // ++ current->state = TASK_INTERRUPTIBLE; ++ do ++ { ++ schedule_timeout(jiffies); ++ ktime_get_real_ts64(&ts_aux); ++ if (NV_TIMERCMP(&ts_aux, &ts_end, <)) ++ { ++ NV_TIMERSUB(&ts_end, &ts_aux, &ts_aux); ++ MicroSeconds = ts_aux.tv_nsec/NSEC_PER_USEC + ts_aux.tv_sec * USEC_PER_SEC; ++ } ++ else ++ MicroSeconds = 0; ++ } while ((jiffies = NV_USECS_TO_JIFFIES(MicroSeconds)) != 0); ++ } ++ ++ if (MicroSeconds > 1000) ++ { ++ mdelay_safe_msec = MicroSeconds / 1000; ++ mdelay(mdelay_safe_msec); ++ MicroSeconds %= 1000; ++ } ++ if (MicroSeconds) ++ { ++ udelay(MicroSeconds); ++ } ++#ifdef NV_CHECK_DELAY_ACCURACY ++ ktime_get_real_ts64(&ts_aux); ++ timersub(&ts_aux, &ts_start, &ts_aux); ++ nv_printf(NV_DBG_ERRORS, "NVRM: osDelay %dmsec: %d.%06dsec\n", ++ MilliSeconds, ts_aux.tv_sec, ts_aux.tv_nsec/NSEC_PER_USEC); ++#endif ++ ++ return NV_OK; ++} ++#endif + + NvU64 NV_API_CALL os_get_cpu_frequency(void) + { +@@ -1896,6 +2083,7 @@ static NV_STATUS NV_API_CALL _os_ipmi_receive_resp + nvipmi_resp_t *p_resp + ) + { ++#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0) + struct ipmi_recv_msg *rx_msg; + int err_no; + struct timeval tv; +@@ -1928,6 +2116,40 @@ static NV_STATUS NV_API_CALL _os_ipmi_receive_resp + os_delay(NV_IPMI_SLEEP_MS); + do_gettimeofday(&tv); + } while (NV_TIMEVAL_TO_US(tv) < (start_time + NV_IPMI_READ_TIMEOUT_US)); ++#else ++ struct ipmi_recv_msg *rx_msg; ++ int err_no; ++ struct timespec64 ts; ++ NvU64 start_time; ++ ++ ktime_get_real_ts64(&ts); ++ start_time = NV_TIMEVAL_TO_US(ts); ++ ++ err_no = -EAGAIN; ++ do ++ { ++ unsigned long flags; ++ struct list_head *ent; ++ ++ rx_msg = NULL; ++ ++ spin_lock_irqsave(&p_priv->msg_lock, flags); ++ if (!list_empty(&p_priv->msgs)) ++ { ++ ent = p_priv->msgs.next; ++ rx_msg = list_entry(ent, struct ipmi_recv_msg, link); ++ list_del(ent); ++ spin_unlock_irqrestore(&p_priv->msg_lock, flags); ++ ++ err_no = 0; ++ break; ++ } ++ ++ spin_unlock_irqrestore(&p_priv->msg_lock, flags); ++ os_delay(NV_IPMI_SLEEP_MS); ++ ktime_get_real_ts64(&ts); ++ } while (NV_TIMEVAL_TO_US(ts) < (start_time + NV_IPMI_READ_TIMEOUT_US)); ++#endif + + if (rx_msg != NULL) + { diff --git a/patches/kernel-5.1.patch b/patches/kernel-5.1.patch new file mode 100644 index 0000000..214d0a3 --- /dev/null +++ b/patches/kernel-5.1.patch @@ -0,0 +1,98 @@ +From c2c16eef00915cbe7a7bc58b1f3308705ef2bfc4 Mon Sep 17 00:00:00 2001 +From: Tk-Glitch +Date: Wed, 3 Apr 2019 18:02:22 +0200 +Subject: nvidia kernel 5.1 patch (exploded into parts). +Thanks to Robert Gadsdon's findings @ http://rglinuxtech.com + + +diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-connector.c b/kernel-dkms/nvidia-drm/nvidia-drm-connector.c +index 4dd12d112..44c9d8ed3 100644 +--- a/kernel-dkms/nvidia-drm/nvidia-drm-connector.c ++++ b/kernel-dkms/nvidia-drm/nvidia-drm-connector.c +@@ -201,6 +203,12 @@ nv_drm_connector_detect(struct drm_connector *connector, bool force) + return __nv_drm_connector_detect_internal(connector); + } + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0) ++int drm_helper_probe_single_connector_modes(struct drm_connector ++ *connector, uint32_t maxX, ++ uint32_t maxY); ++#endif ++ + static struct drm_connector_funcs nv_connector_funcs = { + #if defined NV_DRM_ATOMIC_HELPER_CONNECTOR_DPMS_PRESENT + .dpms = drm_atomic_helper_connector_dpms, +diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-drv.c b/kernel-dkms/nvidia-drm/nvidia-drm-drv.c +index 58fd2724a..fc9169a96 100644 +--- a/kernel-dkms/nvidia-drm/nvidia-drm-drv.c ++++ b/kernel-dkms/nvidia-drm/nvidia-drm-drv.c +@@ -35,6 +37,13 @@ + #include "nvidia-drm-gem-nvkms-memory.h" + #include "nvidia-drm-gem-user-memory.h" + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0) ++void drm_kms_helper_poll_init(struct drm_device *dev); ++void drm_kms_helper_poll_fini(struct drm_device *dev); ++bool drm_helper_hpd_irq_event(struct drm_device *dev); ++void drm_kms_helper_poll_disable(struct drm_device *dev); ++#endif ++ + #if defined(NV_DRM_AVAILABLE) + + #include "nvidia-drm-ioctl.h" +diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-encoder.c b/kernel-dkms/nvidia-drm/nvidia-drm-encoder.c +index f66bbd7c9..4de87a271 100644 +--- a/kernel-dkms/nvidia-drm/nvidia-drm-encoder.c ++++ b/kernel-dkms/nvidia-drm/nvidia-drm-encoder.c +@@ -36,6 +38,10 @@ + #include + #include + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0) ++void drm_kms_helper_hotplug_event(struct drm_device *dev); ++#endif ++ + static void nv_drm_encoder_destroy(struct drm_encoder *encoder) + { + struct nv_drm_encoder *nv_encoder = to_nv_encoder(encoder); +@@ -152,6 +158,12 @@ nv_drm_encoder_new(struct drm_device *dev, + return &nv_encoder->base; + } + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0) ++int drm_helper_probe_single_connector_modes(struct drm_connector ++ *connector, uint32_t maxX, ++ uint32_t maxY); ++#endif ++ + /* + * Add encoder for given NvKmsKapiDisplay + */ +diff --git a/kernel-dkms/nvidia-uvm/uvm8.c b/kernel-dkms/nvidia-uvm/uvm8.c +index 44467988e..4cba5dc33 100644 +--- a/kernel-dkms/nvidia-uvm/uvm8.c ++++ b/kernel-dkms/nvidia-uvm/uvm8.c +@@ -172,7 +172,11 @@ static int uvm_vm_fault_sigbus(struct vm_area_struct *vma, struct vm_fault *vmf) + return VM_FAULT_SIGBUS; + } + ++#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 1, 0) + static int uvm_vm_fault_sigbus_wrapper(struct vm_fault *vmf) ++#else ++static vm_fault_t uvm_vm_fault_sigbus_wrapper(struct vm_fault *vmf) ++#endif + { + #if defined(NV_VM_OPS_FAULT_REMOVED_VMA_ARG) + return uvm_vm_fault_sigbus(vmf->vma, vmf); +@@ -507,7 +511,11 @@ convert_error: + } + } + ++#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 1, 0) + static int uvm_vm_fault_wrapper(struct vm_fault *vmf) ++#else ++static vm_fault_t uvm_vm_fault_wrapper(struct vm_fault *vmf) ++#endif + { + #if defined(NV_VM_OPS_FAULT_REMOVED_VMA_ARG) + return uvm_vm_fault(vmf->vma, vmf); diff --git a/patches/kernel-5.2.patch b/patches/kernel-5.2.patch new file mode 100644 index 0000000..109e5af --- /dev/null +++ b/patches/kernel-5.2.patch @@ -0,0 +1,57 @@ +From 9b34e3b6b42a826fac66c8ff44e6260a09758c53 Mon Sep 17 00:00:00 2001 +From: Tk-Glitch +Date: Mon, 8 Jul 2019 10:19:45 +0200 +Subject: nvidia kernel 5.2 patch + + +diff --git a/kernel-dkms/nvidia-uvm/uvm8_tools.c b/kernel-dkms/nvidia-uvm/uvm8_tools.c +index 82c890587..cea2eb54c 100644 +--- a/kernel-dkms/nvidia-uvm/uvm8_tools.c ++++ b/kernel-dkms/nvidia-uvm/uvm8_tools.c +@@ -206,18 +206,34 @@ static bool tracker_is_counter(uvm_tools_event_tracker_t *event_tracker) + return event_tracker != NULL && !event_tracker->is_queue; + } + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 2, 0) ++static void uvm_put_user_pages_dirty(struct page **pages, NvU64 page_count) ++{ ++ NvU64 i; ++ ++ for (i = 0; i < page_count; i++) { ++ set_page_dirty(pages[i]); ++ put_page(pages[i]); ++ } ++} ++#else + static void put_user_pages(struct page **pages, NvU64 page_count) + { + NvU64 i; + for (i = 0; i < page_count; i++) + put_page(pages[i]); + } ++#endif + + static void unmap_user_pages(struct page **pages, void *addr, NvU64 size) + { + size = DIV_ROUND_UP(size, PAGE_SIZE); + vunmap((NvU8 *)addr); ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 2, 0) ++ uvm_put_user_pages_dirty(pages, size); ++#else + put_user_pages(pages, size); ++#endif + uvm_kvfree(pages); + } + +@@ -281,7 +297,11 @@ fail: + uvm_kvfree(vmas); + + if (ret > 0) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 2, 0) ++ uvm_put_user_pages_dirty(*pages, ret); ++#else + put_user_pages(*pages, ret); ++#endif + else if (ret < 0) + status = errno_to_nv_status(ret); + diff --git a/patches/kernel-5.3.patch b/patches/kernel-5.3.patch new file mode 100644 index 0000000..9cfd4f0 --- /dev/null +++ b/patches/kernel-5.3.patch @@ -0,0 +1,53 @@ +From 635b901ffad338c398a0e2570e990b0df66dd12f Mon Sep 17 00:00:00 2001 +From: Tk-Glitch +Date: Mon, 22 Jul 2019 13:29:48 +0200 +Subject: nvidia kernel 5.3 patch + + +diff --git a/kernel-dkms/common/inc/nv-linux.h b/kernel-dkms/common/inc/nv-linux.h +index 9341e676b..41289217e 100644 +--- a/kernel-dkms/common/inc/nv-linux.h ++++ b/kernel-dkms/common/inc/nv-linux.h +@@ -475,7 +475,11 @@ extern int nv_pat_mode; + __cpuc_flush_kern_all(); + } + #define CACHE_FLUSH() nv_flush_cache_cpu(NULL) +-#define CACHE_FLUSH_ALL() NV_ON_EACH_CPU(nv_flush_cache_cpu, NULL) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0) ++#define CACHE_FLUSH_ALL() on_each_cpu(nv_flush_cache_cpu, NULL, 1) ++#else ++#define CACHE_FLUSH_ALL() NV_ON_EACH_CPU(nv_flush_cache_cpu, NULL) ++#endif + #if defined(NV_OUTER_FLUSH_ALL_PRESENT) + #define OUTER_FLUSH_ALL() outer_flush_all() + #endif +@@ -489,7 +493,11 @@ extern int nv_pat_mode; + flush_cache_all(); + } + #define CACHE_FLUSH() nv_flush_cache_cpu(NULL) +-#define CACHE_FLUSH_ALL() NV_ON_EACH_CPU(nv_flush_cache_cpu, NULL) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0) ++#define CACHE_FLUSH_ALL() on_each_cpu(nv_flush_cache_cpu, NULL, 1) ++#else ++#define CACHE_FLUSH_ALL() NV_ON_EACH_CPU(nv_flush_cache_cpu, NULL) ++#endif + #define WRITE_COMBINE_FLUSH() mb() + #endif + #elif defined(NVCPU_PPC64LE) + +diff --git a/kernel-dkms/nvidia/nv_uvm_interface.c b/kernel-dkms/nvidia/nv_uvm_interface.c +index e96b04e0c..18d80b09f 100644 +--- a/kernel-dkms/nvidia/nv_uvm_interface.c ++++ b/kernel-dkms/nvidia/nv_uvm_interface.c +@@ -988,7 +988,11 @@ void nvUvmInterfaceDeRegisterUvmOps(void) + // Note that since we dropped the lock, another set of callbacks could have + // already been registered. That's ok, since we just need to wait for old + // ones to finish. ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0) ++ on_each_cpu(flush_top_half, NULL, 1); ++#else + NV_ON_EACH_CPU(flush_top_half, NULL); ++#endif + } + EXPORT_SYMBOL(nvUvmInterfaceDeRegisterUvmOps); + diff --git a/patches/kernel-5.4-prime.diff b/patches/kernel-5.4-prime.diff new file mode 100644 index 0000000..aeb4389 --- /dev/null +++ b/patches/kernel-5.4-prime.diff @@ -0,0 +1,110 @@ + diff --git a/kernel-dkms/conftest.sh b/kernel-dkms/conftest.sh + index c9c2db3..a10463d 100755 + --- a/kernel-dkms/conftest.sh + +++ b/kernel-dkms/conftest.sh + @@ -130,6 +130,7 @@ test_headers() { + FILES="$FILES linux/sched/signal.h" + FILES="$FILES linux/sched/task.h" + FILES="$FILES linux/sched/task_stack.h" + + FILES="$FILES linux/reservation.h" + FILES="$FILES xen/ioemu.h" + FILES="$FILES linux/fence.h" + FILES="$FILES soc/tegra/chip-id.h" + @@ -2063,7 +2064,7 @@ compile_test() { + CODE=" + #include + int conftest_drm_driver_has_gem_prime_res_obj(void) { + - return offsetof(struct drm_driver, gem_prime_res_obj); + + //return offsetof(struct drm_driver, gem_prime_res_obj); + }" + + compile_check_conftest "$CODE" "NV_DRM_DRIVER_HAS_GEM_PRIME_RES_OBJ" "" "types" + diff --git a/kernel-dkms/nvidia-drm/nvidia-dma-fence-helper.h b/kernel-dkms/nvidia-drm/nvidia-dma-fence-helper.h + index 0aa5a4f..f289636 100644 + --- a/kernel-dkms/nvidia-drm/nvidia-dma-fence-helper.h + +++ b/kernel-dkms/nvidia-drm/nvidia-dma-fence-helper.h + @@ -40,7 +40,9 @@ + #include + #endif + + +#if defined(NV_LINUX_RESERVATION_H_PRESENT) + #include + +#endif + + #if defined(NV_LINUX_FENCE_H_PRESENT) + typedef struct fence nv_dma_fence_t; + diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-drv.c b/kernel-dkms/nvidia-drm/nvidia-drm-drv.c + index a66d3cc..b79330a 100644 + --- a/kernel-dkms/nvidia-drm/nvidia-drm-drv.c + +++ b/kernel-dkms/nvidia-drm/nvidia-drm-drv.c + @@ -681,7 +681,7 @@ static struct drm_driver nv_drm_driver = { + .gem_prime_vunmap = nv_drm_gem_prime_vunmap, + + #if defined(NV_DRM_DRIVER_HAS_GEM_PRIME_RES_OBJ) + - .gem_prime_res_obj = nv_drm_gem_prime_res_obj, + + //.gem_prime_res_obj = nv_drm_gem_prime_res_obj, + #endif + + #if defined(NV_DRM_DRIVER_HAS_SET_BUSID) + diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-gem.c b/kernel-dkms/nvidia-drm/nvidia-drm-gem.c + index 7201ade..d58f4f0 100644 + --- a/kernel-dkms/nvidia-drm/nvidia-drm-gem.c + +++ b/kernel-dkms/nvidia-drm/nvidia-drm-gem.c + @@ -46,7 +46,7 @@ void nv_drm_gem_free(struct drm_gem_object *gem) + drm_gem_object_release(&nv_gem->base); + + #if defined(NV_DRM_DRIVER_HAS_GEM_PRIME_RES_OBJ) + - reservation_object_fini(&nv_gem->resv); + + dma_resv_fini(&nv_gem->resv); + #endif + + nv_gem->ops->free(nv_gem); + @@ -113,12 +113,14 @@ void nv_drm_gem_prime_vunmap(struct drm_gem_object *gem, void *address) + } + + #if defined(NV_DRM_DRIVER_HAS_GEM_PRIME_RES_OBJ) + +/* + struct reservation_object* nv_drm_gem_prime_res_obj(struct drm_gem_object *obj) + { + struct nv_drm_gem_object *nv_gem = to_nv_gem_object(obj); + + return &nv_gem->resv; + } + +*/ + #endif + + #endif /* NV_DRM_AVAILABLE */ + diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-gem.h b/kernel-dkms/nvidia-drm/nvidia-drm-gem.h + index b621969..e671795 100644 + --- a/kernel-dkms/nvidia-drm/nvidia-drm-gem.h + +++ b/kernel-dkms/nvidia-drm/nvidia-drm-gem.h + @@ -56,7 +56,7 @@ struct nv_drm_gem_object { + const struct nv_drm_gem_object_funcs *ops; + + #if defined(NV_DRM_DRIVER_HAS_GEM_PRIME_RES_OBJ) + - struct reservation_object resv; + + struct dma_resv resv; + #endif + }; + + @@ -127,7 +127,7 @@ void nv_drm_gem_object_init(struct nv_drm_device *nv_dev, + drm_gem_private_object_init(dev, &nv_gem->base, size); + + #if defined(NV_DRM_DRIVER_HAS_GEM_PRIME_RES_OBJ) + - reservation_object_init(&nv_gem->resv); + + dma_resv_init(&nv_gem->resv); + #endif + } + + diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-prime-fence.c b/kernel-dkms/nvidia-drm/nvidia-drm-prime-fence.c + index 1f10940..5114965 100644 + --- a/kernel-dkms/nvidia-drm/nvidia-drm-prime-fence.c + +++ b/kernel-dkms/nvidia-drm/nvidia-drm-prime-fence.c + @@ -518,7 +518,7 @@ int nv_drm_gem_fence_attach_ioctl(struct drm_device *dev, + goto fence_context_create_fence_failed; + } + + - reservation_object_add_excl_fence(&nv_gem->resv, fence); + + dma_resv_add_excl_fence(&nv_gem->resv, fence); + + ret = 0; diff --git a/patches/kernel-5.4-symver.diff b/patches/kernel-5.4-symver.diff new file mode 100644 index 0000000..30048e8 --- /dev/null +++ b/patches/kernel-5.4-symver.diff @@ -0,0 +1,13 @@ +diff --git a/kernel-dkms/conftest.sh b/kernel-dkms/conftest.sh +index c00c826..40c54f6 100755 +--- a/kernel-dkms/conftest.sh ++++ b/kernel-dkms/conftest.sh +@@ -3585,7 +3585,7 @@ case "$5" in + TAB=' ' + + if [ -f "$OUTPUT/Module.symvers" ] && \ +- grep -e "^[^${TAB}]*${TAB}[^${TAB}]*${TAB}vmlinux" \ ++ grep -e "^[^${TAB}]*${TAB}[^${TAB}]*.*${TAB}vmlinux" \ + "$OUTPUT/Module.symvers" >/dev/null 2>&1; then + exit 0 + fi diff --git a/patches/kernel-5.4.patch b/patches/kernel-5.4.patch new file mode 100644 index 0000000..5876020 --- /dev/null +++ b/patches/kernel-5.4.patch @@ -0,0 +1,51 @@ +diff --git a/kernel-dkms/Kbuild b/kernel-dkms/Kbuild +index 1e79d0b..c587f7e 100644 +--- a/kernel-dkms/Kbuild ++++ b/kernel-dkms/Kbuild +@@ -27,10 +27,17 @@ + # $(2): The CFLAGS to add for those object files. + # + ++ifeq ($(shell [ $(VERSION) -gt 5 ] || [ $(VERSION) -eq 5 -a $(PATCHLEVEL) -gt 3 ]; echo $$? ),0) ++ASSIGN_PER_OBJ_CFLAGS = \ ++ $(foreach _cflags_variable, \ ++ $(addprefix CFLAGS_,$(1)), \ ++ $(eval $(_cflags_variable) += $(2))) ++else + ASSIGN_PER_OBJ_CFLAGS = \ + $(foreach _cflags_variable, \ + $(addprefix CFLAGS_,$(notdir $(1))), \ + $(eval $(_cflags_variable) += $(2))) ++endif + + + # +diff --git a/kernel-dkms/conftest.sh b/kernel-dkms/conftest.sh +index c00c826..40c54f6 100755 +--- a/kernel-dkms/conftest.sh ++++ b/kernel-dkms/conftest.sh +@@ -3585,7 +3585,7 @@ case "$5" in + TAB=' ' + + if [ -f "$OUTPUT/Module.symvers" ] && \ +- grep -e "^[^${TAB}]*${TAB}[^${TAB}]*${TAB}vmlinux" \ ++ grep -e "^[^${TAB}]*${TAB}[^${TAB}]*.*${TAB}vmlinux" \ + "$OUTPUT/Module.symvers" >/dev/null 2>&1; then + exit 0 + fi +diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-drv.c b/kernel-dkms/nvidia-drm/nvidia-drm-drv.c +index bc31de7..7eefe95 100644 +--- a/kernel-dkms/nvidia-drm/nvidia-drm-drv.c ++++ b/kernel-dkms/nvidia-drm/nvidia-drm-drv.c +@@ -659,7 +660,11 @@ static const struct drm_ioctl_desc nv_drm_ioctls[] = { + + static struct drm_driver nv_drm_driver = { + ++#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0) + .driver_features = DRIVER_GEM | DRIVER_PRIME | DRIVER_RENDER, ++#else ++ .driver_features = DRIVER_GEM | DRIVER_RENDER, ++#endif + + .gem_free_object = nv_drm_gem_free, + diff --git a/patches/kernel-5.5.patch b/patches/kernel-5.5.patch new file mode 100644 index 0000000..d845e15 --- /dev/null +++ b/patches/kernel-5.5.patch @@ -0,0 +1,380 @@ +From 18e69d251b7fd3e19adc8a1dabd883641c585455 Mon Sep 17 00:00:00 2001 +From: Tk-Glitch +Date: Mon, 18 Dec 2019 14:11:36 +0100 +Subject: Updated 5.5 patch, from Isaak I. Aleksandrov - https://gitlab.com/snippets/1923197 + + +diff --git a/kernel-dkms/common/inc/nv-drm.h b/kernel-dkms/common/inc/nv-drm.h +new file mode 100644 +index 0000000..07e9f3c +--- /dev/null ++++ b/kernel-dkms/common/inc/nv-drm.h +@@ -0,0 +1,36 @@ ++#ifndef _NV_DRM_H_ ++#define _NV_DRM_H_ ++ ++#include "conftest.h" ++ ++#if defined(NV_DRM_DRMP_H_PRESENT) ++#include ++#else ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include ++#include ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include ++#endif ++ ++#endif +diff --git a/kernel-dkms/conftest.sh b/kernel-dkms/conftest.sh +index c9c2db3..dd22bb0 100755 +--- a/kernel-dkms/conftest.sh ++++ b/kernel-dkms/conftest.sh +@@ -1150,6 +1150,9 @@ compile_test() { + CODE=" + #if defined(NV_DRM_DRMP_H_PRESENT) + #include ++ #else ++ #include ++ #include + #endif + #if !defined(CONFIG_DRM) && !defined(CONFIG_DRM_MODULE) + #error DRM not enabled +@@ -1781,6 +1784,8 @@ compile_test() { + echo "$CONFTEST_PREAMBLE + #if defined(NV_DRM_DRMP_H_PRESENT) + #include ++ #else ++ #include + #endif + #include + #if !defined(CONFIG_DRM) && !defined(CONFIG_DRM_MODULE) +@@ -1909,7 +1914,11 @@ compile_test() { + # attached drivers") in v3.14 (2013-12-11) + # + CODE=" ++ #if defined(NV_DRM_DRMP_H_PRESENT) + #include ++ #else ++ #include ++ #endif + int conftest_drm_driver_has_legacy_dev_list(void) { + return offsetof(struct drm_driver, legacy_dev_list); + }" +@@ -1933,7 +1942,11 @@ compile_test() { + # 2017-07-23 e6fc3b68558e4c6d8d160b5daf2511b99afa8814 + # + CODE=" ++ #if defined(NV_DRM_DRMP_H_PRESENT) + #include ++ #else ++ #include ++ #endif + + int conftest_drm_crtc_init_with_planes_has_name_arg(void) { + return +@@ -1949,7 +1962,11 @@ compile_test() { + compile_check_conftest "$CODE" "NV_DRM_CRTC_INIT_WITH_PLANES_HAS_NAME_ARG" "" "types" + + CODE=" ++ #if defined(NV_DRM_DRMP_H_PRESENT) + #include ++ #else ++ #include ++ #endif + + int conftest_drm_encoder_init_has_name_arg(void) { + return +@@ -1964,7 +1981,11 @@ compile_test() { + compile_check_conftest "$CODE" "NV_DRM_ENCODER_INIT_HAS_NAME_ARG" "" "types" + + echo "$CONFTEST_PREAMBLE ++ #if defined(NV_DRM_DRMP_H_PRESENT) + #include ++ #else ++ #include ++ #endif + + int conftest_drm_universal_plane_init_has_format_modifiers_arg(void) { + return +@@ -1991,7 +2012,11 @@ compile_test() { + echo "#undef NV_DRM_UNIVERSAL_PLANE_INIT_HAS_FORMAT_MODIFIERS_ARG" | append_conftest "types" + + echo "$CONFTEST_PREAMBLE ++ #if defined(NV_DRM_DRMP_H_PRESENT) + #include ++ #else ++ #include ++ #endif + + int conftest_drm_universal_plane_init_has_name_arg(void) { + return +@@ -3084,7 +3109,9 @@ compile_test() { + # drm_framebuffer_{get,put}()") in v4.12 (2017-02-28). + # + CODE=" ++ #if defined(NV_DRM_DRMP_H_PRESENT) + #include ++ #endif + #if defined(NV_DRM_DRM_FRAMEBUFFER_H_PRESENT) + #include + #endif +@@ -3103,7 +3130,9 @@ compile_test() { + # drm_gem_object_{get,put}()") in v4.12 (2017-02-28). + # + CODE=" ++ #if defined(NV_DRM_DRMP_H_PRESENT) + #include ++ #endif + #if defined(NV_DRM_DRM_GEM_H_PRESENT) + #include + #endif +@@ -3122,7 +3151,9 @@ compile_test() { + # functions") in v4.15 (2017-09-26). + # + CODE=" ++ #if defined(NV_DRM_DRMP_H_PRESENT) + #include ++ #endif + #if defined(NV_DRM_DRM_DRV_H_PRESENT) + #include + #endif +diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-connector.c b/kernel-dkms/nvidia-drm/nvidia-drm-connector.c +index 1553ebc..f851561 100644 +--- a/kernel-dkms/nvidia-drm/nvidia-drm-connector.c ++++ b/kernel-dkms/nvidia-drm/nvidia-drm-connector.c +@@ -71,7 +73,11 @@ static enum drm_connector_status __nv_drm_connector_detect_internal( + struct nv_drm_encoder *nv_detected_encoder = NULL; + + struct NvKmsKapiDynamicDisplayParams *pDetectParams = NULL; ++#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 5, 0) + unsigned int i; ++#else ++ struct drm_encoder *encoder = NULL; ++#endif + + BUG_ON(!mutex_is_locked(&dev->mode_config.mutex)); + +@@ -87,11 +93,16 @@ static enum drm_connector_status __nv_drm_connector_detect_internal( + goto done; + } + ++#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 5, 0) + for (i = 0; + i < DRM_CONNECTOR_MAX_ENCODER && detected_encoder == NULL; i++) { + struct drm_encoder *encoder; ++#else ++ drm_connector_for_each_possible_encoder(connector, encoder) { ++#endif + struct nv_drm_encoder *nv_encoder; + ++#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 5, 0) + if (connector->encoder_ids[i] == 0) { + break; + } +@@ -102,6 +113,7 @@ static enum drm_connector_status __nv_drm_connector_detect_internal( + BUG_ON(encoder != NULL); + continue; + } ++#endif + + /* + * DVI-I connectors can drive both digital and analog +@@ -169,6 +181,8 @@ static enum drm_connector_status __nv_drm_connector_detect_internal( + } + + detected_encoder = encoder; ++ ++ break; + } + } + +diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-connector.h b/kernel-dkms/nvidia-drm/nvidia-drm-connector.h +index f74e22c..099390d 100644 +--- a/kernel-dkms/nvidia-drm/nvidia-drm-connector.h ++++ b/kernel-dkms/nvidia-drm/nvidia-drm-connector.h +@@ -27,7 +27,7 @@ + + #if defined(NV_DRM_ATOMIC_MODESET_AVAILABLE) + +-#include ++#include "nv-drm.h" + + #include "nvtypes.h" + #include "nvkms-api-types.h" +diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-crtc.h b/kernel-dkms/nvidia-drm/nvidia-drm-crtc.h +index 31ef3b5..5de3a51 100644 +--- a/kernel-dkms/nvidia-drm/nvidia-drm-crtc.h ++++ b/kernel-dkms/nvidia-drm/nvidia-drm-crtc.h +@@ -29,7 +29,7 @@ + + #include "nvidia-drm-helper.h" + +-#include ++#include "nv-drm.h" + #include "nvtypes.h" + #include "nvkms-kapi.h" + +diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-drv.c b/kernel-dkms/nvidia-drm/nvidia-drm-drv.c +index a66d3cc..06bf859 100644 +--- a/kernel-dkms/nvidia-drm/nvidia-drm-drv.c ++++ b/kernel-dkms/nvidia-drm/nvidia-drm-drv.c +@@ -39,7 +39,7 @@ + + #include "nvidia-drm-ioctl.h" + +-#include ++#include "nv-drm.h" + + /* + * Commit fcd70cd36b9b ("drm: Split out drm_probe_helper.h") +diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-encoder.h b/kernel-dkms/nvidia-drm/nvidia-drm-encoder.h +index bbaf986..af341a8 100644 +--- a/kernel-dkms/nvidia-drm/nvidia-drm-encoder.h ++++ b/kernel-dkms/nvidia-drm/nvidia-drm-encoder.h +@@ -32,7 +32,7 @@ + #if defined(NV_DRM_DRM_ENCODER_H_PRESENT) + #include + #else +-#include ++#include "nv-drm.h" + #endif + + #include "nvkms-kapi.h" +diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-fb.h b/kernel-dkms/nvidia-drm/nvidia-drm-fb.h +index 7f292ce..d13bc4c 100644 +--- a/kernel-dkms/nvidia-drm/nvidia-drm-fb.h ++++ b/kernel-dkms/nvidia-drm/nvidia-drm-fb.h +@@ -27,7 +27,7 @@ + + #if defined(NV_DRM_ATOMIC_MODESET_AVAILABLE) + +-#include ++#include "nv-drm.h" + #include "nvidia-drm-gem-nvkms-memory.h" + #include "nvkms-kapi.h" + +diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-gem.h b/kernel-dkms/nvidia-drm/nvidia-drm-gem.h +index b621969..326f810 100644 +--- a/kernel-dkms/nvidia-drm/nvidia-drm-gem.h ++++ b/kernel-dkms/nvidia-drm/nvidia-drm-gem.h +@@ -29,7 +29,7 @@ + + #include "nvidia-drm-priv.h" + +-#include ++#include "nv-drm.h" + #include "nvkms-kapi.h" + + #if defined(NV_DRM_DRIVER_HAS_GEM_PRIME_RES_OBJ) +diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-helper.c b/kernel-dkms/nvidia-drm/nvidia-drm-helper.c +index da602ac..e5d6daa 100644 +--- a/kernel-dkms/nvidia-drm/nvidia-drm-helper.c ++++ b/kernel-dkms/nvidia-drm/nvidia-drm-helper.c +@@ -31,7 +31,7 @@ + + #if defined(NV_DRM_ATOMIC_MODESET_AVAILABLE) + +-#include ++#include "nv-drm.h" + #if defined(NV_DRM_DRM_ATOMIC_UAPI_H_PRESENT) + #include + #endif +diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-helper.h b/kernel-dkms/nvidia-drm/nvidia-drm-helper.h +index 8f050d8..71c4b90 100644 +--- a/kernel-dkms/nvidia-drm/nvidia-drm-helper.h ++++ b/kernel-dkms/nvidia-drm/nvidia-drm-helper.h +@@ -27,7 +27,7 @@ + + #if defined(NV_DRM_AVAILABLE) + +-#include ++#include "nv-drm.h" + + /* + * drm_dev_put() is added by commit 9a96f55034e41b4e002b767e9218d55f03bdff7d +diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-modeset.h b/kernel-dkms/nvidia-drm/nvidia-drm-modeset.h +index 06659c5..e9d7b70 100644 +--- a/kernel-dkms/nvidia-drm/nvidia-drm-modeset.h ++++ b/kernel-dkms/nvidia-drm/nvidia-drm-modeset.h +@@ -27,7 +27,7 @@ + + #if defined(NV_DRM_ATOMIC_MODESET_AVAILABLE) + +-#include ++#include "nv-drm.h" + + struct drm_atomic_state *nv_drm_atomic_state_alloc(struct drm_device *dev); + void nv_drm_atomic_state_clear(struct drm_atomic_state *state); +diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-os-interface.h b/kernel-dkms/nvidia-drm/nvidia-drm-os-interface.h +index f43f851..7f4ff8b 100644 +--- a/kernel-dkms/nvidia-drm/nvidia-drm-os-interface.h ++++ b/kernel-dkms/nvidia-drm/nvidia-drm-os-interface.h +@@ -29,7 +29,7 @@ + + #if defined(NV_DRM_AVAILABLE) + +-#include ++#include "nv-drm.h" + + /* Set to true when the atomic modeset feature is enabled. */ + extern bool nv_drm_modeset_module_param; +diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-prime-fence.h b/kernel-dkms/nvidia-drm/nvidia-drm-prime-fence.h +index 20da923..f3cc2b4 100644 +--- a/kernel-dkms/nvidia-drm/nvidia-drm-prime-fence.h ++++ b/kernel-dkms/nvidia-drm/nvidia-drm-prime-fence.h +@@ -27,7 +27,7 @@ + + #if defined(NV_DRM_AVAILABLE) + +-#include ++#include "nv-drm.h" + + #if defined(NV_DRM_DRIVER_HAS_GEM_PRIME_RES_OBJ) + +diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-priv.h b/kernel-dkms/nvidia-drm/nvidia-drm-priv.h +index 9076835..77a95f3 100644 +--- a/kernel-dkms/nvidia-drm/nvidia-drm-priv.h ++++ b/kernel-dkms/nvidia-drm/nvidia-drm-priv.h +@@ -27,7 +27,7 @@ + + #if defined(NV_DRM_AVAILABLE) + +-#include ++#include "nv-drm.h" + + #if defined(NV_DRM_DRM_GEM_H_PRESENT) + #include +diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-utils.h b/kernel-dkms/nvidia-drm/nvidia-drm-utils.h +index 6d24120..95190c4 100644 +--- a/kernel-dkms/nvidia-drm/nvidia-drm-utils.h ++++ b/kernel-dkms/nvidia-drm/nvidia-drm-utils.h +@@ -27,7 +27,7 @@ + + #if defined(NV_DRM_ATOMIC_MODESET_AVAILABLE) + +-#include ++#include "nv-drm.h" + #include "nvkms-kapi.h" + + struct NvKmsKapiConnectorInfo* diff --git a/patches/kernel-5.6.patch b/patches/kernel-5.6.patch new file mode 100644 index 0000000..8c4dcbb --- /dev/null +++ b/patches/kernel-5.6.patch @@ -0,0 +1,405 @@ +diff --git a/kernel-dkms/nvidia/nvidia.Kbuild b/kernel-dkms/nvidia/nvidia.Kbuild +index 5ec3e65..2897e31 100644 +--- a/kernel-dkms/nvidia/nvidia.Kbuild ++++ b/kernel-dkms/nvidia/nvidia.Kbuild +@@ -150,6 +151,7 @@ NV_CONFTEST_SYMBOL_COMPILE_TESTS += is_export_symbol_present_swiotlb_dma_ops + NV_CONFTEST_TYPE_COMPILE_TESTS += acpi_op_remove + NV_CONFTEST_TYPE_COMPILE_TESTS += outer_flush_all + NV_CONFTEST_TYPE_COMPILE_TESTS += file_operations ++NV_CONFTEST_TYPE_COMPILE_TESTS += proc_ops + NV_CONFTEST_TYPE_COMPILE_TESTS += file_inode + NV_CONFTEST_TYPE_COMPILE_TESTS += kuid_t + NV_CONFTEST_TYPE_COMPILE_TESTS += dma_ops + +diff --git a/kernel-dkms/common/inc/nv-procfs.h b/kernel-dkms/common/inc/nv-procfs.h +index 8b53f86..4c5aceb 100644 +--- a/kernel-dkms/common/inc/nv-procfs.h ++++ b/kernel-dkms/common/inc/nv-procfs.h +@@ -28,6 +28,18 @@ + + #define IS_EXERCISE_ERROR_FORWARDING_ENABLED() (EXERCISE_ERROR_FORWARDING) + ++#if defined(NV_HAVE_PROC_OPS) ++#define NV_CREATE_PROC_FILE(filename,parent,__name,__data) \ ++ ({ \ ++ struct proc_dir_entry *__entry; \ ++ int mode = (S_IFREG | S_IRUGO); \ ++ const struct proc_ops *fops = &nv_procfs_##__name##_fops; \ ++ if (fops->proc_write != 0) \ ++ mode |= S_IWUSR; \ ++ __entry = proc_create_data(filename, mode, parent, fops, __data);\ ++ __entry; \ ++ }) ++#else + #define NV_CREATE_PROC_FILE(filename,parent,__name,__data) \ + ({ \ + struct proc_dir_entry *__entry; \ +@@ -38,6 +50,7 @@ + __entry = proc_create_data(filename, mode, parent, fops, __data);\ + __entry; \ + }) ++#endif + + /* + * proc_mkdir_mode exists in Linux 2.6.9, but isn't exported until Linux 3.0. +@@ -77,6 +90,44 @@ + remove_proc_entry(entry->name, entry->parent); + #endif + ++#if defined(NV_HAVE_PROC_OPS) ++#define NV_DEFINE_SINGLE_PROCFS_FILE(name, open_callback, close_callback) \ ++ static int nv_procfs_open_##name( \ ++ struct inode *inode, \ ++ struct file *filep \ ++ ) \ ++ { \ ++ int ret; \ ++ ret = single_open(filep, nv_procfs_read_##name, \ ++ NV_PDE_DATA(inode)); \ ++ if (ret < 0) \ ++ { \ ++ return ret; \ ++ } \ ++ ret = open_callback(); \ ++ if (ret < 0) \ ++ { \ ++ single_release(inode, filep); \ ++ } \ ++ return ret; \ ++ } \ ++ \ ++ static int nv_procfs_release_##name( \ ++ struct inode *inode, \ ++ struct file *filep \ ++ ) \ ++ { \ ++ close_callback(); \ ++ return single_release(inode, filep); \ ++ } \ ++ \ ++ static const struct proc_ops nv_procfs_##name##_fops = { \ ++ .proc_open = nv_procfs_open_##name, \ ++ .proc_read = seq_read, \ ++ .proc_lseek = seq_lseek, \ ++ .proc_release = nv_procfs_release_##name, \ ++ }; ++#else + #define NV_DEFINE_SINGLE_PROCFS_FILE(name, open_callback, close_callback) \ + static int nv_procfs_open_##name( \ + struct inode *inode, \ +@@ -114,6 +165,7 @@ + .llseek = seq_lseek, \ + .release = nv_procfs_release_##name, \ + }; ++#endif + + #endif /* CONFIG_PROC_FS */ + +diff --git a/kernel-dkms/conftest.sh b/kernel-dkms/conftest.sh +index 57d85a4..4902248 100755 +--- a/kernel-dkms/conftest.sh ++++ b/kernel-dkms/conftest.sh +@@ -806,6 +822,16 @@ compile_test() { + compile_check_conftest "$CODE" "NV_FILE_OPERATIONS_HAS_IOCTL" "" "types" + ;; + ++ proc_ops) ++ CODE=" ++ #include ++ int conftest_proc_ops(void) { ++ return offsetof(struct proc_ops, proc_open); ++ }" ++ ++ compile_check_conftest "$CODE" "NV_HAVE_PROC_OPS" "" "types" ++ ;; ++ + sg_alloc_table) + # + # sg_alloc_table_from_pages added by commit efc42bc98058 +diff --git a/kernel-dkms/nvidia/nv-procfs.c b/kernel-dkms/nvidia/nv-procfs.c +index 064d727..a7308d3 100644 +--- a/kernel-dkms/nvidia/nv-procfs.c ++++ b/kernel-dkms/nvidia/nv-procfs.c +@@ -452,6 +452,15 @@ done: + return ((status < 0) ? status : (int)count); + } + ++#if defined(NV_HAVE_PROC_OPS) ++static struct proc_ops nv_procfs_registry_fops = { ++ .proc_open = nv_procfs_open_registry, ++ .proc_read = seq_read, ++ .proc_write = nv_procfs_write_file, ++ .proc_lseek = seq_lseek, ++ .proc_release = nv_procfs_close_registry, ++}; ++#else + static struct file_operations nv_procfs_registry_fops = { + .owner = THIS_MODULE, + .open = nv_procfs_open_registry, +@@ -460,6 +469,7 @@ static struct file_operations nv_procfs_registry_fops = { + .llseek = seq_lseek, + .release = nv_procfs_close_registry, + }; ++#endif + + #if defined(CONFIG_PM) + static int +@@ -531,6 +541,15 @@ nv_procfs_open_suspend_depth( + return single_open(file, nv_procfs_show_suspend_depth, NULL); + } + ++#if defined(NV_HAVE_PROC_OPS) ++static struct proc_ops nv_procfs_suspend_depth_fops = { ++ .proc_open = nv_procfs_open_suspend_depth, ++ .proc_read = seq_read, ++ .proc_write = nv_procfs_write_suspend_depth, ++ .proc_lseek = seq_lseek, ++ .proc_release = single_release ++}; ++#else + static struct file_operations nv_procfs_suspend_depth_fops = { + .owner = THIS_MODULE, + .open = nv_procfs_open_suspend_depth, +@@ -539,6 +558,7 @@ static struct file_operations nv_procfs_suspend_depth_fops = { + .llseek = seq_lseek, + .release = single_release + }; ++#endif + + static int + nv_procfs_show_suspend( +@@ -613,6 +633,15 @@ nv_procfs_open_suspend( + return single_open(file, nv_procfs_show_suspend, NULL); + } + ++#if defined(NV_HAVE_PROC_OPS) ++static struct proc_ops nv_procfs_suspend_fops = { ++ .proc_open = nv_procfs_open_suspend, ++ .proc_read = seq_read, ++ .proc_write = nv_procfs_write_suspend, ++ .proc_lseek = seq_lseek, ++ .proc_release = single_release ++}; ++#else + static struct file_operations nv_procfs_suspend_fops = { + .owner = THIS_MODULE, + .open = nv_procfs_open_suspend, +@@ -622,6 +651,7 @@ static struct file_operations nv_procfs_suspend_fops = { + .release = single_release + }; + #endif ++#endif + + /* + * Forwards error to nv_log_error which exposes data to vendor callback +@@ -724,12 +754,20 @@ done: + return status; + } + ++#if defined(NV_HAVE_PROC_OPS) ++static struct proc_ops nv_procfs_exercise_error_forwarding_fops = { ++ .proc_open = nv_procfs_open_exercise_error_forwarding, ++ .proc_write = nv_procfs_write_file, ++ .proc_release = nv_procfs_close_exercise_error_forwarding, ++}; ++#else + static struct file_operations nv_procfs_exercise_error_forwarding_fops = { + .owner = THIS_MODULE, + .open = nv_procfs_open_exercise_error_forwarding, + .write = nv_procfs_write_file, + .release = nv_procfs_close_exercise_error_forwarding, + }; ++#endif + + static int + nv_procfs_read_unbind_lock( +@@ -851,6 +889,15 @@ done: + return rc; + } + ++#if defined(NV_HAVE_PROC_OPS) ++static struct proc_ops nv_procfs_unbind_lock_fops = { ++ .proc_open = nv_procfs_open_unbind_lock, ++ .proc_read = seq_read, ++ .proc_write = nv_procfs_write_file, ++ .proc_lseek = seq_lseek, ++ .proc_release = nv_procfs_close_unbind_lock, ++}; ++#else + static struct file_operations nv_procfs_unbind_lock_fops = { + .owner = THIS_MODULE, + .open = nv_procfs_open_unbind_lock, +@@ -859,6 +906,7 @@ static struct file_operations nv_procfs_unbind_lock_fops = { + .llseek = seq_lseek, + .release = nv_procfs_close_unbind_lock, + }; ++#endif + + static const char* + numa_status_describe(nv_numa_status_t state) +@@ -1187,6 +1235,22 @@ done: + return retval; + } + ++#if defined(NV_HAVE_PROC_OPS) ++static const struct proc_ops nv_procfs_numa_status_fops = { ++ .proc_open = nv_procfs_open_numa_status, ++ .proc_read = seq_read, ++ .proc_write = nv_procfs_write_file, ++ .proc_lseek = seq_lseek, ++ .proc_release = nv_procfs_close_numa_status, ++}; ++ ++static const struct proc_ops nv_procfs_offline_pages_fops = { ++ .proc_open = nv_procfs_open_offline_pages, ++ .proc_read = seq_read, ++ .proc_lseek = seq_lseek, ++ .proc_release = nv_procfs_close_offline_pages, ++}; ++#else + static const struct file_operations nv_procfs_numa_status_fops = { + .owner = THIS_MODULE, + .open = nv_procfs_open_numa_status, +@@ -1203,6 +1267,7 @@ static const struct file_operations nv_procfs_offline_pages_fops = { + .llseek = seq_lseek, + .release = nv_procfs_close_offline_pages, + }; ++#endif + + static int + nv_procfs_read_text_file( +diff --git a/kernel-dkms/nvidia/os-interface.c b/kernel-dkms/nvidia/os-interface.c +index 07f1b77..a8f1d85 100644 +--- a/kernel-dkms/nvidia/os-interface.c ++++ b/kernel-dkms/nvidia/os-interface.c +@@ -477,9 +477,15 @@ NV_STATUS NV_API_CALL os_get_current_time( + + void NV_API_CALL os_get_current_tick(NvU64 *nseconds) + { ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0) ++ struct timespec64 ts; ++ ++ jiffies_to_timespec64(jiffies, &ts); ++#else + struct timespec ts; + + jiffies_to_timespec(jiffies, &ts); ++#endif + + *nseconds = ((NvU64)ts.tv_sec * NSEC_PER_SEC + (NvU64)ts.tv_nsec); + } +diff --git a/kernel-dkms/common/inc/56rc3uglyhack.h b/kernel-dkms/common/inc/56rc3uglyhack.h +new file mode 100644 +index 0000000..389d02f +--- /dev/null ++++ b/kernel-dkms/common/inc/56rc3uglyhack.h +@@ -0,0 +1,80 @@ ++ ++typedef __kernel_long_t __kernel_time_t; ++ ++#ifndef _STRUCT_TIMESPEC ++#define _STRUCT_TIMESPEC ++struct timespec { ++ __kernel_old_time_t tv_sec; /* seconds */ ++ long tv_nsec; /* nanoseconds */ ++}; ++#endif ++ ++struct timeval { ++ __kernel_old_time_t tv_sec; /* seconds */ ++ __kernel_suseconds_t tv_usec; /* microseconds */ ++}; ++ ++struct itimerspec { ++ struct timespec it_interval;/* timer period */ ++ struct timespec it_value; /* timer expiration */ ++}; ++ ++struct itimerval { ++ struct timeval it_interval;/* timer interval */ ++ struct timeval it_value; /* current value */ ++}; ++ ++#if __BITS_PER_LONG == 64 ++ ++/* timespec64 is defined as timespec here */ ++static inline struct timespec timespec64_to_timespec(const struct timespec64 ts64) ++{ ++ return *(const struct timespec *)&ts64; ++} ++ ++static inline struct timespec64 timespec_to_timespec64(const struct timespec ts) ++{ ++ return *(const struct timespec64 *)&ts; ++} ++ ++#else ++static inline struct timespec timespec64_to_timespec(const struct timespec64 ts64) ++{ ++ struct timespec ret; ++ ++ ret.tv_sec = (time_t)ts64.tv_sec; ++ ret.tv_nsec = ts64.tv_nsec; ++ return ret; ++} ++ ++static inline struct timespec64 timespec_to_timespec64(const struct timespec ts) ++{ ++ struct timespec64 ret; ++ ++ ret.tv_sec = ts.tv_sec; ++ ret.tv_nsec = ts.tv_nsec; ++ return ret; ++} ++#endif ++ ++static inline void getnstimeofday(struct timespec *ts) ++{ ++ struct timespec64 ts64; ++ ++ ktime_get_real_ts64(&ts64); ++ *ts = timespec64_to_timespec(ts64); ++} ++ ++static inline s64 timespec_to_ns(const struct timespec *ts) ++{ ++ return ((s64) ts->tv_sec * NSEC_PER_SEC) + ts->tv_nsec; ++} ++ ++static inline void getrawmonotonic(struct timespec *ts) ++{ ++ struct timespec64 ts64; ++ ++ ktime_get_raw_ts64(&ts64); ++ *ts = timespec64_to_timespec(ts64); ++} ++ +diff --git a/kernel-dkms/common/inc/nv-time.h b/kernel-dkms/common/inc/nv-time.h +index 968b873..165f18b 100644 +--- a/kernel-dkms/common/inc/nv-time.h ++++ b/kernel-dkms/common/inc/nv-time.h +@@ -27,6 +27,10 @@ + + #include + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0) ++#include "56rc3uglyhack.h" ++#endif ++ + static inline void nv_gettimeofday(struct timeval *tv) + { + #ifdef NV_DO_GETTIMEOFDAY_PRESENT +diff --git a/kernel-dkms/nvidia/linux_nvswitch.c b/kernel-dkms/nvidia/linux_nvswitch.c +index 1d2c1bc..388d64f 100644 +--- a/kernel-dkms/nvidia/linux_nvswitch.c ++++ b/kernel-dkms/nvidia/linux_nvswitch.c +@@ -26,6 +26,9 @@ + #include "conftest.h" + #include "nvmisc.h" + #include "nv-linux.h" ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0) ++#include "nv-time.h" ++#endif + #include "nv-procfs.h" + #include "nvlink_common.h" + #include "nvlink_errors.h" diff --git a/patches/linux-version.diff b/patches/linux-version.diff new file mode 100644 index 0000000..247c4d4 --- /dev/null +++ b/patches/linux-version.diff @@ -0,0 +1,166 @@ +diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-gem-nvkms-memory.c b/kernel-dkms/nvidia-drm/nvidia-drm-gem-nvkms-memory.c +index 1db7777..863bb77 100644 +--- a/kernel-dkms/nvidia-drm/nvidia-drm-gem-nvkms-memory.c ++++ b/kernel-dkms/nvidia-drm/nvidia-drm-gem-nvkms-memory.c +@@ -20,6 +20,8 @@ + * DEALINGS IN THE SOFTWARE. + */ + ++#include ++ + #include "nvidia-drm-conftest.h" + + #if defined(NV_DRM_ATOMIC_MODESET_AVAILABLE) + +diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-encoder.c b/kernel-dkms/nvidia-drm/nvidia-drm-encoder.c +index f66bbd7c9..4de87a271 100644 +--- a/kernel-dkms/nvidia-drm/nvidia-drm-encoder.c ++++ b/kernel-dkms/nvidia-drm/nvidia-drm-encoder.c +@@ -20,6 +20,8 @@ + * DEALINGS IN THE SOFTWARE. + */ + ++#include ++ + #include "nvidia-drm-conftest.h" /* NV_DRM_ATOMIC_MODESET_AVAILABLE */ + + #if defined(NV_DRM_ATOMIC_MODESET_AVAILABLE) + +diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-drv.c b/kernel-dkms/nvidia-drm/nvidia-drm-drv.c +index 58fd2724a..fc9169a96 100644 +--- a/kernel-dkms/nvidia-drm/nvidia-drm-drv.c ++++ b/kernel-dkms/nvidia-drm/nvidia-drm-drv.c +@@ -20,6 +20,8 @@ + * DEALINGS IN THE SOFTWARE. + */ + ++#include ++ + #include "nvidia-drm-conftest.h" /* NV_DRM_AVAILABLE and NV_DRM_DRM_GEM_H_PRESENT */ + + #include "nvidia-drm-priv.h" + +diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-connector.c b/kernel-dkms/nvidia-drm/nvidia-drm-connector.c +index 4dd12d112..44c9d8ed3 100644 +--- a/kernel-dkms/nvidia-drm/nvidia-drm-connector.c ++++ b/kernel-dkms/nvidia-drm/nvidia-drm-connector.c +@@ -20,6 +20,8 @@ + * DEALINGS IN THE SOFTWARE. + */ + ++#include ++ + #include "nvidia-drm-conftest.h" /* NV_DRM_ATOMIC_MODESET_AVAILABLE */ + + #if defined(NV_DRM_ATOMIC_MODESET_AVAILABLE) + +diff --git a/kernel-dkms/common/inc/nv.h b/kernel-dkms/common/inc/nv.h +index d52c2a1ef..f6dc2dc32 100644 +--- a/kernel-dkms/common/inc/nv.h ++++ b/kernel-dkms/common/inc/nv.h +@@ -18,6 +18,8 @@ + #include + #include + ++#include ++ + #if !defined(NV_MIN) + #define NV_MIN(_a,_b) ((_a) < (_b) ? (_a) : (_b)) + #endif + +diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-gem.h b/kernel-dkms/nvidia-drm/nvidia-drm-gem.h +index f276588db..7cbdbe632 100644 +--- a/kernel-dkms/nvidia-drm/nvidia-drm-gem.h ++++ b/kernel-dkms/nvidia-drm/nvidia-drm-gem.h +@@ -38,6 +38,8 @@ + + #endif + ++#include ++ + struct nv_drm_gem_object; + + struct nv_drm_gem_object_funcs { + +diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-helper.c b/kernel-dkms/nvidia-drm/nvidia-drm-helper.c +index 4ccf81929..7fb59bbb3 100644 +--- a/kernel-dkms/nvidia-drm/nvidia-drm-helper.c ++++ b/kernel-dkms/nvidia-drm/nvidia-drm-helper.c +@@ -29,6 +29,8 @@ + + #include "nvidia-drm-helper.h" + ++#include ++ + #if defined(NV_DRM_ATOMIC_MODESET_AVAILABLE) + + #include + +diff --git a/kernel-dkms/nvidia-drm/nvidia-drm-linux.c b/kernel-dkms/nvidia-drm/nvidia-drm-linux.c +index 5a2bbc18c..133d8fe64 100644 +--- a/kernel-dkms/nvidia-drm/nvidia-drm-linux.c ++++ b/kernel-dkms/nvidia-drm/nvidia-drm-linux.c +@@ -20,6 +20,8 @@ + * DEALINGS IN THE SOFTWARE. + */ + ++#include ++ + #include + #include + #include + +diff --git a/kernel-dkms/nvidia-uvm/uvm_linux.h b/kernel-dkms/nvidia-uvm/uvm_linux.h +index 8707ac070..990cefbd4 100644 +--- a/kernel-dkms/nvidia-uvm/uvm_linux.h ++++ b/kernel-dkms/nvidia-uvm/uvm_linux.h +@@ -29,6 +29,8 @@ + // + // + ++#include ++ + #ifndef _UVM_LINUX_H + #define _UVM_LINUX_H + +diff --git a/kernel-dkms/nvidia/nvlink_linux.c b/kernel-dkms/nvidia/nvlink_linux.c +index c13b72515..db691679c 100644 +--- a/kernel-dkms/nvidia/nvlink_linux.c ++++ b/kernel-dkms/nvidia/nvlink_linux.c +@@ -37,6 +37,8 @@ + #include + #include + ++#include ++ + #define MAX_ERROR_STRING 512 + + #define NV_MAX_ISR_DELAY_US 20000 + +diff --git a/kernel-dkms/nvidia/os-interface.c b/kernel-dkms/nvidia/os-interface.c +index d1c889f69..88c57b2da 100644 +--- a/kernel-dkms/nvidia/os-interface.c ++++ b/kernel-dkms/nvidia/os-interface.c +@@ -14,6 +14,8 @@ + #include "os-interface.h" + #include "nv-linux.h" + ++#include ++ + #define MAX_ERROR_STRING 512 + static char nv_error_string[MAX_ERROR_STRING]; + nv_spinlock_t nv_error_string_lock; + +diff --git a/kernel-dkms/nvidia-modeset/nvidia-modeset-linux.c b/kernel-dkms/nvidia-modeset/nvidia-modeset-linux.c +index 1b9148ee7..4c1bd3617 100644 +--- a/kernel-dkms/nvidia-modeset/nvidia-modeset-linux.c ++++ b/kernel-dkms/nvidia-modeset/nvidia-modeset-linux.c +@@ -8,6 +8,8 @@ + * _NVRM_COPYRIGHT_END_ + */ + ++#include ++ + #include + #include + #include diff --git a/patches/list_is_first.diff b/patches/list_is_first.diff new file mode 100644 index 0000000..b25bace --- /dev/null +++ b/patches/list_is_first.diff @@ -0,0 +1,39 @@ +From d42eed1eca8947a3c601a5e21c7820f0bba8550b Mon Sep 17 00:00:00 2001 +From: Tk-Glitch +Date: Wed, 3 Apr 2019 18:41:21 +0200 +Subject: nvidia-fix-2 + + +diff --git a/kernel-dkms/common/inc/nv-list-helpers.h b/kernel-dkms/common/inc/nv-list-helpers.h +index 2feaa1afd..0d66f00c8 100644 +--- a/kernel-dkms/common/inc/nv-list-helpers.h ++++ b/kernel-dkms/common/inc/nv-list-helpers.h +@@ -23,6 +23,8 @@ + #ifndef __NV_LIST_HELPERS_H__ + #define __NV_LIST_HELPERS_H__ + ++#include ++ + #include + #include "conftest.h" + +diff --git a/kernel-dkms/nvidia-uvm/uvm8_range_tree.c b/kernel-dkms/nvidia-uvm/uvm8_range_tree.c +index b7170d03c..7d24b01f3 100644 +--- a/kernel-dkms/nvidia-uvm/uvm8_range_tree.c ++++ b/kernel-dkms/nvidia-uvm/uvm8_range_tree.c +@@ -31,9 +31,15 @@ static uvm_range_tree_node_t *get_range_node(struct rb_node *rb_node) + + uvm_range_tree_node_t *uvm_range_tree_prev(uvm_range_tree_t *tree, uvm_range_tree_node_t *node) + { ++#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 1, 0) + if (list_is_first(&node->list, &tree->head)) + return NULL; + return list_prev_entry(node, list); ++#else ++ if (nv_list_is_first(&node->list, &tree->head)) ++ return NULL; ++ return list_prev_entry(node, list); ++#endif + } + + uvm_range_tree_node_t *uvm_range_tree_next(uvm_range_tree_t *tree, uvm_range_tree_node_t *node) diff --git a/system/10-nvidia-drm-outputclass.conf b/system/10-nvidia-drm-outputclass.conf new file mode 100644 index 0000000..dd2936c --- /dev/null +++ b/system/10-nvidia-drm-outputclass.conf @@ -0,0 +1,15 @@ +Section "OutputClass" + Identifier "intel" + MatchDriver "i915" + Driver "modesetting" +EndSection + +Section "OutputClass" + Identifier "nvidia" + MatchDriver "nvidia-drm" + Driver "nvidia" + Option "AllowEmptyInitialConfiguration" + Option "PrimaryGPU" "yes" + ModulePath "/usr/lib/nvidia/xorg" + ModulePath "/usr/lib/xorg/modules" +EndSection diff --git a/system/20-nvidia.conf b/system/20-nvidia.conf new file mode 100644 index 0000000..8b8e268 --- /dev/null +++ b/system/20-nvidia.conf @@ -0,0 +1,4 @@ +Section "Device" + Identifier "Default Nvidia Device" + Option "NoLogo" "True" +EndSection diff --git a/system/egl-wayland/licenses/egl-wayland/COPYING b/system/egl-wayland/licenses/egl-wayland/COPYING new file mode 100644 index 0000000..6f84d7e --- /dev/null +++ b/system/egl-wayland/licenses/egl-wayland/COPYING @@ -0,0 +1,20 @@ + Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + diff --git a/system/egl-wayland/pkgconfig/wayland-eglstream-protocols.pc b/system/egl-wayland/pkgconfig/wayland-eglstream-protocols.pc new file mode 100644 index 0000000..4e5c29f --- /dev/null +++ b/system/egl-wayland/pkgconfig/wayland-eglstream-protocols.pc @@ -0,0 +1,8 @@ +prefix=/usr +datarootdir=${prefix}/share +pkgdatadir=${datarootdir}/wayland-eglstream + +Name: wayland-eglstream-protocols +Description: Nvidia Wayland EGLStream XML protocol files +Version: 1.1.2 + diff --git a/system/egl-wayland/pkgconfig/wayland-eglstream.pc b/system/egl-wayland/pkgconfig/wayland-eglstream.pc new file mode 100644 index 0000000..c361b5a --- /dev/null +++ b/system/egl-wayland/pkgconfig/wayland-eglstream.pc @@ -0,0 +1,12 @@ +prefix=/usr +exec_prefix=${prefix} +libdir=${exec_prefix}/lib +includedir=${prefix}/include + +Name: wayland-eglstream +Description: Nvidia Wayland EGLStream compositor helper libraries +Version: 1.1.2 +Cflags: -I${includedir} +Libs: -L${libdir} -lnvidia-egl-wayland +Requires: eglexternalplatform >= 1.1 eglexternalplatform < 2 + diff --git a/system/egl-wayland/wayland-eglstream/wayland-eglstream-controller.xml b/system/egl-wayland/wayland-eglstream/wayland-eglstream-controller.xml new file mode 100644 index 0000000..2c3a635 --- /dev/null +++ b/system/egl-wayland/wayland-eglstream/wayland-eglstream-controller.xml @@ -0,0 +1,87 @@ + + + + Copyright (c) 2017-2018, NVIDIA CORPORATION. All rights reserved. + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + + + + + + - dont_care: Using this enum will tell the server to make its own + decisions regarding present mode. + + - fifo: Tells the server to use a fifo present mode. The decision to + use fifo synchronous is left up to the server. + + - mailbox: Tells the server to use a mailbox present mode. + + + + + + + + + - present_mode: Must be one of wl_eglstream_controller_present_mode. Tells the + server the desired present mode that should be used. + + - fifo_length: Only valid when the present_mode attrib is provided and its + value is specified as fifo. Tells the server the desired fifo + length to be used when the desired present_mode is fifo. + + + + + + + + Creates the corresponding server side EGLStream from the given wl_buffer + and attaches a consumer to it. + + + + + + + + Creates the corresponding server side EGLStream from the given wl_buffer + and attaches a consumer to it using the given attributes. + + + + + + It contains key-value pairs compatible with intptr_t type. A key must + be one of wl_eglstream_controller_attrib enumeration values. What a value + represents is attribute-specific. + + + + + diff --git a/system/egl-wayland/wayland-eglstream/wayland-eglstream.xml b/system/egl-wayland/wayland-eglstream/wayland-eglstream.xml new file mode 100644 index 0000000..c3c9117 --- /dev/null +++ b/system/egl-wayland/wayland-eglstream/wayland-eglstream.xml @@ -0,0 +1,161 @@ + + + + + Copyright (c) 2014-2016, NVIDIA CORPORATION. All rights reserved. + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + + + + + + + + + + + + + + + - fd: The given handle represents a file descriptor, and the + EGLStream connection must be done as described in + EGL_KHR_stream_cross_process_fd + + - inet: The EGLStream connection must be done using an inet address + and port as described in EGL_NV_stream_socket. The given + handle can be ignored, but both inet address and port must + be given as attributes. + + - socket: The given handle represents a unix socket, and the EGLStream + connection must be done as described in EGL_NV_stream_socket. + + + + + + + + + + - inet_addr: The given attribute encodes an IPv4 address of a client + socket. Both IPv4 address and port must be set at the same + time. + + - inet_port: The given attribute encodes a port of a client socket. Both + IPv4 address and port must be set at the same time. + + + + + + + + + + + + This enum values should be used as bit masks. + + - stream_fd: The server supports EGLStream connections as described + in EGL_KHR_stream_cross_process_fd + + - stream_inet: The server supports EGLStream inet connections as + described in EGL_NV_stream_socket. + + - stream_socket: The server supports EGLStream unix socket connections + as described in EGL_NV_stream_socket. + + + + + + + + + + The capabilities event is sent out at wl_eglstream_display binding + time. It allows the server to advertise what features it supports so + clients may know what is safe to be used. + + + + + + + The swapinterval_override event is sent out whenever a client requests + a swapinterval setting through swap_interval() and there is an override + in place that will make such request to be ignored. + The swapinterval_override event will provide the override value so + that the client is made aware of it. + + + + + + + + + Create a wl_buffer corresponding to given handle. The attributes list + may be used to define additional EGLStream connection data (e.g inet + address/port). The server can create its EGLStream handle using the + information encoded in the wl_buffer. + + + + + + + + + It contains key-value pairs compatible with intptr_t type. A key must + be one of wl_eglstream_display_attrib enumeration values. What a value + represents is attribute-specific. + + + + + + + Set the swap interval for the consumer of the given EGLStream. The swap + interval is silently clamped to the valid range on the server side. + + + + + + diff --git a/system/nvidia-tkg.install b/system/nvidia-tkg.install new file mode 100644 index 0000000..d01636f --- /dev/null +++ b/system/nvidia-tkg.install @@ -0,0 +1,54 @@ +_depmod() { + # Update module dependencies for all kernels + local -a _kernels + mapfile -t _kernels < <(find /usr/lib/modules/*/build/version -exec cat {} +) + for _kernel in "${_kernels[@]}"; do + depmod $_kernel + done +} + +_rmmod() { + # Try unloading + if lsmod | grep -q nvidia; then + rmmod nvidia + fi + + # What? + if [[ $? != 0 ]]; then + # X running? + if pidof Xorg >/dev/null; then + echo ":: Please reboot or exit X first." + fi + fi +} + +post_install() { + _depmod + + # X running? + if pidof Xorg >/dev/null; then + echo ":: Please reboot or exit X to unload the current module." + fi + echo "" + echo -e "\e[31m###########################################################\e[0m" + echo "" + echo -e "\e[31m It is recommended to run mkinitcpio -P after installation\e[0m" + echo "" + echo -e "\e[31m###########################################################\e[0m" + echo "" +} + +post_upgrade() { + _depmod + + # Not rebuilding? + if (( $(vercmp $1 $2) != 0 )); then + _rmmod + fi +} + +post_remove() { + _depmod + + _rmmod +} diff --git a/system/nvidia-utils-tkg.install b/system/nvidia-utils-tkg.install new file mode 100644 index 0000000..e3fe280 --- /dev/null +++ b/system/nvidia-utils-tkg.install @@ -0,0 +1,14 @@ +post_upgrade() { + echo ":: If CUDA is unavailable, run 'nvidia-modprobe'." + echo "" + echo -e "\e[31m###########################################################\e[0m" + echo "" + echo -e "\e[31m It is recommended to run mkinitcpio -P after installation\e[0m" + echo "" + echo -e "\e[31m###########################################################\e[0m" + echo "" +} + +post_install() { + post_upgrade +} diff --git a/system/nvidia-utils-tkg.sysusers b/system/nvidia-utils-tkg.sysusers new file mode 100644 index 0000000..71c0608 --- /dev/null +++ b/system/nvidia-utils-tkg.sysusers @@ -0,0 +1 @@ +u nvidia-persistenced 143 'NVIDIA Persistence Daemon'