From 202f4eece1c4620798a768857dd94e475d44a899 Mon Sep 17 00:00:00 2001 From: peter Date: Mon, 22 Sep 2003 21:56:48 +0000 Subject: MFi386: machdep.c:1.570 clock.c:1.204 by bde: Quick fix for calling DELAY for ddb input in some atkbd-based console drivers. ddb must not use any normal locks but DELAY() normally calls getit() which needs clock_lock. This also removes the need for recursion on clock_lock. --- sys/amd64/amd64/machdep.c | 2 +- sys/amd64/isa/clock.c | 20 ++++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c index 86fff6c..1f5948b 100644 --- a/sys/amd64/amd64/machdep.c +++ b/sys/amd64/amd64/machdep.c @@ -1166,7 +1166,7 @@ hammer_time(u_int64_t modulep, u_int64_t physfree) * under witness. */ mutex_init(); - mtx_init(&clock_lock, "clk", NULL, MTX_SPIN | MTX_RECURSE); + mtx_init(&clock_lock, "clk", NULL, MTX_SPIN); mtx_init(&icu_lock, "icu", NULL, MTX_SPIN | MTX_NOWITNESS); /* exceptions */ diff --git a/sys/amd64/isa/clock.c b/sys/amd64/isa/clock.c index 2ed1544..c88e488 100644 --- a/sys/amd64/isa/clock.c +++ b/sys/amd64/isa/clock.c @@ -413,8 +413,18 @@ DELAY(int n) * takes about 1.5 usec for each of the i/o's in getit(). The loop * takes about 6 usec on a 486/33 and 13 usec on a 386/20. The * multiplications and divisions to scale the count take a while). + * + * However, if ddb is active then use a fake counter since reading + * the i8254 counter involves acquiring a lock. ddb must not go + * locking for many reasons, but it calls here for at least atkbd + * input. */ - prev_tick = getit(); +#ifdef DDB + if (db_active) + prev_tick = 0; + else +#endif + prev_tick = getit(); n -= 0; /* XXX actually guess no initial overhead */ /* * Calculate (n * (timer_freq / 1e6)) without using floating point @@ -441,7 +451,13 @@ DELAY(int n) / 1000000; while (ticks_left > 0) { - tick = getit(); +#ifdef DDB + if (db_active) { + inb(0x84); + tick = prev_tick + 1; + } else +#endif + tick = getit(); #ifdef DELAYDEBUG ++getit_calls; #endif -- cgit v1.1