commit d643482cd5a25637c9020c4a7e87fcae813841f5
Author: Leigh Scott <leigh123linux(a)gmail.com>
Date: Fri Dec 20 01:18:47 2019 +0000
patch for kernel-5.4.0
buildfix_kernel_5.4.patch | 117 ++++++++++++++++++++++++++++++++++++++++++++++
nvidia-340xx-kmod.spec | 9 ++--
2 files changed, 123 insertions(+), 3 deletions(-)
---
diff --git a/buildfix_kernel_5.4.patch b/buildfix_kernel_5.4.patch
new file mode 100644
index 0000000..49b8559
--- /dev/null
+++ b/buildfix_kernel_5.4.patch
@@ -0,0 +1,117 @@
+From f90c388c755a6bd9b72cb51c712a0ae686e0b377 Mon Sep 17 00:00:00 2001
+From: Alberto Milone <alberto.milone(a)canonical.com>
+Date: Wed, 27 Nov 2019 13:01:18 +0100
+Subject: [PATCH 1/1] Add support for Linux 5.4
+
+---
+ conftest.sh | 46 ++++++++++++++++++++++++++++++++++++++++
+ nv-drm.c | 9 +++++---
+ nvidia-modules-common.mk | 2 +-
+ 3 files changed, 53 insertions(+), 4 deletions(-)
+
+diff --git a/kernel/conftest.sh b/kernel/conftest.sh
+index fb0bf60..babbb50 100755
+--- a/kernel/conftest.sh
++++ b/kernel/conftest.sh
+@@ -265,6 +265,23 @@ build_cflags() {
+ if [ -n "$BUILD_PARAMS" ]; then
+ CFLAGS="$CFLAGS -D$BUILD_PARAMS"
+ fi
++
++ # Check if gcc supports asm goto and set CC_HAVE_ASM_GOTO if it does.
++ # Older kernels perform this check and set this flag in Kbuild, and since
++ # conftest.sh runs outside of Kbuild it ends up building without this flag.
++ # Starting with commit e9666d10a5677a494260d60d1fa0b73cc7646eb3 this test
++ # is done within Kconfig, and the preprocessor flag is no longer needed.
++
++ GCC_GOTO_SH="$SOURCES/build/gcc-goto.sh"
++
++ if [ -f "$GCC_GOTO_SH" ]; then
++ # Newer versions of gcc-goto.sh don't print anything on success, but
++ # this is okay, since it's no longer necessary to set CC_HAVE_ASM_GOTO
++ # based on the output of those versions of gcc-goto.sh.
++ if [ `/bin/sh "$GCC_GOTO_SH" "$CC"` = "y" ]; then
++ CFLAGS="$CFLAGS -DCC_HAVE_ASM_GOTO"
++ fi
++ fi
+ }
+
+ CONFTEST_PREAMBLE="#include \"conftest.h\"
+@@ -1521,6 +1538,35 @@ compile_test() {
+ compile_check_conftest "$CODE" "NV_DRM_AVAILABLE"
"" "generic"
+ ;;
+
++ drm_driver_prime_flag_present)
++ #
++ # Determine whether driver feature flag DRIVER_PRIME is present.
++ #
++ # The DRIVER_PRIME flag was added by commit 3248877ea179 (drm:
++ # base prime/dma-buf support (v5)) in v3.4 (2011-11-25) and is
++ # removed by commit 0424fdaf883a (drm/prime: Actually remove
++ # DRIVER_PRIME everywhere) on 2019-06-17.
++ #
++ # DRIVER_PRIME definition moved from drmP.h to drm_drv.h by
++ # commit 85e634bce01a (drm: Extract drm_drv.h) in v4.10
++ # (2016-11-14).
++ #
++ # DRIVER_PRIME define is changed to enum value by commit
++ # 0e2a933b02c9 (drm: Switch DRIVER_ flags to an enum) in v5.1
++ # (2019-01-29).
++ #
++ CODE="
++ #include <drm/drmP.h>
++ #if defined(NV_DRM_DRM_DRV_H_PRESENT)
++ #include <drm/drm_drv.h>
++ #endif
++ unsigned int drm_driver_prime_flag_present_conftest(void) {
++ return DRIVER_PRIME;
++ }"
++
++ compile_check_conftest "$CODE"
"NV_DRM_DRIVER_PRIME_FLAG_PRESENT" "" "types"
++ ;;
++
+ proc_create_data)
+ #
+ # Determine if the proc_create_data() function is present.
+diff --git a/kernel/nv-drm.c b/kernel/nv-drm.c
+index 76719bb..12f7029 100644
+--- a/kernel/nv-drm.c
++++ b/kernel/nv-drm.c
+@@ -156,11 +156,14 @@
+ };
+
+ static struct drm_driver nv_drm_driver = {
+-#if defined(DRIVER_LEGACY)
+- .driver_features = DRIVER_GEM | DRIVER_PRIME | DRIVER_LEGACY,
+-#else
+- .driver_features = DRIVER_GEM | DRIVER_PRIME,
+-#endif
++ .driver_features =
++#if defined(NV_DRM_DRIVER_PRIME_FLAG_PRESENT)
++ DRIVER_PRIME |
++#endif
++#if defined(DRIVER_LEGACY) || LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0)
++ DRIVER_LEGACY |
++#endif
++ DRIVER_GEM,
+ .load = nv_drm_load,
+ .unload = nv_drm_unload,
+ .fops = &nv_drm_fops,
+
+diff --git a/kernel/nvidia-modules-common.mk b/kernel/nvidia-modules-common.mk
+index 8ac7058..7418005 100644
+--- a/kernel/nvidia-modules-common.mk
++++ b/kernel/nvidia-modules-common.mk
+@@ -176,7 +176,7 @@ ifndef NV_VERBOSE
+ endif
+
+ KBUILD_PARAMS += KBUILD_VERBOSE=$(NV_VERBOSE)
+-KBUILD_PARAMS += -C $(KERNEL_SOURCES) SUBDIRS=$(PWD)
++KBUILD_PARAMS += -C $(KERNEL_SOURCES) M=$(PWD)
+ KBUILD_PARAMS += ARCH=$(ARCH)
+
+ #
+--
+2.20.1
+
+
diff --git a/nvidia-340xx-kmod.spec b/nvidia-340xx-kmod.spec
index 6997025..c77dca3 100644
--- a/nvidia-340xx-kmod.spec
+++ b/nvidia-340xx-kmod.spec
@@ -10,7 +10,7 @@ Name: nvidia-340xx-kmod
Epoch: 1
Version: 340.107
# Taken over by kmodtool
-Release: 11%{?dist}
+Release: 12%{?dist}
Summary: NVIDIA display driver kernel module
Group: System Environment/Kernel
License: Redistributable, no modification permitted
@@ -19,8 +19,8 @@ URL:
http://www.nvidia.com/
Source11: nvidia-kmodtool-excludekernel-filterfile
Patch0: nv-linux-arm.patch
Patch1: buildfix_kernel_5.0.patch
-Patch2: xf86-video-nvidia-legacy-02-fix-linux-5.1.patch
-Patch3: buildfix_kernel_5.3.patch
+Patch2: buildfix_kernel_5.3.patch
+Patch3: buildfix_kernel_5.4.patch
%if 0%{?fedora} > 30
ExclusiveArch: x86_64
@@ -81,6 +81,9 @@ done
%{?akmod_install}
%changelog
+* Fri Dec 20 2019 Leigh Scott <leigh123linux(a)gmail.com> - 1:340.107-12
+- patch for kernel-5.4.0
+
* Sun Nov 24 2019 João Carlos Mendes Luís <redhat(a)jonny.eng.br> - 1:340.107-11
- patch for kernel-5.3.0