Skip to content

Commit c3afa71

Browse files
committed
hw/intc/loongarch_extioi: Add irq routing support from physical id
The simliar with IPI interrupt controller, physical cpu id is used for irq routing for extioi interrupt controller. Signed-off-by: Bibo Mao <[email protected]> Reviewed-by: Bibo Mao <[email protected]>
1 parent 0443b85 commit c3afa71

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

hw/intc/loongarch_extioi.c

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,23 @@
1515
#include "hw/intc/loongarch_extioi.h"
1616
#include "trace.h"
1717

18+
static int extioi_get_index_from_archid(LoongArchExtIOICommonState *s,
19+
uint64_t arch_id)
20+
{
21+
int i;
22+
23+
for (i = 0; i < s->num_cpu; i++) {
24+
if (s->cpu[i].arch_id == arch_id) {
25+
break;
26+
}
27+
}
28+
29+
if ((i < s->num_cpu) && s->cpu[i].cpu) {
30+
return i;
31+
}
32+
33+
return -1;
34+
}
1835

1936
static void extioi_update_irq(LoongArchExtIOICommonState *s, int irq, int level)
2037
{
@@ -125,7 +142,7 @@ static inline void extioi_enable_irq(LoongArchExtIOICommonState *s, int index,\
125142
static inline void extioi_update_sw_coremap(LoongArchExtIOICommonState *s,
126143
int irq, uint64_t val, bool notify)
127144
{
128-
int i, cpu;
145+
int i, cpu, cpuid;
129146

130147
/*
131148
* loongarch only support little endian,
@@ -134,12 +151,17 @@ static inline void extioi_update_sw_coremap(LoongArchExtIOICommonState *s,
134151
val = cpu_to_le64(val);
135152

136153
for (i = 0; i < 4; i++) {
137-
cpu = val & 0xff;
154+
cpuid = val & 0xff;
138155
val = val >> 8;
139156

140157
if (!(s->status & BIT(EXTIOI_ENABLE_CPU_ENCODE))) {
141-
cpu = ctz32(cpu);
142-
cpu = (cpu >= 4) ? 0 : cpu;
158+
cpuid = ctz32(cpuid);
159+
cpuid = (cpuid >= 4) ? 0 : cpuid;
160+
}
161+
162+
cpu = extioi_get_index_from_archid(s, cpuid);
163+
if (cpu < 0) {
164+
continue;
143165
}
144166

145167
if (s->sw_coremap[irq + i] == cpu) {

0 commit comments

Comments
 (0)