1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2012 Regents of the University of California
4 * Copyright (C) 2017 SiFive
5 * Copyright (C) 2018 Christoph Hellwig
8 #include <linux/interrupt.h>
9 #include <linux/irqchip.h>
10 #include <linux/irqdomain.h>
11 #include <linux/module.h>
12 #include <linux/seq_file.h>
15 #include <asm/softirq_stack.h>
16 #include <asm/stacktrace.h>
18 static struct fwnode_handle *(*__get_intc_node)(void);
20 void riscv_set_intc_hwnode_fn(struct fwnode_handle *(*fn)(void))
25 struct fwnode_handle *riscv_get_intc_hwnode(void)
28 return __get_intc_node();
32 EXPORT_SYMBOL_GPL(riscv_get_intc_hwnode);
34 #ifdef CONFIG_IRQ_STACKS
35 #include <asm/irq_stack.h>
37 DEFINE_PER_CPU(ulong *, irq_stack_ptr);
39 #ifdef CONFIG_VMAP_STACK
40 static void init_irq_stacks(void)
45 for_each_possible_cpu(cpu) {
46 p = arch_alloc_vmap_stack(IRQ_STACK_SIZE, cpu_to_node(cpu));
47 per_cpu(irq_stack_ptr, cpu) = p;
51 /* irq stack only needs to be 16 byte aligned - not IRQ_STACK_SIZE aligned. */
52 DEFINE_PER_CPU_ALIGNED(ulong [IRQ_STACK_SIZE/sizeof(ulong)], irq_stack);
54 static void init_irq_stacks(void)
58 for_each_possible_cpu(cpu)
59 per_cpu(irq_stack_ptr, cpu) = per_cpu(irq_stack, cpu);
61 #endif /* CONFIG_VMAP_STACK */
63 #ifdef CONFIG_HAVE_SOFTIRQ_ON_OWN_STACK
64 void do_softirq_own_stack(void)
66 #ifdef CONFIG_IRQ_STACKS
67 if (on_thread_stack()) {
68 ulong *sp = per_cpu(irq_stack_ptr, smp_processor_id())
69 + IRQ_STACK_SIZE/sizeof(ulong);
71 "addi sp, sp, -"RISCV_SZPTR "\n"
73 "addi sp, sp, -"RISCV_SZPTR "\n"
75 "addi s0, sp, 2*"RISCV_SZPTR "\n"
77 "call __do_softirq \n"
78 "addi sp, s0, -2*"RISCV_SZPTR"\n"
80 "addi sp, sp, "RISCV_SZPTR "\n"
82 "addi sp, sp, "RISCV_SZPTR "\n"
85 : "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7",
86 "t0", "t1", "t2", "t3", "t4", "t5", "t6",
92 #endif /* CONFIG_HAVE_SOFTIRQ_ON_OWN_STACK */
95 static void init_irq_stacks(void) {}
96 #endif /* CONFIG_IRQ_STACKS */
98 int arch_show_interrupts(struct seq_file *p, int prec)
100 show_ipi_stats(p, prec);
104 void __init init_IRQ(void)
108 if (!handle_arch_irq)
109 panic("No interrupt controller found.");