pc, pc64: fix missed qunlock, use Ref with incref()/decref() instead of _xinc()/_xdec()
This commit is contained in:
parent
ce38380b8f
commit
0a2b418535
1 changed files with 16 additions and 10 deletions
|
@ -186,7 +186,7 @@ mtrrop(Mtrrop **op)
|
||||||
int s;
|
int s;
|
||||||
ulong cr0, cr4;
|
ulong cr0, cr4;
|
||||||
vlong def;
|
vlong def;
|
||||||
static long bar1, bar2;
|
static Ref bar1, bar2;
|
||||||
|
|
||||||
s = splhi(); /* avoid race with mtrrclock */
|
s = splhi(); /* avoid race with mtrrclock */
|
||||||
|
|
||||||
|
@ -194,8 +194,8 @@ mtrrop(Mtrrop **op)
|
||||||
* wait for all CPUs to sync here, so that the MTRR setup gets
|
* wait for all CPUs to sync here, so that the MTRR setup gets
|
||||||
* done at roughly the same time on all processors.
|
* done at roughly the same time on all processors.
|
||||||
*/
|
*/
|
||||||
_xinc(&bar1);
|
incref(&bar1);
|
||||||
while(bar1 < conf.nmach)
|
while(bar1.ref < conf.nmach)
|
||||||
microdelay(10);
|
microdelay(10);
|
||||||
|
|
||||||
cr4 = getcr4();
|
cr4 = getcr4();
|
||||||
|
@ -218,14 +218,14 @@ mtrrop(Mtrrop **op)
|
||||||
* wait for all CPUs to sync up again, so that we don't continue
|
* wait for all CPUs to sync up again, so that we don't continue
|
||||||
* executing while the MTRRs are still being set up.
|
* executing while the MTRRs are still being set up.
|
||||||
*/
|
*/
|
||||||
_xinc(&bar2);
|
incref(&bar2);
|
||||||
while(bar2 < conf.nmach)
|
while(bar2.ref < conf.nmach)
|
||||||
microdelay(10);
|
microdelay(10);
|
||||||
|
decref(&bar1);
|
||||||
|
while(bar1.ref > 0)
|
||||||
|
microdelay(10);
|
||||||
|
decref(&bar2);
|
||||||
*op = nil;
|
*op = nil;
|
||||||
_xdec(&bar1);
|
|
||||||
while(bar1 > 0)
|
|
||||||
microdelay(10);
|
|
||||||
_xdec(&bar2);
|
|
||||||
wakeup(&oprend);
|
wakeup(&oprend);
|
||||||
splx(s);
|
splx(s);
|
||||||
}
|
}
|
||||||
|
@ -288,6 +288,10 @@ mtrr(uvlong base, uvlong size, char *tstr)
|
||||||
}
|
}
|
||||||
|
|
||||||
qlock(&mtrrlk);
|
qlock(&mtrrlk);
|
||||||
|
if(waserror()){
|
||||||
|
qunlock(&mtrrlk);
|
||||||
|
nexterror();
|
||||||
|
}
|
||||||
slot = -1;
|
slot = -1;
|
||||||
vcnt = cap & Capvcnt;
|
vcnt = cap & Capvcnt;
|
||||||
if(vcnt > Nmtrr)
|
if(vcnt > Nmtrr)
|
||||||
|
@ -305,14 +309,16 @@ mtrr(uvlong base, uvlong size, char *tstr)
|
||||||
if(slot == -1)
|
if(slot == -1)
|
||||||
error("no free mtrr slots");
|
error("no free mtrr slots");
|
||||||
|
|
||||||
while(postedop != nil)
|
while(!opavail(0))
|
||||||
sleep(&oprend, opavail, 0);
|
sleep(&oprend, opavail, 0);
|
||||||
|
|
||||||
mtrrenc(&entry, base, size, type, 1);
|
mtrrenc(&entry, base, size, type, 1);
|
||||||
op.reg = &entry;
|
op.reg = &entry;
|
||||||
op.slot = slot;
|
op.slot = slot;
|
||||||
postedop = &op;
|
postedop = &op;
|
||||||
mtrrop(&postedop);
|
mtrrop(&postedop);
|
||||||
qunlock(&mtrrlk);
|
qunlock(&mtrrlk);
|
||||||
|
poperror();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue