The branch main has been updated by aokblast:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=1685192ea1faac28f2d4feede53e70b6a380500f

commit 1685192ea1faac28f2d4feede53e70b6a380500f
Author:     ShengYi Hung <aokbl...@freebsd.org>
AuthorDate: 2025-08-21 17:59:15 +0000
Commit:     ShengYi Hung <aokbl...@freebsd.org>
CommitDate: 2025-08-23 04:50:09 +0000

    hkbd: remove erorr 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:      trash...@ellael.org, marklmi26-f...@yahoo.com, 
trkell...@gmail.coom
    Approved by:    lwsu (mentor), markj (mentor)
    MFC after       1 week
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D52101
    
    mvalsmva
---
 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..86a2320092be 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);
 }

Reply via email to