aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2005-11-07 21:42:23 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2005-11-07 21:42:23 -0500
commitd27ba47e7e8c466c18983a1779d611f82d6a354f (patch)
tree2870d82516be16e0cae63e1f7e84bd855bb34a23 /arch
parente3d8b77bc7a89d190ee895d0570af10c026e5086 (diff)
parentdd3e2dcf3408843ed35501c28626f389b30be756 (diff)
Merge master.kernel.org:/pub/scm/linux/kernel/git/davem/sparc-2.6
Diffstat (limited to 'arch')
-rw-r--r--arch/sparc/Kconfig8
-rw-r--r--arch/sparc/kernel/Makefile1
-rw-r--r--arch/sparc/kernel/led.c139
-rw-r--r--arch/sparc/kernel/sunos_ioctl.c1
-rw-r--r--arch/sparc64/kernel/ioctl32.c459
-rw-r--r--arch/sparc64/kernel/setup.c12
-rw-r--r--arch/sparc64/kernel/signal32.c6
-rw-r--r--arch/sparc64/kernel/smp.c79
-rw-r--r--arch/sparc64/kernel/sunos_ioctl32.c1
-rw-r--r--arch/sparc64/kernel/time.c13
10 files changed, 184 insertions, 535 deletions
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 6537445dac0e..3cfb8be3ff6d 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -201,6 +201,14 @@ config SUN_OPENPROMFS
201 Only choose N if you know in advance that you will not need to modify 201 Only choose N if you know in advance that you will not need to modify
202 OpenPROM settings on the running system. 202 OpenPROM settings on the running system.
203 203
204config SPARC_LED
205 tristate "Sun4m LED driver"
206 help
207 This driver toggles the front-panel LED on sun4m systems
208 in a user-specifyable manner. It's state can be probed
209 by reading /proc/led and it's blinking mode can be changed
210 via writes to /proc/led
211
204source "fs/Kconfig.binfmt" 212source "fs/Kconfig.binfmt"
205 213
206config SUNOS_EMUL 214config SUNOS_EMUL
diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
index 3d22ba2af01c..1b83e21841b5 100644
--- a/arch/sparc/kernel/Makefile
+++ b/arch/sparc/kernel/Makefile
@@ -21,6 +21,7 @@ obj-$(CONFIG_SUN_AUXIO) += auxio.o
21obj-$(CONFIG_PCI) += ebus.o 21obj-$(CONFIG_PCI) += ebus.o
22obj-$(CONFIG_SUN_PM) += apc.o pmc.o 22obj-$(CONFIG_SUN_PM) += apc.o pmc.o
23obj-$(CONFIG_MODULES) += module.o sparc_ksyms.o 23obj-$(CONFIG_MODULES) += module.o sparc_ksyms.o
24obj-$(CONFIG_SPARC_LED) += led.o
24 25
25ifdef CONFIG_SUNOS_EMUL 26ifdef CONFIG_SUNOS_EMUL
26obj-y += sys_sunos.o sunos_ioctl.o 27obj-y += sys_sunos.o sunos_ioctl.o
diff --git a/arch/sparc/kernel/led.c b/arch/sparc/kernel/led.c
new file mode 100644
index 000000000000..2a3afca453c9
--- /dev/null
+++ b/arch/sparc/kernel/led.c
@@ -0,0 +1,139 @@
1#include <linux/kernel.h>
2#include <linux/module.h>
3#include <linux/init.h>
4#include <linux/proc_fs.h>
5#include <linux/string.h>
6
7#include <asm/auxio.h>
8
9#define LED_MAX_LENGTH 8 /* maximum chars written to proc file */
10
11static inline void led_toggle(void)
12{
13 unsigned char val = get_auxio();
14 unsigned char on, off;
15
16 if (val & AUXIO_LED) {
17 on = 0;
18 off = AUXIO_LED;
19 } else {
20 on = AUXIO_LED;
21 off = 0;
22 }
23
24 set_auxio(on, off);
25}
26
27static struct timer_list led_blink_timer;
28
29static void led_blink(unsigned long timeout)
30{
31 led_toggle();
32
33 /* reschedule */
34 if (!timeout) { /* blink according to load */
35 led_blink_timer.expires = jiffies +
36 ((1 + (avenrun[0] >> FSHIFT)) * HZ);
37 led_blink_timer.data = 0;
38 } else { /* blink at user specified interval */
39 led_blink_timer.expires = jiffies + (timeout * HZ);
40 led_blink_timer.data = timeout;
41 }
42 add_timer(&led_blink_timer);
43}
44
45static int led_read_proc(char *buf, char **start, off_t offset, int count,
46 int *eof, void *data)
47{
48 int len = 0;
49
50 if (get_auxio() & AUXIO_LED)
51 len = sprintf(buf, "on\n");
52 else
53 len = sprintf(buf, "off\n");
54
55 return len;
56}
57
58static int led_write_proc(struct file *file, const char *buffer,
59 unsigned long count, void *data)
60{
61 char *buf = NULL;
62
63 if (count > LED_MAX_LENGTH)
64 count = LED_MAX_LENGTH;
65
66 buf = kmalloc(sizeof(char) * (count + 1), GFP_KERNEL);
67 if (!buf)
68 return -ENOMEM;
69
70 if (copy_from_user(buf, buffer, count)) {
71 kfree(buf);
72 return -EFAULT;
73 }
74
75 buf[count] = '\0';
76
77 /* work around \n when echo'ing into proc */
78 if (buf[count - 1] == '\n')
79 buf[count - 1] = '\0';
80
81 /* before we change anything we want to stop any running timers,
82 * otherwise calls such as on will have no persistent effect
83 */
84 del_timer_sync(&led_blink_timer);
85
86 if (!strcmp(buf, "on")) {
87 auxio_set_led(AUXIO_LED_ON);
88 } else if (!strcmp(buf, "toggle")) {
89 led_toggle();
90 } else if ((*buf > '0') && (*buf <= '9')) {
91 led_blink(simple_strtoul(buf, NULL, 10));
92 } else if (!strcmp(buf, "load")) {
93 led_blink(0);
94 } else {
95 auxio_set_led(AUXIO_LED_OFF);
96 }
97
98 kfree(buf);
99
100 return count;
101}
102
103static struct proc_dir_entry *led;
104
105#define LED_VERSION "0.1"
106
107static int __init led_init(void)
108{
109 init_timer(&led_blink_timer);
110 led_blink_timer.function = led_blink;
111
112 led = create_proc_entry("led", 0, NULL);
113 if (!led)
114 return -ENOMEM;
115
116 led->read_proc = led_read_proc; /* reader function */
117 led->write_proc = led_write_proc; /* writer function */
118 led->owner = THIS_MODULE;
119
120 printk(KERN_INFO
121 "led: version %s, Lars Kotthoff <metalhead@metalhead.ws>\n",
122 LED_VERSION);
123
124 return 0;
125}
126
127static void __exit led_exit(void)
128{
129 remove_proc_entry("led", NULL);
130 del_timer_sync(&led_blink_timer);
131}
132
133module_init(led_init);
134module_exit(led_exit);
135
136MODULE_AUTHOR("Lars Kotthoff <metalhead@metalhead.ws>");
137MODULE_DESCRIPTION("Provides control of the front LED on SPARC systems.");
138MODULE_LICENSE("GPL");
139MODULE_VERSION(LED_VERSION);
diff --git a/arch/sparc/kernel/sunos_ioctl.c b/arch/sparc/kernel/sunos_ioctl.c
index df1c0b31a930..a6ba3d26222c 100644
--- a/arch/sparc/kernel/sunos_ioctl.c
+++ b/arch/sparc/kernel/sunos_ioctl.c
@@ -23,7 +23,6 @@
23#include <linux/smp_lock.h> 23#include <linux/smp_lock.h>
24#include <linux/syscalls.h> 24#include <linux/syscalls.h>
25#include <linux/file.h> 25#include <linux/file.h>
26#include <asm/kbio.h>
27 26
28#if 0 27#if 0
29extern char sunkbd_type; 28extern char sunkbd_type;
diff --git a/arch/sparc64/kernel/ioctl32.c b/arch/sparc64/kernel/ioctl32.c
index e6a00325075a..92e26304de90 100644
--- a/arch/sparc64/kernel/ioctl32.c
+++ b/arch/sparc64/kernel/ioctl32.c
@@ -11,33 +11,14 @@
11 11
12#define INCLUDES 12#define INCLUDES
13#include "compat_ioctl.c" 13#include "compat_ioctl.c"
14#include <linux/ncp_fs.h>
15#include <linux/syscalls.h> 14#include <linux/syscalls.h>
16#include <asm/fbio.h> 15#include <asm/fbio.h>
17#include <asm/kbio.h>
18#include <asm/vuid_event.h>
19#include <asm/envctrl.h>
20#include <asm/display7seg.h>
21#include <asm/openpromio.h>
22#include <asm/audioio.h>
23#include <asm/watchdog.h>
24 16
25/* Use this to get at 32-bit user passed pointers. 17/* Use this to get at 32-bit user passed pointers.
26 * See sys_sparc32.c for description about it. 18 * See sys_sparc32.c for description about it.
27 */ 19 */
28#define A(__x) compat_ptr(__x) 20#define A(__x) compat_ptr(__x)
29 21
30static __inline__ void *alloc_user_space(long len)
31{
32 struct pt_regs *regs = current_thread_info()->kregs;
33 unsigned long usp = regs->u_regs[UREG_I6];
34
35 if (!(test_thread_flag(TIF_32BIT)))
36 usp += STACK_BIAS;
37
38 return (void *) (usp - len);
39}
40
41#define CODE 22#define CODE
42#include "compat_ioctl.c" 23#include "compat_ioctl.c"
43 24
@@ -111,357 +92,6 @@ static int fbiogscursor(unsigned int fd, unsigned int cmd, unsigned long arg)
111 return sys_ioctl (fd, FBIOSCURSOR, (unsigned long)p); 92 return sys_ioctl (fd, FBIOSCURSOR, (unsigned long)p);
112} 93}
113 94
114#if defined(CONFIG_DRM) || defined(CONFIG_DRM_MODULE)
115/* This really belongs in include/linux/drm.h -DaveM */
116#include "../../../drivers/char/drm/drm.h"
117
118typedef struct drm32_version {
119 int version_major; /* Major version */
120 int version_minor; /* Minor version */
121 int version_patchlevel;/* Patch level */
122 int name_len; /* Length of name buffer */
123 u32 name; /* Name of driver */
124 int date_len; /* Length of date buffer */
125 u32 date; /* User-space buffer to hold date */
126 int desc_len; /* Length of desc buffer */
127 u32 desc; /* User-space buffer to hold desc */
128} drm32_version_t;
129#define DRM32_IOCTL_VERSION DRM_IOWR(0x00, drm32_version_t)
130
131static int drm32_version(unsigned int fd, unsigned int cmd, unsigned long arg)
132{
133 drm32_version_t __user *uversion = (drm32_version_t __user *)arg;
134 drm_version_t __user *p = compat_alloc_user_space(sizeof(*p));
135 compat_uptr_t addr;
136 int n;
137 int ret;
138
139 if (clear_user(p, 3 * sizeof(int)) ||
140 get_user(n, &uversion->name_len) ||
141 put_user(n, &p->name_len) ||
142 get_user(addr, &uversion->name) ||
143 put_user(compat_ptr(addr), &p->name) ||
144 get_user(n, &uversion->date_len) ||
145 put_user(n, &p->date_len) ||
146 get_user(addr, &uversion->date) ||
147 put_user(compat_ptr(addr), &p->date) ||
148 get_user(n, &uversion->desc_len) ||
149 put_user(n, &p->desc_len) ||
150 get_user(addr, &uversion->desc) ||
151 put_user(compat_ptr(addr), &p->desc))
152 return -EFAULT;
153
154 ret = sys_ioctl(fd, DRM_IOCTL_VERSION, (unsigned long)p);
155 if (ret)
156 return ret;
157
158 if (copy_in_user(uversion, p, 3 * sizeof(int)) ||
159 get_user(n, &p->name_len) ||
160 put_user(n, &uversion->name_len) ||
161 get_user(n, &p->date_len) ||
162 put_user(n, &uversion->date_len) ||
163 get_user(n, &p->desc_len) ||
164 put_user(n, &uversion->desc_len))
165 return -EFAULT;
166
167 return 0;
168}
169
170typedef struct drm32_unique {
171 int unique_len; /* Length of unique */
172 u32 unique; /* Unique name for driver instantiation */
173} drm32_unique_t;
174#define DRM32_IOCTL_GET_UNIQUE DRM_IOWR(0x01, drm32_unique_t)
175#define DRM32_IOCTL_SET_UNIQUE DRM_IOW( 0x10, drm32_unique_t)
176
177static int drm32_getsetunique(unsigned int fd, unsigned int cmd, unsigned long arg)
178{
179 drm32_unique_t __user *uarg = (drm32_unique_t __user *)arg;
180 drm_unique_t __user *p = compat_alloc_user_space(sizeof(*p));
181 compat_uptr_t addr;
182 int n;
183 int ret;
184
185 if (get_user(n, &uarg->unique_len) ||
186 put_user(n, &p->unique_len) ||
187 get_user(addr, &uarg->unique) ||
188 put_user(compat_ptr(addr), &p->unique))
189 return -EFAULT;
190
191 if (cmd == DRM32_IOCTL_GET_UNIQUE)
192 ret = sys_ioctl (fd, DRM_IOCTL_GET_UNIQUE, (unsigned long)p);
193 else
194 ret = sys_ioctl (fd, DRM_IOCTL_SET_UNIQUE, (unsigned long)p);
195
196 if (ret)
197 return ret;
198
199 if (get_user(n, &p->unique_len) || put_user(n, &uarg->unique_len))
200 return -EFAULT;
201
202 return 0;
203}
204
205typedef struct drm32_map {
206 u32 offset; /* Requested physical address (0 for SAREA)*/
207 u32 size; /* Requested physical size (bytes) */
208 drm_map_type_t type; /* Type of memory to map */
209 drm_map_flags_t flags; /* Flags */
210 u32 handle; /* User-space: "Handle" to pass to mmap */
211 /* Kernel-space: kernel-virtual address */
212 int mtrr; /* MTRR slot used */
213 /* Private data */
214} drm32_map_t;
215#define DRM32_IOCTL_ADD_MAP DRM_IOWR(0x15, drm32_map_t)
216
217static int drm32_addmap(unsigned int fd, unsigned int cmd, unsigned long arg)
218{
219 drm32_map_t __user *uarg = (drm32_map_t __user *) arg;
220 drm_map_t karg;
221 mm_segment_t old_fs;
222 u32 tmp;
223 int ret;
224
225 ret = get_user(karg.offset, &uarg->offset);
226 ret |= get_user(karg.size, &uarg->size);
227 ret |= get_user(karg.type, &uarg->type);
228 ret |= get_user(karg.flags, &uarg->flags);
229 ret |= get_user(tmp, &uarg->handle);
230 ret |= get_user(karg.mtrr, &uarg->mtrr);
231 if (ret)
232 return -EFAULT;
233
234 karg.handle = (void *) (unsigned long) tmp;
235
236 old_fs = get_fs();
237 set_fs(KERNEL_DS);
238 ret = sys_ioctl(fd, DRM_IOCTL_ADD_MAP, (unsigned long) &karg);
239 set_fs(old_fs);
240
241 if (!ret) {
242 ret = put_user(karg.offset, &uarg->offset);
243 ret |= put_user(karg.size, &uarg->size);
244 ret |= put_user(karg.type, &uarg->type);
245 ret |= put_user(karg.flags, &uarg->flags);
246 tmp = (u32) (long)karg.handle;
247 ret |= put_user(tmp, &uarg->handle);
248 ret |= put_user(karg.mtrr, &uarg->mtrr);
249 if (ret)
250 ret = -EFAULT;
251 }
252
253 return ret;
254}
255
256typedef struct drm32_buf_info {
257 int count; /* Entries in list */
258 u32 list; /* (drm_buf_desc_t *) */
259} drm32_buf_info_t;
260#define DRM32_IOCTL_INFO_BUFS DRM_IOWR(0x18, drm32_buf_info_t)
261
262static int drm32_info_bufs(unsigned int fd, unsigned int cmd, unsigned long arg)
263{
264 drm32_buf_info_t __user *uarg = (drm32_buf_info_t __user *)arg;
265 drm_buf_info_t __user *p = compat_alloc_user_space(sizeof(*p));
266 compat_uptr_t addr;
267 int n;
268 int ret;
269
270 if (get_user(n, &uarg->count) || put_user(n, &p->count) ||
271 get_user(addr, &uarg->list) || put_user(compat_ptr(addr), &p->list))
272 return -EFAULT;
273
274 ret = sys_ioctl(fd, DRM_IOCTL_INFO_BUFS, (unsigned long)p);
275 if (ret)
276 return ret;
277
278 if (get_user(n, &p->count) || put_user(n, &uarg->count))
279 return -EFAULT;
280
281 return 0;
282}
283
284typedef struct drm32_buf_free {
285 int count;
286 u32 list; /* (int *) */
287} drm32_buf_free_t;
288#define DRM32_IOCTL_FREE_BUFS DRM_IOW( 0x1a, drm32_buf_free_t)
289
290static int drm32_free_bufs(unsigned int fd, unsigned int cmd, unsigned long arg)
291{
292 drm32_buf_free_t __user *uarg = (drm32_buf_free_t __user *)arg;
293 drm_buf_free_t __user *p = compat_alloc_user_space(sizeof(*p));
294 compat_uptr_t addr;
295 int n;
296
297 if (get_user(n, &uarg->count) || put_user(n, &p->count) ||
298 get_user(addr, &uarg->list) || put_user(compat_ptr(addr), &p->list))
299 return -EFAULT;
300
301 return sys_ioctl(fd, DRM_IOCTL_FREE_BUFS, (unsigned long)p);
302}
303
304typedef struct drm32_buf_pub {
305 int idx; /* Index into master buflist */
306 int total; /* Buffer size */
307 int used; /* Amount of buffer in use (for DMA) */
308 u32 address; /* Address of buffer (void *) */
309} drm32_buf_pub_t;
310
311typedef struct drm32_buf_map {
312 int count; /* Length of buflist */
313 u32 virtual; /* Mmaped area in user-virtual (void *) */
314 u32 list; /* Buffer information (drm_buf_pub_t *) */
315} drm32_buf_map_t;
316#define DRM32_IOCTL_MAP_BUFS DRM_IOWR(0x19, drm32_buf_map_t)
317
318static int drm32_map_bufs(unsigned int fd, unsigned int cmd, unsigned long arg)
319{
320 drm32_buf_map_t __user *uarg = (drm32_buf_map_t __user *)arg;
321 drm32_buf_pub_t __user *ulist;
322 drm_buf_map_t __user *arg64;
323 drm_buf_pub_t __user *list;
324 int orig_count, ret, i;
325 int n;
326 compat_uptr_t addr;
327
328 if (get_user(orig_count, &uarg->count))
329 return -EFAULT;
330
331 arg64 = compat_alloc_user_space(sizeof(drm_buf_map_t) +
332 (size_t)orig_count * sizeof(drm_buf_pub_t));
333 list = (void __user *)(arg64 + 1);
334
335 if (put_user(orig_count, &arg64->count) ||
336 put_user(list, &arg64->list) ||
337 get_user(addr, &uarg->virtual) ||
338 put_user(compat_ptr(addr), &arg64->virtual) ||
339 get_user(addr, &uarg->list))
340 return -EFAULT;
341
342 ulist = compat_ptr(addr);
343
344 for (i = 0; i < orig_count; i++) {
345 if (get_user(n, &ulist[i].idx) ||
346 put_user(n, &list[i].idx) ||
347 get_user(n, &ulist[i].total) ||
348 put_user(n, &list[i].total) ||
349 get_user(n, &ulist[i].used) ||
350 put_user(n, &list[i].used) ||
351 get_user(addr, &ulist[i].address) ||
352 put_user(compat_ptr(addr), &list[i].address))
353 return -EFAULT;
354 }
355
356 ret = sys_ioctl(fd, DRM_IOCTL_MAP_BUFS, (unsigned long) arg64);
357 if (ret)
358 return ret;
359
360 for (i = 0; i < orig_count; i++) {
361 void __user *p;
362 if (get_user(n, &list[i].idx) ||
363 put_user(n, &ulist[i].idx) ||
364 get_user(n, &list[i].total) ||
365 put_user(n, &ulist[i].total) ||
366 get_user(n, &list[i].used) ||
367 put_user(n, &ulist[i].used) ||
368 get_user(p, &list[i].address) ||
369 put_user((unsigned long)p, &ulist[i].address))
370 return -EFAULT;
371 }
372
373 if (get_user(n, &arg64->count) || put_user(n, &uarg->count))
374 return -EFAULT;
375
376 return 0;
377}
378
379typedef struct drm32_dma {
380 /* Indices here refer to the offset into
381 buflist in drm_buf_get_t. */
382 int context; /* Context handle */
383 int send_count; /* Number of buffers to send */
384 u32 send_indices; /* List of handles to buffers (int *) */
385 u32 send_sizes; /* Lengths of data to send (int *) */
386 drm_dma_flags_t flags; /* Flags */
387 int request_count; /* Number of buffers requested */
388 int request_size; /* Desired size for buffers */
389 u32 request_indices; /* Buffer information (int *) */
390 u32 request_sizes; /* (int *) */
391 int granted_count; /* Number of buffers granted */
392} drm32_dma_t;
393#define DRM32_IOCTL_DMA DRM_IOWR(0x29, drm32_dma_t)
394
395/* RED PEN The DRM layer blindly dereferences the send/request
396 * index/size arrays even though they are userland
397 * pointers. -DaveM
398 */
399static int drm32_dma(unsigned int fd, unsigned int cmd, unsigned long arg)
400{
401 drm32_dma_t __user *uarg = (drm32_dma_t __user *) arg;
402 drm_dma_t __user *p = compat_alloc_user_space(sizeof(*p));
403 compat_uptr_t addr;
404 int ret;
405
406 if (copy_in_user(p, uarg, 2 * sizeof(int)) ||
407 get_user(addr, &uarg->send_indices) ||
408 put_user(compat_ptr(addr), &p->send_indices) ||
409 get_user(addr, &uarg->send_sizes) ||
410 put_user(compat_ptr(addr), &p->send_sizes) ||
411 copy_in_user(&p->flags, &uarg->flags, sizeof(drm_dma_flags_t)) ||
412 copy_in_user(&p->request_count, &uarg->request_count, sizeof(int))||
413 copy_in_user(&p->request_size, &uarg->request_size, sizeof(int)) ||
414 get_user(addr, &uarg->request_indices) ||
415 put_user(compat_ptr(addr), &p->request_indices) ||
416 get_user(addr, &uarg->request_sizes) ||
417 put_user(compat_ptr(addr), &p->request_sizes) ||
418 copy_in_user(&p->granted_count, &uarg->granted_count, sizeof(int)))
419 return -EFAULT;
420
421 ret = sys_ioctl(fd, DRM_IOCTL_DMA, (unsigned long)p);
422 if (ret)
423 return ret;
424
425 if (copy_in_user(uarg, p, 2 * sizeof(int)) ||
426 copy_in_user(&uarg->flags, &p->flags, sizeof(drm_dma_flags_t)) ||
427 copy_in_user(&uarg->request_count, &p->request_count, sizeof(int))||
428 copy_in_user(&uarg->request_size, &p->request_size, sizeof(int)) ||
429 copy_in_user(&uarg->granted_count, &p->granted_count, sizeof(int)))
430 return -EFAULT;
431
432 return 0;
433}
434
435typedef struct drm32_ctx_res {
436 int count;
437 u32 contexts; /* (drm_ctx_t *) */
438} drm32_ctx_res_t;
439#define DRM32_IOCTL_RES_CTX DRM_IOWR(0x26, drm32_ctx_res_t)
440
441static int drm32_res_ctx(unsigned int fd, unsigned int cmd, unsigned long arg)
442{
443 drm32_ctx_res_t __user *uarg = (drm32_ctx_res_t __user *) arg;
444 drm_ctx_res_t __user *p = compat_alloc_user_space(sizeof(*p));
445 compat_uptr_t addr;
446 int ret;
447
448 if (copy_in_user(p, uarg, sizeof(int)) ||
449 get_user(addr, &uarg->contexts) ||
450 put_user(compat_ptr(addr), &p->contexts))
451 return -EFAULT;
452
453 ret = sys_ioctl(fd, DRM_IOCTL_RES_CTX, (unsigned long)p);
454 if (ret)
455 return ret;
456
457 if (copy_in_user(uarg, p, sizeof(int)))
458 return -EFAULT;
459
460 return 0;
461}
462
463#endif
464
465typedef int (* ioctl32_handler_t)(unsigned int, unsigned int, unsigned long, struct file *); 95typedef int (* ioctl32_handler_t)(unsigned int, unsigned int, unsigned long, struct file *);
466 96
467#define COMPATIBLE_IOCTL(cmd) HANDLE_IOCTL((cmd),sys_ioctl) 97#define COMPATIBLE_IOCTL(cmd) HANDLE_IOCTL((cmd),sys_ioctl)
@@ -485,103 +115,14 @@ COMPATIBLE_IOCTL(FBIOSCURPOS)
485COMPATIBLE_IOCTL(FBIOGCURPOS) 115COMPATIBLE_IOCTL(FBIOGCURPOS)
486COMPATIBLE_IOCTL(FBIOGCURMAX) 116COMPATIBLE_IOCTL(FBIOGCURMAX)
487/* Little k */ 117/* Little k */
488COMPATIBLE_IOCTL(KIOCTYPE)
489COMPATIBLE_IOCTL(KIOCLAYOUT)
490COMPATIBLE_IOCTL(KIOCGTRANS)
491COMPATIBLE_IOCTL(KIOCTRANS)
492COMPATIBLE_IOCTL(KIOCCMD)
493COMPATIBLE_IOCTL(KIOCSDIRECT)
494COMPATIBLE_IOCTL(KIOCSLED)
495COMPATIBLE_IOCTL(KIOCGLED)
496COMPATIBLE_IOCTL(KIOCSRATE)
497COMPATIBLE_IOCTL(KIOCGRATE)
498COMPATIBLE_IOCTL(VUIDSFORMAT)
499COMPATIBLE_IOCTL(VUIDGFORMAT)
500/* Little v, the video4linux ioctls */ 118/* Little v, the video4linux ioctls */
501COMPATIBLE_IOCTL(_IOR('p', 20, int[7])) /* RTCGET */ 119COMPATIBLE_IOCTL(_IOR('p', 20, int[7])) /* RTCGET */
502COMPATIBLE_IOCTL(_IOW('p', 21, int[7])) /* RTCSET */ 120COMPATIBLE_IOCTL(_IOW('p', 21, int[7])) /* RTCSET */
503COMPATIBLE_IOCTL(ENVCTRL_RD_WARNING_TEMPERATURE)
504COMPATIBLE_IOCTL(ENVCTRL_RD_SHUTDOWN_TEMPERATURE)
505COMPATIBLE_IOCTL(ENVCTRL_RD_CPU_TEMPERATURE)
506COMPATIBLE_IOCTL(ENVCTRL_RD_FAN_STATUS)
507COMPATIBLE_IOCTL(ENVCTRL_RD_VOLTAGE_STATUS)
508COMPATIBLE_IOCTL(ENVCTRL_RD_SCSI_TEMPERATURE)
509COMPATIBLE_IOCTL(ENVCTRL_RD_ETHERNET_TEMPERATURE)
510COMPATIBLE_IOCTL(ENVCTRL_RD_MTHRBD_TEMPERATURE)
511COMPATIBLE_IOCTL(ENVCTRL_RD_CPU_VOLTAGE)
512COMPATIBLE_IOCTL(ENVCTRL_RD_GLOBALADDRESS)
513/* COMPATIBLE_IOCTL(D7SIOCRD) same value as ENVCTRL_RD_VOLTAGE_STATUS */
514COMPATIBLE_IOCTL(D7SIOCWR)
515COMPATIBLE_IOCTL(D7SIOCTM)
516/* OPENPROMIO, SunOS/Solaris only, the NetBSD one's have
517 * embedded pointers in the arg which we'd need to clean up...
518 */
519COMPATIBLE_IOCTL(OPROMGETOPT)
520COMPATIBLE_IOCTL(OPROMSETOPT)
521COMPATIBLE_IOCTL(OPROMNXTOPT)
522COMPATIBLE_IOCTL(OPROMSETOPT2)
523COMPATIBLE_IOCTL(OPROMNEXT)
524COMPATIBLE_IOCTL(OPROMCHILD)
525COMPATIBLE_IOCTL(OPROMGETPROP)
526COMPATIBLE_IOCTL(OPROMNXTPROP)
527COMPATIBLE_IOCTL(OPROMU2P)
528COMPATIBLE_IOCTL(OPROMGETCONS)
529COMPATIBLE_IOCTL(OPROMGETFBNAME)
530COMPATIBLE_IOCTL(OPROMGETBOOTARGS)
531COMPATIBLE_IOCTL(OPROMSETCUR)
532COMPATIBLE_IOCTL(OPROMPCI2NODE)
533COMPATIBLE_IOCTL(OPROMPATH2NODE)
534/* Big L */
535COMPATIBLE_IOCTL(LOOP_SET_STATUS64)
536COMPATIBLE_IOCTL(LOOP_GET_STATUS64)
537/* Big A */
538COMPATIBLE_IOCTL(AUDIO_GETINFO)
539COMPATIBLE_IOCTL(AUDIO_SETINFO)
540COMPATIBLE_IOCTL(AUDIO_DRAIN)
541COMPATIBLE_IOCTL(AUDIO_GETDEV)
542COMPATIBLE_IOCTL(AUDIO_GETDEV_SUNOS)
543COMPATIBLE_IOCTL(AUDIO_FLUSH)
544COMPATIBLE_IOCTL(AUTOFS_IOC_EXPIRE_MULTI)
545#if defined(CONFIG_DRM) || defined(CONFIG_DRM_MODULE)
546COMPATIBLE_IOCTL(DRM_IOCTL_GET_MAGIC)
547COMPATIBLE_IOCTL(DRM_IOCTL_IRQ_BUSID)
548COMPATIBLE_IOCTL(DRM_IOCTL_AUTH_MAGIC)
549COMPATIBLE_IOCTL(DRM_IOCTL_BLOCK)
550COMPATIBLE_IOCTL(DRM_IOCTL_UNBLOCK)
551COMPATIBLE_IOCTL(DRM_IOCTL_CONTROL)
552COMPATIBLE_IOCTL(DRM_IOCTL_ADD_BUFS)
553COMPATIBLE_IOCTL(DRM_IOCTL_MARK_BUFS)
554COMPATIBLE_IOCTL(DRM_IOCTL_ADD_CTX)
555COMPATIBLE_IOCTL(DRM_IOCTL_RM_CTX)
556COMPATIBLE_IOCTL(DRM_IOCTL_MOD_CTX)
557COMPATIBLE_IOCTL(DRM_IOCTL_GET_CTX)
558COMPATIBLE_IOCTL(DRM_IOCTL_SWITCH_CTX)
559COMPATIBLE_IOCTL(DRM_IOCTL_NEW_CTX)
560COMPATIBLE_IOCTL(DRM_IOCTL_ADD_DRAW)
561COMPATIBLE_IOCTL(DRM_IOCTL_RM_DRAW)
562COMPATIBLE_IOCTL(DRM_IOCTL_LOCK)
563COMPATIBLE_IOCTL(DRM_IOCTL_UNLOCK)
564COMPATIBLE_IOCTL(DRM_IOCTL_FINISH)
565#endif /* DRM */
566COMPATIBLE_IOCTL(WIOCSTART)
567COMPATIBLE_IOCTL(WIOCSTOP)
568COMPATIBLE_IOCTL(WIOCGSTAT)
569/* And these ioctls need translation */ 121/* And these ioctls need translation */
570/* Note SIOCRTMSG is no longer, so this is safe and * the user would have seen just an -EINVAL anyways. */ 122/* Note SIOCRTMSG is no longer, so this is safe and * the user would have seen just an -EINVAL anyways. */
571HANDLE_IOCTL(FBIOPUTCMAP32, fbiogetputcmap) 123HANDLE_IOCTL(FBIOPUTCMAP32, fbiogetputcmap)
572HANDLE_IOCTL(FBIOGETCMAP32, fbiogetputcmap) 124HANDLE_IOCTL(FBIOGETCMAP32, fbiogetputcmap)
573HANDLE_IOCTL(FBIOSCURSOR32, fbiogscursor) 125HANDLE_IOCTL(FBIOSCURSOR32, fbiogscursor)
574#if defined(CONFIG_DRM) || defined(CONFIG_DRM_MODULE)
575HANDLE_IOCTL(DRM32_IOCTL_VERSION, drm32_version)
576HANDLE_IOCTL(DRM32_IOCTL_GET_UNIQUE, drm32_getsetunique)
577HANDLE_IOCTL(DRM32_IOCTL_SET_UNIQUE, drm32_getsetunique)
578HANDLE_IOCTL(DRM32_IOCTL_ADD_MAP, drm32_addmap)
579HANDLE_IOCTL(DRM32_IOCTL_INFO_BUFS, drm32_info_bufs)
580HANDLE_IOCTL(DRM32_IOCTL_FREE_BUFS, drm32_free_bufs)
581HANDLE_IOCTL(DRM32_IOCTL_MAP_BUFS, drm32_map_bufs)
582HANDLE_IOCTL(DRM32_IOCTL_DMA, drm32_dma)
583HANDLE_IOCTL(DRM32_IOCTL_RES_CTX, drm32_res_ctx)
584#endif /* DRM */
585#if 0 126#if 0
586HANDLE_IOCTL(RTC32_IRQP_READ, do_rtc_ioctl) 127HANDLE_IOCTL(RTC32_IRQP_READ, do_rtc_ioctl)
587HANDLE_IOCTL(RTC32_IRQP_SET, do_rtc_ioctl) 128HANDLE_IOCTL(RTC32_IRQP_SET, do_rtc_ioctl)
diff --git a/arch/sparc64/kernel/setup.c b/arch/sparc64/kernel/setup.c
index c1f34237cdf2..bf1849dd9c49 100644
--- a/arch/sparc64/kernel/setup.c
+++ b/arch/sparc64/kernel/setup.c
@@ -154,6 +154,7 @@ int prom_callback(long *args)
154 pud_t *pudp; 154 pud_t *pudp;
155 pmd_t *pmdp; 155 pmd_t *pmdp;
156 pte_t *ptep; 156 pte_t *ptep;
157 pte_t pte;
157 158
158 for_each_process(p) { 159 for_each_process(p) {
159 mm = p->mm; 160 mm = p->mm;
@@ -178,8 +179,9 @@ int prom_callback(long *args)
178 * being called from inside OBP. 179 * being called from inside OBP.
179 */ 180 */
180 ptep = pte_offset_map(pmdp, va); 181 ptep = pte_offset_map(pmdp, va);
181 if (pte_present(*ptep)) { 182 pte = *ptep;
182 tte = pte_val(*ptep); 183 if (pte_present(pte)) {
184 tte = pte_val(pte);
183 res = PROM_TRUE; 185 res = PROM_TRUE;
184 } 186 }
185 pte_unmap(ptep); 187 pte_unmap(ptep);
@@ -218,6 +220,7 @@ int prom_callback(long *args)
218 pud_t *pudp; 220 pud_t *pudp;
219 pmd_t *pmdp; 221 pmd_t *pmdp;
220 pte_t *ptep; 222 pte_t *ptep;
223 pte_t pte;
221 int error; 224 int error;
222 225
223 if ((va >= LOW_OBP_ADDRESS) && (va < HI_OBP_ADDRESS)) { 226 if ((va >= LOW_OBP_ADDRESS) && (va < HI_OBP_ADDRESS)) {
@@ -240,8 +243,9 @@ int prom_callback(long *args)
240 * being called from inside OBP. 243 * being called from inside OBP.
241 */ 244 */
242 ptep = pte_offset_kernel(pmdp, va); 245 ptep = pte_offset_kernel(pmdp, va);
243 if (pte_present(*ptep)) { 246 pte = *ptep;
244 tte = pte_val(*ptep); 247 if (pte_present(pte)) {
248 tte = pte_val(pte);
245 res = PROM_TRUE; 249 res = PROM_TRUE;
246 } 250 }
247 goto done; 251 goto done;
diff --git a/arch/sparc64/kernel/signal32.c b/arch/sparc64/kernel/signal32.c
index aecccd0df1d1..009a86e5ded4 100644
--- a/arch/sparc64/kernel/signal32.c
+++ b/arch/sparc64/kernel/signal32.c
@@ -863,6 +863,7 @@ static void new_setup_frame32(struct k_sigaction *ka, struct pt_regs *regs,
863 pud_t *pudp = pud_offset(pgdp, address); 863 pud_t *pudp = pud_offset(pgdp, address);
864 pmd_t *pmdp = pmd_offset(pudp, address); 864 pmd_t *pmdp = pmd_offset(pudp, address);
865 pte_t *ptep; 865 pte_t *ptep;
866 pte_t pte;
866 867
867 regs->u_regs[UREG_I7] = (unsigned long) (&(sf->insns[0]) - 2); 868 regs->u_regs[UREG_I7] = (unsigned long) (&(sf->insns[0]) - 2);
868 869
@@ -873,9 +874,10 @@ static void new_setup_frame32(struct k_sigaction *ka, struct pt_regs *regs,
873 874
874 preempt_disable(); 875 preempt_disable();
875 ptep = pte_offset_map(pmdp, address); 876 ptep = pte_offset_map(pmdp, address);
876 if (pte_present(*ptep)) { 877 pte = *ptep;
878 if (pte_present(pte)) {
877 unsigned long page = (unsigned long) 879 unsigned long page = (unsigned long)
878 page_address(pte_page(*ptep)); 880 page_address(pte_page(pte));
879 881
880 wmb(); 882 wmb();
881 __asm__ __volatile__("flush %0 + %1" 883 __asm__ __volatile__("flush %0 + %1"
diff --git a/arch/sparc64/kernel/smp.c b/arch/sparc64/kernel/smp.c
index b137fd63f5e1..5d90ee9aebf1 100644
--- a/arch/sparc64/kernel/smp.c
+++ b/arch/sparc64/kernel/smp.c
@@ -839,43 +839,29 @@ void smp_flush_tlb_all(void)
839 * questionable (in theory the big win for threads is the massive sharing of 839 * questionable (in theory the big win for threads is the massive sharing of
840 * address space state across processors). 840 * address space state across processors).
841 */ 841 */
842
843/* This currently is only used by the hugetlb arch pre-fault
844 * hook on UltraSPARC-III+ and later when changing the pagesize
845 * bits of the context register for an address space.
846 */
842void smp_flush_tlb_mm(struct mm_struct *mm) 847void smp_flush_tlb_mm(struct mm_struct *mm)
843{ 848{
844 /* 849 u32 ctx = CTX_HWBITS(mm->context);
845 * This code is called from two places, dup_mmap and exit_mmap. In the 850 int cpu = get_cpu();
846 * former case, we really need a flush. In the later case, the callers
847 * are single threaded exec_mmap (really need a flush), multithreaded
848 * exec_mmap case (do not need to flush, since the caller gets a new
849 * context via activate_mm), and all other callers of mmput() whence
850 * the flush can be optimized since the associated threads are dead and
851 * the mm is being torn down (__exit_mm and other mmput callers) or the
852 * owning thread is dissociating itself from the mm. The
853 * (atomic_read(&mm->mm_users) == 0) check ensures real work is done
854 * for single thread exec and dup_mmap cases. An alternate check might
855 * have been (current->mm != mm).
856 * Kanoj Sarcar
857 */
858 if (atomic_read(&mm->mm_users) == 0)
859 return;
860
861 {
862 u32 ctx = CTX_HWBITS(mm->context);
863 int cpu = get_cpu();
864 851
865 if (atomic_read(&mm->mm_users) == 1) { 852 if (atomic_read(&mm->mm_users) == 1) {
866 mm->cpu_vm_mask = cpumask_of_cpu(cpu); 853 mm->cpu_vm_mask = cpumask_of_cpu(cpu);
867 goto local_flush_and_out; 854 goto local_flush_and_out;
868 } 855 }
869 856
870 smp_cross_call_masked(&xcall_flush_tlb_mm, 857 smp_cross_call_masked(&xcall_flush_tlb_mm,
871 ctx, 0, 0, 858 ctx, 0, 0,
872 mm->cpu_vm_mask); 859 mm->cpu_vm_mask);
873 860
874 local_flush_and_out: 861local_flush_and_out:
875 __flush_tlb_mm(ctx, SECONDARY_CONTEXT); 862 __flush_tlb_mm(ctx, SECONDARY_CONTEXT);
876 863
877 put_cpu(); 864 put_cpu();
878 }
879} 865}
880 866
881void smp_flush_tlb_pending(struct mm_struct *mm, unsigned long nr, unsigned long *vaddrs) 867void smp_flush_tlb_pending(struct mm_struct *mm, unsigned long nr, unsigned long *vaddrs)
@@ -883,34 +869,13 @@ void smp_flush_tlb_pending(struct mm_struct *mm, unsigned long nr, unsigned long
883 u32 ctx = CTX_HWBITS(mm->context); 869 u32 ctx = CTX_HWBITS(mm->context);
884 int cpu = get_cpu(); 870 int cpu = get_cpu();
885 871
886 if (mm == current->active_mm && atomic_read(&mm->mm_users) == 1) { 872 if (mm == current->active_mm && atomic_read(&mm->mm_users) == 1)
887 mm->cpu_vm_mask = cpumask_of_cpu(cpu); 873 mm->cpu_vm_mask = cpumask_of_cpu(cpu);
888 goto local_flush_and_out; 874 else
889 } else { 875 smp_cross_call_masked(&xcall_flush_tlb_pending,
890 /* This optimization is not valid. Normally 876 ctx, nr, (unsigned long) vaddrs,
891 * we will be holding the page_table_lock, but 877 mm->cpu_vm_mask);
892 * there is an exception which is copy_page_range()
893 * when forking. The lock is held during the individual
894 * page table updates in the parent, but not at the
895 * top level, which is where we are invoked.
896 */
897 if (0) {
898 cpumask_t this_cpu_mask = cpumask_of_cpu(cpu);
899
900 /* By virtue of running under the mm->page_table_lock,
901 * and mmu_context.h:switch_mm doing the same, the
902 * following operation is safe.
903 */
904 if (cpus_equal(mm->cpu_vm_mask, this_cpu_mask))
905 goto local_flush_and_out;
906 }
907 }
908
909 smp_cross_call_masked(&xcall_flush_tlb_pending,
910 ctx, nr, (unsigned long) vaddrs,
911 mm->cpu_vm_mask);
912 878
913local_flush_and_out:
914 __flush_tlb_pending(ctx, nr, vaddrs); 879 __flush_tlb_pending(ctx, nr, vaddrs);
915 880
916 put_cpu(); 881 put_cpu();
diff --git a/arch/sparc64/kernel/sunos_ioctl32.c b/arch/sparc64/kernel/sunos_ioctl32.c
index 7654b8a7f03a..3f619ead22cc 100644
--- a/arch/sparc64/kernel/sunos_ioctl32.c
+++ b/arch/sparc64/kernel/sunos_ioctl32.c
@@ -24,7 +24,6 @@
24#include <linux/smp_lock.h> 24#include <linux/smp_lock.h>
25#include <linux/syscalls.h> 25#include <linux/syscalls.h>
26#include <linux/compat.h> 26#include <linux/compat.h>
27#include <asm/kbio.h>
28 27
29#define SUNOS_NR_OPEN 256 28#define SUNOS_NR_OPEN 256
30 29
diff --git a/arch/sparc64/kernel/time.c b/arch/sparc64/kernel/time.c
index 38c5525087a2..459c8fbe02b4 100644
--- a/arch/sparc64/kernel/time.c
+++ b/arch/sparc64/kernel/time.c
@@ -60,17 +60,6 @@ static void __iomem *mstk48t59_regs;
60 60
61static int set_rtc_mmss(unsigned long); 61static int set_rtc_mmss(unsigned long);
62 62
63static __init unsigned long dummy_get_tick(void)
64{
65 return 0;
66}
67
68static __initdata struct sparc64_tick_ops dummy_tick_ops = {
69 .get_tick = dummy_get_tick,
70};
71
72struct sparc64_tick_ops *tick_ops __read_mostly = &dummy_tick_ops;
73
74#define TICK_PRIV_BIT (1UL << 63) 63#define TICK_PRIV_BIT (1UL << 63)
75 64
76#ifdef CONFIG_SMP 65#ifdef CONFIG_SMP
@@ -200,6 +189,8 @@ static struct sparc64_tick_ops tick_operations __read_mostly = {
200 .softint_mask = 1UL << 0, 189 .softint_mask = 1UL << 0,
201}; 190};
202 191
192struct sparc64_tick_ops *tick_ops __read_mostly = &tick_operations;
193
203static void stick_init_tick(unsigned long offset) 194static void stick_init_tick(unsigned long offset)
204{ 195{
205 tick_disable_protection(); 196 tick_disable_protection();