Loading...
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * Author: Kumar Gala <galak@kernel.crashing.org>
4 *
5 * Copyright 2009 Freescale Semiconductor Inc.
6 */
7
8#include <linux/stddef.h>
9#include <linux/kernel.h>
10#include <linux/smp.h>
11#include <linux/threads.h>
12#include <linux/hardirq.h>
13
14#include <asm/dbell.h>
15#include <asm/interrupt.h>
16#include <asm/irq_regs.h>
17#include <asm/kvm_ppc.h>
18#include <asm/trace.h>
19
20#ifdef CONFIG_SMP
21
22DEFINE_INTERRUPT_HANDLER_ASYNC(doorbell_exception)
23{
24 struct pt_regs *old_regs = set_irq_regs(regs);
25
26 trace_doorbell_entry(regs);
27
28 ppc_msgsync();
29
30 may_hard_irq_enable();
31
32 kvmppc_clear_host_ipi(smp_processor_id());
33 __this_cpu_inc(irq_stat.doorbell_irqs);
34
35 smp_ipi_demux_relaxed(); /* already performed the barrier */
36
37 trace_doorbell_exit(regs);
38
39 set_irq_regs(old_regs);
40}
41#else /* CONFIG_SMP */
42DEFINE_INTERRUPT_HANDLER_ASYNC(doorbell_exception)
43{
44 printk(KERN_WARNING "Received doorbell on non-smp system\n");
45}
46#endif /* CONFIG_SMP */
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#include <linux/hardirq.h>
17
18#include <asm/dbell.h>
19#include <asm/irq_regs.h>
20#include <asm/kvm_ppc.h>
21
22#ifdef CONFIG_SMP
23void doorbell_setup_this_cpu(void)
24{
25 unsigned long tag = mfspr(SPRN_DOORBELL_CPUTAG) & PPC_DBELL_TAG_MASK;
26
27 smp_muxed_ipi_set_data(smp_processor_id(), tag);
28}
29
30void doorbell_cause_ipi(int cpu, unsigned long data)
31{
32 /* Order previous accesses vs. msgsnd, which is treated as a store */
33 mb();
34 ppc_msgsnd(PPC_DBELL_MSGTYPE, 0, data);
35}
36
37void doorbell_exception(struct pt_regs *regs)
38{
39 struct pt_regs *old_regs = set_irq_regs(regs);
40
41 irq_enter();
42
43 may_hard_irq_enable();
44
45 kvmppc_set_host_ipi(smp_processor_id(), 0);
46 __this_cpu_inc(irq_stat.doorbell_irqs);
47
48 smp_ipi_demux();
49
50 irq_exit();
51 set_irq_regs(old_regs);
52}
53#else /* CONFIG_SMP */
54void doorbell_exception(struct pt_regs *regs)
55{
56 printk(KERN_WARNING "Received doorbell on non-smp system\n");
57}
58#endif /* CONFIG_SMP */
59