blob: c70034fbd4ce0e9820d07ae9279f4c28643c3e7f [file] [log] [blame]
Thomas Gleixnercaab2772019-06-03 07:44:50 +02001// SPDX-License-Identifier: GPL-2.0-only
Marc Zyngierfb9bd7d62012-03-05 11:49:29 +00002/*
3 * Based on arch/arm/kernel/irq.c
4 *
5 * Copyright (C) 1992 Linus Torvalds
6 * Modifications for ARM processor Copyright (C) 1995-2000 Russell King.
7 * Support for Dynamic Tick Timer Copyright (C) 2004-2005 Nokia Corporation.
8 * Dynamic Tick Timer written by Tony Lindgren <tony@atomide.com> and
9 * Tuukka Tikkanen <tuukka.tikkanen@elektrobit.com>.
10 * Copyright (C) 2012 ARM Ltd.
Marc Zyngierfb9bd7d62012-03-05 11:49:29 +000011 */
12
13#include <linux/kernel_stat.h>
14#include <linux/irq.h>
Mark Rutlande3067862017-07-21 14:25:33 +010015#include <linux/memory.h>
Marc Zyngierfb9bd7d62012-03-05 11:49:29 +000016#include <linux/smp.h>
17#include <linux/init.h>
Catalin Marinase851b582013-01-14 12:39:31 +000018#include <linux/irqchip.h>
Marc Zyngierfb9bd7d62012-03-05 11:49:29 +000019#include <linux/seq_file.h>
Mark Rutlande3067862017-07-21 14:25:33 +010020#include <linux/vmalloc.h>
James Morseed8b20d2018-01-08 15:38:10 +000021#include <asm/vmap_stack.h>
Marc Zyngierfb9bd7d62012-03-05 11:49:29 +000022
23unsigned long irq_err_count;
24
Julien Thierry58709702019-01-31 14:58:39 +000025/* Only access this in an NMI enter/exit */
26DEFINE_PER_CPU(struct nmi_ctx, nmi_contexts);
27
Mark Rutlandf60fe782017-07-31 21:17:03 +010028DEFINE_PER_CPU(unsigned long *, irq_stack_ptr);
AKASHI Takahiro132cd882015-12-04 11:02:26 +000029
Marc Zyngierfb9bd7d62012-03-05 11:49:29 +000030int arch_show_interrupts(struct seq_file *p, int prec)
31{
Marc Zyngierfb9bd7d62012-03-05 11:49:29 +000032 show_ipi_list(p, prec);
Marc Zyngierfb9bd7d62012-03-05 11:49:29 +000033 seq_printf(p, "%*s: %10lu\n", prec, "Err", irq_err_count);
34 return 0;
35}
36
Mark Rutlande3067862017-07-21 14:25:33 +010037#ifdef CONFIG_VMAP_STACK
38static void init_irq_stacks(void)
39{
40 int cpu;
41 unsigned long *p;
42
43 for_each_possible_cpu(cpu) {
James Morseed8b20d2018-01-08 15:38:10 +000044 p = arch_alloc_vmap_stack(IRQ_STACK_SIZE, cpu_to_node(cpu));
Mark Rutlande3067862017-07-21 14:25:33 +010045 per_cpu(irq_stack_ptr, cpu) = p;
46 }
47}
48#else
49/* irq stack only needs to be 16 byte aligned - not IRQ_STACK_SIZE aligned. */
50DEFINE_PER_CPU_ALIGNED(unsigned long [IRQ_STACK_SIZE/sizeof(long)], irq_stack);
51
Mark Rutlandf60fe782017-07-31 21:17:03 +010052static void init_irq_stacks(void)
53{
54 int cpu;
55
56 for_each_possible_cpu(cpu)
57 per_cpu(irq_stack_ptr, cpu) = per_cpu(irq_stack, cpu);
58}
Mark Rutlande3067862017-07-21 14:25:33 +010059#endif
Mark Rutlandf60fe782017-07-31 21:17:03 +010060
Marc Zyngierfb9bd7d62012-03-05 11:49:29 +000061void __init init_IRQ(void)
62{
Mark Rutlandf60fe782017-07-31 21:17:03 +010063 init_irq_stacks();
Catalin Marinase851b582013-01-14 12:39:31 +000064 irqchip_init();
Marc Zyngierfb9bd7d62012-03-05 11:49:29 +000065 if (!handle_arch_irq)
66 panic("No interrupt controller found.");
67}