usbuhci: remove resetlk, simplify scanpci()
This commit is contained in:
parent
87b1d454ed
commit
3240008dd1
1 changed files with 28 additions and 39 deletions
|
@ -144,6 +144,7 @@ struct Ctlr
|
||||||
Lock; /* for ilock. qh lists and basic ctlr I/O */
|
Lock; /* for ilock. qh lists and basic ctlr I/O */
|
||||||
QLock portlck; /* for port resets/enable... */
|
QLock portlck; /* for port resets/enable... */
|
||||||
Pcidev* pcidev;
|
Pcidev* pcidev;
|
||||||
|
Ctlr *next;
|
||||||
int active;
|
int active;
|
||||||
int port; /* I/O address */
|
int port; /* I/O address */
|
||||||
Qh* qhs; /* list of Qhs for this controller */
|
Qh* qhs; /* list of Qhs for this controller */
|
||||||
|
@ -289,8 +290,6 @@ struct Td
|
||||||
#define dqprint if(debug || (qh->io && qh->io->debug))print
|
#define dqprint if(debug || (qh->io && qh->io->debug))print
|
||||||
#define ddqprint if(debug>1 || (qh->io && qh->io->debug>1))print
|
#define ddqprint if(debug>1 || (qh->io && qh->io->debug>1))print
|
||||||
|
|
||||||
static Ctlr* ctlrs[Nhcis];
|
|
||||||
|
|
||||||
static Tdpool tdpool;
|
static Tdpool tdpool;
|
||||||
static Qhpool qhpool;
|
static Qhpool qhpool;
|
||||||
static int debug;
|
static int debug;
|
||||||
|
@ -533,19 +532,8 @@ xdump(Ctlr *ctlr, int doilock)
|
||||||
Qh *qh;
|
Qh *qh;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if(doilock){
|
if(doilock)
|
||||||
if(ctlr == ctlrs[0]){
|
|
||||||
lock(&tdpool);
|
|
||||||
print("tds: alloc %d = inuse %d + free %d\n",
|
|
||||||
tdpool.nalloc, tdpool.ninuse, tdpool.nfree);
|
|
||||||
unlock(&tdpool);
|
|
||||||
lock(&qhpool);
|
|
||||||
print("qhs: alloc %d = inuse %d + free %d\n",
|
|
||||||
qhpool.nalloc, qhpool.ninuse, qhpool.nfree);
|
|
||||||
unlock(&qhpool);
|
|
||||||
}
|
|
||||||
ilock(ctlr);
|
ilock(ctlr);
|
||||||
}
|
|
||||||
print("uhci port %#x frames %#p nintr %d ntdintr %d",
|
print("uhci port %#x frames %#p nintr %d ntdintr %d",
|
||||||
ctlr->port, ctlr->frames, ctlr->nintr, ctlr->ntdintr);
|
ctlr->port, ctlr->frames, ctlr->nintr, ctlr->ntdintr);
|
||||||
print(" nqhintr %d nisointr %d\n", ctlr->nqhintr, ctlr->nisointr);
|
print(" nqhintr %d nisointr %d\n", ctlr->nqhintr, ctlr->nisointr);
|
||||||
|
@ -564,8 +552,19 @@ xdump(Ctlr *ctlr, int doilock)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print("\n");
|
print("\n");
|
||||||
if(doilock)
|
if(doilock){
|
||||||
iunlock(ctlr);
|
iunlock(ctlr);
|
||||||
|
if(ctlr->next == nil){
|
||||||
|
lock(&tdpool);
|
||||||
|
print("tds: alloc %d = inuse %d + free %d\n",
|
||||||
|
tdpool.nalloc, tdpool.ninuse, tdpool.nfree);
|
||||||
|
unlock(&tdpool);
|
||||||
|
lock(&qhpool);
|
||||||
|
print("qhs: alloc %d = inuse %d + free %d\n",
|
||||||
|
qhpool.nalloc, qhpool.ninuse, qhpool.nfree);
|
||||||
|
unlock(&qhpool);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -2109,18 +2108,18 @@ portstatus(Hci *hp, int port)
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static Ctlr*
|
||||||
scanpci(void)
|
scanpci(void)
|
||||||
{
|
{
|
||||||
static int already = 0;
|
static Ctlr *first, **lastp;
|
||||||
int io;
|
|
||||||
int i;
|
|
||||||
Ctlr *ctlr;
|
Ctlr *ctlr;
|
||||||
Pcidev *p;
|
Pcidev *p;
|
||||||
|
int io;
|
||||||
|
|
||||||
|
if(lastp != nil)
|
||||||
|
return first;
|
||||||
|
lastp = &first;
|
||||||
|
|
||||||
if(already)
|
|
||||||
return;
|
|
||||||
already = 1;
|
|
||||||
p = nil;
|
p = nil;
|
||||||
while(p = pcimatch(p, 0, 0)){
|
while(p = pcimatch(p, 0, 0)){
|
||||||
/*
|
/*
|
||||||
|
@ -2158,14 +2157,11 @@ scanpci(void)
|
||||||
}
|
}
|
||||||
ctlr->pcidev = p;
|
ctlr->pcidev = p;
|
||||||
ctlr->port = io;
|
ctlr->port = io;
|
||||||
for(i = 0; i < Nhcis; i++)
|
|
||||||
if(ctlrs[i] == nil){
|
*lastp = ctlr;
|
||||||
ctlrs[i] = ctlr;
|
lastp = &ctlr->next;
|
||||||
break;
|
|
||||||
}
|
|
||||||
if(i == Nhcis)
|
|
||||||
print("usbuhci: bug: no more controllers\n");
|
|
||||||
}
|
}
|
||||||
|
return first;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -2293,32 +2289,24 @@ shutdown(Hci *hp)
|
||||||
static int
|
static int
|
||||||
reset(Hci *hp)
|
reset(Hci *hp)
|
||||||
{
|
{
|
||||||
static Lock resetlck;
|
|
||||||
int i;
|
|
||||||
Ctlr *ctlr;
|
Ctlr *ctlr;
|
||||||
Pcidev *p;
|
Pcidev *p;
|
||||||
|
|
||||||
if(getconf("*nousbuhci"))
|
if(getconf("*nousbuhci"))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
ilock(&resetlck);
|
|
||||||
scanpci();
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Any adapter matches if no hp->port is supplied,
|
* Any adapter matches if no hp->port is supplied,
|
||||||
* otherwise the ports must match.
|
* otherwise the ports must match.
|
||||||
*/
|
*/
|
||||||
ctlr = nil;
|
for(ctlr = scanpci(); ctlr != nil; ctlr = ctlr->next){
|
||||||
for(i = 0; i < Nhcis && ctlrs[i] != nil; i++){
|
|
||||||
ctlr = ctlrs[i];
|
|
||||||
if(ctlr->active == 0)
|
if(ctlr->active == 0)
|
||||||
if(hp->port == 0 || hp->port == ctlr->port){
|
if(hp->port == 0 || hp->port == ctlr->port){
|
||||||
ctlr->active = 1;
|
ctlr->active = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
iunlock(&resetlck);
|
if(ctlr == nil)
|
||||||
if(ctlrs[i] == nil || i == Nhcis)
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
p = ctlr->pcidev;
|
p = ctlr->pcidev;
|
||||||
|
@ -2352,6 +2340,7 @@ reset(Hci *hp)
|
||||||
hp->shutdown = shutdown;
|
hp->shutdown = shutdown;
|
||||||
hp->debug = setdebug;
|
hp->debug = setdebug;
|
||||||
hp->type = "uhci";
|
hp->type = "uhci";
|
||||||
|
|
||||||
intrenable(hp->irq, hp->interrupt, hp, hp->tbdf, hp->type);
|
intrenable(hp->irq, hp->interrupt, hp, hp->tbdf, hp->type);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue