blob: a5a730cea0f52c83d54470344e3a3b75e7d000cd [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2** SMP Support
3**
4** Copyright (C) 1999 Walt Drummond <drummond@valinux.com>
5** Copyright (C) 1999 David Mosberger-Tang <davidm@hpl.hp.com>
6** Copyright (C) 2001,2004 Grant Grundler <grundler@parisc-linux.org>
7**
8** Lots of stuff stolen from arch/alpha/kernel/smp.c
9** ...and then parisc stole from arch/ia64/kernel/smp.c. Thanks David! :^)
10**
11** Thanks to John Curry and Ullas Ponnadi. I learned alot from their work.
12** -grant (1/12/2001)
13**
14** This program is free software; you can redistribute it and/or modify
15** it under the terms of the GNU General Public License as published by
16** the Free Software Foundation; either version 2 of the License, or
17** (at your option) any later version.
18*/
19#undef ENTRY_SYS_CPUS /* syscall support for iCOD-like functionality */
20
Linus Torvalds1da177e2005-04-16 15:20:36 -070021
22#include <linux/types.h>
23#include <linux/spinlock.h>
24#include <linux/slab.h>
25
26#include <linux/kernel.h>
27#include <linux/module.h>
28#include <linux/sched.h>
29#include <linux/init.h>
30#include <linux/interrupt.h>
31#include <linux/smp.h>
32#include <linux/kernel_stat.h>
33#include <linux/mm.h>
34#include <linux/delay.h>
35#include <linux/bitops.h>
36
37#include <asm/system.h>
38#include <asm/atomic.h>
39#include <asm/current.h>
40#include <asm/delay.h>
Matthew Wilcox1b2425e2006-01-10 20:47:49 -050041#include <asm/tlbflush.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070042
43#include <asm/io.h>
44#include <asm/irq.h> /* for CPU_IRQ_REGION and friends */
45#include <asm/mmu_context.h>
46#include <asm/page.h>
47#include <asm/pgtable.h>
48#include <asm/pgalloc.h>
49#include <asm/processor.h>
50#include <asm/ptrace.h>
51#include <asm/unistd.h>
52#include <asm/cacheflush.h>
53
Kyle McMartin5492a0f2007-01-15 12:23:03 -050054#undef DEBUG_SMP
55#ifdef DEBUG_SMP
56static int smp_debug_lvl = 0;
57#define smp_debug(lvl, printargs...) \
58 if (lvl >= smp_debug_lvl) \
59 printk(printargs);
60#else
61#define smp_debug(lvl, ...)
62#endif /* DEBUG_SMP */
Linus Torvalds1da177e2005-04-16 15:20:36 -070063
64DEFINE_SPINLOCK(smp_lock);
65
66volatile struct task_struct *smp_init_current_idle_task;
67
Helge Deller8039de12006-01-10 20:35:03 -050068static volatile int cpu_now_booting __read_mostly = 0; /* track which CPU is booting */
Linus Torvalds1da177e2005-04-16 15:20:36 -070069
Helge Deller8039de12006-01-10 20:35:03 -050070static int parisc_max_cpus __read_mostly = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -070071
72/* online cpus are ones that we've managed to bring up completely
73 * possible cpus are all valid cpu
74 * present cpus are all detected cpu
75 *
76 * On startup we bring up the "possible" cpus. Since we discover
77 * CPUs later, we add them as hotplug, so the possible cpu mask is
78 * empty in the beginning.
79 */
80
Helge Deller8039de12006-01-10 20:35:03 -050081cpumask_t cpu_online_map __read_mostly = CPU_MASK_NONE; /* Bitmap of online CPUs */
82cpumask_t cpu_possible_map __read_mostly = CPU_MASK_ALL; /* Bitmap of Present CPUs */
Linus Torvalds1da177e2005-04-16 15:20:36 -070083
84EXPORT_SYMBOL(cpu_online_map);
85EXPORT_SYMBOL(cpu_possible_map);
86
Kyle McMartin3c97b5e2006-12-07 23:52:27 -050087DEFINE_PER_CPU(spinlock_t, ipi_lock) = SPIN_LOCK_UNLOCKED;
Linus Torvalds1da177e2005-04-16 15:20:36 -070088
89struct smp_call_struct {
90 void (*func) (void *info);
91 void *info;
92 long wait;
93 atomic_t unstarted_count;
94 atomic_t unfinished_count;
95};
96static volatile struct smp_call_struct *smp_call_function_data;
97
98enum ipi_message_type {
99 IPI_NOP=0,
100 IPI_RESCHEDULE=1,
101 IPI_CALL_FUNC,
102 IPI_CPU_START,
103 IPI_CPU_STOP,
104 IPI_CPU_TEST
105};
106
107
108/********** SMP inter processor interrupt and communication routines */
109
110#undef PER_CPU_IRQ_REGION
111#ifdef PER_CPU_IRQ_REGION
112/* XXX REVISIT Ignore for now.
113** *May* need this "hook" to register IPI handler
114** once we have perCPU ExtIntr switch tables.
115*/
116static void
117ipi_init(int cpuid)
118{
119
120 /* If CPU is present ... */
121#ifdef ENTRY_SYS_CPUS
122 /* *and* running (not stopped) ... */
123#error iCOD support wants state checked here.
124#endif
125
126#error verify IRQ_OFFSET(IPI_IRQ) is ipi_interrupt() in new IRQ region
127
128 if(cpu_online(cpuid) )
129 {
130 switch_to_idle_task(current);
131 }
132
133 return;
134}
135#endif
136
137
138/*
139** Yoink this CPU from the runnable list...
140**
141*/
142static void
143halt_processor(void)
144{
145#ifdef ENTRY_SYS_CPUS
146#error halt_processor() needs rework
147/*
148** o migrate I/O interrupts off this CPU.
149** o leave IPI enabled - __cli() will disable IPI.
150** o leave CPU in online map - just change the state
151*/
152 cpu_data[this_cpu].state = STATE_STOPPED;
153 mark_bh(IPI_BH);
154#else
155 /* REVISIT : redirect I/O Interrupts to another CPU? */
156 /* REVISIT : does PM *know* this CPU isn't available? */
157 cpu_clear(smp_processor_id(), cpu_online_map);
158 local_irq_disable();
159 for (;;)
160 ;
161#endif
162}
163
164
165irqreturn_t
Matthew Wilcoxc7753f12006-10-07 06:01:11 -0600166ipi_interrupt(int irq, void *dev_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167{
168 int this_cpu = smp_processor_id();
169 struct cpuinfo_parisc *p = &cpu_data[this_cpu];
170 unsigned long ops;
171 unsigned long flags;
172
173 /* Count this now; we may make a call that never returns. */
174 p->ipi_count++;
175
176 mb(); /* Order interrupt and bit testing. */
177
178 for (;;) {
Kyle McMartin3c97b5e2006-12-07 23:52:27 -0500179 spinlock_t *lock = &per_cpu(ipi_lock, this_cpu);
180 spin_lock_irqsave(lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181 ops = p->pending_ipi;
182 p->pending_ipi = 0;
Kyle McMartin3c97b5e2006-12-07 23:52:27 -0500183 spin_unlock_irqrestore(lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184
185 mb(); /* Order bit clearing and data access. */
186
187 if (!ops)
188 break;
189
190 while (ops) {
191 unsigned long which = ffz(~ops);
192
James Bottomleyd911aed2005-11-17 16:27:02 -0500193 ops &= ~(1 << which);
194
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195 switch (which) {
James Bottomleyd911aed2005-11-17 16:27:02 -0500196 case IPI_NOP:
Kyle McMartin5492a0f2007-01-15 12:23:03 -0500197 smp_debug(100, KERN_DEBUG "CPU%d IPI_NOP\n", this_cpu);
James Bottomleyd911aed2005-11-17 16:27:02 -0500198 break;
199
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200 case IPI_RESCHEDULE:
Kyle McMartin5492a0f2007-01-15 12:23:03 -0500201 smp_debug(100, KERN_DEBUG "CPU%d IPI_RESCHEDULE\n", this_cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700202 /*
203 * Reschedule callback. Everything to be
204 * done is done by the interrupt return path.
205 */
206 break;
207
208 case IPI_CALL_FUNC:
Kyle McMartin5492a0f2007-01-15 12:23:03 -0500209 smp_debug(100, KERN_DEBUG "CPU%d IPI_CALL_FUNC\n", this_cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210 {
211 volatile struct smp_call_struct *data;
212 void (*func)(void *info);
213 void *info;
214 int wait;
215
216 data = smp_call_function_data;
217 func = data->func;
218 info = data->info;
219 wait = data->wait;
220
221 mb();
222 atomic_dec ((atomic_t *)&data->unstarted_count);
223
224 /* At this point, *data can't
225 * be relied upon.
226 */
227
228 (*func)(info);
229
230 /* Notify the sending CPU that the
231 * task is done.
232 */
233 mb();
234 if (wait)
235 atomic_dec ((atomic_t *)&data->unfinished_count);
236 }
237 break;
238
239 case IPI_CPU_START:
Kyle McMartin5492a0f2007-01-15 12:23:03 -0500240 smp_debug(100, KERN_DEBUG "CPU%d IPI_CPU_START\n", this_cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241#ifdef ENTRY_SYS_CPUS
242 p->state = STATE_RUNNING;
243#endif
244 break;
245
246 case IPI_CPU_STOP:
Kyle McMartin5492a0f2007-01-15 12:23:03 -0500247 smp_debug(100, KERN_DEBUG "CPU%d IPI_CPU_STOP\n", this_cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248#ifdef ENTRY_SYS_CPUS
249#else
250 halt_processor();
251#endif
252 break;
253
254 case IPI_CPU_TEST:
Kyle McMartin5492a0f2007-01-15 12:23:03 -0500255 smp_debug(100, KERN_DEBUG "CPU%d is alive!\n", this_cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256 break;
257
258 default:
259 printk(KERN_CRIT "Unknown IPI num on CPU%d: %lu\n",
260 this_cpu, which);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261 return IRQ_NONE;
262 } /* Switch */
James Bottomley70856892006-09-09 12:36:25 -0700263 /* let in any pending interrupts */
264 local_irq_enable();
265 local_irq_disable();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700266 } /* while (ops) */
267 }
268 return IRQ_HANDLED;
269}
270
271
272static inline void
273ipi_send(int cpu, enum ipi_message_type op)
274{
275 struct cpuinfo_parisc *p = &cpu_data[cpu];
Kyle McMartin3c97b5e2006-12-07 23:52:27 -0500276 spinlock_t *lock = &per_cpu(ipi_lock, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277 unsigned long flags;
278
Kyle McMartin3c97b5e2006-12-07 23:52:27 -0500279 spin_lock_irqsave(lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280 p->pending_ipi |= 1 << op;
281 gsc_writel(IPI_IRQ - CPU_IRQ_BASE, cpu_data[cpu].hpa);
Kyle McMartin3c97b5e2006-12-07 23:52:27 -0500282 spin_unlock_irqrestore(lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283}
284
285
286static inline void
287send_IPI_single(int dest_cpu, enum ipi_message_type op)
288{
289 if (dest_cpu == NO_PROC_ID) {
290 BUG();
291 return;
292 }
293
294 ipi_send(dest_cpu, op);
295}
296
297static inline void
298send_IPI_allbutself(enum ipi_message_type op)
299{
300 int i;
301
Andrew Morton394e3902006-03-23 03:01:05 -0800302 for_each_online_cpu(i) {
303 if (i != smp_processor_id())
Linus Torvalds1da177e2005-04-16 15:20:36 -0700304 send_IPI_single(i, op);
305 }
306}
307
308
309inline void
310smp_send_stop(void) { send_IPI_allbutself(IPI_CPU_STOP); }
311
312static inline void
313smp_send_start(void) { send_IPI_allbutself(IPI_CPU_START); }
314
315void
316smp_send_reschedule(int cpu) { send_IPI_single(cpu, IPI_RESCHEDULE); }
317
James Bottomleyd911aed2005-11-17 16:27:02 -0500318void
319smp_send_all_nop(void)
320{
321 send_IPI_allbutself(IPI_NOP);
322}
323
Linus Torvalds1da177e2005-04-16 15:20:36 -0700324
325/**
326 * Run a function on all other CPUs.
327 * <func> The function to run. This must be fast and non-blocking.
328 * <info> An arbitrary pointer to pass to the function.
329 * <retry> If true, keep retrying until ready.
330 * <wait> If true, wait until function has completed on other CPUs.
331 * [RETURNS] 0 on success, else a negative status code.
332 *
333 * Does not return until remote CPUs are nearly ready to execute <func>
334 * or have executed.
335 */
336
337int
338smp_call_function (void (*func) (void *info), void *info, int retry, int wait)
339{
340 struct smp_call_struct data;
341 unsigned long timeout;
342 static DEFINE_SPINLOCK(lock);
343 int retries = 0;
344
345 if (num_online_cpus() < 2)
346 return 0;
347
348 /* Can deadlock when called with interrupts disabled */
349 WARN_ON(irqs_disabled());
James Bottomley9a8b4582005-11-17 16:24:52 -0500350
351 /* can also deadlock if IPIs are disabled */
352 WARN_ON((get_eiem() & (1UL<<(CPU_IRQ_MAX - IPI_IRQ))) == 0);
353
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354
355 data.func = func;
356 data.info = info;
357 data.wait = wait;
358 atomic_set(&data.unstarted_count, num_online_cpus() - 1);
359 atomic_set(&data.unfinished_count, num_online_cpus() - 1);
360
361 if (retry) {
362 spin_lock (&lock);
363 while (smp_call_function_data != 0)
364 barrier();
365 }
366 else {
367 spin_lock (&lock);
368 if (smp_call_function_data) {
369 spin_unlock (&lock);
370 return -EBUSY;
371 }
372 }
373
374 smp_call_function_data = &data;
375 spin_unlock (&lock);
376
377 /* Send a message to all other CPUs and wait for them to respond */
378 send_IPI_allbutself(IPI_CALL_FUNC);
379
380 retry:
381 /* Wait for response */
382 timeout = jiffies + HZ;
383 while ( (atomic_read (&data.unstarted_count) > 0) &&
384 time_before (jiffies, timeout) )
385 barrier ();
386
387 if (atomic_read (&data.unstarted_count) > 0) {
388 printk(KERN_CRIT "SMP CALL FUNCTION TIMED OUT! (cpu=%d), try %d\n",
389 smp_processor_id(), ++retries);
390 goto retry;
391 }
392 /* We either got one or timed out. Release the lock */
393
394 mb();
395 smp_call_function_data = NULL;
396
397 while (wait && atomic_read (&data.unfinished_count) > 0)
398 barrier ();
399
400 return 0;
401}
402
403EXPORT_SYMBOL(smp_call_function);
404
405/*
406 * Flush all other CPU's tlb and then mine. Do this with on_each_cpu()
407 * as we want to ensure all TLB's flushed before proceeding.
408 */
409
Linus Torvalds1da177e2005-04-16 15:20:36 -0700410void
411smp_flush_tlb_all(void)
412{
Matthew Wilcox1b2425e2006-01-10 20:47:49 -0500413 on_each_cpu(flush_tlb_all_local, NULL, 1, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700414}
415
Linus Torvalds1da177e2005-04-16 15:20:36 -0700416/*
417 * Called by secondaries to update state and initialize CPU registers.
418 */
419static void __init
420smp_cpu_init(int cpunum)
421{
Grant Grundler56f335c2006-09-03 00:02:16 -0700422 extern int init_per_cpu(int); /* arch/parisc/kernel/processor.c */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700423 extern void init_IRQ(void); /* arch/parisc/kernel/irq.c */
Grant Grundler56f335c2006-09-03 00:02:16 -0700424 extern void start_cpu_itimer(void); /* arch/parisc/kernel/time.c */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700425
426 /* Set modes and Enable floating point coprocessor */
427 (void) init_per_cpu(cpunum);
428
429 disable_sr_hashing();
430
431 mb();
432
433 /* Well, support 2.4 linux scheme as well. */
434 if (cpu_test_and_set(cpunum, cpu_online_map))
435 {
436 extern void machine_halt(void); /* arch/parisc.../process.c */
437
438 printk(KERN_CRIT "CPU#%d already initialized!\n", cpunum);
439 machine_halt();
440 }
441
442 /* Initialise the idle task for this CPU */
443 atomic_inc(&init_mm.mm_count);
444 current->active_mm = &init_mm;
445 if(current->mm)
446 BUG();
447 enter_lazy_tlb(&init_mm, current);
448
449 init_IRQ(); /* make sure no IRQ's are enabled or pending */
Grant Grundler56f335c2006-09-03 00:02:16 -0700450 start_cpu_itimer();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700451}
452
453
454/*
455 * Slaves start using C here. Indirectly called from smp_slave_stext.
456 * Do what start_kernel() and main() do for boot strap processor (aka monarch)
457 */
458void __init smp_callin(void)
459{
460 int slave_id = cpu_now_booting;
461#if 0
462 void *istack;
463#endif
464
465 smp_cpu_init(slave_id);
Nick Piggin5bfb5d62005-11-08 21:39:01 -0800466 preempt_disable();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700467
468#if 0 /* NOT WORKING YET - see entry.S */
469 istack = (void *)__get_free_pages(GFP_KERNEL,ISTACK_ORDER);
470 if (istack == NULL) {
471 printk(KERN_CRIT "Failed to allocate interrupt stack for cpu %d\n",slave_id);
472 BUG();
473 }
474 mtctl(istack,31);
475#endif
476
477 flush_cache_all_local(); /* start with known state */
Matthew Wilcox1b2425e2006-01-10 20:47:49 -0500478 flush_tlb_all_local(NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479
480 local_irq_enable(); /* Interrupts have been off until now */
481
482 cpu_idle(); /* Wait for timer to schedule some work */
483
484 /* NOTREACHED */
485 panic("smp_callin() AAAAaaaaahhhh....\n");
486}
487
488/*
489 * Bring one cpu online.
490 */
491int __init smp_boot_one_cpu(int cpuid)
492{
493 struct task_struct *idle;
494 long timeout;
495
496 /*
497 * Create an idle task for this CPU. Note the address wed* give
498 * to kernel_thread is irrelevant -- it's going to start
499 * where OS_BOOT_RENDEVZ vector in SAL says to start. But
500 * this gets all the other task-y sort of data structures set
501 * up like we wish. We need to pull the just created idle task
502 * off the run queue and stuff it into the init_tasks[] array.
503 * Sheesh . . .
504 */
505
506 idle = fork_idle(cpuid);
507 if (IS_ERR(idle))
508 panic("SMP: fork failed for CPU:%d", cpuid);
509
Al Viro40f1f0d2006-01-12 01:05:55 -0800510 task_thread_info(idle)->cpu = cpuid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700511
512 /* Let _start know what logical CPU we're booting
513 ** (offset into init_tasks[],cpu_data[])
514 */
515 cpu_now_booting = cpuid;
516
517 /*
518 ** boot strap code needs to know the task address since
519 ** it also contains the process stack.
520 */
521 smp_init_current_idle_task = idle ;
522 mb();
523
524 printk("Releasing cpu %d now, hpa=%lx\n", cpuid, cpu_data[cpuid].hpa);
525
526 /*
527 ** This gets PDC to release the CPU from a very tight loop.
528 **
529 ** From the PA-RISC 2.0 Firmware Architecture Reference Specification:
530 ** "The MEM_RENDEZ vector specifies the location of OS_RENDEZ which
531 ** is executed after receiving the rendezvous signal (an interrupt to
532 ** EIR{0}). MEM_RENDEZ is valid only when it is nonzero and the
533 ** contents of memory are valid."
534 */
535 gsc_writel(TIMER_IRQ - CPU_IRQ_BASE, cpu_data[cpuid].hpa);
536 mb();
537
538 /*
539 * OK, wait a bit for that CPU to finish staggering about.
540 * Slave will set a bit when it reaches smp_cpu_init().
541 * Once the "monarch CPU" sees the bit change, it can move on.
542 */
543 for (timeout = 0; timeout < 10000; timeout++) {
544 if(cpu_online(cpuid)) {
545 /* Which implies Slave has started up */
546 cpu_now_booting = 0;
547 smp_init_current_idle_task = NULL;
548 goto alive ;
549 }
550 udelay(100);
551 barrier();
552 }
553
554 put_task_struct(idle);
555 idle = NULL;
556
557 printk(KERN_CRIT "SMP: CPU:%d is stuck.\n", cpuid);
558 return -1;
559
560alive:
561 /* Remember the Slave data */
Kyle McMartin5492a0f2007-01-15 12:23:03 -0500562 smp_debug(100, KERN_DEBUG "SMP: CPU:%d came alive after %ld _us\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700563 cpuid, timeout * 100);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700564#ifdef ENTRY_SYS_CPUS
565 cpu_data[cpuid].state = STATE_RUNNING;
566#endif
567 return 0;
568}
569
570void __devinit smp_prepare_boot_cpu(void)
571{
572 int bootstrap_processor=cpu_data[0].cpuid; /* CPU ID of BSP */
573
574#ifdef ENTRY_SYS_CPUS
575 cpu_data[0].state = STATE_RUNNING;
576#endif
577
578 /* Setup BSP mappings */
579 printk("SMP: bootstrap CPU ID is %d\n",bootstrap_processor);
580
581 cpu_set(bootstrap_processor, cpu_online_map);
582 cpu_set(bootstrap_processor, cpu_present_map);
583}
584
585
586
587/*
588** inventory.c:do_inventory() hasn't yet been run and thus we
589** don't 'discover' the additional CPU's until later.
590*/
591void __init smp_prepare_cpus(unsigned int max_cpus)
592{
593 cpus_clear(cpu_present_map);
594 cpu_set(0, cpu_present_map);
595
596 parisc_max_cpus = max_cpus;
597 if (!max_cpus)
598 printk(KERN_INFO "SMP mode deactivated.\n");
599}
600
601
602void smp_cpus_done(unsigned int cpu_max)
603{
604 return;
605}
606
607
Gautham R Shenoyb282b6f2007-01-10 23:15:34 -0800608int __cpuinit __cpu_up(unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700609{
610 if (cpu != 0 && cpu < parisc_max_cpus)
611 smp_boot_one_cpu(cpu);
612
613 return cpu_online(cpu) ? 0 : -ENOSYS;
614}
615
616
617
618#ifdef ENTRY_SYS_CPUS
619/* Code goes along with:
620** entry.s: ENTRY_NAME(sys_cpus) / * 215, for cpu stat * /
621*/
622int sys_cpus(int argc, char **argv)
623{
624 int i,j=0;
625 extern int current_pid(int cpu);
626
627 if( argc > 2 ) {
628 printk("sys_cpus:Only one argument supported\n");
629 return (-1);
630 }
631 if ( argc == 1 ){
632
633#ifdef DUMP_MORE_STATE
Andrew Morton394e3902006-03-23 03:01:05 -0800634 for_each_online_cpu(i) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700635 int cpus_per_line = 4;
Andrew Morton394e3902006-03-23 03:01:05 -0800636
637 if (j++ % cpus_per_line)
638 printk(" %3d",i);
639 else
640 printk("\n %3d",i);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700641 }
642 printk("\n");
643#else
644 printk("\n 0\n");
645#endif
646 } else if((argc==2) && !(strcmp(argv[1],"-l"))) {
647 printk("\nCPUSTATE TASK CPUNUM CPUID HARDCPU(HPA)\n");
648#ifdef DUMP_MORE_STATE
Andrew Morton394e3902006-03-23 03:01:05 -0800649 for_each_online_cpu(i) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700650 if (cpu_data[i].cpuid != NO_PROC_ID) {
651 switch(cpu_data[i].state) {
652 case STATE_RENDEZVOUS:
653 printk("RENDEZVS ");
654 break;
655 case STATE_RUNNING:
656 printk((current_pid(i)!=0) ? "RUNNING " : "IDLING ");
657 break;
658 case STATE_STOPPED:
659 printk("STOPPED ");
660 break;
661 case STATE_HALTED:
662 printk("HALTED ");
663 break;
664 default:
665 printk("%08x?", cpu_data[i].state);
666 break;
667 }
668 if(cpu_online(i)) {
669 printk(" %4d",current_pid(i));
670 }
671 printk(" %6d",cpu_number_map(i));
672 printk(" %5d",i);
673 printk(" 0x%lx\n",cpu_data[i].hpa);
674 }
675 }
676#else
677 printk("\n%s %4d 0 0 --------",
678 (current->pid)?"RUNNING ": "IDLING ",current->pid);
679#endif
680 } else if ((argc==2) && !(strcmp(argv[1],"-s"))) {
681#ifdef DUMP_MORE_STATE
682 printk("\nCPUSTATE CPUID\n");
Andrew Morton394e3902006-03-23 03:01:05 -0800683 for_each_online_cpu(i) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700684 if (cpu_data[i].cpuid != NO_PROC_ID) {
685 switch(cpu_data[i].state) {
686 case STATE_RENDEZVOUS:
687 printk("RENDEZVS");break;
688 case STATE_RUNNING:
689 printk((current_pid(i)!=0) ? "RUNNING " : "IDLING");
690 break;
691 case STATE_STOPPED:
692 printk("STOPPED ");break;
693 case STATE_HALTED:
694 printk("HALTED ");break;
695 default:
696 }
697 printk(" %5d\n",i);
698 }
699 }
700#else
701 printk("\n%s CPU0",(current->pid==0)?"RUNNING ":"IDLING ");
702#endif
703 } else {
704 printk("sys_cpus:Unknown request\n");
705 return (-1);
706 }
707 return 0;
708}
709#endif /* ENTRY_SYS_CPUS */
710
711#ifdef CONFIG_PROC_FS
712int __init
713setup_profiling_timer(unsigned int multiplier)
714{
715 return -EINVAL;
716}
717#endif