Date: Thu, 2 Oct 2025 16:42:01 GMT From: Ed Maste <emaste@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 2acabc7318ac - stable/14 - hkbd: remove error detection in KDSKBSTATE ioctl Message-ID: <202510021642.592Gg18C003654@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/14 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=2acabc7318ac47401e078de28e7b89a38b356cb9 commit 2acabc7318ac47401e078de28e7b89a38b356cb9 Author: ShengYi Hung <aokblast@FreeBSD.org> AuthorDate: 2025-08-21 17:59:15 +0000 Commit: Ed Maste <emaste@FreeBSD.org> CommitDate: 2025-10-02 16:41:17 +0000 hkbd: remove error detection in KDSKBSTATE ioctl The KDSKBSTATE ioctl brings the LED up. However, some keyboards (like qemu keyboard) may not have LED or failed to set the LED due to unexpected reason. Therefore, removing the error check as ukbd(4) does allow the keyboard works correctly with kbdcontrol(4). Also move hw.hid.hkbd.no_leds sysctl out of HID_BUG thus users can disable setting LEDs PR: 288968 Reviewed by: wulf Tested by: trashcan@ellael.org, marklmi26-fbsd@yahoo.com, trkellers@gmail.coom Approved by: lwsu (mentor), markj (mentor) MFC after 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D52101 (cherry picked from commit 1685192ea1faac28f2d4feede53e70b6a380500f) (cherry picked from commit 6ea7e1f92882706cc8818a13e8bd55b7d2f48e27) --- sys/dev/hid/hkbd.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/sys/dev/hid/hkbd.c b/sys/dev/hid/hkbd.c index 5eff7557bc42..6255c42d3b62 100644 --- a/sys/dev/hid/hkbd.c +++ b/sys/dev/hid/hkbd.c @@ -95,14 +95,16 @@ #ifdef HID_DEBUG static int hkbd_debug = 0; +#endif static int hkbd_no_leds = 0; static SYSCTL_NODE(_hw_hid, OID_AUTO, hkbd, CTLFLAG_RW, 0, "USB keyboard"); +#ifdef HID_DEBUG SYSCTL_INT(_hw_hid_hkbd, OID_AUTO, debug, CTLFLAG_RWTUN, &hkbd_debug, 0, "Debug level"); +#endif SYSCTL_INT(_hw_hid_hkbd, OID_AUTO, no_leds, CTLFLAG_RWTUN, &hkbd_no_leds, 0, "Disables setting of keyboard leds"); -#endif #define INPUT_EPOCH global_epoch_preempt @@ -1596,8 +1598,16 @@ hkbd_ioctl_locked(keyboard_t *kbd, u_long cmd, caddr_t arg) sc->sc_state &= ~LOCK_MASK; sc->sc_state |= *(int *)arg; - /* set LEDs and quit */ - return (hkbd_ioctl_locked(kbd, KDSETLED, arg)); + /* + * Attempt to set the keyboard LEDs; ignore the return value + * intentionally. Note: Some hypervisors/emulators (e.g., QEMU, + * Parallels—at least as of the time of writing) may fail when + * setting LEDs. This can prevent kbdmux from attaching the + * keyboard, which in turn may block the console from accessing + * it. + */ + (void)hkbd_ioctl_locked(kbd, KDSETLED, arg); + return (0); case KDSETREPEAT: /* set keyboard repeat rate (new * interface) */ @@ -1766,10 +1776,8 @@ hkbd_set_leds(struct hkbd_softc *sc, uint8_t leds) SYSCONS_LOCK_ASSERT(); DPRINTF("leds=0x%02x\n", leds); -#ifdef HID_DEBUG if (hkbd_no_leds) return (0); -#endif memset(sc->sc_buffer, 0, HKBD_BUFFER_SIZE); @@ -1820,6 +1828,7 @@ hkbd_set_leds(struct hkbd_softc *sc, uint8_t leds) SYSCONS_UNLOCK(); error = hid_write(sc->sc_dev, buf, len); SYSCONS_LOCK(); + DPRINTF("error %d", error); return (error); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202510021642.592Gg18C003654>