Skip to content

Commit b340c65

Browse files
author
Chris Metcalf
committed
tile: support arch_irq_work_raise
Tile includes a hypervisor hook to deliver messages to arbitrary tiles, so we can use that to raise an interrupt as soon as possible on our own core. Unfortunately the Tilera hypervisor disabled that support on principle in previous releases, but it will be available in MDE 4.3.4 and later. Signed-off-by: Chris Metcalf <cmetcalf@ezchip.com> Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
1 parent 9088616 commit b340c65

File tree

4 files changed

+46
-2
lines changed

4 files changed

+46
-2
lines changed

arch/tile/include/asm/Kbuild

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ generic-y += ioctl.h
1616
generic-y += ioctls.h
1717
generic-y += ipcbuf.h
1818
generic-y += irq_regs.h
19-
generic-y += irq_work.h
2019
generic-y += local.h
2120
generic-y += local64.h
2221
generic-y += mcs_spinlock.h

arch/tile/include/asm/irq_work.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#ifndef __ASM_IRQ_WORK_H
2+
#define __ASM_IRQ_WORK_H
3+
4+
static inline bool arch_irq_work_has_interrupt(void)
5+
{
6+
#ifdef CONFIG_SMP
7+
extern bool self_interrupt_ok;
8+
return self_interrupt_ok;
9+
#else
10+
return false;
11+
#endif
12+
}
13+
14+
#endif /* __ASM_IRQ_WORK_H */

arch/tile/include/asm/smp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ static inline int xy_to_cpu(int x, int y)
6969
#define MSG_TAG_STOP_CPU 2
7070
#define MSG_TAG_CALL_FUNCTION_MANY 3
7171
#define MSG_TAG_CALL_FUNCTION_SINGLE 4
72+
#define MSG_TAG_IRQ_WORK 5
7273

7374
/* Hook for the generic smp_call_function_many() routine. */
7475
static inline void arch_send_call_function_ipi_mask(struct cpumask *mask)

arch/tile/kernel/smp.c

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <linux/interrupt.h>
1919
#include <linux/io.h>
2020
#include <linux/irq.h>
21+
#include <linux/irq_work.h>
2122
#include <linux/module.h>
2223
#include <asm/cacheflush.h>
2324
#include <asm/homecache.h>
@@ -33,6 +34,8 @@ EXPORT_SYMBOL(smp_topology);
3334
static unsigned long __iomem *ipi_mappings[NR_CPUS];
3435
#endif
3536

37+
/* Does messaging work correctly to the local cpu? */
38+
bool self_interrupt_ok;
3639

3740
/*
3841
* Top-level send_IPI*() functions to send messages to other cpus.
@@ -147,6 +150,10 @@ void evaluate_message(int tag)
147150
generic_smp_call_function_single_interrupt();
148151
break;
149152

153+
case MSG_TAG_IRQ_WORK: /* Invoke IRQ work */
154+
irq_work_run();
155+
break;
156+
150157
default:
151158
panic("Unknown IPI message tag %d", tag);
152159
break;
@@ -186,6 +193,15 @@ void flush_icache_range(unsigned long start, unsigned long end)
186193
EXPORT_SYMBOL(flush_icache_range);
187194

188195

196+
#ifdef CONFIG_IRQ_WORK
197+
void arch_irq_work_raise(void)
198+
{
199+
if (arch_irq_work_has_interrupt())
200+
send_IPI_single(smp_processor_id(), MSG_TAG_IRQ_WORK);
201+
}
202+
#endif
203+
204+
189205
/* Called when smp_send_reschedule() triggers IRQ_RESCHEDULE. */
190206
static irqreturn_t handle_reschedule_ipi(int irq, void *token)
191207
{
@@ -203,8 +219,22 @@ static struct irqaction resched_action = {
203219

204220
void __init ipi_init(void)
205221
{
222+
int cpu = smp_processor_id();
223+
HV_Recipient recip = { .y = cpu_y(cpu), .x = cpu_x(cpu),
224+
.state = HV_TO_BE_SENT };
225+
int tag = MSG_TAG_CALL_FUNCTION_SINGLE;
226+
227+
/*
228+
* Test if we can message ourselves for arch_irq_work_raise.
229+
* This functionality is only available in the Tilera hypervisor
230+
* in versions 4.3.4 and following.
231+
*/
232+
if (hv_send_message(&recip, 1, (HV_VirtAddr)&tag, sizeof(tag)) == 1)
233+
self_interrupt_ok = true;
234+
else
235+
pr_warn("Older hypervisor: disabling fast irq_work_raise\n");
236+
206237
#if CHIP_HAS_IPI()
207-
int cpu;
208238
/* Map IPI trigger MMIO addresses. */
209239
for_each_possible_cpu(cpu) {
210240
HV_Coord tile;

0 commit comments

Comments
 (0)