diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2014-06-08 01:33:15 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2014-06-08 01:33:15 +0200 |
commit | 0a2b418535915c6954fa9df575d71fb04171bb34 (patch) | |
tree | b00aa9f7bfe93db4e321852a279387712c225356 /sys/src | |
parent | ce38380b8f3c31597487b3ada9ed027f6a54adbd (diff) |
pc, pc64: fix missed qunlock, use Ref with incref()/decref() instead of _xinc()/_xdec()
Diffstat (limited to 'sys/src')
-rw-r--r-- | sys/src/9/pc/mtrr.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/sys/src/9/pc/mtrr.c b/sys/src/9/pc/mtrr.c index 1d5901693..1a2715c53 100644 --- a/sys/src/9/pc/mtrr.c +++ b/sys/src/9/pc/mtrr.c @@ -186,7 +186,7 @@ mtrrop(Mtrrop **op) int s; ulong cr0, cr4; vlong def; - static long bar1, bar2; + static Ref bar1, bar2; 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 * done at roughly the same time on all processors. */ - _xinc(&bar1); - while(bar1 < conf.nmach) + incref(&bar1); + while(bar1.ref < conf.nmach) microdelay(10); cr4 = getcr4(); @@ -218,14 +218,14 @@ mtrrop(Mtrrop **op) * wait for all CPUs to sync up again, so that we don't continue * executing while the MTRRs are still being set up. */ - _xinc(&bar2); - while(bar2 < conf.nmach) + incref(&bar2); + while(bar2.ref < conf.nmach) microdelay(10); - *op = nil; - _xdec(&bar1); - while(bar1 > 0) + decref(&bar1); + while(bar1.ref > 0) microdelay(10); - _xdec(&bar2); + decref(&bar2); + *op = nil; wakeup(&oprend); splx(s); } @@ -288,6 +288,10 @@ mtrr(uvlong base, uvlong size, char *tstr) } qlock(&mtrrlk); + if(waserror()){ + qunlock(&mtrrlk); + nexterror(); + } slot = -1; vcnt = cap & Capvcnt; if(vcnt > Nmtrr) @@ -305,14 +309,16 @@ mtrr(uvlong base, uvlong size, char *tstr) if(slot == -1) error("no free mtrr slots"); - while(postedop != nil) + while(!opavail(0)) sleep(&oprend, opavail, 0); + mtrrenc(&entry, base, size, type, 1); op.reg = &entry; op.slot = slot; postedop = &op; mtrrop(&postedop); qunlock(&mtrrlk); + poperror(); return 0; } |