Thomas Gleixner | caab277 | 2019-06-03 07:44:50 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Marc Zyngier | fb9bd7d6 | 2012-03-05 11:49:29 +0000 | [diff] [blame] | 2 | /* |
| 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 Zyngier | fb9bd7d6 | 2012-03-05 11:49:29 +0000 | [diff] [blame] | 11 | */ |
| 12 | |
| 13 | #include <linux/kernel_stat.h> |
| 14 | #include <linux/irq.h> |
Mark Rutland | e306786 | 2017-07-21 14:25:33 +0100 | [diff] [blame] | 15 | #include <linux/memory.h> |
Marc Zyngier | fb9bd7d6 | 2012-03-05 11:49:29 +0000 | [diff] [blame] | 16 | #include <linux/smp.h> |
| 17 | #include <linux/init.h> |
Catalin Marinas | e851b58 | 2013-01-14 12:39:31 +0000 | [diff] [blame] | 18 | #include <linux/irqchip.h> |
Marc Zyngier | fb9bd7d6 | 2012-03-05 11:49:29 +0000 | [diff] [blame] | 19 | #include <linux/seq_file.h> |
Mark Rutland | e306786 | 2017-07-21 14:25:33 +0100 | [diff] [blame] | 20 | #include <linux/vmalloc.h> |
James Morse | ed8b20d | 2018-01-08 15:38:10 +0000 | [diff] [blame] | 21 | #include <asm/vmap_stack.h> |
Marc Zyngier | fb9bd7d6 | 2012-03-05 11:49:29 +0000 | [diff] [blame] | 22 | |
| 23 | unsigned long irq_err_count; |
| 24 | |
Julien Thierry | 5870970 | 2019-01-31 14:58:39 +0000 | [diff] [blame] | 25 | /* Only access this in an NMI enter/exit */ |
| 26 | DEFINE_PER_CPU(struct nmi_ctx, nmi_contexts); |
| 27 | |
Mark Rutland | f60fe78 | 2017-07-31 21:17:03 +0100 | [diff] [blame] | 28 | DEFINE_PER_CPU(unsigned long *, irq_stack_ptr); |
AKASHI Takahiro | 132cd88 | 2015-12-04 11:02:26 +0000 | [diff] [blame] | 29 | |
Marc Zyngier | fb9bd7d6 | 2012-03-05 11:49:29 +0000 | [diff] [blame] | 30 | int arch_show_interrupts(struct seq_file *p, int prec) |
| 31 | { |
Marc Zyngier | fb9bd7d6 | 2012-03-05 11:49:29 +0000 | [diff] [blame] | 32 | show_ipi_list(p, prec); |
Marc Zyngier | fb9bd7d6 | 2012-03-05 11:49:29 +0000 | [diff] [blame] | 33 | seq_printf(p, "%*s: %10lu\n", prec, "Err", irq_err_count); |
| 34 | return 0; |
| 35 | } |
| 36 | |
Mark Rutland | e306786 | 2017-07-21 14:25:33 +0100 | [diff] [blame] | 37 | #ifdef CONFIG_VMAP_STACK |
| 38 | static void init_irq_stacks(void) |
| 39 | { |
| 40 | int cpu; |
| 41 | unsigned long *p; |
| 42 | |
| 43 | for_each_possible_cpu(cpu) { |
James Morse | ed8b20d | 2018-01-08 15:38:10 +0000 | [diff] [blame] | 44 | p = arch_alloc_vmap_stack(IRQ_STACK_SIZE, cpu_to_node(cpu)); |
Mark Rutland | e306786 | 2017-07-21 14:25:33 +0100 | [diff] [blame] | 45 | 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. */ |
| 50 | DEFINE_PER_CPU_ALIGNED(unsigned long [IRQ_STACK_SIZE/sizeof(long)], irq_stack); |
| 51 | |
Mark Rutland | f60fe78 | 2017-07-31 21:17:03 +0100 | [diff] [blame] | 52 | static 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 Rutland | e306786 | 2017-07-21 14:25:33 +0100 | [diff] [blame] | 59 | #endif |
Mark Rutland | f60fe78 | 2017-07-31 21:17:03 +0100 | [diff] [blame] | 60 | |
Marc Zyngier | fb9bd7d6 | 2012-03-05 11:49:29 +0000 | [diff] [blame] | 61 | void __init init_IRQ(void) |
| 62 | { |
Mark Rutland | f60fe78 | 2017-07-31 21:17:03 +0100 | [diff] [blame] | 63 | init_irq_stacks(); |
Catalin Marinas | e851b58 | 2013-01-14 12:39:31 +0000 | [diff] [blame] | 64 | irqchip_init(); |
Marc Zyngier | fb9bd7d6 | 2012-03-05 11:49:29 +0000 | [diff] [blame] | 65 | if (!handle_arch_irq) |
| 66 | panic("No interrupt controller found."); |
| 67 | } |