- prepared for kernel >= 2.6.13: link Module.symvers
[packages/xorg-driver-video-nvidia.git] / NVIDIA_kernel-1.0-6629-1189413.diff
1 diff -ru usr/src/nv/nv-linux.h usr/src/nv.1189413/nv-linux.h
2 --- usr/src/nv/nv-linux.h       2004-11-03 22:53:00.000000000 +0100
3 +++ usr/src/nv.1189413/nv-linux.h       2005-01-07 15:44:01.000000000 +0100
4 @@ -627,75 +627,109 @@
5  #define NV_REMAP_PAGE_RANGE(x...) remap_page_range(x)
6  #endif
7  
8 +
9 +#define NV_PGD_OFFSET(address, kernel, mm)              \
10 +   ({                                                   \
11 +        pgd_t *__pgd;                                   \
12 +        if (!kernel)                                    \
13 +            __pgd = pgd_offset(mm, address);            \
14 +        else                                            \
15 +            __pgd = pgd_offset_k(address);              \
16 +        __pgd;                                          \
17 +    })
18 +
19 +#define NV_PGD_PRESENT(pgd)                             \
20 +   ({                                                   \
21 +         if ((pgd != NULL) &&                           \
22 +             (pgd_bad(*pgd) || pgd_none(*pgd)))         \
23 +            /* static */ pgd = NULL;                    \
24 +         pgd != NULL;                                   \
25 +    })
26 +
27  #if defined(pmd_offset_map)
28 -#define NV_PMD_OFFSET(addres, pg_dir, pg_mid_dir) \
29 -    { \
30 -        pg_mid_dir = pmd_offset_map(pg_dir, address); \
31 -    }
32 -#define NV_PMD_UNMAP(pg_mid_dir) \
33 -    { \
34 -        pmd_unmap(pg_mid_dir); \
35 -    }
36 +#define NV_PMD_OFFSET(address, pgd)                     \
37 +   ({                                                   \
38 +        pmd_t *__pmd;                                   \
39 +        __pmd = pmd_offset_map(pgd, address);           \
40 +   })
41 +#define NV_PMD_UNMAP(pmd) pmd_unmap(pmd);
42  #else
43 -#define NV_PMD_OFFSET(addres, pg_dir, pg_mid_dir) \
44 -    { \
45 -        pg_mid_dir = pmd_offset(pg_dir, address); \
46 -    }
47 -#define NV_PMD_UNMAP(pg_mid_dir)
48 +#if defined(PUD_SHIFT) /* 4-level pgtable */
49 +#define NV_PMD_OFFSET(address, pgd)                     \
50 +   ({                                                   \
51 +        pmd_t *__pmd = NULL;                            \
52 +        pud_t *__pud;                                   \
53 +        __pud = pud_offset(pgd, address);               \
54 +        if ((__pud != NULL) &&                          \
55 +            !(pud_bad(*__pud) || pud_none(*__pud)))     \
56 +            __pmd = pmd_offset(__pud, address);         \
57 +        __pmd;                                          \
58 +    })
59 +#else /* 3-level pgtable */
60 +#define NV_PMD_OFFSET(address, pgd)                     \
61 +   ({                                                   \
62 +        pmd_t *__pmd;                                   \
63 +        __pmd = pmd_offset(pgd, address);               \
64 +    })
65 +#endif
66 +#define NV_PMD_UNMAP(pmd)
67  #endif
68  
69 -#define NV_PMD_PRESENT(pg_mid_dir) \
70 -    ({ \
71 -        if ( (pg_mid_dir) && (pmd_none(*pg_mid_dir))) { \
72 -            NV_PMD_UNMAP(pg_mid_dir); pg_mid_dir = NULL; \
73 -        } pg_mid_dir != NULL; \
74 +#define NV_PMD_PRESENT(pmd)                             \
75 +   ({                                                   \
76 +        if ((pmd != NULL) &&                            \
77 +            (pmd_bad(*pmd) || pmd_none(*pmd)))          \
78 +        {                                               \
79 +            NV_PMD_UNMAP(pmd);                          \
80 +            pmd = NULL; /* mark invalid */              \
81 +        }                                               \
82 +        pmd != NULL;                                    \
83      })
84  
85  #if defined(pte_offset_atomic)
86 -#define NV_PTE_OFFSET(addres, pg_mid_dir, pte) \
87 -    { \
88 -        pte = pte_offset_atomic(pg_mid_dir, address); \
89 -        NV_PMD_UNMAP(pg_mid_dir); \
90 -    }
91 -#define NV_PTE_UNMAP(pte) \
92 -    { \
93 -        pte_kunmap(pte); \
94 -    }
95 +#define NV_PTE_OFFSET(address, pmd)                     \
96 +   ({                                                   \
97 +        pte_t *__pte;                                   \
98 +        __pte = pte_offset_atomic(pmd, address);        \
99 +        NV_PMD_UNMAP(pmd); __pte;                       \
100 +    })
101 +#define NV_PTE_UNMAP(pte) pte_kunmap(pte);
102  #elif defined(pte_offset)
103 -#define NV_PTE_OFFSET(addres, pg_mid_dir, pte) \
104 -    { \
105 -        pte = pte_offset(pg_mid_dir, address); \
106 -        NV_PMD_UNMAP(pg_mid_dir); \
107 -    }
108 +#define NV_PTE_OFFSET(address, pmd)                     \
109 +   ({                                                   \
110 +        pte_t *__pte;                                   \
111 +        __pte = pte_offset(pmd, address);               \
112 +        NV_PMD_UNMAP(pmd); __pte;                       \
113 +    })
114  #define NV_PTE_UNMAP(pte)
115  #else
116 -#define NV_PTE_OFFSET(addres, pg_mid_dir, pte) \
117 -    { \
118 -        pte = pte_offset_map(pg_mid_dir, address); \
119 -        NV_PMD_UNMAP(pg_mid_dir); \
120 -    }
121 -#define NV_PTE_UNMAP(pte) \
122 -    { \
123 -        pte_unmap(pte); \
124 -    }
125 +#define NV_PTE_OFFSET(address, pmd)                     \
126 +   ({                                                   \
127 +        pte_t *__pte;                                   \
128 +        __pte = pte_offset_map(pmd, address);           \
129 +        NV_PMD_UNMAP(pmd); __pte;                       \
130 +    })
131 +#define NV_PTE_UNMAP(pte) pte_unmap(pte);
132  #endif
133  
134 -#define NV_PTE_PRESENT(pte) \
135 -    ({ \
136 -        if (pte) { \
137 -            if (!pte_present(*pte)) { \
138 -                NV_PTE_UNMAP(pte); pte = NULL; \
139 -            } \
140 -        } pte != NULL; \
141 +#define NV_PTE_PRESENT(pte)                             \
142 +   ({                                                   \
143 +        if ((pte != NULL) && !pte_present(*pte))        \
144 +        {                                               \
145 +            NV_PTE_UNMAP(pte);                          \
146 +            pte = NULL; /* mark invalid */              \
147 +        }                                               \
148 +        pte != NULL;                                    \
149      })
150  
151 -#define NV_PTE_VALUE(pte) \
152 -    ({ \
153 -        unsigned long __pte_value = pte_val(*pte); \
154 -        NV_PTE_UNMAP(pte); \
155 -        __pte_value; \
156 +#define NV_PTE_VALUE(pte)                               \
157 +   ({                                                   \
158 +        unsigned long __pte_value = pte_val(*pte);      \
159 +        NV_PTE_UNMAP(pte);                              \
160 +        __pte_value;                                    \
161      })
162  
163 +
164  #define NV_PAGE_ALIGN(addr)             ( ((addr) + PAGE_SIZE - 1) / PAGE_SIZE)
165  #define NV_MASK_OFFSET(addr)            ( (addr) & (PAGE_SIZE - 1) )
166  
167 diff -ru usr/src/nv/nv-vm.c usr/src/nv.1189413/nv-vm.c
168 --- usr/src/nv/nv-vm.c  2004-11-03 22:53:00.000000000 +0100
169 +++ usr/src/nv.1189413/nv-vm.c  2005-01-07 15:43:22.000000000 +0100
170 @@ -53,12 +53,13 @@
171   * conflicts. we try to rely on the kernel's provided interfaces when possible,
172   * but need additional flushing on earlier kernels.
173   */
174 -
175 +#if defined(KERNEL_2_4)
176  /* wrap CACHE_FLUSH so we can pass it to smp_call_function */
177  static void cache_flush(void *p)
178  {
179      CACHE_FLUSH();
180  }
181 +#endif
182  
183  /*
184   * 2.4 kernels handle flushing in the change_page_attr() call, but kernels 
185 diff -ru usr/src/nv/nv.c usr/src/nv.1189413/nv.c
186 --- usr/src/nv/nv.c     2004-11-03 22:53:00.000000000 +0100
187 +++ usr/src/nv.1189413/nv.c     2005-01-07 15:43:22.000000000 +0100
188 @@ -2492,26 +2492,23 @@
189  )
190  {
191      struct mm_struct *mm;
192 -    pgd_t *pg_dir;
193 -    pmd_t *pg_mid_dir;
194 -    pte_t *pte;
195 +    pgd_t *pgd = NULL;
196 +    pmd_t *pmd = NULL;
197 +    pte_t *pte = NULL;
198      unsigned long retval;
199  
200      mm = (kern) ? &init_mm : current->mm;
201      spin_lock(&mm->page_table_lock);
202  
203 -    if (kern) pg_dir = pgd_offset_k(address);
204 -    else pg_dir = pgd_offset(mm, address);
205 -
206 -    if (!pg_dir || pgd_none(*pg_dir))
207 +    pgd = NV_PGD_OFFSET(address, kern, mm);
208 +    if (!NV_PGD_PRESENT(pgd))
209          goto failed;
210  
211 -    NV_PMD_OFFSET(address, pg_dir, pg_mid_dir);
212 -    if (!NV_PMD_PRESENT(pg_mid_dir))
213 +    pmd = NV_PMD_OFFSET(address, pgd);
214 +    if (!NV_PMD_PRESENT(pmd))
215          goto failed;
216  
217 -    NV_PTE_OFFSET(address, pg_mid_dir, pte);
218 -
219 +    pte = NV_PTE_OFFSET(address, pmd);
220      if (!NV_PTE_PRESENT(pte))
221          goto failed;
222  
This page took 0.052478 seconds and 3 git commands to generate.