From b0e8a2af1f722c2ac2c13de4daeec09b9891e402 Mon Sep 17 00:00:00 2001 From: bde Date: Fri, 28 Dec 2001 18:08:10 +0000 Subject: Fixed locking bugs in rev.1.346: (1) Don't attempt aquire the non-recursive lock sio_lock recursively. Doing so caused unbounded recursion in some setups. E.g., if DDB, BREAK_TO_DEBUGGER and WITNESS are configured; if the debugger is entered using a break, then WITNESS will actually detect the invalid recursion and will add to it attempting to print a message about it. (2) Don't use sio_lock before it has been initialized. The old check (sio_inited != 0) didn't work when sio_inited was boolean because sio_inited was set too early, and became just wrong when sio_inited was changed to a tri-state variable in rev.1.348. Reported and fixed in another way by: fenner (1) --- sys/dev/sio/sio.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'sys/dev') diff --git a/sys/dev/sio/sio.c b/sys/dev/sio/sio.c index 5133064..76eade6 100644 --- a/sys/dev/sio/sio.c +++ b/sys/dev/sio/sio.c @@ -3092,6 +3092,7 @@ siocnputc(dev, c) dev_t dev; int c; { + int need_unlock; int s; struct siocnstate sp; Port_t iobase; @@ -3101,13 +3102,16 @@ siocnputc(dev, c) else iobase = siocniobase; s = spltty(); - if (sio_inited) + need_unlock = 0; + if (sio_inited == 2 && !mtx_owned(&sio_lock)) { mtx_lock_spin(&sio_lock); + need_unlock = 1; + } siocnopen(&sp, iobase, comdefaultrate); siocntxwait(iobase); outb(iobase + com_data, c); siocnclose(&sp, iobase); - if (sio_inited) + if (need_unlock) mtx_unlock_spin(&sio_lock); splx(s); } -- cgit v1.1