Skip to content

Commit 2984479

Browse files
greentimepalmer-dabbelt
authored andcommitted
riscv: Support irq_work via self IPIs
Support for arch_irq_work_raise() and arch_irq_work_has_interrupt() was missing from riscv (a prerequisite for FULL_NOHZ). Signed-off-by: Greentime Hu <[email protected]> Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 3c46979 commit 2984479

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

arch/riscv/include/asm/irq_work.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
#ifndef _ASM_RISCV_IRQ_WORK_H
3+
#define _ASM_RISCV_IRQ_WORK_H
4+
5+
static inline bool arch_irq_work_has_interrupt(void)
6+
{
7+
return true;
8+
}
9+
extern void arch_irq_work_raise(void);
10+
#endif /* _ASM_RISCV_IRQ_WORK_H */

arch/riscv/kernel/smp.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <linux/sched.h>
1717
#include <linux/seq_file.h>
1818
#include <linux/delay.h>
19+
#include <linux/irq_work.h>
1920

2021
#include <asm/clint.h>
2122
#include <asm/sbi.h>
@@ -26,6 +27,7 @@ enum ipi_message_type {
2627
IPI_RESCHEDULE,
2728
IPI_CALL_FUNC,
2829
IPI_CPU_STOP,
30+
IPI_IRQ_WORK,
2931
IPI_MAX
3032
};
3133

@@ -123,6 +125,13 @@ static inline void clear_ipi(void)
123125
clint_clear_ipi(cpuid_to_hartid_map(smp_processor_id()));
124126
}
125127

128+
#ifdef CONFIG_IRQ_WORK
129+
void arch_irq_work_raise(void)
130+
{
131+
send_ipi_single(smp_processor_id(), IPI_IRQ_WORK);
132+
}
133+
#endif
134+
126135
void handle_IPI(struct pt_regs *regs)
127136
{
128137
struct pt_regs *old_regs = set_irq_regs(regs);
@@ -158,6 +167,11 @@ void handle_IPI(struct pt_regs *regs)
158167
ipi_stop();
159168
}
160169

170+
if (ops & (1 << IPI_IRQ_WORK)) {
171+
stats[IPI_IRQ_WORK]++;
172+
irq_work_run();
173+
}
174+
161175
BUG_ON((ops >> IPI_MAX) != 0);
162176

163177
/* Order data access and bit testing. */
@@ -173,6 +187,7 @@ static const char * const ipi_names[] = {
173187
[IPI_RESCHEDULE] = "Rescheduling interrupts",
174188
[IPI_CALL_FUNC] = "Function call interrupts",
175189
[IPI_CPU_STOP] = "CPU stop interrupts",
190+
[IPI_IRQ_WORK] = "IRQ work interrupts",
176191
};
177192

178193
void show_ipi_stats(struct seq_file *p, int prec)

0 commit comments

Comments
 (0)