diff --git a/srcpkgs/nvidia390/files/gcc-14.patch b/srcpkgs/nvidia390/files/gcc-14.patch new file mode 100644 index 00000000000..46b588886b4 --- /dev/null +++ b/srcpkgs/nvidia390/files/gcc-14.patch @@ -0,0 +1,14 @@ +diff --git a/conftest.sh b/conftest.sh +index 093704c..a9db899 100755 +--- a/conftest.sh ++++ b/conftest.sh +@@ -153,7 +153,8 @@ test_headers() { + build_cflags() { + BASE_CFLAGS="-O2 -D__KERNEL__ \ + -DKBUILD_BASENAME=\"#conftest$$\" -DKBUILD_MODNAME=\"#conftest$$\" \ +--nostdinc -isystem $ISYSTEM" ++-nostdinc -isystem $ISYSTEM \ ++-Wno-implicit-function-declaration -Wno-strict-prototypes -Wno-incompatible-pointer-types" + + if [ "$OUTPUT" != "$SOURCES" ]; then + OUTPUT_CFLAGS="-I$OUTPUT/include2 -I$OUTPUT/include" diff --git a/srcpkgs/nvidia390/files/linux-6.12.patch b/srcpkgs/nvidia390/files/linux-6.12.patch new file mode 100644 index 00000000000..f4f8cf8976e --- /dev/null +++ b/srcpkgs/nvidia390/files/linux-6.12.patch @@ -0,0 +1,177 @@ +diff --git a/nvidia-drm/nvidia-drm-drv.c b/kernel/nvidia-drm/nvidia-drm-drv.c +index 132d4d4..1291893 100644 +--- a/nvidia-drm/nvidia-drm-drv.c ++++ b/nvidia-drm/nvidia-drm-drv.c +@@ -654,6 +654,13 @@ static const struct file_operations nv_drm_fops = { + .llseek = noop_llseek, + }; + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 8, 0) ++// Rel. commit. "drm: Remove locking for legacy ioctls and DRM_UNLOCKED" (Thomas Zimmermann, 22 Nov 2023) ++// Mock this flag, which was already useless on any recent kernel, since it ++// only did something if the driver set DRIVER_LEGACY in driver_features. ++static const enum drm_ioctl_flags DRM_UNLOCKED = 0; ++#endif ++ + static const struct drm_ioctl_desc nv_drm_ioctls[] = { + #if defined(NV_DRM_ATOMIC_MODESET_AVAILABLE) + DRM_IOCTL_DEF_DRV(NVIDIA_GEM_IMPORT_NVKMS_MEMORY, +diff --git a/conftest.sh b/kernel/conftest.sh +index a9db899..4da7588 100755 +--- a/conftest.sh ++++ b/conftest.sh +@@ -4464,20 +4464,22 @@ compile_test() { + compile_check_conftest "$CODE" "NV_DRM_GEM_OBJECT_VMAP_HAS_MAP_ARG" "" "types" + ;; + +- unsafe_follow_pfn) ++ follow_pfn) + # +- # Determine if unsafe_follow_pfn() is present. ++ # Determine if follow_pfn() is present. + # +- # unsafe_follow_pfn() was added by commit 69bacee7f9ad +- # ("mm: Add unsafe_follow_pfn") in v5.13-rc1. ++ # follow_pfn() was added by commit 3b6748e2dd69 ++ # ("mm: introduce follow_pfn()") in v2.6.31-rc1, and removed ++ # by commit 233eb0bf3b94 ("mm: remove follow_pfn") ++ # from linux-next 233eb0bf3b94. + # + CODE=" + #include +- void conftest_unsafe_follow_pfn(void) { +- unsafe_follow_pfn(); ++ void conftest_follow_pfn(void) { ++ follow_pfn(); + }" + +- compile_check_conftest "$CODE" "NV_UNSAFE_FOLLOW_PFN_PRESENT" "" "functions" ++ compile_check_conftest "$CODE" "NV_FOLLOW_PFN_PRESENT" "" "functions" + ;; + + drm_plane_atomic_check_has_atomic_state_arg) +diff --git a/nvidia/nvidia.Kbuild b/kernel/nvidia/nvidia.Kbuild +index d6995ca..3a3dd17 100644 +--- a/nvidia/nvidia.Kbuild ++++ b/nvidia/nvidia.Kbuild +@@ -165,7 +165,7 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += ktime_get_raw_ts64 + NV_CONFTEST_FUNCTION_COMPILE_TESTS += ktime_get_real_ts64 + NV_CONFTEST_FUNCTION_COMPILE_TESTS += ioremap_nocache + NV_CONFTEST_FUNCTION_COMPILE_TESTS += vga_tryget +-NV_CONFTEST_FUNCTION_COMPILE_TESTS += unsafe_follow_pfn ++NV_CONFTEST_FUNCTION_COMPILE_TESTS += follow_pfn + NV_CONFTEST_FUNCTION_COMPILE_TESTS += acpi_bus_get_device + NV_CONFTEST_FUNCTION_COMPILE_TESTS += acpi_video_backlight_use_native + +diff --git a/nvidia/os-mlock.c b/kernel/nvidia/os-mlock.c +index f88daed..9e1bd0c 100644 +--- a/nvidia/os-mlock.c ++++ b/nvidia/os-mlock.c +@@ -18,10 +18,10 @@ static inline int nv_follow_pfn(struct vm_area_struct *vma, + unsigned long address, + unsigned long *pfn) + { +-#if defined(NV_UNSAFE_FOLLOW_PFN_PRESENT) +- return unsafe_follow_pfn(vma, address, pfn); +-#else ++#if defined(NV_FOLLOW_PFN_PRESENT) + return follow_pfn(vma, address, pfn); ++#else ++ return -1; + #endif + } + +diff --git a/nvidia-drm/nvidia-drm-drv.c b/nvidia-drm/nvidia-drm-drv.c +index 1291893..53dfad8 100644 +--- a/nvidia-drm/nvidia-drm-drv.c ++++ b/nvidia-drm/nvidia-drm-drv.c +@@ -84,6 +84,10 @@ + #include + #endif + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 12, 0) ++#include ++#endif ++ + static struct nv_drm_device *dev_list = NULL; + + #if defined(NV_DRM_ATOMIC_MODESET_AVAILABLE) +@@ -168,7 +172,12 @@ static const struct drm_mode_config_funcs nv_mode_config_funcs = { + .atomic_check = nv_drm_atomic_check, + .atomic_commit = nv_drm_atomic_commit, + ++#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 12, 0) ++ // Rel. commit. "drm: Remove struct drm_mode_config_funcs.output_poll_changed" (Thomas Zimmermann, 12 Aug 2024) ++ // Replace this callback with a DRM client's hotplug callback. ++ // This is required for e.g. /sys/class/drm/card*/modes to work. + .output_poll_changed = nv_drm_output_poll_changed, ++#endif + }; + + static void nv_drm_event_callback(const struct NvKmsKapiEvent *event) +@@ -652,6 +661,10 @@ static const struct file_operations nv_drm_fops = { + .read = drm_read, + + .llseek = noop_llseek, ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 12, 0) ++ // Rel. commit. "fs: move FMODE_UNSIGNED_OFFSET to fop_flags" (Christian Brauner, 9 Aug 2024) ++ .fop_flags = FOP_UNSIGNED_OFFSET, ++#endif + }; + + #if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 8, 0) +@@ -790,7 +803,18 @@ static void nv_drm_update_drm_driver_features(void) + #endif /* NV_DRM_ATOMIC_MODESET_AVAILABLE */ + } + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 12, 0) ++static int hotplug_helper_client_hotplug(struct drm_client_dev *client) ++{ ++ nv_drm_output_poll_changed(client->dev); ++ return 0; ++} + ++static const struct drm_client_funcs nv_hotplug_helper_client_funcs = { ++ .owner = THIS_MODULE, ++ .hotplug = hotplug_helper_client_hotplug, ++}; ++#endif + + /* + * Helper function for allocate/register DRM device for given NVIDIA GPU ID. +@@ -844,6 +868,20 @@ static void nv_drm_register_drm_device(const nv_gpu_info_t *gpu_info) + goto failed_drm_register; + } + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 12, 0) ++ /* Register a DRM client for receiving hotplug events */ ++ struct drm_client_dev *client = kzalloc(sizeof(*client), GFP_KERNEL); ++ if (client == NULL || drm_client_init(dev, client, ++ "nv-hotplug-helper", &nv_hotplug_helper_client_funcs)) { ++ printk(KERN_WARNING "Failed to initialize the nv-hotplug-helper DRM client" ++ " (ensure DRM kernel mode setting is enabled via nvidia-drm.modeset=1).\n"); ++ goto failed_drm_client_init; ++ } ++ ++ drm_client_register(client); ++ pr_info("Registered the nv-hotplug-helper DRM client.\n"); ++#endif ++ + /* Add NVIDIA-DRM device into list */ + + nv_dev->next = dev_list; +@@ -851,6 +889,14 @@ static void nv_drm_register_drm_device(const nv_gpu_info_t *gpu_info) + + return; /* Success */ + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 12, 0) ++failed_drm_client_init: ++ ++ kfree(client); ++ drm_dev_unregister(dev); ++ ++#endif ++ + failed_drm_register: + + nv_drm_dev_free(dev); diff --git a/srcpkgs/nvidia390/template b/srcpkgs/nvidia390/template index 48492ca7d80..3e48b929611 100644 --- a/srcpkgs/nvidia390/template +++ b/srcpkgs/nvidia390/template @@ -4,7 +4,7 @@ _desc="NVIDIA drivers (GeForce 400, 500 series)" pkgname=nvidia390 version=390.157 -revision=6 +revision=7 maintainer="Andrew Benson " license="custom:NVIDIA Proprietary" homepage="https://www.nvidia.com/en-us/drivers/unix/" @@ -44,14 +44,15 @@ do_patch() { case "$XBPS_TARGET_MACHINE" in i686) patch ${patch_args} -i ${FILESDIR}/linux-6.5-x86.patch - patch ${patch_args} -i ${FILESDIR}/linux6.3-x86.patch - patch ${patch_args} -i ${FILESDIR}/linux6.6.patch ;; + patch ${patch_args} -i ${FILESDIR}/linux6.3-x86.patch ;; x86_64) patch ${patch_args} -i ${FILESDIR}/linux-6.5-x64.patch - patch ${patch_args} -i ${FILESDIR}/linux6.3-x64.patch - patch ${patch_args} -i ${FILESDIR}/linux6.6.patch ;; + patch ${patch_args} -i ${FILESDIR}/linux6.3-x64.patch ;; esac + patch ${patch_args} -i ${FILESDIR}/linux6.6.patch patch ${patch_args} -i ${FILESDIR}/linux-6.4.patch + patch ${patch_args} -i ${FILESDIR}/linux-6.12.patch + patch ${patch_args} -i ${FILESDIR}/gcc-14.patch } pre_install() {