# HG changeset patch # User Gorka Guardiola # Date 1328639632 0 # Node ID 22d00b9e0529e4494a66bc39a379448ac2f45150 # Parent e8ba6d2b039386ab1f1d3729b67395fa477b0abf lapic: Disable timer for ACs. We had them enabled, but were not calling EOI, which interfered with other interrupts (like IPIs). R=nixiedev, nemo, john CC=nix-dev http://codereview.appspot.com/5600056 Committer: John Floren diff -r e8ba6d2b0393 -r 22d00b9e0529 sys/src/nix/k10/acore.c --- a/sys/src/nix/k10/acore.c Tue Feb 07 18:29:04 2012 +0000 +++ b/sys/src/nix/k10/acore.c Tue Feb 07 18:33:52 2012 +0000 @@ -197,6 +197,10 @@ m->pfault++; DBG("actrap: cpu%d: PF cr2 %#ullx\n", m->machno, cr2get()); break; + case IdtTIMER: + apiceoi(IdtTIMER); + panic("timer interrupt in an AC"); + break; default: print("actrap: cpu%d: %ulld\n", m->machno, u->type); } diff -r e8ba6d2b0393 -r 22d00b9e0529 sys/src/nix/k10/apic.c --- a/sys/src/nix/k10/apic.c Tue Feb 07 18:29:04 2012 +0000 +++ b/sys/src/nix/k10/apic.c Tue Feb 07 18:33:52 2012 +0000 @@ -309,11 +309,13 @@ * accepted by the APIC. */ microdelay((TK2MS(1)*1000/apmachno) * m->machno); - apicrput(Tic, apic->max); - if(apic->machno == 0) + if(apic->machno == 0){ + apicrput(Tic, apic->max); intrenable(IdtTIMER, apictimer, 0, -1, "APIC timer"); - apicrput(Tlvt, Periodic|IrqTIMER); + apicrput(Tlvt, Periodic|IrqTIMER); + } + if(m->machno == 0) apicrput(Tp, 0); @@ -322,6 +324,20 @@ return 1; } +/* To start timers on TCs as part of the boot process. */ +void +apictimerenab(void) +{ + Apic *apic; + + apic = &xlapic[(apicrget(Id)>>24) & 0xff]; + + apiceoi(IdtTIMER); + apicrput(Tic, apic->max); + apicrput(Tlvt, Periodic|IrqTIMER); + +} + void apictimerset(uvlong next) { diff -r e8ba6d2b0393 -r 22d00b9e0529 sys/src/nix/k10/apic.h --- a/sys/src/nix/k10/apic.h Tue Feb 07 18:29:04 2012 +0000 +++ b/sys/src/nix/k10/apic.h Tue Feb 07 18:33:52 2012 +0000 @@ -85,4 +85,5 @@ #define l64get(p) (((u64int)l32get(p+4)<<32)|l32get(p)) extern void apicdump(void); +extern void apictimerenab(void); extern void ioapicdump(void); diff -r e8ba6d2b0393 -r 22d00b9e0529 sys/src/nix/k10/main.c --- a/sys/src/nix/k10/main.c Tue Feb 07 18:29:04 2012 +0000 +++ b/sys/src/nix/k10/main.c Tue Feb 07 18:33:52 2012 +0000 @@ -5,6 +5,7 @@ #include "fns.h" #include "init.h" +#include "apic.h" #include "io.h" @@ -159,6 +160,7 @@ /* * Enable the timer interrupt. */ + apictimerenab(); apicpri(0); timersinit();