[TG3]: Set minimal hw interrupt mitigation.
[linux-2.6/verdex.git] / kernel / power / smp.c
blobcba3584b80fefa88b3fdcb8d938800b08d44abeb
1 /*
2 * drivers/power/smp.c - Functions for stopping other CPUs.
4 * Copyright 2004 Pavel Machek <pavel@suse.cz>
5 * Copyright (C) 2002-2003 Nigel Cunningham <ncunningham@clear.net.nz>
7 * This file is released under the GPLv2.
8 */
10 #undef DEBUG
12 #include <linux/smp_lock.h>
13 #include <linux/interrupt.h>
14 #include <linux/suspend.h>
15 #include <linux/module.h>
16 #include <asm/atomic.h>
17 #include <asm/tlbflush.h>
19 static atomic_t cpu_counter, freeze;
22 static void smp_pause(void * data)
24 struct saved_context ctxt;
25 __save_processor_state(&ctxt);
26 printk("Sleeping in:\n");
27 dump_stack();
28 atomic_inc(&cpu_counter);
29 while (atomic_read(&freeze)) {
30 /* FIXME: restore takes place at random piece inside this.
31 This should probably be written in assembly, and
32 preserve general-purpose registers, too
34 What about stack? We may need to move to new stack here.
36 This should better be ran with interrupts disabled.
38 cpu_relax();
39 barrier();
41 atomic_dec(&cpu_counter);
42 __restore_processor_state(&ctxt);
45 static cpumask_t oldmask;
47 void disable_nonboot_cpus(void)
49 oldmask = current->cpus_allowed;
50 set_cpus_allowed(current, cpumask_of_cpu(0));
51 printk("Freezing CPUs (at %d)", _smp_processor_id());
52 current->state = TASK_INTERRUPTIBLE;
53 schedule_timeout(HZ);
54 printk("...");
55 BUG_ON(_smp_processor_id() != 0);
57 /* FIXME: for this to work, all the CPUs must be running
58 * "idle" thread (or we deadlock). Is that guaranteed? */
60 atomic_set(&cpu_counter, 0);
61 atomic_set(&freeze, 1);
62 smp_call_function(smp_pause, NULL, 0, 0);
63 while (atomic_read(&cpu_counter) < (num_online_cpus() - 1)) {
64 cpu_relax();
65 barrier();
67 printk("ok\n");
70 void enable_nonboot_cpus(void)
72 printk("Restarting CPUs");
73 atomic_set(&freeze, 0);
74 while (atomic_read(&cpu_counter)) {
75 cpu_relax();
76 barrier();
78 printk("...");
79 set_cpus_allowed(current, oldmask);
80 schedule();
81 printk("ok\n");