From owner-svn-src-stable@freebsd.org Wed Mar 14 07:11:34 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 69748F5AE72; Wed, 14 Mar 2018 07:11:34 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 17A46711FA; Wed, 14 Mar 2018 07:11:34 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EC75C24D2D; Wed, 14 Mar 2018 07:11:33 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w2E7BXDU055371; Wed, 14 Mar 2018 07:11:33 GMT (envelope-from eadler@FreeBSD.org) Received: (from eadler@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w2E7BXYO055370; Wed, 14 Mar 2018 07:11:33 GMT (envelope-from eadler@FreeBSD.org) Message-Id: <201803140711.w2E7BXYO055370@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: eadler set sender to eadler@FreeBSD.org using -f From: Eitan Adler Date: Wed, 14 Mar 2018 07:11:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r330911 - stable/11/sys/dev/kbdmux X-SVN-Group: stable-11 X-SVN-Commit-Author: eadler X-SVN-Commit-Paths: stable/11/sys/dev/kbdmux X-SVN-Commit-Revision: 330911 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 Mar 2018 07:11:34 -0000 Author: eadler Date: Wed Mar 14 07:11:33 2018 New Revision: 330911 URL: https://svnweb.freebsd.org/changeset/base/330911 Log: MFC r305060: Fix keyboard polling "on/off" to support recursion. vt depends on this, and sc will soon depend on it again. The on/off request is passed without modification to lower layers, so the bug was smaller in this layer than in in lower layers (the sequence on;on;off left polling off when it should be on, but the sequence on;on;off;on;off... doesn't allow the interrupt handler to eat the input after an "off" that should't turn off polled mode, provided lower layers don't have the bug, since this layer is virtual. The bug was small in lower layers too. Normally everything is Giant locked for keyboards, and this locks out the interrupt handler in on;on;off;on;off... sequences. However, PR 211884 says that fixing this bug in ukbd in r303765 apparently causes the eating-by-interrupt behaviour that the fix is to prevent. Modified: stable/11/sys/dev/kbdmux/kbdmux.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/kbdmux/kbdmux.c ============================================================================== --- stable/11/sys/dev/kbdmux/kbdmux.c Wed Mar 14 07:08:46 2018 (r330910) +++ stable/11/sys/dev/kbdmux/kbdmux.c Wed Mar 14 07:11:33 2018 (r330911) @@ -158,9 +158,9 @@ struct kbdmux_state int ks_flags; /* flags */ #define COMPOSE (1 << 0) /* compose char flag */ -#define POLLING (1 << 1) /* polling */ #define TASK (1 << 2) /* interrupt task queued */ + int ks_polling; /* poll nesting count */ int ks_mode; /* K_XLATE, K_RAW, K_CODE */ int ks_state; /* state */ int ks_accents; /* accent key index (> 0) */ @@ -717,7 +717,7 @@ next_code: /* see if there is something in the keyboard queue */ scancode = kbdmux_kbd_getc(state); if (scancode == -1) { - if (state->ks_flags & POLLING) { + if (state->ks_polling != 0) { kbdmux_kbd_t *k; SLIST_FOREACH(k, &state->ks_kbds, next) { @@ -1317,7 +1317,8 @@ kbdmux_clear_state_locked(kbdmux_state_t *state) { KBDMUX_LOCK_ASSERT(state, MA_OWNED); - state->ks_flags &= ~(COMPOSE|POLLING); + state->ks_flags &= ~COMPOSE; + state->ks_polling = 0; state->ks_state &= LOCK_MASK; /* preserve locking key state */ state->ks_accents = 0; state->ks_composed_char = 0; @@ -1377,9 +1378,9 @@ kbdmux_poll(keyboard_t *kbd, int on) KBDMUX_LOCK(state); if (on) - state->ks_flags |= POLLING; + state->ks_polling++; else - state->ks_flags &= ~POLLING; + state->ks_polling--; /* set poll on slave keyboards */ SLIST_FOREACH(k, &state->ks_kbds, next)