pc kernel: kproc error and exit

catch the error() that can be thrown by sleep() and tsleep()
in kprocs.

add missing pexit() calls.

always set the freemem argument to pexit() from kproc otherwise
the process gets added to the broken list.
This commit is contained in:
cinap_lenrek 2013-11-22 22:29:31 +01:00
parent df6b68092c
commit 55d31f2cab
17 changed files with 89 additions and 27 deletions

View file

@ -449,10 +449,13 @@ eventoccured(void)
static void static void
processevents(void *) processevents(void *)
{ {
while (1) { int message;
int message; Cardbus *cb;
Cardbus *cb;
while(waserror())
;
for(;;){
sleep(&revents, (int (*)(void *))eventoccured, nil); sleep(&revents, (int (*)(void *))eventoccured, nil);
cb = nil; cb = nil;

View file

@ -1228,18 +1228,19 @@ gc82543watchdog(void* arg)
Ctlr *ctlr; Ctlr *ctlr;
edev = arg; edev = arg;
while(waserror())
;
for(;;){ for(;;){
tsleep(&up->sleep, return0, 0, 1000); tsleep(&up->sleep, return0, 0, 1000);
ctlr = edev->ctlr; ctlr = edev->ctlr;
if(ctlr == nil){ if(ctlr == nil)
print("%s: exiting\n", up->text); break;
pexit("disabled", 0);
}
gc82543checklink(ctlr); gc82543checklink(ctlr);
gc82543replenish(ctlr); gc82543replenish(ctlr);
} }
print("%s: exiting\n", up->text);
pexit("disabled", 1);
} }
static void static void

View file

@ -348,6 +348,8 @@ watchdog(void* arg)
static void txstart(Ether*); static void txstart(Ether*);
ether = arg; ether = arg;
while(waserror())
;
for(;;){ for(;;){
tsleep(&up->sleep, return0, 0, 4000); tsleep(&up->sleep, return0, 0, 4000);
@ -357,10 +359,8 @@ watchdog(void* arg)
* the future. * the future.
*/ */
ctlr = ether->ctlr; ctlr = ether->ctlr;
if(ctlr == nil || ctlr->state == 0){ if(ctlr == nil || ctlr->state == 0)
print("%s: exiting\n", up->text); break;
pexit("disabled", 0);
}
ilock(&ctlr->cblock); ilock(&ctlr->cblock);
if(ctlr->tick++){ if(ctlr->tick++){
@ -369,6 +369,8 @@ watchdog(void* arg)
} }
iunlock(&ctlr->cblock); iunlock(&ctlr->cblock);
} }
print("%s: exiting\n", up->text);
pexit("disabled", 1);
} }
static void static void

View file

@ -853,6 +853,8 @@ i82563tproc(void *v)
i82563txinit(ctlr); i82563txinit(ctlr);
tdt = ctlr->tdt; tdt = ctlr->tdt;
while(waserror())
;
for(;;){ for(;;){
n = NEXT(tdt, ctlr->ntd); n = NEXT(tdt, ctlr->ntd);
if(n == i82563cleanup(ctlr)){ if(n == i82563cleanup(ctlr)){
@ -986,6 +988,8 @@ i82563rproc(void *arg)
}else }else
im = Rxt0|Rxo|Rxdmt0|Rxseq|Ack; im = Rxt0|Rxo|Rxdmt0|Rxseq|Ack;
while(waserror())
;
for(;;){ for(;;){
i82563im(ctlr, im); i82563im(ctlr, im);
ctlr->rsleep++; ctlr->rsleep++;
@ -1163,9 +1167,13 @@ phyl79proc(void *v)
c = e->ctlr; c = e->ctlr;
phyno = phyprobe(c, 3<<1); phyno = phyprobe(c, 3<<1);
if(phyno == ~0) if(phyno == ~0){
return; print("%s: no phy, exiting\n", up->text);
pexit("no phy", 1);
}
while(waserror())
;
for(;;){ for(;;){
phy = phyread(c, phyno, Phystat); phy = phyread(c, phyno, Phystat);
if(phy == ~0){ if(phy == ~0){
@ -1203,11 +1211,16 @@ phylproc(void *v)
c = e->ctlr; c = e->ctlr;
phyno = phyprobe(c, 3<<1); phyno = phyprobe(c, 3<<1);
if(phyno == ~0) if(phyno == ~0){
return; print("%s: no phy, exiting\n", up->text);
pexit("no phy", 1);
}
if(c->type == i82573 && (phy = phyread(c, phyno, Phyier)) != ~0) if(c->type == i82573 && (phy = phyread(c, phyno, Phyier)) != ~0)
phywrite(c, phyno, Phyier, phy | Lscie | Ancie | Spdie | Panie); phywrite(c, phyno, Phyier, phy | Lscie | Ancie | Spdie | Panie);
while(waserror())
;
for(;;){ for(;;){
phy = phyread(c, phyno, Physsr); phy = phyread(c, phyno, Physsr);
if(phy == ~0){ if(phy == ~0){
@ -1263,6 +1276,8 @@ pcslproc(void *v)
if(c->type == i82575 || c->type == i82576) if(c->type == i82575 || c->type == i82576)
csr32w(c, Connsw, Enrgirq); csr32w(c, Connsw, Enrgirq);
while(waserror())
;
for(;;){ for(;;){
phy = csr32r(c, Pcsstat); phy = csr32r(c, Pcsstat);
e->link = phy & Linkok; e->link = phy & Linkok;
@ -1290,6 +1305,8 @@ serdeslproc(void *v)
e = v; e = v;
c = e->ctlr; c = e->ctlr;
while(waserror())
;
for(;;){ for(;;){
rx = csr32r(c, Rxcw); rx = csr32r(c, Rxcw);
tx = csr32r(c, Txcw); tx = csr32r(c, Txcw);

View file

@ -375,6 +375,8 @@ lproc(void *v)
e = v; e = v;
c = e->ctlr; c = e->ctlr;
while(waserror())
;
for (;;) { for (;;) {
r = c->reg[Links]; r = c->reg[Links];
e->link = (r & Lnkup) != 0; e->link = (r & Lnkup) != 0;
@ -467,6 +469,8 @@ tproc(void *v)
e = v; e = v;
c = e->ctlr; c = e->ctlr;
while(waserror())
;
for (;;) { for (;;) {
sleep(&c->trendez, tim, c); /* transmit kicks us */ sleep(&c->trendez, tim, c); /* transmit kicks us */
c->tim = 0; c->tim = 0;
@ -551,6 +555,8 @@ rproc(void *v)
c = e->ctlr; c = e->ctlr;
m = c->nrd - 1; m = c->nrd - 1;
rdh = 0; rdh = 0;
while(waserror())
;
loop: loop:
replenish(c, rdh); replenish(c, rdh);
im(c, Irx0); im(c, Irx0);

View file

@ -782,6 +782,8 @@ igbelproc(void* arg)
edev = arg; edev = arg;
ctlr = edev->ctlr; ctlr = edev->ctlr;
while(waserror())
;
for(;;){ for(;;){
if(ctlr->mii == nil || ctlr->mii->curphy == nil) if(ctlr->mii == nil || ctlr->mii->curphy == nil)
continue; continue;
@ -1091,6 +1093,9 @@ igberproc(void* arg)
r |= Ren; r |= Ren;
csr32w(ctlr, Rctl, r); csr32w(ctlr, Rctl, r);
while(waserror())
;
for(;;){ for(;;){
ctlr->rim = 0; ctlr->rim = 0;
igbeim(ctlr, Rxt0|Rxo|Rxdmt0|Rxseq); igbeim(ctlr, Rxt0|Rxo|Rxdmt0|Rxseq);

View file

@ -1997,11 +1997,10 @@ iwlrecover(void *arg)
edev = arg; edev = arg;
ctlr = edev->ctlr; ctlr = edev->ctlr;
while(waserror())
;
for(;;){ for(;;){
while(waserror())
;
tsleep(&up->sleep, return0, 0, 4000); tsleep(&up->sleep, return0, 0, 4000);
poperror();
qlock(ctlr); qlock(ctlr);
for(;;){ for(;;){

View file

@ -1082,6 +1082,8 @@ m10rx(void *v)
e = v; e = v;
c = e->ctlr; c = e->ctlr;
while(waserror())
;
for(;;){ for(;;){
replenish(&c->sm); replenish(&c->sm);
replenish(&c->bg); replenish(&c->bg);
@ -1144,6 +1146,8 @@ txproc(void *v)
e = v; e = v;
c = e->ctlr; c = e->ctlr;
tx = &c->tx; tx = &c->tx;
while(waserror())
;
for(;;){ for(;;){
sleep(&c->txrendez, txcansleep, c); sleep(&c->txrendez, txcansleep, c);
txcleanup(tx, gbit32(c->stats->txcnt)); txcleanup(tx, gbit32(c->stats->txcnt));

View file

@ -440,6 +440,8 @@ vt6102lproc(void* arg)
edev = arg; edev = arg;
ctlr = edev->ctlr; ctlr = edev->ctlr;
while(waserror())
;
for(;;){ for(;;){
if(ctlr->mii == nil || ctlr->mii->curphy == nil) if(ctlr->mii == nil || ctlr->mii->curphy == nil)
break; break;

View file

@ -547,6 +547,8 @@ vt6105Mlproc(void* arg)
edev = arg; edev = arg;
ctlr = edev->ctlr; ctlr = edev->ctlr;
while(waserror())
;
for(;;){ for(;;){
if(ctlr->mii == nil || ctlr->mii->curphy == nil) if(ctlr->mii == nil || ctlr->mii->curphy == nil)
break; break;

View file

@ -1243,6 +1243,8 @@ tproc(void *v)
txinit(e); txinit(e);
linkup(c, Txen); linkup(c, Txen);
while(waserror())
;
for(;;){ for(;;){
if((b = qbread(e->oq, 100000)) == nil) if((b = qbread(e->oq, 100000)) == nil)
break; break;
@ -1381,6 +1383,8 @@ rproc(void *v)
rxinit(e); rxinit(e);
linkup(c, Rxen); linkup(c, Rxen);
while(waserror())
;
for(;;) for(;;)
if(replenish(e, c) == 0){ if(replenish(e, c) == 0){
starve(k); starve(k);
@ -1750,7 +1754,8 @@ iproc(void *v)
e = v; e = v;
c = e->ctlr; c = e->ctlr;
k = &c->iproc; k = &c->iproc;
while(waserror())
;
for(;;){ for(;;){
starve(k); starve(k);
cause = c->reg[Eisr]; cause = c->reg[Eisr];

View file

@ -44,10 +44,11 @@ genrandom(void*)
up->basepri = PriNormal; up->basepri = PriNormal;
up->priority = up->basepri; up->priority = up->basepri;
while(waserror())
;
for(;;){ for(;;){
for(;;) if(++rb.randomcount <= 100000)
if(++rb.randomcount > 100000) continue;
break;
if(anyhigher()) if(anyhigher())
sched(); sched();
if(!rbnotfull(0)) if(!rbnotfull(0))

View file

@ -1177,6 +1177,8 @@ satakproc(void*)
{ {
int i; int i;
while(waserror())
;
for(;;){ for(;;){
tsleep(&up->sleep, return0, 0, Nms); tsleep(&up->sleep, return0, 0, Nms);
for(i = 0; i < niadrive; i++) for(i = 0; i < niadrive; i++)

View file

@ -1100,6 +1100,8 @@ satakproc(void*)
{ {
int i; int i;
while(waserror())
;
for(;;){ for(;;){
tsleep(&up->sleep, return0, 0, Nms); tsleep(&up->sleep, return0, 0, Nms);
for(i = 0; i < nmvsatadrive; i++) for(i = 0; i < nmvsatadrive; i++)

View file

@ -2272,6 +2272,8 @@ mskproc(void*)
{ {
int i; int i;
while(waserror())
;
for(;;){ for(;;){
tsleep(&up->sleep, return0, 0, Nms); tsleep(&up->sleep, return0, 0, Nms);
for(i = 0; i < nmsdrive; i++) for(i = 0; i < nmsdrive; i++)

View file

@ -682,6 +682,8 @@ w_timer(void* arg)
Ctlr* ctlr = (Ctlr*)ether->ctlr; Ctlr* ctlr = (Ctlr*)ether->ctlr;
ctlr->timerproc = up; ctlr->timerproc = up;
while(waserror())
;
for(;;){ for(;;){
tsleep(&up->sleep, return0, 0, MSperTick); tsleep(&up->sleep, return0, 0, MSperTick);
ctlr = (Ctlr*)ether->ctlr; ctlr = (Ctlr*)ether->ctlr;
@ -732,7 +734,7 @@ w_timer(void* arg)
} }
iunlock(ctlr); iunlock(ctlr);
} }
pexit("terminated", 0); pexit("terminated", 1);
} }
void void

View file

@ -450,9 +450,14 @@ wifiproc(void *arg)
b = nil; b = nil;
wifi = arg; wifi = arg;
while(waserror())
;
for(;;){ for(;;){
if(b != nil) if(b != nil){
freeb(b); freeb(b);
b = nil;
continue;
}
if((b = qbread(wifi->iq, 100000)) == nil) if((b = qbread(wifi->iq, 100000)) == nil)
break; break;
w = (Wifipkt*)b->rp; w = (Wifipkt*)b->rp;
@ -526,7 +531,7 @@ wifiproc(void *arg)
break; break;
} }
} }
pexit("wifi in queue closed", 0); pexit("wifi in queue closed", 1);
} }
static void static void
@ -584,9 +589,11 @@ wifoproc(void *arg)
wifi = arg; wifi = arg;
ether = wifi->ether; ether = wifi->ether;
while(waserror())
;
while((b = qbread(ether->oq, 1000000)) != nil) while((b = qbread(ether->oq, 1000000)) != nil)
wifietheroq(wifi, b); wifietheroq(wifi, b);
pexit("ether out queue closed", 0); pexit("ether out queue closed", 1);
} }
static void static void