Hi Patrick On 9/9/22 11:45, Patrick Delaunay wrote: > Add a new CONFIG_USB_HUB_DEBOUNCE_TIMEOUT to increase the > HUB_DEBOUNCE_TIMEOUT value, for example to 2s because some usb device > needs around 1.5s or more to make the hub port status to be > connected steadily after being powered off and powered on. > > This 2s value is aligned with Linux driver and avoids to configure > "usb_pgood_delay" as a workaround for connection timeout on > some USB device; normally the env variable "usb_pgood_delay" is used > to delay the first query after power ON and thus the device answer, > but this variable not used to increase the connection timeout delay. > > Signed-off-by: Patrick Delaunay <patrick.delau...@foss.st.com> > --- > Hi, > > V2 of previous patch [1] after Marek request to a add a CONFIG_. > > I think this patch solves a general issue because a 1s timeout for > USB connection is too short on problematic USB keys / USB HUB. > The issue was introduced by the commit c998da0d6709 ("usb: Change > power-on / scanning timeout handling") > > Patching usb_hub allows to avoid to patch in each board/driver. > > For example, commit 0417169054cb ("imx: ventana: add usb_pgood_delay > 2sec default") => use pgood_delay = 2s !? > > or ("ARM: stm32: Increase USB power-good delay on DHSOM") > https://patchwork.ozlabs.org/project/uboot/patch/20211113022444.231801-1-ma...@denx.de/ > > or commit 2bf352f0c1b7 ("usb: dwc2: Add delay to fix the USB > detection problem on SoCFPGA") => patch in USB DWC2 driver to add > a timeout in driver > > The commit 319418c01c95 ("usb: hub: allow pgood_delay to be > specified via env") introduces an env variable for warm-up times > managed by hub->query_delay. > > But it is not linked to the connect timeout after power on > managed by hub->connect_timeout. > > This patch allow to increase the boot time for some board when USB device > is not available; the default value = 1s of the config > CONFIG_USB_HUB_DEBOUNCE_TIMEOUT allow to keep the current behavior. > > This issue appears with DWC2 and USB HUB used in STM32MP135F-DK board; > pgood_delay=2 is not enough to solved all the USB key detection issues. > > [1] [2/2] usb: hub: increase HUB_DEBOUNCE_TIMEOUT > http://patchwork.ozlabs.org/project/uboot/patch/20220704124540.2.I5eabf3f9fdbbaf763cd44e9c018cb5b74a0c65ac@changeid/ > > Patrick > > > Changes in v2: > - allow defconfig configuration by CONFIG_USB_HUB_DEBOUNCE_TIMEOUT > > common/Kconfig | 12 ++++++++++++ > common/usb_hub.c | 2 +- > 2 files changed, 13 insertions(+), 1 deletion(-) > > diff --git a/common/Kconfig b/common/Kconfig > index e7914ca750a..fedb643ea58 100644 > --- a/common/Kconfig > +++ b/common/Kconfig > @@ -992,3 +992,15 @@ config FDT_SIMPLEFB > These functions can be used by board to indicate to the OS > the presence of the simple frame buffer with associated reserved > memory > + > +config USB_HUB_DEBOUNCE_TIMEOUT > + int "Timeout in milliseconds for USB HUB connection" > + depends on USB > + default 1000 > + help > + Value in milliseconds of the USB connection timeout, the max delay to > + wait the hub port status to be connected steadily after being powered > + off and powered on in the usb hub driver. > + This define allows to increase the HUB_DEBOUNCE_TIMEOUT default > + value = 1s because some usb device needs around 1.5s to be initialized > + and a 2s value should solve detection issue on problematic USB keys. > diff --git a/common/usb_hub.c b/common/usb_hub.c > index d73638950b9..87fd93c55db 100644 > --- a/common/usb_hub.c > +++ b/common/usb_hub.c > @@ -47,7 +47,7 @@ > #define HUB_SHORT_RESET_TIME 20 > #define HUB_LONG_RESET_TIME 200 > > -#define HUB_DEBOUNCE_TIMEOUT 1000 > +#define HUB_DEBOUNCE_TIMEOUT CONFIG_USB_HUB_DEBOUNCE_TIMEOUT > > #define PORT_OVERCURRENT_MAX_SCAN_COUNT 3 > Reviewed-by: Patrice Chotard <patrice.chot...@foss.st.com>
Thanks Patrice