Fix interrupt distribution to multiple CPUs on systems with cascaded PICs.
Because slave PICs send all interrupts to their CPU 0 output line (which is routed to a pin on the master PIC), changes to per-CPU register banks like EOI on the slave PIC must be accessed for CPU 0, instead of the CPU actually processing the interrupt. Submitted by: Andreas Tobler
This commit is contained in:
parent
0870f0be13
commit
4dc2f910ee
@ -74,7 +74,7 @@ openpic_set_priority(struct openpic_softc *sc, int pri)
|
||||
uint32_t x;
|
||||
|
||||
sched_pin();
|
||||
tpr = OPENPIC_PCPU_TPR(PCPU_GET(cpuid));
|
||||
tpr = OPENPIC_PCPU_TPR((sc->sc_dev == root_pic) ? PCPU_GET(cpuid) : 0);
|
||||
x = openpic_read(sc, tpr);
|
||||
x &= ~OPENPIC_TPR_MASK;
|
||||
x |= pri;
|
||||
@ -208,10 +208,10 @@ openpic_attach(device_t dev)
|
||||
for (irq = 0; irq < sc->sc_nirq; irq++)
|
||||
openpic_write(sc, OPENPIC_IDEST(irq), 1 << 0);
|
||||
|
||||
/* clear all pending interrupts */
|
||||
/* clear all pending interrupts from cpu 0 */
|
||||
for (irq = 0; irq < sc->sc_nirq; irq++) {
|
||||
(void)openpic_read(sc, OPENPIC_PCPU_IACK(PCPU_GET(cpuid)));
|
||||
openpic_write(sc, OPENPIC_PCPU_EOI(PCPU_GET(cpuid)), 0);
|
||||
(void)openpic_read(sc, OPENPIC_PCPU_IACK(0));
|
||||
openpic_write(sc, OPENPIC_PCPU_EOI(0), 0);
|
||||
}
|
||||
|
||||
for (cpu = 0; cpu < sc->sc_ncpu; cpu++)
|
||||
@ -282,7 +282,8 @@ openpic_dispatch(device_t dev, struct trapframe *tf)
|
||||
|
||||
CTR1(KTR_INTR, "%s: got interrupt", __func__);
|
||||
|
||||
cpuid = PCPU_GET(cpuid);
|
||||
cpuid = (dev == root_pic) ? PCPU_GET(cpuid) : 0;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
|
||||
while (1) {
|
||||
@ -318,19 +319,25 @@ void
|
||||
openpic_eoi(device_t dev, u_int irq __unused)
|
||||
{
|
||||
struct openpic_softc *sc;
|
||||
u_int cpuid;
|
||||
|
||||
cpuid = (dev == root_pic) ? PCPU_GET(cpuid) : 0;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
openpic_write(sc, OPENPIC_PCPU_EOI(PCPU_GET(cpuid)), 0);
|
||||
openpic_write(sc, OPENPIC_PCPU_EOI(cpuid), 0);
|
||||
}
|
||||
|
||||
void
|
||||
openpic_ipi(device_t dev, u_int cpu)
|
||||
{
|
||||
struct openpic_softc *sc;
|
||||
u_int cpuid;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
sched_pin();
|
||||
openpic_write(sc, OPENPIC_PCPU_IPI_DISPATCH(PCPU_GET(cpuid), 0),
|
||||
cpuid = (dev == root_pic) ? PCPU_GET(cpuid) : 0;
|
||||
|
||||
openpic_write(sc, OPENPIC_PCPU_IPI_DISPATCH(cpuid, 0),
|
||||
1u << cpu);
|
||||
sched_unpin();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user