diff options
author | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2010-07-09 01:29:53 -0400 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2010-07-09 01:29:53 -0400 |
commit | b9f1cd71dbf21a91fb7e2336a1d1ff18b97771e5 (patch) | |
tree | 3c99af81977a06bce82f13ab1f3c748a444c5362 /arch/powerpc/kernel/dbell.c | |
parent | e3145b387a02d4bf8b8033b1354d413fc0864494 (diff) |
powerpc/book3e: More doorbell cleanups. Sample the PIR register
The doorbells use the content of the PIR register to match messages
from other CPUs. This may or may not be the same as our linux CPU
number, so using that as the "target" is no right.
Instead, we sample the PIR register at boot on every processor
and use that value subsequently when sending IPIs.
We also use a per-cpu message mask rather than a global array which
should limit cache line contention.
Note: We could use the CPU number in the device-tree instead of
the PIR register, as they are supposed to be equivalent. This
might prove useful if doorbells are to be used to kick CPUs out
of FW at boot time, thus before we can sample the PIR. This is
however not the case now and using the PIR just works.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/kernel/dbell.c')
-rw-r--r-- | arch/powerpc/kernel/dbell.c | 47 |
1 files changed, 34 insertions, 13 deletions
diff --git a/arch/powerpc/kernel/dbell.c b/arch/powerpc/kernel/dbell.c index e3a717704fd6..1c7a94580c3f 100644 --- a/arch/powerpc/kernel/dbell.c +++ b/arch/powerpc/kernel/dbell.c | |||
@@ -13,45 +13,66 @@ | |||
13 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
14 | #include <linux/smp.h> | 14 | #include <linux/smp.h> |
15 | #include <linux/threads.h> | 15 | #include <linux/threads.h> |
16 | #include <linux/percpu.h> | ||
16 | 17 | ||
17 | #include <asm/dbell.h> | 18 | #include <asm/dbell.h> |
18 | 19 | ||
19 | #ifdef CONFIG_SMP | 20 | #ifdef CONFIG_SMP |
20 | unsigned long dbell_smp_message[NR_CPUS]; | 21 | struct doorbell_cpu_info { |
22 | unsigned long messages; /* current messages bits */ | ||
23 | unsigned int tag; /* tag value */ | ||
24 | }; | ||
21 | 25 | ||
22 | void smp_dbell_message_pass(int target, int msg) | 26 | static DEFINE_PER_CPU(struct doorbell_cpu_info, doorbell_cpu_info); |
27 | |||
28 | void doorbell_setup_this_cpu(void) | ||
29 | { | ||
30 | struct doorbell_cpu_info *info = &__get_cpu_var(doorbell_cpu_info); | ||
31 | |||
32 | info->messages = 0; | ||
33 | info->tag = mfspr(SPRN_PIR) & 0x3fff; | ||
34 | } | ||
35 | |||
36 | void doorbell_message_pass(int target, int msg) | ||
23 | { | 37 | { |
38 | struct doorbell_cpu_info *info; | ||
24 | int i; | 39 | int i; |
25 | 40 | ||
26 | if(target < NR_CPUS) { | 41 | if (target < NR_CPUS) { |
27 | set_bit(msg, &dbell_smp_message[target]); | 42 | info = &per_cpu(doorbell_cpu_info, target); |
28 | ppc_msgsnd(PPC_DBELL, 0, target); | 43 | set_bit(msg, &info->messages); |
44 | ppc_msgsnd(PPC_DBELL, 0, info->tag); | ||
29 | } | 45 | } |
30 | else if(target == MSG_ALL_BUT_SELF) { | 46 | else if (target == MSG_ALL_BUT_SELF) { |
31 | for_each_online_cpu(i) { | 47 | for_each_online_cpu(i) { |
32 | if (i == smp_processor_id()) | 48 | if (i == smp_processor_id()) |
33 | continue; | 49 | continue; |
34 | set_bit(msg, &dbell_smp_message[i]); | 50 | info = &per_cpu(doorbell_cpu_info, i); |
35 | ppc_msgsnd(PPC_DBELL, 0, i); | 51 | set_bit(msg, &info->messages); |
52 | ppc_msgsnd(PPC_DBELL, 0, info->tag); | ||
36 | } | 53 | } |
37 | } | 54 | } |
38 | else { /* target == MSG_ALL */ | 55 | else { /* target == MSG_ALL */ |
39 | for_each_online_cpu(i) | 56 | for_each_online_cpu(i) { |
40 | set_bit(msg, &dbell_smp_message[i]); | 57 | info = &per_cpu(doorbell_cpu_info, i); |
58 | set_bit(msg, &info->messages); | ||
59 | } | ||
41 | ppc_msgsnd(PPC_DBELL, PPC_DBELL_MSG_BRDCAST, 0); | 60 | ppc_msgsnd(PPC_DBELL, PPC_DBELL_MSG_BRDCAST, 0); |
42 | } | 61 | } |
43 | } | 62 | } |
44 | 63 | ||
45 | void doorbell_exception(struct pt_regs *regs) | 64 | void doorbell_exception(struct pt_regs *regs) |
46 | { | 65 | { |
47 | int cpu = smp_processor_id(); | 66 | struct doorbell_cpu_info *info = &__get_cpu_var(doorbell_cpu_info); |
48 | int msg; | 67 | int msg; |
49 | 68 | ||
50 | if (num_online_cpus() < 2) | 69 | /* Warning: regs can be NULL when called from irq enable */ |
70 | |||
71 | if (!info->messages || (num_online_cpus() < 2)) | ||
51 | return; | 72 | return; |
52 | 73 | ||
53 | for (msg = 0; msg < 4; msg++) | 74 | for (msg = 0; msg < 4; msg++) |
54 | if (test_and_clear_bit(msg, &dbell_smp_message[cpu])) | 75 | if (test_and_clear_bit(msg, &info->messages)) |
55 | smp_message_recv(msg); | 76 | smp_message_recv(msg); |
56 | } | 77 | } |
57 | 78 | ||