Thomas Gleixner | 2874c5f | 2019-05-27 08:55:01 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
Kumar Gala | 620165f | 2009-02-12 13:54:53 +0000 | [diff] [blame] | 2 | /* |
| 3 | * Author: Kumar Gala <galak@kernel.crashing.org> |
| 4 | * |
| 5 | * Copyright 2009 Freescale Semiconductor Inc. |
Kumar Gala | 620165f | 2009-02-12 13:54:53 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <linux/stddef.h> |
| 9 | #include <linux/kernel.h> |
| 10 | #include <linux/smp.h> |
| 11 | #include <linux/threads.h> |
Milton Miller | 23d72bf | 2011-05-10 19:29:39 +0000 | [diff] [blame] | 12 | #include <linux/hardirq.h> |
Kumar Gala | 620165f | 2009-02-12 13:54:53 +0000 | [diff] [blame] | 13 | |
| 14 | #include <asm/dbell.h> |
Nicholas Piggin | 3a96570 | 2021-01-30 23:08:38 +1000 | [diff] [blame] | 15 | #include <asm/interrupt.h> |
David Gibson | 0e37d25 | 2010-07-09 15:32:30 +1000 | [diff] [blame] | 16 | #include <asm/irq_regs.h> |
Paul Mackerras | 755563b | 2015-03-19 19:29:01 +1100 | [diff] [blame] | 17 | #include <asm/kvm_ppc.h> |
Anton Blanchard | 5b2a152 | 2018-10-04 16:23:37 +1000 | [diff] [blame] | 18 | #include <asm/trace.h> |
Kumar Gala | 620165f | 2009-02-12 13:54:53 +0000 | [diff] [blame] | 19 | |
| 20 | #ifdef CONFIG_SMP |
Benjamin Herrenschmidt | b9f1cd7 | 2010-07-09 15:29:53 +1000 | [diff] [blame] | 21 | |
Nicholas Piggin | 3a96570 | 2021-01-30 23:08:38 +1000 | [diff] [blame] | 22 | DEFINE_INTERRUPT_HANDLER_ASYNC(doorbell_exception) |
Benjamin Herrenschmidt | e3145b3 | 2010-07-09 15:25:18 +1000 | [diff] [blame] | 23 | { |
David Gibson | 0e37d25 | 2010-07-09 15:32:30 +1000 | [diff] [blame] | 24 | struct pt_regs *old_regs = set_irq_regs(regs); |
Benjamin Herrenschmidt | e3145b3 | 2010-07-09 15:25:18 +1000 | [diff] [blame] | 25 | |
Anton Blanchard | 5b2a152 | 2018-10-04 16:23:37 +1000 | [diff] [blame] | 26 | trace_doorbell_entry(regs); |
Benjamin Herrenschmidt | b9f1cd7 | 2010-07-09 15:29:53 +1000 | [diff] [blame] | 27 | |
Nicholas Piggin | b87ac02 | 2017-04-13 20:16:22 +1000 | [diff] [blame] | 28 | ppc_msgsync(); |
| 29 | |
Nicholas Piggin | 0faf20a | 2021-09-23 00:54:50 +1000 | [diff] [blame] | 30 | if (should_hard_irq_enable()) |
| 31 | do_hard_irq_enable(); |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 32 | |
Michael Roth | 3a83f67 | 2019-09-11 17:31:55 -0500 | [diff] [blame] | 33 | kvmppc_clear_host_ipi(smp_processor_id()); |
Christoph Lameter | 69111ba | 2014-10-21 15:23:25 -0500 | [diff] [blame] | 34 | __this_cpu_inc(irq_stat.doorbell_irqs); |
Ian Munsie | a6a058e | 2013-03-21 19:22:52 +0000 | [diff] [blame] | 35 | |
Nicholas Piggin | b87ac02 | 2017-04-13 20:16:22 +1000 | [diff] [blame] | 36 | smp_ipi_demux_relaxed(); /* already performed the barrier */ |
Benjamin Herrenschmidt | e3145b3 | 2010-07-09 15:25:18 +1000 | [diff] [blame] | 37 | |
Anton Blanchard | 5b2a152 | 2018-10-04 16:23:37 +1000 | [diff] [blame] | 38 | trace_doorbell_exit(regs); |
Nicholas Piggin | 1b1b6a6 | 2021-01-30 23:08:44 +1000 | [diff] [blame] | 39 | |
David Gibson | 0e37d25 | 2010-07-09 15:32:30 +1000 | [diff] [blame] | 40 | set_irq_regs(old_regs); |
Benjamin Herrenschmidt | e3145b3 | 2010-07-09 15:25:18 +1000 | [diff] [blame] | 41 | } |
Benjamin Herrenschmidt | e3145b3 | 2010-07-09 15:25:18 +1000 | [diff] [blame] | 42 | #else /* CONFIG_SMP */ |
Nicholas Piggin | 3a96570 | 2021-01-30 23:08:38 +1000 | [diff] [blame] | 43 | DEFINE_INTERRUPT_HANDLER_ASYNC(doorbell_exception) |
Benjamin Herrenschmidt | e3145b3 | 2010-07-09 15:25:18 +1000 | [diff] [blame] | 44 | { |
| 45 | printk(KERN_WARNING "Received doorbell on non-smp system\n"); |
| 46 | } |
| 47 | #endif /* CONFIG_SMP */ |