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 + #if defined(NV_DRM_DRM_DRV_H_PRESENT) + #include + #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 const struct file_operations nv_drm_fops = { }; static struct drm_driver nv_drm_driver = { + .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_features = DRIVER_GEM | DRIVER_PRIME | DRIVER_LEGACY, -#else - .driver_features = DRIVER_GEM | DRIVER_PRIME, + 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