pc drivers: more pci cleanup

This commit is contained in:
cinap_lenrek 2018-10-07 23:38:41 +02:00
parent 9fec0e7360
commit c458216121
4 changed files with 13 additions and 6 deletions

View file

@ -470,6 +470,7 @@ shutdown(Ether* edev)
{
Ctlr *ctlr = edev->ctlr;
outb(ctlr->port+Qstatus, 0);
pciclrbme(ctlr->pcidev);
}
static void
@ -577,6 +578,7 @@ pciprobe(int typ)
c->typ = typ;
c->pcidev = p;
pcienable(p);
c->id = (p->did<<16)|p->vid;
/* §3.1.2 Legacy Device Initialization */
@ -603,6 +605,7 @@ pciprobe(int typ)
}
if(i < 2){
print("ethervirtio: no queues\n");
pcidisable(p);
free(c);
continue;
}
@ -626,9 +629,8 @@ reset(Ether* edev)
Ctlr *ctlr;
int i;
if(ctlrhead == nil) {
if(ctlrhead == nil)
ctlrhead = pciprobe(1);
}
for(ctlr = ctlrhead; ctlr != nil; ctlr = ctlr->next){
if(ctlr->active)
@ -668,6 +670,7 @@ reset(Ether* edev)
edev->promiscuous = promiscuous;
}
pcisetbme(ctlr->pcidev);
intrenable(edev->irq, interrupt, edev, edev->tbdf, edev->name);
return 0;

View file

@ -2129,14 +2129,13 @@ setup(Ctlr *c)
Pcidev *p;
p = c->p;
pcienable(p);
c->io = p->mem[0].bar&~0xf;
mem = vmap(c->io, p->mem[0].size);
if(mem == nil){
print("yuk: cant map %#p\n", c->io);
return -1;
}
pcienable(p);
c->p = p;
c->reg = (uint*)mem;
c->reg8 = (uchar*)mem;
@ -2159,15 +2158,15 @@ setup(Ctlr *c)
c->rx.r = slice(&v, 16*4096, sizeof c->rx.r[0] * c->rx.cnt);
c->nports = 1; /* BOTCH */
pcisetbme(p);
if(reset(c)){
print("yuk: cant reset\n");
pciclrbme(p);
free(c->alloc);
vunmap(mem, p->mem[0].size);
pcidisable(p);
return -1;
}
macinit(c);
pcisetbme(p);
return 0;
}

View file

@ -2438,6 +2438,7 @@ msdisable(SDev *s)
// disable(c->hba);
snprint(buf, sizeof buf, "%s (%s)", s->name, s->ifc->name);
intrdisable(c->pci->intl, msinterrupt, c, c->pci->tbdf, buf);
pciclrbme(c->pci);
c->enabled = 0;
iunlock(c);
return 1;
@ -2655,6 +2656,7 @@ mspnp(void)
print("sdodin: bar %#p in use\n", c->reg);
continue;
}
pcienable(p);
nunit = p->did>>4 & 0xf;
s->ifc = &sdodinifc;
s->idno = 'a' + nmsctlr;

View file

@ -217,6 +217,7 @@ viopnpdevs(int typ)
}
vd->typ = typ;
vd->pci = p;
pcienable(p);
/* reset */
outb(vd->port+Status, 0);
@ -576,6 +577,7 @@ vioenable(SDev *sd)
Vdev *vd;
vd = sd->ctlr;
pcisetbme(vd->pci);
snprint(name, sizeof(name), "%s (%s)", sd->name, sd->ifc->name);
intrenable(vd->pci->intl, viointerrupt, vd, vd->pci->tbdf, name);
outb(vd->port+Status, inb(vd->port+Status) | DriverOk);
@ -591,6 +593,7 @@ viodisable(SDev *sd)
vd = sd->ctlr;
snprint(name, sizeof(name), "%s (%s)", sd->name, sd->ifc->name);
intrdisable(vd->pci->intl, viointerrupt, vd, vd->pci->tbdf, name);
pciclrbme(vd->pci);
return 1;
}