From 59b3f471f6c4ef91e64ad28e6e88ae6c6bf79fec Mon Sep 17 00:00:00 2001 From: yokota Date: Sat, 22 Jul 2000 04:08:12 +0000 Subject: [PATCH] This is yet another attempt to fix "psmintr out of sync.." problems. - Properly protect the watchdog timer routine. - Relocate the sync check statement so that we don't see too many error messages. --- sys/dev/atkbdc/psm.c | 22 +++++++++------------- sys/isa/psm.c | 22 +++++++++------------- 2 files changed, 18 insertions(+), 26 deletions(-) diff --git a/sys/dev/atkbdc/psm.c b/sys/dev/atkbdc/psm.c index bcc8a870766e..b3433c9ec44b 100644 --- a/sys/dev/atkbdc/psm.c +++ b/sys/dev/atkbdc/psm.c @@ -1830,10 +1830,11 @@ psmtimeout(void *arg) unit = (int)arg; sc = devclass_get_softc(psm_devclass, unit); - if (sc->watchdog) { + if (sc->watchdog && kbdc_lock(sc->kbdc, TRUE)) { if (verbose >= 4) log(LOG_DEBUG, "psm%d: lost interrupt?\n", unit); psmintr(sc); + kbdc_lock(sc->kbdc, FALSE); } sc->watchdog = TRUE; sc->callout = timeout(psmtimeout, (void *)unit, hz); @@ -1880,18 +1881,6 @@ psmintr(void *arg) if ((sc->state & PSM_OPEN) == 0) continue; - /* - * Check sync bits. We check for overflow bits and the bit 3 - * for most mice. True, the code doesn't work if overflow - * condition occurs. But we expect it rarely happens... - */ - if ((sc->inputbytes == 0) - && ((c & sc->mode.syncmask[0]) != sc->mode.syncmask[1])) { - log(LOG_DEBUG, "psmintr: out of sync (%04x != %04x).\n", - c & sc->mode.syncmask[0], sc->mode.syncmask[1]); - continue; - } - sc->ipacket[sc->inputbytes++] = c; if (sc->inputbytes < sc->mode.packetsize) continue; @@ -1904,6 +1893,13 @@ psmintr(void *arg) c = sc->ipacket[0]; + if ((c & sc->mode.syncmask[0]) != sc->mode.syncmask[1]) { + log(LOG_DEBUG, "psmintr: out of sync (%04x != %04x).\n", + c & sc->mode.syncmask[0], sc->mode.syncmask[1]); + sc->inputbytes = 0; + continue; + } + /* * A kludge for Kensington device! * The MSB of the horizontal count appears to be stored in diff --git a/sys/isa/psm.c b/sys/isa/psm.c index bcc8a870766e..b3433c9ec44b 100644 --- a/sys/isa/psm.c +++ b/sys/isa/psm.c @@ -1830,10 +1830,11 @@ psmtimeout(void *arg) unit = (int)arg; sc = devclass_get_softc(psm_devclass, unit); - if (sc->watchdog) { + if (sc->watchdog && kbdc_lock(sc->kbdc, TRUE)) { if (verbose >= 4) log(LOG_DEBUG, "psm%d: lost interrupt?\n", unit); psmintr(sc); + kbdc_lock(sc->kbdc, FALSE); } sc->watchdog = TRUE; sc->callout = timeout(psmtimeout, (void *)unit, hz); @@ -1880,18 +1881,6 @@ psmintr(void *arg) if ((sc->state & PSM_OPEN) == 0) continue; - /* - * Check sync bits. We check for overflow bits and the bit 3 - * for most mice. True, the code doesn't work if overflow - * condition occurs. But we expect it rarely happens... - */ - if ((sc->inputbytes == 0) - && ((c & sc->mode.syncmask[0]) != sc->mode.syncmask[1])) { - log(LOG_DEBUG, "psmintr: out of sync (%04x != %04x).\n", - c & sc->mode.syncmask[0], sc->mode.syncmask[1]); - continue; - } - sc->ipacket[sc->inputbytes++] = c; if (sc->inputbytes < sc->mode.packetsize) continue; @@ -1904,6 +1893,13 @@ psmintr(void *arg) c = sc->ipacket[0]; + if ((c & sc->mode.syncmask[0]) != sc->mode.syncmask[1]) { + log(LOG_DEBUG, "psmintr: out of sync (%04x != %04x).\n", + c & sc->mode.syncmask[0], sc->mode.syncmask[1]); + sc->inputbytes = 0; + continue; + } + /* * A kludge for Kensington device! * The MSB of the horizontal count appears to be stored in