blob: f55c6fb34a3a03b3d48c4d52a6e1d6492d8fec62 [file] [log] [blame]
Thomas Gleixner2874c5f2019-05-27 08:55:01 +02001// SPDX-License-Identifier: GPL-2.0-or-later
Kumar Gala620165f2009-02-12 13:54:53 +00002/*
3 * Author: Kumar Gala <galak@kernel.crashing.org>
4 *
5 * Copyright 2009 Freescale Semiconductor Inc.
Kumar Gala620165f2009-02-12 13:54:53 +00006 */
7
8#include <linux/stddef.h>
9#include <linux/kernel.h>
10#include <linux/smp.h>
11#include <linux/threads.h>
Milton Miller23d72bf2011-05-10 19:29:39 +000012#include <linux/hardirq.h>
Kumar Gala620165f2009-02-12 13:54:53 +000013
14#include <asm/dbell.h>
Nicholas Piggin3a965702021-01-30 23:08:38 +100015#include <asm/interrupt.h>
David Gibson0e37d252010-07-09 15:32:30 +100016#include <asm/irq_regs.h>
Paul Mackerras755563b2015-03-19 19:29:01 +110017#include <asm/kvm_ppc.h>
Anton Blanchard5b2a1522018-10-04 16:23:37 +100018#include <asm/trace.h>
Kumar Gala620165f2009-02-12 13:54:53 +000019
20#ifdef CONFIG_SMP
Benjamin Herrenschmidtb9f1cd72010-07-09 15:29:53 +100021
Nicholas Piggin3a965702021-01-30 23:08:38 +100022DEFINE_INTERRUPT_HANDLER_ASYNC(doorbell_exception)
Benjamin Herrenschmidte3145b32010-07-09 15:25:18 +100023{
David Gibson0e37d252010-07-09 15:32:30 +100024 struct pt_regs *old_regs = set_irq_regs(regs);
Benjamin Herrenschmidte3145b32010-07-09 15:25:18 +100025
Anton Blanchard5b2a1522018-10-04 16:23:37 +100026 trace_doorbell_entry(regs);
Benjamin Herrenschmidtb9f1cd72010-07-09 15:29:53 +100027
Nicholas Pigginb87ac022017-04-13 20:16:22 +100028 ppc_msgsync();
29
Nicholas Piggin0faf20a2021-09-23 00:54:50 +100030 if (should_hard_irq_enable())
31 do_hard_irq_enable();
Benjamin Herrenschmidt7230c562012-03-06 18:27:59 +110032
Michael Roth3a83f672019-09-11 17:31:55 -050033 kvmppc_clear_host_ipi(smp_processor_id());
Christoph Lameter69111ba2014-10-21 15:23:25 -050034 __this_cpu_inc(irq_stat.doorbell_irqs);
Ian Munsiea6a058e2013-03-21 19:22:52 +000035
Nicholas Pigginb87ac022017-04-13 20:16:22 +100036 smp_ipi_demux_relaxed(); /* already performed the barrier */
Benjamin Herrenschmidte3145b32010-07-09 15:25:18 +100037
Anton Blanchard5b2a1522018-10-04 16:23:37 +100038 trace_doorbell_exit(regs);
Nicholas Piggin1b1b6a62021-01-30 23:08:44 +100039
David Gibson0e37d252010-07-09 15:32:30 +100040 set_irq_regs(old_regs);
Benjamin Herrenschmidte3145b32010-07-09 15:25:18 +100041}
Benjamin Herrenschmidte3145b32010-07-09 15:25:18 +100042#else /* CONFIG_SMP */
Nicholas Piggin3a965702021-01-30 23:08:38 +100043DEFINE_INTERRUPT_HANDLER_ASYNC(doorbell_exception)
Benjamin Herrenschmidte3145b32010-07-09 15:25:18 +100044{
45 printk(KERN_WARNING "Received doorbell on non-smp system\n");
46}
47#endif /* CONFIG_SMP */