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> |
Milton Miller | 23d72bf | 2011-05-10 19:29:39 +0000 | [diff] [blame] | 16 | #include <linux/hardirq.h> |
Kumar Gala | 620165f | 2009-02-12 13:54:53 +0000 | [diff] [blame] | 17 | |
| 18 | #include <asm/dbell.h> |
David Gibson | 0e37d25 | 2010-07-09 15:32:30 +1000 | [diff] [blame] | 19 | #include <asm/irq_regs.h> |
Kumar Gala | 620165f | 2009-02-12 13:54:53 +0000 | [diff] [blame] | 20 | |
| 21 | #ifdef CONFIG_SMP |
Benjamin Herrenschmidt | b9f1cd7 | 2010-07-09 15:29:53 +1000 | [diff] [blame] | 22 | void doorbell_setup_this_cpu(void) |
Kumar Gala | 620165f | 2009-02-12 13:54:53 +0000 | [diff] [blame] | 23 | { |
Ian Munsie | 42d02b8 | 2012-11-14 18:49:44 +0000 | [diff] [blame] | 24 | unsigned long tag = mfspr(SPRN_DOORBELL_CPUTAG) & PPC_DBELL_TAG_MASK; |
Benjamin Herrenschmidt | b9f1cd7 | 2010-07-09 15:29:53 +1000 | [diff] [blame] | 25 | |
Milton Miller | 23d72bf | 2011-05-10 19:29:39 +0000 | [diff] [blame] | 26 | smp_muxed_ipi_set_data(smp_processor_id(), tag); |
Benjamin Herrenschmidt | b9f1cd7 | 2010-07-09 15:29:53 +1000 | [diff] [blame] | 27 | } |
| 28 | |
Milton Miller | 23d72bf | 2011-05-10 19:29:39 +0000 | [diff] [blame] | 29 | void doorbell_cause_ipi(int cpu, unsigned long data) |
Benjamin Herrenschmidt | b9f1cd7 | 2010-07-09 15:29:53 +1000 | [diff] [blame] | 30 | { |
Paul Mackerras | 9fb1b36 | 2012-09-04 18:33:08 +0000 | [diff] [blame] | 31 | /* Order previous accesses vs. msgsnd, which is treated as a store */ |
| 32 | mb(); |
Ian Munsie | 42d02b8 | 2012-11-14 18:49:44 +0000 | [diff] [blame] | 33 | ppc_msgsnd(PPC_DBELL_MSGTYPE, 0, data); |
Kumar Gala | 620165f | 2009-02-12 13:54:53 +0000 | [diff] [blame] | 34 | } |
Benjamin Herrenschmidt | e3145b3 | 2010-07-09 15:25:18 +1000 | [diff] [blame] | 35 | |
| 36 | void doorbell_exception(struct pt_regs *regs) |
| 37 | { |
David Gibson | 0e37d25 | 2010-07-09 15:32:30 +1000 | [diff] [blame] | 38 | struct pt_regs *old_regs = set_irq_regs(regs); |
Benjamin Herrenschmidt | e3145b3 | 2010-07-09 15:25:18 +1000 | [diff] [blame] | 39 | |
Milton Miller | 23d72bf | 2011-05-10 19:29:39 +0000 | [diff] [blame] | 40 | irq_enter(); |
Benjamin Herrenschmidt | b9f1cd7 | 2010-07-09 15:29:53 +1000 | [diff] [blame] | 41 | |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 42 | may_hard_irq_enable(); |
| 43 | |
Christoph Lameter | 69111ba | 2014-10-21 15:23:25 -0500 | [diff] [blame] | 44 | __this_cpu_inc(irq_stat.doorbell_irqs); |
Ian Munsie | a6a058e | 2013-03-21 19:22:52 +0000 | [diff] [blame] | 45 | |
Milton Miller | 23d72bf | 2011-05-10 19:29:39 +0000 | [diff] [blame] | 46 | smp_ipi_demux(); |
Benjamin Herrenschmidt | e3145b3 | 2010-07-09 15:25:18 +1000 | [diff] [blame] | 47 | |
Milton Miller | 23d72bf | 2011-05-10 19:29:39 +0000 | [diff] [blame] | 48 | irq_exit(); |
David Gibson | 0e37d25 | 2010-07-09 15:32:30 +1000 | [diff] [blame] | 49 | set_irq_regs(old_regs); |
Benjamin Herrenschmidt | e3145b3 | 2010-07-09 15:25:18 +1000 | [diff] [blame] | 50 | } |
Benjamin Herrenschmidt | e3145b3 | 2010-07-09 15:25:18 +1000 | [diff] [blame] | 51 | #else /* CONFIG_SMP */ |
| 52 | void doorbell_exception(struct pt_regs *regs) |
| 53 | { |
| 54 | printk(KERN_WARNING "Received doorbell on non-smp system\n"); |
| 55 | } |
| 56 | #endif /* CONFIG_SMP */ |
| 57 | |