From owner-svn-src-all@freebsd.org Sat Oct 27 20:22:43 2018 Return-Path: Delivered-To: svn-src-all@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 5D15710D2588; Sat, 27 Oct 2018 20:22:43 +0000 (UTC) (envelope-from wulf@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 10C6879B77; Sat, 27 Oct 2018 20:22:43 +0000 (UTC) (envelope-from wulf@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 E5D62152F0; Sat, 27 Oct 2018 20:22:42 +0000 (UTC) (envelope-from wulf@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w9RKMgj2023578; Sat, 27 Oct 2018 20:22:42 GMT (envelope-from wulf@FreeBSD.org) Received: (from wulf@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w9RKMgOZ023575; Sat, 27 Oct 2018 20:22:42 GMT (envelope-from wulf@FreeBSD.org) Message-Id: <201810272022.w9RKMgOZ023575@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: wulf set sender to wulf@FreeBSD.org using -f From: Vladimir Kondratyev Date: Sat, 27 Oct 2018 20:22:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r339823 - in head/sys/dev: atkbdc evdev kbdmux usb/input X-SVN-Group: head X-SVN-Commit-Author: wulf X-SVN-Commit-Paths: in head/sys/dev: atkbdc evdev kbdmux usb/input X-SVN-Commit-Revision: 339823 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 27 Oct 2018 20:22:43 -0000 Author: wulf Date: Sat Oct 27 20:22:41 2018 New Revision: 339823 URL: https://svnweb.freebsd.org/changeset/base/339823 Log: evdev: Use console lock as evdev lock for all supported keyboard drivers. Now evdev part of keyboard drivers does not take any locks if corresponding input/eventN device node is not opened by userland consumers. Do not assert console lock inside evdev to handle the cases when keyboard driver is called from some special single-threaded context like shutdown thread. Modified: head/sys/dev/atkbdc/atkbd.c head/sys/dev/evdev/evdev_private.h head/sys/dev/kbdmux/kbdmux.c head/sys/dev/usb/input/ukbd.c Modified: head/sys/dev/atkbdc/atkbd.c ============================================================================== --- head/sys/dev/atkbdc/atkbd.c Sat Oct 27 20:17:57 2018 (r339822) +++ head/sys/dev/atkbdc/atkbd.c Sat Oct 27 20:22:41 2018 (r339823) @@ -484,7 +484,7 @@ atkbd_init(int unit, keyboard_t **kbdp, void *arg, int evdev_support_led(evdev, LED_CAPSL); evdev_support_led(evdev, LED_SCROLLL); - if (evdev_register(evdev)) + if (evdev_register_mtx(evdev, &Giant)) evdev_free(evdev); else state->ks_evdev = evdev; Modified: head/sys/dev/evdev/evdev_private.h ============================================================================== --- head/sys/dev/evdev/evdev_private.h Sat Oct 27 20:17:57 2018 (r339822) +++ head/sys/dev/evdev/evdev_private.h Sat Oct 27 20:22:41 2018 (r339823) @@ -132,9 +132,14 @@ struct evdev_dev LIST_HEAD(, evdev_client) ev_clients; }; +#define SYSTEM_CONSOLE_LOCK &Giant + #define EVDEV_LOCK(evdev) mtx_lock((evdev)->ev_lock) #define EVDEV_UNLOCK(evdev) mtx_unlock((evdev)->ev_lock) -#define EVDEV_LOCK_ASSERT(evdev) mtx_assert((evdev)->ev_lock, MA_OWNED) +#define EVDEV_LOCK_ASSERT(evdev) do { \ + if ((evdev)->ev_lock != SYSTEM_CONSOLE_LOCK) \ + mtx_assert((evdev)->ev_lock, MA_OWNED); \ +} while (0) #define EVDEV_ENTER(evdev) do { \ if ((evdev)->ev_lock_type == EV_LOCK_INTERNAL) \ EVDEV_LOCK(evdev); \ Modified: head/sys/dev/kbdmux/kbdmux.c ============================================================================== --- head/sys/dev/kbdmux/kbdmux.c Sat Oct 27 20:17:57 2018 (r339822) +++ head/sys/dev/kbdmux/kbdmux.c Sat Oct 27 20:22:41 2018 (r339823) @@ -505,7 +505,7 @@ kbdmux_init(int unit, keyboard_t **kbdp, void *arg, in evdev_support_led(evdev, LED_CAPSL); evdev_support_led(evdev, LED_SCROLLL); - if (evdev_register(evdev)) + if (evdev_register_mtx(evdev, &Giant)) evdev_free(evdev); else state->ks_evdev = evdev; Modified: head/sys/dev/usb/input/ukbd.c ============================================================================== --- head/sys/dev/usb/input/ukbd.c Sat Oct 27 20:17:57 2018 (r339822) +++ head/sys/dev/usb/input/ukbd.c Sat Oct 27 20:22:41 2018 (r339823) @@ -1361,7 +1361,7 @@ ukbd_attach(device_t dev) if (sc->sc_flags & UKBD_FLAG_SCROLLLOCK) evdev_support_led(evdev, LED_SCROLLL); - if (evdev_register(evdev)) + if (evdev_register_mtx(evdev, &Giant)) evdev_free(evdev); else sc->sc_evdev = evdev;