- fix building kernel module for kernel 4.4.169
[packages/xorg-driver-video-nvidia.git] / kernel-4.4.169.patch
1 --- NVIDIA-Linux-x86_64-390.87-no-compat32/kernel/conftest.sh~  2018-08-22 06:47:57.000000000 +0900
2 +++ NVIDIA-Linux-x86_64-390.87-no-compat32/kernel/conftest.sh   2018-12-29 09:33:30.537541114 +0900
3 @@ -2725,6 +2725,32 @@
4                  return
5              fi
6  
7 +            # Conftest #3: Check if get_user_pages has gup_flags instead of write and force parameters.
8 +            # Return if available.
9 +            # Fall through to default case if absent.
10 +
11 +            echo "$CONFTEST_PREAMBLE
12 +            #include <linux/mm.h>
13 +            long get_user_pages(struct task_struct *tsk,
14 +                                struct mm_struct *mm,
15 +                                unsigned long start,
16 +                                unsigned long nr_pages,
17 +                                unsigned int gup_flags,
18 +                                struct page **pages,
19 +                                struct vm_area_struct **vmas) {
20 +                return 0;
21 +            }" > conftest$$.c
22 +
23 +            $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
24 +            rm -f conftest$$.c
25 +
26 +            if [ -f conftest$$.o ]; then
27 +                echo "#undef NV_GET_USER_PAGES_HAS_WRITE_AND_FORCE_ARGS" | append_conftest "functions"
28 +                echo "#define NV_GET_USER_PAGES_HAS_TASK_STRUCT" | append_conftest "functions"
29 +                rm -f conftest$$.o
30 +                return
31 +            fi
32 +
33              echo "#define NV_GET_USER_PAGES_HAS_WRITE_AND_FORCE_ARGS" | append_conftest "functions"
34              echo "#define NV_GET_USER_PAGES_HAS_TASK_STRUCT" | append_conftest "functions"
35  
36 --- NVIDIA-Linux-x86_64-390.87-no-compat32/kernel/common/inc/nv-mm.h~   2018-08-22 09:55:23.000000000 +0900
37 +++ NVIDIA-Linux-x86_64-390.87-no-compat32/kernel/common/inc/nv-mm.h    2018-12-29 09:30:55.797962776 +0900
38 @@ -40,8 +40,31 @@
39   */
40  
41  #if defined(NV_GET_USER_PAGES_HAS_TASK_STRUCT)
42 +    #if defined(NV_GET_USER_PAGES_HAS_WRITE_AND_FORCE_ARGS)
43      #define NV_GET_USER_PAGES(start, nr_pages, write, force, pages, vmas) \
44          get_user_pages(current, current->mm, start, nr_pages, write, force, pages, vmas)
45 +    #else
46 +        #include <asm/current.h>
47 +        #include <linux/mm.h>
48 +        #include <linux/sched.h>
49 +
50 +        static inline long NV_GET_USER_PAGES(unsigned long start,
51 +                                             unsigned long nr_pages,
52 +                                             int write,
53 +                                             int force,
54 +                                             struct page **pages,
55 +                                             struct vm_area_struct **vmas)
56 +        {
57 +            unsigned int flags = 0;
58 +
59 +            if (write)
60 +                flags |= FOLL_WRITE;
61 +            if (force)
62 +                flags |= FOLL_FORCE;
63 +
64 +            return get_user_pages(current, current->mm, start, nr_pages, flags, pages, vmas);
65 +        }
66 +    #endif
67  #else
68      #if defined(NV_GET_USER_PAGES_HAS_WRITE_AND_FORCE_ARGS)
69          #define NV_GET_USER_PAGES get_user_pages
70 @@ -147,7 +147,32 @@
71          }
72      #endif
73  #else
74 -    #define NV_GET_USER_PAGES_REMOTE    get_user_pages
75 +    #if defined(NV_GET_USER_PAGES_HAS_WRITE_AND_FORCE_ARGS)
76 +        #define NV_GET_USER_PAGES_REMOTE    get_user_pages
77 +    #else
78 +        #include <asm/current.h>
79 +        #include <linux/mm.h>
80 +        #include <linux/sched.h>
81 +
82 +        static inline long NV_GET_USER_PAGES_REMOTE(struct task_struct *tsk,
83 +                                                    struct mm_struct *mm,
84 +                                                    unsigned long start,
85 +                                                    unsigned long nr_pages,
86 +                                                    int write,
87 +                                                    int force,
88 +                                                    struct page **pages,
89 +                                                    struct vm_area_struct **vmas)
90 +        {
91 +            unsigned int flags = 0;
92 +
93 +            if (write)
94 +                flags |= FOLL_WRITE;
95 +            if (force)
96 +                flags |= FOLL_FORCE;
97 +
98 +            return get_user_pages(tsk, mm, start, nr_pages, flags, pages, vmas);
99 +        }
100 +    #endif
101  #endif
102  
103  
This page took 0.067149 seconds and 3 git commands to generate.