Unverified Commit 3e2d14b0 authored by Masum Reza's avatar Masum Reza Committed by GitHub
Browse files

linuxPackages.nvidiaPackages.legacy_(390,470}: patch for linux 6.17 (#458686)

parents c9f46eb0 403b09dc
Loading
Loading
Loading
Loading
+40 −22
Original line number Diff line number Diff line
@@ -50,8 +50,8 @@ let
  # Source corresponding to https://aur.archlinux.org/packages/nvidia-390xx-dkms
  aurPatches = fetchgit {
    url = "https://aur.archlinux.org/nvidia-390xx-utils.git";
    rev = "94dffc01e23a93c354a765ea7ac64484a3ef96c1";
    hash = "sha256-c94qXNZyMrSf7Dik7jvz2ECaGELqN7WEYNpnbUkzeeU=";
    rev = "cf1a1c571c425b4b66d12e468fc4ce45a397c583";
    hash = "sha256-SERB5ihOroagJn7apAiqjUckbrfP2FZPCuTLWcBccoM=";
  };

  # https://github.com/NVIDIA/open-gpu-kernel-modules/issues/840
@@ -166,24 +166,37 @@ rec {
  };

  # Last one supporting Kepler architecture
  legacy_470 = generic {
  legacy_470 =
    let
      # Source corresponding to https://aur.archlinux.org/packages/nvidia-470xx-dkms
      aurPatches = fetchgit {
        url = "https://aur.archlinux.org/nvidia-470xx-utils.git";
        rev = "7c1c2c124147d960a6c7114eb26a4eadae9b9f3d";
        hash = "sha256-sNW+I4dkPSudfORLEp1RNGHyQKWBYnBEeGrfJU7SYTs=";
      };
    in
    generic {
      version = "470.256.02";
      sha256_64bit = "sha256-1kUYYt62lbsER/O3zWJo9z6BFowQ4sEFl/8/oBNJsd4=";
      sha256_aarch64 = "sha256-e+QvE+S3Fv3JRqC9ZyxTSiCu8gJdZXSz10gF/EN6DY0=";
      settingsSha256 = "sha256-kftQ4JB0iSlE8r/Ze/+UMnwLzn0nfQtqYXBj+t6Aguk=";
      persistencedSha256 = "sha256-iYoSib9VEdwjOPBP1+Hx5wCIMhW8q8cCHu9PULWfnyQ=";

    patches = [
      "${aurPatches}/gcc-14.patch"
      # fixes 6.10 follow_pfn
      ./follow_pfn.patch
      # https://gist.github.com/joanbm/a6d3f7f873a60dec0aa4a734c0f1d64e
      (fetchpatch {
        url = "https://gist.github.com/joanbm/a6d3f7f873a60dec0aa4a734c0f1d64e/raw/6bae5606c033b6c6c08233523091992370e357b7/nvidia-470xx-fix-linux-6.12.patch";
        hash = "sha256-6nbzcRTRCxW8GDAhB8Zwx9rVcCzwPtVYlqoUhL9gxlY=";
        stripLen = 1;
        extraPrefix = "kernel/";
      })
      patches = map (patch: "${aurPatches}/${patch}") [
        "0001-Fix-conftest-to-ignore-implicit-function-declaration.patch"
        "0002-Fix-conftest-to-use-a-short-wchar_t.patch"
        "0003-Fix-conftest-to-use-nv_drm_gem_vmap-which-has-the-se.patch"
        "nvidia-470xx-fix-gcc-15.patch"
        "kernel-6.10.patch"
        "kernel-6.12.patch"
        "nvidia-470xx-fix-linux-6.13.patch"
        "nvidia-470xx-fix-linux-6.14.patch"
        "nvidia-470xx-fix-linux-6.15.patch"
        "nvidia-470xx-fix-linux-6.17.patch"
      ];
      patchFlags = [
        "-p1"
        "--directory=kernel"
      ];
    };

@@ -206,8 +219,13 @@ rec {
      "gcc-14.patch"
      "kernel-6.10.patch"
      "kernel-6.12.patch"
      "kernel-6.13.patch"
      "kernel-6.14.patch"
      "gcc-15.patch"
      "kernel-6.15.patch"
      "kernel-6.17.patch"
    ];
    broken = kernel.kernelAtLeast "6.13";
    broken = kernel.kernelAtLeast "6.18";

    # fixes the bug described in https://bbs.archlinux.org/viewtopic.php?pid=2083439#p2083439
    # see https://bbs.archlinux.org/viewtopic.php?pid=2083651#p2083651
+0 −61
Original line number Diff line number Diff line
diff -ruNb a/kernel/conftest.sh b/kernel/conftest.sh
--- a/kernel/conftest.sh        2024-07-19 04:36:26.183701185 -0500
+++ b/kernel/conftest.sh        2024-07-19 04:36:26.230366381 -0500
@@ -4464,20 +4464,22 @@
             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 <linux/mm.h>
-            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 -ruNb a/kernel/nvidia/nvidia.Kbuild b/kernel/nvidia/nvidia.Kbuild
--- a/kernel/nvidia/nvidia.Kbuild       2022-10-12 04:29:57.000000000 -0500
+++ b/kernel/nvidia/nvidia.Kbuild       2024-07-19 05:17:39.148448922 -0500
@@ -164,7 +164,7 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += cc
 NV_CONFTEST_FUNCTION_COMPILE_TESTS += iterate_fd
 NV_CONFTEST_FUNCTION_COMPILE_TESTS += seq_read_iter
 NV_CONFTEST_FUNCTION_COMPILE_TESTS += sg_page_iter_page
-NV_CONFTEST_FUNCTION_COMPILE_TESTS += unsafe_follow_pfn
+NV_CONFTEST_FUNCTION_COMPILE_TESTS += follow_pfn
 NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_gem_object_get
 NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_gem_object_put_unlocked
 NV_CONFTEST_FUNCTION_COMPILE_TESTS += set_close_on_exec
diff -ruNb a/kernel/nvidia/os-mlock.c b/kernel/nvidia/os-mlock.c
--- a/kernel/nvidia/os-mlock.c  2022-10-12 04:30:26.000000000 -0500
+++ b/kernel/nvidia/os-mlock.c  2024-07-19 04:36:26.230366381 -0500
@@ -18,10 +18,10 @@
                                 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
 }
 No newline at end of file