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/scs.h>
13 #include <linux/seq_file.h>
16 #include <asm/softirq_stack.h>
17 #include <asm/stacktrace.h>
19 static struct fwnode_handle
*(*__get_intc_node
)(void);
21 void riscv_set_intc_hwnode_fn(struct fwnode_handle
*(*fn
)(void))
26 struct fwnode_handle
*riscv_get_intc_hwnode(void)
29 return __get_intc_node();
33 EXPORT_SYMBOL_GPL(riscv_get_intc_hwnode
);
35 #ifdef CONFIG_IRQ_STACKS
36 #include <asm/irq_stack.h>
38 DECLARE_PER_CPU(ulong
*, irq_shadow_call_stack_ptr
);
40 #ifdef CONFIG_SHADOW_CALL_STACK
41 DEFINE_PER_CPU(ulong
*, irq_shadow_call_stack_ptr
);
44 static void init_irq_scs(void)
48 if (!scs_is_enabled())
51 for_each_possible_cpu(cpu
)
52 per_cpu(irq_shadow_call_stack_ptr
, cpu
) =
53 scs_alloc(cpu_to_node(cpu
));
56 DEFINE_PER_CPU(ulong
*, irq_stack_ptr
);
58 #ifdef CONFIG_VMAP_STACK
59 static void init_irq_stacks(void)
64 for_each_possible_cpu(cpu
) {
65 p
= arch_alloc_vmap_stack(IRQ_STACK_SIZE
, cpu_to_node(cpu
));
66 per_cpu(irq_stack_ptr
, cpu
) = p
;
70 /* irq stack only needs to be 16 byte aligned - not IRQ_STACK_SIZE aligned. */
71 DEFINE_PER_CPU_ALIGNED(ulong
[IRQ_STACK_SIZE
/sizeof(ulong
)], irq_stack
);
73 static void init_irq_stacks(void)
77 for_each_possible_cpu(cpu
)
78 per_cpu(irq_stack_ptr
, cpu
) = per_cpu(irq_stack
, cpu
);
80 #endif /* CONFIG_VMAP_STACK */
82 #ifdef CONFIG_SOFTIRQ_ON_OWN_STACK
83 static void ___do_softirq(struct pt_regs
*regs
)
88 void do_softirq_own_stack(void)
90 if (on_thread_stack())
91 call_on_irq_stack(NULL
, ___do_softirq
);
95 #endif /* CONFIG_SOFTIRQ_ON_OWN_STACK */
98 static void init_irq_scs(void) {}
99 static void init_irq_stacks(void) {}
100 #endif /* CONFIG_IRQ_STACKS */
102 int arch_show_interrupts(struct seq_file
*p
, int prec
)
104 show_ipi_stats(p
, prec
);
108 void __init
init_IRQ(void)
113 if (!handle_arch_irq
)
114 panic("No interrupt controller found.");