1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
|
--- conftest.sh.orig 2008-08-28 00:12:01.000000000 -0300
+++ conftest.sh 2008-08-28 01:04:19.000000000 -0300
@@ -40,6 +40,12 @@ if [ -n "$BUILD_PARAMS" ]; then
CFLAGS="$CFLAGS -D$BUILD_PARAMS"
fi
+CONFTEST_PREAMBLE="#include <linux/autoconf.h>
+ #if defined(CONFIG_XEN) && \
+ defined(CONFIG_XEN_INTERFACE_VERSION) && !defined(__XEN_INTERFACE_VERSION__)
+ #define __XEN_INTERFACE_VERSION__ CONFIG_XEN_INTERFACE_VERSION
+ #endif"
+
compile_test() {
case "$1" in
remap_page_range)
@@ -672,6 +678,121 @@ compile_test() {
fi
;;
+ smp_call_function)
+ #
+ # Determine if the smp_call_function() function is
+ # present and how many arguments it takes.
+ #
+ echo "$CONFTEST_PREAMBLE
+ #include <linux/smp.h>
+ void conftest_smp_call_function(void) {
+ #ifdef CONFIG_SMP
+ smp_call_function();
+ #endif
+ }" > conftest$$.c
+
+ $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
+ rm -f conftest$$.c
+
+ if [ -f conftest$$.o ]; then
+ rm -f conftest$$.o
+ echo "#undef NV_SMP_CALL_FUNCTION_PRESENT" >> conftest.h
+ return
+ fi
+
+ echo "$CONFTEST_PREAMBLE
+ #include <linux/smp.h>
+ void conftest_smp_call_function(void) {
+ smp_call_function(NULL, NULL, 0, 0);
+ }" > conftest$$.c
+
+ $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
+ rm -f conftest$$.c
+
+ if [ -f conftest$$.o ]; then
+ rm -f conftest$$.o
+ echo "#define NV_SMP_CALL_FUNCTION_PRESENT" >> conftest.h
+ echo "#define NV_SMP_CALL_FUNCTION_ARGUMENT_COUNT 4 " >> conftest.h
+ return
+ fi
+
+ echo "$CONFTEST_PREAMBLE
+ #include <linux/smp.h>
+ void conftest_smp_call_function(void) {
+ smp_call_function(NULL, NULL, 0);
+ }" > conftest$$.c
+
+ $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
+ rm -f conftest$$.c
+
+ if [ -f conftest$$.o ]; then
+ rm -f conftest$$.o
+ echo "#define NV_SMP_CALL_FUNCTION_PRESENT" >> conftest.h
+ echo "#define NV_SMP_CALL_FUNCTION_ARGUMENT_COUNT 3 " >> conftest.h
+ return
+ else
+ echo "#error smp_call_function() conftest failed!" >> conftest.h
+ fi
+ ;;
+
+ on_each_cpu)
+ #
+ # Determine if the on_each_cpu() function is present
+ # and how many arguments it takes.
+ #
+ echo "$CONFTEST_PREAMBLE
+ #include <linux/smp.h>
+ void conftest_on_each_cpu(void) {
+ #ifdef CONFIG_SMP
+ on_each_cpu();
+ #endif
+ }" > conftest$$.c
+
+ $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
+ rm -f conftest$$.c
+
+ if [ -f conftest$$.o ]; then
+ rm -f conftest$$.o
+ echo "#undef NV_ON_EACH_CPU" >> conftest.h
+ return
+ fi
+
+ echo "$CONFTEST_PREAMBLE
+ #include <linux/smp.h>
+ void conftest_on_each_cpu(void) {
+ on_each_cpu(NULL, NULL, 0, 0);
+ }" > conftest$$.c
+
+ $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
+ rm -f conftest$$.c
+
+ if [ -f conftest$$.o ]; then
+ rm -f conftest$$.o
+ echo "#define NV_ON_EACH_CPU_PRESENT" >> conftest.h
+ echo "#define NV_ON_EACH_CPU_ARGUMENT_COUNT 4 " >> conftest.h
+ return
+ fi
+
+ echo "$CONFTEST_PREAMBLE
+ #include <linux/smp.h>
+ void conftest_on_each_cpu(void) {
+ on_each_cpu(NULL, NULL, 0);
+ }" > conftest$$.c
+
+ $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
+ rm -f conftest$$.c
+
+ if [ -f conftest$$.o ]; then
+ rm -f conftest$$.o
+ echo "#define NV_ON_EACH_CPU_PRESENT" >> conftest.h
+ echo "#define NV_ON_EACH_CPU_ARGUMENT_COUNT 3 " >> conftest.h
+ return
+ else
+ echo "#error on_each_cpu() conftest failed!" >> conftest.h
+ fi
+ ;;
+
+
esac
}
@@ -1203,11 +1324,21 @@ case "$5" in
# Run a series of compile tests to determine the set of interfaces
# and features available in the target kernel.
#
+ FILES="linux/semaphore.h"
shift 5
rm -f conftest.h
for i in $*; do compile_test $i; done
+ for FILE in $FILES; do
+ FILE_DEFINE=NV_`echo $FILE | tr '/.' '_' | tr 'a-z' 'A-Z'`_PRESENT
+ if [ -f $HEADERS/$FILE -o -f $OUTPUT/include/$FILE ]; then
+ echo "#define $FILE_DEFINE" >> conftest.h
+ else
+ echo "#undef $FILE_DEFINE" >> conftest.h
+ fi
+ done
+
if [ -n "$SHOW_COMPILE_TEST_RESULTS" -a -f conftest.h ]; then
cat conftest.h
fi
--- Makefile.kbuild.orig 2008-08-28 00:26:41.000000000 -0300
+++ Makefile.kbuild 2008-08-28 00:30:01.000000000 -0300
@@ -186,13 +186,16 @@ ifneq ($(PATCHLEVEL), 4)
BREAKPOINT \
acpi_device_ops \
acquire_console_sem \
- kmem_cache_create
+ kmem_cache_create \
+ on_each_cpu \
+ smp_call_function
else
COMPILE_TESTS = \
remap_page_range \
vmap \
change_page_attr \
- i2c_adapter
+ i2c_adapter \
+ smp_call_function
endif
#
--- Makefile.nvidia.orig 2008-08-28 00:30:18.000000000 -0300
+++ Makefile.nvidia 2008-08-28 00:30:35.000000000 -0300
@@ -62,7 +62,8 @@ COMPILE_TESTS = \
remap_page_range \
vmap \
change_page_attr \
- i2c_adapter
+ i2c_adapter \
+ smp_call_function
DEFINES+=$(EXTRA_DEFINES)
--- nv.c.orig 2008-08-28 00:08:18.000000000 -0300
+++ nv.c 2008-08-28 01:00:05.000000000 -0300
@@ -832,8 +832,8 @@ static void __nv_setup_pat_entries(void
unsigned long eflags;
#if defined(CONFIG_HOTPLUG_CPU)
- unsigned int cpu = (NvUPtr)info;
- if ((cpu != 0) && (cpu != smp_processor_id()))
+ int cpu = (NvUPtr)info;
+ if ((cpu != 0) && (cpu != (int)smp_processor_id()))
return;
#endif
@@ -858,8 +858,8 @@ static void __nv_restore_pat_entries(voi
unsigned long eflags;
#if defined(CONFIG_HOTPLUG_CPU)
- unsigned int cpu = (NvUPtr)info;
- if ((cpu != 0) && (cpu != smp_processor_id()))
+ int cpu = (NvUPtr)info;
+ if ((cpu != 0) && (cpu != (int)smp_processor_id()))
return;
#endif
@@ -1179,27 +1179,27 @@ failed:
static int
nv_kern_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
{
- unsigned int cpu = (NvUPtr)hcpu;
-
+ unsigned int cpu = get_cpu();
+
switch (action)
{
case CPU_DOWN_FAILED:
case CPU_ONLINE:
- if (get_cpu() == cpu)
+ if (cpu == (NvUPtr)hcpu)
__nv_setup_pat_entries(NULL);
else
- smp_call_function(__nv_setup_pat_entries, hcpu, 1, 1);
- put_cpu();
+ NV_SMP_CALL_FUNCTION(__nv_setup_pat_entries, hcpu, 1);
break;
case CPU_DOWN_PREPARE:
- if (get_cpu() == cpu)
+ if (cpu == (NvUPtr)hcpu)
__nv_restore_pat_entries(NULL);
else
- smp_call_function(__nv_restore_pat_entries, hcpu, 1, 1);
- put_cpu();
+ NV_SMP_CALL_FUNCTION(__nv_restore_pat_entries, hcpu, 1);
break;
}
+ put_cpu();
+
return NOTIFY_OK;
}
--- nv-linux.h.orig 2008-08-28 00:13:57.000000000 -0300
+++ nv-linux.h 2008-08-28 01:05:50.000000000 -0300
@@ -103,7 +103,11 @@
#endif
#include <linux/spinlock.h>
+#if defined(NV_LINUX_SEMAPHORE_H_PRESENT)
+#include <linux/semaphore.h>
+#else
#include <asm/semaphore.h>
+#endif
#include <linux/completion.h>
#include <linux/highmem.h>
@@ -609,6 +613,46 @@ static inline unsigned long nv_virt_to_p
#endif /* !defined NVWATCH */
+#if defined(NV_SMP_CALL_FUNCTION_PRESENT)
+#if (NV_SMP_CALL_FUNCTION_ARGUMENT_COUNT == 4)
+#define NV_SMP_CALL_FUNCTION(func, info, wait) \
+ ({ \
+ int __ret = smp_call_function(func, info, 1, wait); \
+ __ret; \
+ })
+#elif (NV_SMP_CALL_FUNCTION_ARGUMENT_COUNT == 3)
+#define NV_SMP_CALL_FUNCTION(func, info, wait) \
+ ({ \
+ int __ret = smp_call_function(func, info, wait); \
+ __ret; \
+ })
+#else
+#error "NV_SMP_CALL_FUNCTION_ARGUMENT_COUNT value unrecognized!"
+#endif
+#elif defined(CONFIG_SMP)
+#error "NV_SMP_CALL_FUNCTION() undefined (smp_call_function() unavailable)!"
+#endif
+
+#if defined(NV_ON_EACH_CPU_PRESENT)
+#if (NV_ON_EACH_CPU_ARGUMENT_COUNT == 4)
+#define NV_ON_EACH_CPU(func, info, wait) \
+ ({ \
+ int __ret = on_each_cpu(func, info, 1, wait); \
+ __ret; \
+ })
+#elif (NV_ON_EACH_CPU_ARGUMENT_COUNT == 3)
+#define NV_ON_EACH_CPU(func, info, wait) \
+ ({ \
+ int __ret = on_each_cpu(func, info, wait); \
+ __ret; \
+ })
+#else
+#error "NV_ON_EACH_CPU_ARGUMENT_COUNT value unrecognized!"
+#endif
+#elif !defined(KERNEL_2_4) && defined(CONFIG_SMP)
+#error "NV_ON_EACH_CPU() undefined (on_each_cpu() unavailable)!"
+#endif
+
static inline int nv_execute_on_all_cpus(void (*func)(void *info), void *info)
{
int ret = 0;
@@ -618,13 +662,13 @@ static inline int nv_execute_on_all_cpus
#if defined(preempt_disable)
preempt_disable();
#endif
- ret = smp_call_function(func, info, 1, 1);
+ ret = NV_SMP_CALL_FUNCTION(func, info, 1);
func(info);
#if defined(preempt_enable)
preempt_enable();
#endif
#else
- ret = on_each_cpu(func, info, 1, 1);
+ ret = NV_ON_EACH_CPU(func, info, 1);
#endif
return ret;
}
--- os-interface.c.orig 2008-08-28 00:20:50.000000000 -0300
+++ os-interface.c 2008-08-28 01:21:49.000000000 -0300
@@ -48,7 +48,7 @@ RM_STATUS NV_API_CALL os_raise_smp_barri
#endif
local_bh_disable();
atomic_set(&os_smp_barrier, 1);
- ret = smp_call_function(ipi_handler, NULL, 1, 0);
+ ret = NV_SMP_CALL_FUNCTION(ipi_handler, NULL, 0);
#endif
return (ret == 0) ? RM_OK : RM_ERROR;
}
--- os-interface.c.orig 2008-08-28 13:11:52.000000000 -0300
+++ os-interface.c 2008-08-28 13:12:33.000000000 -0300
@@ -632,7 +632,7 @@ RM_STATUS NV_API_CALL os_kill_process(
U032 sig
)
{
- return kill_proc(pid, sig, 1) ? RM_ERR_OPERATING_SYSTEM : RM_OK;
+ return /*kill_proc(pid, sig, 1) ?*/ RM_ERR_OPERATING_SYSTEM /*: RM_OK*/;
}
/*******************************************************************************/
|