git: 8758aabb169d - main - usb(4): Make the enumeration thread nice time a variable.
Date: Fri, 07 Oct 2022 11:41:37 UTC
The branch main has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=8758aabb169d98f08c20f2a1fce5184434b1ddf6 commit 8758aabb169d98f08c20f2a1fce5184434b1ddf6 Author: Hans Petter Selasky <hselasky@FreeBSD.org> AuthorDate: 2022-10-07 11:28:38 +0000 Commit: Hans Petter Selasky <hselasky@FreeBSD.org> CommitDate: 2022-10-07 11:41:00 +0000 usb(4): Make the enumeration thread nice time a variable. Depends on "options USB_DEBUG". Suggested by: koobs@ MFC after: 1 week Sponsored by: NVIDIA Networking --- sys/dev/usb/controller/usb_controller.c | 2 +- sys/dev/usb/usb.h | 1 + sys/dev/usb/usb_debug.c | 7 ++++++- sys/dev/usb/usb_debug.h | 2 ++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/sys/dev/usb/controller/usb_controller.c b/sys/dev/usb/controller/usb_controller.c index 959f54a4583f..783c9c32dab2 100644 --- a/sys/dev/usb/controller/usb_controller.c +++ b/sys/dev/usb/controller/usb_controller.c @@ -416,7 +416,7 @@ usb_bus_explore(struct usb_proc_msg *pm) #endif /* Nice the enumeration a bit, to avoid looping too fast. */ - usb_pause_mtx(&bus->bus_mtx, USB_MS_TO_TICKS(16)); + usb_pause_mtx(&bus->bus_mtx, USB_MS_TO_TICKS(usb_enum_nice_time)); } /*------------------------------------------------------------------------* diff --git a/sys/dev/usb/usb.h b/sys/dev/usb/usb.h index ad0381366f98..0bef7a10bc6c 100644 --- a/sys/dev/usb/usb.h +++ b/sys/dev/usb/usb.h @@ -123,6 +123,7 @@ MALLOC_DECLARE(M_USBDEV); #define USB_RESUME_WAIT 50 /* ms */ #define USB_RESUME_RECOVERY 50 /* ms */ #define USB_EXTRA_POWER_UP_TIME 20 /* ms */ +#define USB_ENUM_NICE_TIME 16 /* ms */ #define USB_MIN_POWER 100 /* mA */ #define USB_MAX_POWER 500 /* mA */ diff --git a/sys/dev/usb/usb_debug.c b/sys/dev/usb/usb_debug.c index 5e521f7ec3a5..6ad8dce9a037 100644 --- a/sys/dev/usb/usb_debug.c +++ b/sys/dev/usb/usb_debug.c @@ -2,7 +2,7 @@ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD * - * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. + * Copyright (c) 2008-2022 Hans Petter Selasky * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -123,6 +123,10 @@ SYSCTL_PROC(_hw_usb_timings, OID_AUTO, extra_power_up_time, CTLTYPE_UINT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, &usb_extra_power_up_time, sizeof(usb_extra_power_up_time), usb_timings_sysctl_handler, "IU", "Extra PowerUp Time"); +SYSCTL_PROC(_hw_usb_timings, OID_AUTO, enum_nice_time, + CTLTYPE_UINT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, &usb_enum_nice_time, + sizeof(usb_enum_nice_time), usb_timings_sysctl_handler, "IU", + "Enumeration thread nice time"); #endif /*------------------------------------------------------------------------* @@ -245,6 +249,7 @@ unsigned int usb_resume_delay = USB_RESUME_DELAY; unsigned int usb_resume_wait = USB_RESUME_WAIT; unsigned int usb_resume_recovery = USB_RESUME_RECOVERY; unsigned int usb_extra_power_up_time = USB_EXTRA_POWER_UP_TIME; +unsigned int usb_enum_nice_time = USB_ENUM_NICE_TIME; /*------------------------------------------------------------------------* * usb_timings_sysctl_handler diff --git a/sys/dev/usb/usb_debug.h b/sys/dev/usb/usb_debug.h index 9bcbaec70ef4..c9df04111b60 100644 --- a/sys/dev/usb/usb_debug.h +++ b/sys/dev/usb/usb_debug.h @@ -74,6 +74,7 @@ extern unsigned int usb_resume_delay; extern unsigned int usb_resume_wait; extern unsigned int usb_resume_recovery; extern unsigned int usb_extra_power_up_time; +extern unsigned int usb_enum_nice_time; #else #define usb_port_reset_delay USB_PORT_RESET_DELAY #define usb_port_root_reset_delay USB_PORT_ROOT_RESET_DELAY @@ -85,6 +86,7 @@ extern unsigned int usb_extra_power_up_time; #define usb_resume_wait USB_RESUME_WAIT #define usb_resume_recovery USB_RESUME_RECOVERY #define usb_extra_power_up_time USB_EXTRA_POWER_UP_TIME +#define usb_enum_nice_time USB_ENUM_NICE_TIME #endif #endif /* _USB_DEBUG_H_ */