blob: f4217819cc31fd417243d17f079c8bf2471d37a5 [file] [log] [blame]
Kumar Gala620165f2009-02-12 13:54:53 +00001/*
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 Miller23d72bf2011-05-10 19:29:39 +000016#include <linux/hardirq.h>
Kumar Gala620165f2009-02-12 13:54:53 +000017
18#include <asm/dbell.h>
David Gibson0e37d252010-07-09 15:32:30 +100019#include <asm/irq_regs.h>
Kumar Gala620165f2009-02-12 13:54:53 +000020
21#ifdef CONFIG_SMP
Benjamin Herrenschmidtb9f1cd72010-07-09 15:29:53 +100022void doorbell_setup_this_cpu(void)
Kumar Gala620165f2009-02-12 13:54:53 +000023{
Ian Munsie42d02b82012-11-14 18:49:44 +000024 unsigned long tag = mfspr(SPRN_DOORBELL_CPUTAG) & PPC_DBELL_TAG_MASK;
Benjamin Herrenschmidtb9f1cd72010-07-09 15:29:53 +100025
Milton Miller23d72bf2011-05-10 19:29:39 +000026 smp_muxed_ipi_set_data(smp_processor_id(), tag);
Benjamin Herrenschmidtb9f1cd72010-07-09 15:29:53 +100027}
28
Milton Miller23d72bf2011-05-10 19:29:39 +000029void doorbell_cause_ipi(int cpu, unsigned long data)
Benjamin Herrenschmidtb9f1cd72010-07-09 15:29:53 +100030{
Paul Mackerras9fb1b362012-09-04 18:33:08 +000031 /* Order previous accesses vs. msgsnd, which is treated as a store */
32 mb();
Ian Munsie42d02b82012-11-14 18:49:44 +000033 ppc_msgsnd(PPC_DBELL_MSGTYPE, 0, data);
Kumar Gala620165f2009-02-12 13:54:53 +000034}
Benjamin Herrenschmidte3145b32010-07-09 15:25:18 +100035
36void doorbell_exception(struct pt_regs *regs)
37{
David Gibson0e37d252010-07-09 15:32:30 +100038 struct pt_regs *old_regs = set_irq_regs(regs);
Benjamin Herrenschmidte3145b32010-07-09 15:25:18 +100039
Milton Miller23d72bf2011-05-10 19:29:39 +000040 irq_enter();
Benjamin Herrenschmidtb9f1cd72010-07-09 15:29:53 +100041
Benjamin Herrenschmidt7230c562012-03-06 18:27:59 +110042 may_hard_irq_enable();
43
Christoph Lameter69111ba2014-10-21 15:23:25 -050044 __this_cpu_inc(irq_stat.doorbell_irqs);
Ian Munsiea6a058e2013-03-21 19:22:52 +000045
Milton Miller23d72bf2011-05-10 19:29:39 +000046 smp_ipi_demux();
Benjamin Herrenschmidte3145b32010-07-09 15:25:18 +100047
Milton Miller23d72bf2011-05-10 19:29:39 +000048 irq_exit();
David Gibson0e37d252010-07-09 15:32:30 +100049 set_irq_regs(old_regs);
Benjamin Herrenschmidte3145b32010-07-09 15:25:18 +100050}
Benjamin Herrenschmidte3145b32010-07-09 15:25:18 +100051#else /* CONFIG_SMP */
52void doorbell_exception(struct pt_regs *regs)
53{
54 printk(KERN_WARNING "Received doorbell on non-smp system\n");
55}
56#endif /* CONFIG_SMP */
57