Kumar Gala | 620165f | 2009-02-12 13:54:53 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Author: Kumar Gala <galak@kernel.crashing.org> |
| 3 | * |
| 4 | * Copyright 2009 Freescale Semiconductor Inc. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify it |
| 7 | * under the terms of the GNU General Public License as published by the |
| 8 | * Free Software Foundation; either version 2 of the License, or (at your |
| 9 | * option) any later version. |
| 10 | */ |
| 11 | |
| 12 | #include <linux/stddef.h> |
| 13 | #include <linux/kernel.h> |
| 14 | #include <linux/smp.h> |
| 15 | #include <linux/threads.h> |
| 16 | |
| 17 | #include <asm/dbell.h> |
| 18 | |
| 19 | #ifdef CONFIG_SMP |
| 20 | unsigned long dbell_smp_message[NR_CPUS]; |
| 21 | |
| 22 | void smp_dbell_message_pass(int target, int msg) |
| 23 | { |
| 24 | int i; |
| 25 | |
| 26 | if(target < NR_CPUS) { |
| 27 | set_bit(msg, &dbell_smp_message[target]); |
| 28 | ppc_msgsnd(PPC_DBELL, 0, target); |
| 29 | } |
| 30 | else if(target == MSG_ALL_BUT_SELF) { |
| 31 | for_each_online_cpu(i) { |
| 32 | if (i == smp_processor_id()) |
| 33 | continue; |
| 34 | set_bit(msg, &dbell_smp_message[i]); |
| 35 | ppc_msgsnd(PPC_DBELL, 0, i); |
| 36 | } |
| 37 | } |
| 38 | else { /* target == MSG_ALL */ |
| 39 | for_each_online_cpu(i) |
| 40 | set_bit(msg, &dbell_smp_message[i]); |
| 41 | ppc_msgsnd(PPC_DBELL, PPC_DBELL_MSG_BRDCAST, 0); |
| 42 | } |
| 43 | } |
Benjamin Herrenschmidt | e3145b3 | 2010-07-09 15:25:18 +1000 | [diff] [blame^] | 44 | |
| 45 | void doorbell_exception(struct pt_regs *regs) |
| 46 | { |
| 47 | int cpu = smp_processor_id(); |
| 48 | int msg; |
| 49 | |
| 50 | if (num_online_cpus() < 2) |
| 51 | return; |
| 52 | |
| 53 | for (msg = 0; msg < 4; msg++) |
| 54 | if (test_and_clear_bit(msg, &dbell_smp_message[cpu])) |
| 55 | smp_message_recv(msg); |
| 56 | } |
| 57 | |
| 58 | #else /* CONFIG_SMP */ |
| 59 | void doorbell_exception(struct pt_regs *regs) |
| 60 | { |
| 61 | printk(KERN_WARNING "Received doorbell on non-smp system\n"); |
| 62 | } |
| 63 | #endif /* CONFIG_SMP */ |
| 64 | |