diff --git a/share/man/man4/atkbdc.4 b/share/man/man4/atkbdc.4 index 48067c98a5be8..5ef1b022aacee 100644 --- a/share/man/man4/atkbdc.4 +++ b/share/man/man4/atkbdc.4 @@ -24,7 +24,7 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd February 26, 2023 +.Dd August 29, 2025 .Dt ATKBDC 4 .Os .Sh NAME @@ -36,12 +36,17 @@ .Cd "options KBD_DELAY1=N" .Cd "options KBD_DELAY2=N" .Cd "options KBDIO_DEBUG=N" +.Cd "options RESET_DELAY_DIVISION_FACTOR=N" .Cd "device atkbdc" .Pp In .Pa /boot/device.hints : .Cd hint.atkbdc.0.at="isa" .Cd hint.atkbdc.0.port="0x060" +.Pp +In +.Pa /boot/loader.conf : +.Cd hw.atkbd.short_delay .Sh DESCRIPTION The keyboard controller .Nm @@ -101,6 +106,21 @@ The default value is 100ms. Sets the debug level to .Fa N . The default value is zero, which suppresses all debugging output. +.It Em RESET_DELAY_DIVISION_FACTOR=N +The default value is 40. It is suppose to divide original 200ms delay by 40 and result 5ms delay for modern hardware. +.El +.Ss Tunables +The following tunable can be set at the +.Xr loader 8 +prompt or in +.Pa /boot/loader.conf : +.Bl -tag -width indent +.It Va hw.atkbd.short_delay +The default value is one, which enables shorter delays during controller +initialization. Setting this to zero restores the original, longer delays. +Using shorter delays can significantly improve boot time on modern +systems, but may cause problems on some legacy hardware that requires +longer timing for reliable operation. .El .\".Ss Driver Flags .\".Sh FILES @@ -124,3 +144,5 @@ The kbdio module, the .Nm driver and this manual page were written by .An Kazutaka Yokota Aq Mt yokota@FreeBSD.org . +Then updated by +.An Lahiru Gunathilake Aq Mt bllgg@FreeBSD.org . diff --git a/stand/libsa/zfs/zfsimpl.c b/stand/libsa/zfs/zfsimpl.c index f15d9b016068e..b1dc3c7617ef8 100644 --- a/stand/libsa/zfs/zfsimpl.c +++ b/stand/libsa/zfs/zfsimpl.c @@ -34,6 +34,8 @@ #include #include #include +#include + #include #include "zfsimpl.h" @@ -162,11 +164,14 @@ vdev_indirect_mapping_entry_phys_t * static void zfs_init(void) { + TSENTER(); STAILQ_INIT(&zfs_pools); dnode_cache_buf = malloc(SPA_MAXBLOCKSIZE); zfs_init_crc(); + TSEXIT(); + #ifdef HAS_ZSTD_ZFS zstd_init(); #endif diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c index 3f0a7b40245de..e09bfa70ec2b4 100644 --- a/sys/dev/acpica/acpi.c +++ b/sys/dev/acpica/acpi.c @@ -55,6 +55,7 @@ #include #include #include +#include #if defined(__i386__) || defined(__amd64__) #include @@ -493,6 +494,7 @@ acpi_attach(device_t dev) char *env; enum power_stype stype; + TSENTER(); ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); sc = device_get_softc(dev); @@ -769,7 +771,10 @@ acpi_attach(device_t dev) error = 0; + TSEXIT(); + out: + TSEXIT(); return_VALUE (error); } diff --git a/sys/dev/atkbdc/atkbd.c b/sys/dev/atkbdc/atkbd.c index e046b59803b09..b291f6acc98ab 100644 --- a/sys/dev/atkbdc/atkbd.c +++ b/sys/dev/atkbdc/atkbd.c @@ -384,11 +384,14 @@ atkbd_init(int unit, keyboard_t **kbdp, void *arg, int flags) char phys_loc[8]; #endif + TSENTER(); /* XXX */ if (unit == ATKBD_DEFAULT) { *kbdp = kbd = &default_kbd; - if (KBD_IS_INITIALIZED(kbd) && KBD_IS_CONFIGURED(kbd)) + if (KBD_IS_INITIALIZED(kbd) && KBD_IS_CONFIGURED(kbd)) { + TSEXIT(); return 0; + } state = &default_kbd_state; keymap = &default_keymap; accmap = &default_accentmap; @@ -410,6 +413,7 @@ atkbd_init(int unit, keyboard_t **kbdp, void *arg, int flags) goto bad; } } else if (KBD_IS_INITIALIZED(*kbdp) && KBD_IS_CONFIGURED(*kbdp)) { + TSEXIT(); return 0; } else { kbd = *kbdp; @@ -505,6 +509,7 @@ atkbd_init(int unit, keyboard_t **kbdp, void *arg, int flags) KBD_CONFIG_DONE(kbd); } + TSEXIT(); return 0; bad: if (needfree) { @@ -521,6 +526,8 @@ atkbd_init(int unit, keyboard_t **kbdp, void *arg, int flags) *kbdp = NULL; /* insure ref doesn't leak to caller */ } } + + TSEXIT(); return error; } @@ -948,6 +955,7 @@ atkbd_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg) int ival; #endif + TSENTER(); s = spltty(); switch (cmd) { case KDGKBMODE: /* get keyboard mode */ @@ -978,6 +986,7 @@ atkbd_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg) break; default: splx(s); + TSEXIT(); return EINVAL; } break; @@ -996,6 +1005,7 @@ atkbd_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg) /* NOTE: lock key state in ks_state won't be changed */ if (*(int *)arg & ~LOCK_MASK) { splx(s); + TSEXIT(); return EINVAL; } i = *(int *)arg; @@ -1012,6 +1022,7 @@ atkbd_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg) ledmap[i & LED_MASK]); if (error) { splx(s); + TSEXIT(); return error; } } @@ -1037,18 +1048,23 @@ atkbd_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg) case KDSKBSTATE: /* set lock key state */ if (*(int *)arg & ~LOCK_MASK) { splx(s); + TSEXIT(); return EINVAL; } state->ks_state &= ~LOCK_MASK; state->ks_state |= *(int *)arg; splx(s); + + TSEXIT(); /* set LEDs and quit */ return atkbd_ioctl(kbd, KDSETLED, arg); case KDSETREPEAT: /* set keyboard repeat rate (new interface) */ splx(s); - if (!KBD_HAS_DEVICE(kbd)) + if (!KBD_HAS_DEVICE(kbd)) { + TSEXIT(); return 0; + } i = typematic(((int *)arg)[0], ((int *)arg)[1]); error = write_kbd(state->kbdc, KBDC_SET_TYPEMATIC, i); if (error == 0) { @@ -1060,6 +1076,7 @@ atkbd_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg) evdev_push_repeats(state->ks_evdev, kbd); #endif } + TSEXIT(); return error; #if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \ @@ -1071,8 +1088,10 @@ atkbd_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg) #endif case KDSETRAD: /* set keyboard repeat rate (old interface) */ splx(s); - if (!KBD_HAS_DEVICE(kbd)) + if (!KBD_HAS_DEVICE(kbd)) { + TSEXIT(); return 0; + } error = write_kbd(state->kbdc, KBDC_SET_TYPEMATIC, *(int *)arg); if (error == 0) { kbd->kb_delay1 = typematic_delay(*(int *)arg); @@ -1083,6 +1102,7 @@ atkbd_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg) evdev_push_repeats(state->ks_evdev, kbd); #endif } + TSEXIT(); return error; case PIO_KEYMAP: /* set keyboard translation table */ @@ -1096,10 +1116,13 @@ atkbd_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg) /* FALLTHROUGH */ default: splx(s); + TSEXIT(); return genkbd_commonioctl(kbd, cmd, arg); } splx(s); + TSEXIT(); + return 0; } @@ -1363,8 +1386,10 @@ init_keyboard(KBDC kbdc, int *type, int flags) int id; int c; + TSENTER(); if (!kbdc_lock(kbdc, TRUE)) { /* driver error? */ + TSEXIT(); return EIO; } @@ -1378,6 +1403,7 @@ init_keyboard(KBDC kbdc, int *type, int flags) /* CONTROLLER ERROR */ kbdc_lock(kbdc, FALSE); printf("atkbd: unable to get the current command byte value.\n"); + TSEXIT(); return EIO; } if (bootverbose) @@ -1393,12 +1419,14 @@ init_keyboard(KBDC kbdc, int *type, int flags) /* CONTROLLER ERROR: there is very little we can do... */ printf("atkbd: unable to set the command byte.\n"); kbdc_lock(kbdc, FALSE); + TSEXIT(); return EIO; } if (HAS_QUIRK(kbdc, KBDC_QUIRK_RESET_AFTER_PROBE) && atkbd_reset(kbdc, flags, c)) { kbdc_lock(kbdc, FALSE); + TSEXIT(); return EIO; } @@ -1449,6 +1477,7 @@ init_keyboard(KBDC kbdc, int *type, int flags) if (!HAS_QUIRK(kbdc, KBDC_QUIRK_RESET_AFTER_PROBE) && atkbd_reset(kbdc, flags, c)) { kbdc_lock(kbdc, FALSE); + TSEXIT(); return EIO; } @@ -1472,6 +1501,7 @@ init_keyboard(KBDC kbdc, int *type, int flags) ? 0xff : KBD_KBD_CONTROL_BITS, c); kbdc_lock(kbdc, FALSE); printf("atkbd: unable to set the XT keyboard mode.\n"); + TSEXIT(); return EIO; } } @@ -1502,10 +1532,12 @@ init_keyboard(KBDC kbdc, int *type, int flags) KBD_OVERRIDE_KBD_LOCK), c); kbdc_lock(kbdc, FALSE); printf("atkbd: unable to enable the keyboard port and intr.\n"); + TSEXIT(); return EIO; } kbdc_lock(kbdc, FALSE); + TSEXIT(); return 0; } diff --git a/sys/dev/atkbdc/atkbd_atkbdc.c b/sys/dev/atkbdc/atkbd_atkbdc.c index d5ef9706d7b9a..995f4d37cc023 100644 --- a/sys/dev/atkbdc/atkbd_atkbdc.c +++ b/sys/dev/atkbdc/atkbd_atkbdc.c @@ -116,24 +116,30 @@ atkbdattach(device_t dev) int rid; int error; + TSENTER(); sc = device_get_softc(dev); rid = KBDC_RID_KBD; irq = bus_get_resource_start(dev, SYS_RES_IRQ, rid); flags = device_get_flags(dev); error = atkbd_attach_unit(dev, &kbd, irq, flags); - if (error) + if (error) { + TSEXIT(); return error; + } /* declare our interrupt handler */ sc->intr = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE); - if (sc->intr == NULL) + if (sc->intr == NULL) { + TSEXIT(); return ENXIO; + } error = bus_setup_intr(dev, sc->intr, INTR_TYPE_TTY, NULL, atkbdintr, kbd, &sc->ih); if (error) bus_release_resource(dev, SYS_RES_IRQ, rid, sc->intr); + TSEXIT(); return error; } diff --git a/sys/dev/atkbdc/atkbdc.c b/sys/dev/atkbdc/atkbdc.c index c23afe3323cfa..b934f210c3cb7 100644 --- a/sys/dev/atkbdc/atkbdc.c +++ b/sys/dev/atkbdc/atkbdc.c @@ -33,16 +33,20 @@ */ #include -#include "opt_kbd.h" - #include #include #include #include #include +#include +#include +#include +#include + #include #include -#include + +#include "opt_kbd.h" #if defined(__amd64__) #include @@ -54,7 +58,13 @@ /* constants */ -#define MAXKBDC 1 /* XXX */ +#define MAXKBDC 1 /* XXX */ +#define MILLISECOND_MULTIPLIER 1000 /* micro second values will be + * multiplied to convert to + * milli seconds */ +#define RESET_DELAY_DIVISION_FACTOR 40 /* keyboard reset delay + * time division factor */ + /* macros */ @@ -77,6 +87,11 @@ #define write_command(k, d) \ (bus_space_write_1((k)->iot, (k)->ioh1, 0, (d))) +#define ATKBD_DELAY(x) (atkbd_short_delay ? (x) : (x) * MILLISECOND_MULTIPLIER) +#define RESET_DELAY(x) \ + (atkbd_short_delay ? (x) * MILLISECOND_MULTIPLIER : \ + (x) * MILLISECOND_MULTIPLIER / RESET_DELAY_DIVISION_FACTOR) + /* local variables */ /* @@ -103,6 +118,21 @@ static int wait_for_kbd_ack(atkbdc_softc_t *kbdc); static int wait_for_aux_data(atkbdc_softc_t *kbdc); static int wait_for_aux_ack(atkbdc_softc_t *kbdc); +static int atkbd_short_delay = 0; /* 1 = short delay (default), 0 = long delay */ + +/* Create hw.atkbd sysctl node (defines _hw_atkbd) */ +SYSCTL_NODE(_hw, OID_AUTO, atkbd, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, + "AT keyboard controller"); + +/* loader tunable: hw.atkbd.short_delay */ +TUNABLE_INT("hw.atkbd.short_delay", &atkbd_short_delay); + +/* sysctl knob: hw.atkbd.short_delay */ +SYSCTL_DECL(_hw_atkbd); +SYSCTL_INT(_hw_atkbd, OID_AUTO, short_delay, CTLFLAG_RWTUN, + &atkbd_short_delay, 0, + "Keyboard delays: 1=fast, 0=slow (default)"); + struct atkbdc_quirks { const char *bios_vendor; const char *maker; @@ -563,6 +593,8 @@ wait_for_aux_ack(struct atkbdc_softc *kbdc) int f; int b; + TSENTER(); + /* CPU will stay inside the loop for 200msec at most */ retry = kbdc->retry * 2; @@ -572,8 +604,10 @@ wait_for_aux_ack(struct atkbdc_softc *kbdc) b = read_data(kbdc); if ((f & KBDS_BUFFER_FULL) == KBDS_AUX_BUFFER_FULL) { if ((b == PSM_ACK) || (b == PSM_RESEND) - || (b == PSM_RESET_FAIL)) + || (b == PSM_RESET_FAIL)) { + TSEXIT(); return b; + } addq(&kbdc->aux, b); } else if ((f & KBDS_BUFFER_FULL) == KBDS_KBD_BUFFER_FULL) { addq(&kbdc->kbd, b); @@ -581,6 +615,7 @@ wait_for_aux_ack(struct atkbdc_softc *kbdc) } DELAY(KBDC_DELAYTIME); } + TSEXIT(); return -1; } @@ -923,6 +958,8 @@ empty_both_buffers(KBDC p, int wait) { int t; int f; + + TSENTER(); int waited = 0; #if KBDIO_DEBUG >= 2 int c1 = 0; @@ -945,17 +982,22 @@ empty_both_buffers(KBDC p, int wait) t -= delta; } - /* - * Some systems (Intel/IBM blades) do not have keyboard devices and - * will thus hang in this procedure. Time out after delta seconds to - * avoid this hang -- the keyboard attach will fail later on. - */ - waited += (delta * 1000); - if (waited == (delta * 1000000)) - return; + /* + * Some systems (Intel/IBM blades) do not have keyboard devices and + * will thus hang in this procedure. Time out after delta seconds to + * avoid this hang -- the keyboard attach will fail later on. + */ + unsigned int effective_delay = ATKBD_DELAY(delta); + waited += effective_delay; + + if (waited == effective_delay * MILLISECOND_MULTIPLIER) { + TSEXIT(); + return; + } + + DELAY(effective_delay); + } - DELAY(delta*1000); - } #if KBDIO_DEBUG >= 2 if ((c1 > 0) || (c2 > 0)) log(LOG_DEBUG, "kbdc: %d:%d char read (empty_both_buffers)\n", c1, c2); @@ -963,6 +1005,7 @@ empty_both_buffers(KBDC p, int wait) emptyq(&p->kbd); emptyq(&p->aux); + TSEXIT(); } /* keyboard and mouse device control */ @@ -974,34 +1017,46 @@ int reset_kbd(KBDC p) { int retry = KBD_MAXRETRY; - int again = KBD_MAXWAIT; int c = KBD_RESEND; /* keep the compiler happy */ + TSENTER(); + while (retry-- > 0) { empty_both_buffers(p, 10); if (!write_kbd_command(p, KBDC_RESET_KBD)) - continue; - emptyq(&p->kbd); + continue; + emptyq(&p->kbd); c = read_controller_data(p); - if (verbose || bootverbose) + if (verbose || bootverbose) log(LOG_DEBUG, "kbdc: RESET_KBD return code:%04x\n", c); if (c == KBD_ACK) /* keyboard has agreed to reset itself... */ - break; + break; } - if (retry < 0) + if (retry < 0) { + TSEXIT(); return FALSE; + } - while (again-- > 0) { + int delay_us = RESET_DELAY(KBD_RESETDELAY); /* if the atkbd_short_delay is + * activated, + * the delay will be shorten */ + int max_wait_us = KBD_RESETDELAY * MILLISECOND_MULTIPLIER * KBD_MAXWAIT; + int attempts = max_wait_us / delay_us; + + while (attempts-- > 0) { /* wait awhile, well, in fact we must wait quite loooooooooooong */ - DELAY(KBD_RESETDELAY*1000); + DELAY(delay_us); c = read_controller_data(p); /* RESET_DONE/RESET_FAIL */ if (c != -1) /* wait again if the controller is not ready */ break; } if (verbose || bootverbose) log(LOG_DEBUG, "kbdc: RESET_KBD status:%04x\n", c); - if (c != KBD_RESET_DONE) + if (c != KBD_RESET_DONE) { + TSEXIT(); return FALSE; + } + TSEXIT(); return TRUE; } @@ -1015,6 +1070,7 @@ reset_aux_dev(KBDC p) int again = KBD_MAXWAIT; int c = PSM_RESEND; /* keep the compiler happy */ + TSENTER(); while (retry-- > 0) { empty_both_buffers(p, 10); if (!write_aux_command(p, PSMC_RESET_DEV)) @@ -1022,7 +1078,7 @@ reset_aux_dev(KBDC p) emptyq(&p->aux); /* NOTE: Compaq Armada laptops require extra delay here. XXX */ for (again = KBD_MAXWAIT; again > 0; --again) { - DELAY(KBD_RESETDELAY*1000); + DELAY(ATKBD_DELAY(KBD_RESETDELAY)); c = read_aux_data_no_wait(p); if (c != -1) break; @@ -1032,25 +1088,31 @@ reset_aux_dev(KBDC p) if (c == PSM_ACK) /* aux dev is about to reset... */ break; } - if (retry < 0) + if (retry < 0) { + TSEXIT(); return FALSE; + } for (again = KBD_MAXWAIT; again > 0; --again) { /* wait awhile, well, quite looooooooooooong */ - DELAY(KBD_RESETDELAY*1000); + DELAY(ATKBD_DELAY(KBD_RESETDELAY)); c = read_aux_data_no_wait(p); /* RESET_DONE/RESET_FAIL */ if (c != -1) /* wait again if the controller is not ready */ break; } if (verbose || bootverbose) log(LOG_DEBUG, "kbdc: RESET_AUX status:%04x\n", c); - if (c != PSM_RESET_DONE) /* reset status */ + if (c != PSM_RESET_DONE) { /* reset status */ + TSEXIT(); return FALSE; + } c = read_aux_data(p); /* device ID */ if (verbose || bootverbose) log(LOG_DEBUG, "kbdc: RESET_AUX ID:%04x\n", c); /* NOTE: we could check the device ID now, but leave it later... */ + + TSEXIT(); return TRUE; } @@ -1060,7 +1122,6 @@ int test_controller(KBDC p) { int retry = KBD_MAXRETRY; - int again = KBD_MAXWAIT; int c = KBD_DIAG_FAIL; while (retry-- > 0) { @@ -1072,9 +1133,14 @@ test_controller(KBDC p) return FALSE; emptyq(&p->kbd); - while (again-- > 0) { + + int delay_us = RESET_DELAY(KBD_RESETDELAY); + int max_wait_us = KBD_RESETDELAY * MILLISECOND_MULTIPLIER * KBD_MAXWAIT; + int attempts = max_wait_us / delay_us; + + while (attempts-- > 0) { /* wait awhile */ - DELAY(KBD_RESETDELAY*1000); + DELAY(delay_us); c = read_controller_data(p); /* DIAG_DONE/DIAG_FAIL */ if (c != -1) /* wait again if the controller is not ready */ break; diff --git a/sys/dev/atkbdc/psm.c b/sys/dev/atkbdc/psm.c index 8563b5f93aa2e..e25b3b3adfc2b 100644 --- a/sys/dev/atkbdc/psm.c +++ b/sys/dev/atkbdc/psm.c @@ -82,9 +82,10 @@ #include #include #include - #include #include +#include + #include #ifdef DEV_ISA @@ -1383,21 +1384,24 @@ psmprobe(device_t dev) #if 0 kbdc_debug(TRUE); #endif - + TSENTER(); /* see if IRQ is available */ rid = KBDC_RID_AUX; sc->intr = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE); if (sc->intr == NULL) { if (bootverbose) device_printf(dev, "unable to allocate IRQ\n"); + TSEXIT(); return (ENXIO); } bus_release_resource(dev, SYS_RES_IRQ, rid, sc->intr); sc->dev = dev; sc->kbdc = atkbdc_open(device_get_unit(device_get_parent(dev))); - if (sc->kbdc == NULL) + if (sc->kbdc == NULL) { + TSEXIT(); return (ENXIO); + } sc->config = device_get_flags(dev) & PSM_CONFIG_FLAGS; /* XXX: for backward compatibility */ #if defined(PSM_HOOKRESUME) || defined(PSM_HOOKAPM) @@ -1419,6 +1423,7 @@ psmprobe(device_t dev) device_printf(dev, "unable to lock the controller.\n"); if (bootverbose) --verbose; + TSEXIT(); return (ENXIO); } @@ -1680,6 +1685,8 @@ psmprobe(device_t dev) /* done */ kbdc_set_device_mask(sc->kbdc, mask | KBD_AUX_CONTROL_BITS); kbdc_lock(sc->kbdc, FALSE); + + TSEXIT(); return (0); } @@ -7626,14 +7633,17 @@ psmcpnp_probe(device_t dev) u_long irq; int rid; + TSENTER(); if (ISA_PNP_PROBE(device_get_parent(dev), dev, forcepad_ids) == 0) sc->type = PSMCPNP_FORCEPAD; else if (ISA_PNP_PROBE(device_get_parent(dev), dev, topbtpad_ids) == 0) sc->type = PSMCPNP_TOPBUTTONPAD; else if (ISA_PNP_PROBE(device_get_parent(dev), dev, psmcpnp_ids) == 0) sc->type = PSMCPNP_GENERIC; - else + else { + TSEXIT(); return (ENXIO); + } /* * The PnP BIOS and ACPI are supposed to assign an IRQ (12) @@ -7659,6 +7669,7 @@ psmcpnp_probe(device_t dev) if (!bootverbose) device_quiet(dev); + TSEXIT(); return ((res == NULL) ? ENXIO : 0); } @@ -7667,12 +7678,14 @@ psmcpnp_attach(device_t dev) { device_t atkbdc; + TSENTER(); /* find the keyboard controller, which may be on acpi* or isa* bus */ atkbdc = devclass_get_device(devclass_find(ATKBDC_DRIVER_NAME), device_get_unit(dev)); if ((atkbdc != NULL) && (device_get_state(atkbdc) == DS_ATTACHED)) create_a_copy(atkbdc, dev); + TSEXIT(); return (0); } diff --git a/sys/dev/usb/controller/usb_controller.c b/sys/dev/usb/controller/usb_controller.c index 7e89a5ab01551..5303d019146a8 100644 --- a/sys/dev/usb/controller/usb_controller.c +++ b/sys/dev/usb/controller/usb_controller.c @@ -48,6 +48,7 @@ #include #include #include +#include #include #include @@ -166,12 +167,14 @@ usb_root_mount_rel(struct usb_bus *bus) static int usb_attach(device_t dev) { + TSENTER(); struct usb_bus *bus = device_get_ivars(dev); DPRINTF("\n"); if (bus == NULL) { device_printf(dev, "USB device has no ivars\n"); + TSEXIT(); return (ENXIO); } @@ -183,6 +186,7 @@ usb_attach(device_t dev) #endif usb_attach_sub(dev, bus); + TSEXIT(); return (0); /* return success */ } diff --git a/sys/dev/usb/usb_hub.c b/sys/dev/usb/usb_hub.c index ee9d8ab0c9bb9..179a0f80815f7 100644 --- a/sys/dev/usb/usb_hub.c +++ b/sys/dev/usb/usb_hub.c @@ -53,6 +53,7 @@ #include #include #include +#include #include #include @@ -1202,6 +1203,7 @@ uhub_query_info(struct usb_device *udev, uint8_t *pnports, uint8_t *ptt) int uhub_attach(device_t dev) { + TSENTER(); struct uhub_softc *sc = device_get_softc(dev); struct usb_attach_arg *uaa = device_get_ivars(dev); struct usb_device *udev = uaa->device; @@ -1526,6 +1528,7 @@ uhub_attach(device_t dev) usbd_set_power_mode(udev, USB_POWER_MODE_SAVE); + TSEXIT(); return (0); error: @@ -1538,6 +1541,7 @@ uhub_attach(device_t dev) mtx_destroy(&sc->sc_mtx); + TSEXIT(); return (ENXIO); } diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c index bf5bda7e058d4..3cac090e6fd3f 100644 --- a/sys/kern/subr_bus.c +++ b/sys/kern/subr_bus.c @@ -55,6 +55,8 @@ #include #include #include +#include + #ifdef INTRNG #include #endif @@ -420,7 +422,7 @@ void bus_topo_assert(void) { - GIANT_REQUIRED; + GIANT_REQUIRED; } struct mtx * @@ -2550,14 +2552,19 @@ device_probe_and_attach(device_t dev) { int error; + TSENTER(); bus_topo_assert(); error = device_probe(dev); - if (error == -1) + if (error == -1) { + TSEXIT(); return (0); - else if (error != 0) + } + else if (error != 0) { + TSEXIT(); return (error); - + } + TSEXIT(); return (device_attach(dev)); } @@ -2587,6 +2594,7 @@ device_attach(device_t dev) uint16_t attachentropy; int error; + TSENTER(); if (resource_disabled(dev->driver->name, dev->unit)) { /* * Mostly detach the device, but leave it attached to @@ -2597,6 +2605,7 @@ device_attach(device_t dev) dev->state = DS_NOTPRESENT; if (bootverbose) device_printf(dev, "disabled via hints entry\n"); + TSEXIT(); return (ENXIO); } @@ -2637,6 +2646,8 @@ device_attach(device_t dev) dev->state = DS_NOTPRESENT; } CURVNET_RESTORE(); + TSEXIT(); + return (error); } CURVNET_RESTORE(); @@ -2651,6 +2662,8 @@ device_attach(device_t dev) dev->state = DS_ATTACHED; dev->flags &= ~DF_DONENOMATCH; EVENTHANDLER_DIRECT_INVOKE(device_attach, dev); + TSEXIT(); + return (0); } diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c index 13403acacc083..88896197da3d5 100644 --- a/sys/kern/vfs_mount.c +++ b/sys/kern/vfs_mount.c @@ -64,6 +64,8 @@ #include #include #include +#include + #include #include @@ -1600,21 +1602,28 @@ vfs_domount( char *pathbuf; int error; + TSENTER(); /* * Be ultra-paranoid about making sure the type and fspath * variables will fit in our mp buffers, including the * terminating NUL. */ - if (strlen(fstype) >= MFSNAMELEN || strlen(fspath) >= MNAMELEN) + if (strlen(fstype) >= MFSNAMELEN || strlen(fspath) >= MNAMELEN) { + TSEXIT(); return (ENAMETOOLONG); + } if (jail_export) { error = priv_check(td, PRIV_NFS_DAEMON); - if (error) + if (error) { + TSEXIT(); return (error); + } } else if (jailed(td->td_ucred) || usermount == 0) { - if ((error = priv_check(td, PRIV_VFS_MOUNT)) != 0) + if ((error = priv_check(td, PRIV_VFS_MOUNT)) != 0) { + TSEXIT(); return (error); + } } /* @@ -1622,13 +1631,17 @@ vfs_domount( */ if (fsflags & MNT_EXPORTED) { error = priv_check(td, PRIV_VFS_MOUNT_EXPORTED); - if (error) + if (error) { + TSEXIT(); return (error); + } } if (fsflags & MNT_SUIDDIR) { error = priv_check(td, PRIV_VFS_MOUNT_SUIDDIR); - if (error) + if (error) { + TSEXIT(); return (error); + } } /* * Silently enforce MNT_NOSUID and MNT_USER for unprivileged users. @@ -1643,11 +1656,15 @@ vfs_domount( if ((fsflags & MNT_UPDATE) == 0) { /* Don't try to load KLDs if we're mounting the root. */ if (fsflags & MNT_ROOTFS) { - if ((vfsp = vfs_byname(fstype)) == NULL) + if ((vfsp = vfs_byname(fstype)) == NULL) { + TSEXIT(); return (ENODEV); + } } else { - if ((vfsp = vfs_byname_kld(fstype, td, &error)) == NULL) + if ((vfsp = vfs_byname_kld(fstype, td, &error)) == NULL) { + TSEXIT(); return (error); + } } } @@ -1657,8 +1674,10 @@ vfs_domount( NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | AUDITVNODE1 | WANTPARENT, UIO_SYSSPACE, fspath); error = namei(&nd); - if (error != 0) + if (error != 0) { + TSEXIT(); return (error); + } vp = nd.ni_vp; /* * Don't allow stacking file mounts to work around problems with the way @@ -1696,10 +1715,12 @@ vfs_domount( error = vfs_domount_update(td, vp, fsflags, jail_export, optlist); + TSEXIT(); out: NDFREE_PNBUF(&nd); vrele(nd.ni_dvp); + TSEXIT(); return (error); }