Hi Francesco, > -----Original Message----- > From: Francesco Dolcini <francesco@xxxxxxxxxx> > Sent: Friday, October 28, 2022 8:32 PM > To: Peter Chen <peter.chen@xxxxxxxxxx>; linux-usb@xxxxxxxxxxxxxxx; Jun Li > <jun.li@xxxxxxx> > Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>; Shawn Guo > <shawnguo@xxxxxxxxxx>; Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>; Pengutronix > Kernel Team <kernel@xxxxxxxxxxxxxx>; Fabio Estevam <festevam@xxxxxxxxx>; > dl-linux-imx <linux-imx@xxxxxxx>; Felipe Balbi <balbi@xxxxxxxxxx>; > philippe.schenker@xxxxxxxxxxx; Francesco Dolcini > <francesco.dolcini@xxxxxxxxxxx> > Subject: USB runtime PM issues on i.MX6ULL > > Hello all, > > I am debugging some unexpected USB behavior on a i.MX6ULL SOC, > chipidea controller ("fsl,imx6ul-usb") and a fsl mxs usbphy > ("fsl,imx6ul-usbphy"). > > The HW design has 2 USB interface, the first one is dual-role, while the > second > one is a host port with NO way to re-read the VBUS (USB_OTG2_VBUS is not > really connected, there is just a capacitor to GND). How is your USB_OTG1_VBUS status? Can you try to make your USB_OTG1_VBUS pad has a valid VBUS voltage, then run your Host only port test with runtime PM enabled? Li Jun > > Focusing on the second interface, USB Host only, what I do experience is > the > following: > > - if there is no USB HUB connected and no device connected at boot, any > USB > device hotplugged is not working, ci_runtime_suspend is called and it > never > resume. > - if there is a HUB in between it somehow works, however I have a continuos > runtime powermanagement reset loop every 2 seconds > [ 1026.146360] ci_hdrc ci_hdrc.1: at ci_runtime_suspend > [ 1026.164725] ci_hdrc ci_hdrc.1: at ci_controller_resume > [ 1026.487844] usb 1-1: reset high-speed USB device number 2 using > ci_hdrc > [ 1028.326789] ci_hdrc ci_hdrc.1: at ci_runtime_suspend > [ 1028.335378] ci_hdrc ci_hdrc.1: at ci_controller_resume > [ 1028.657853] usb 1-1: reset high-speed USB device number 2 using > ci_hdrc > > > I was able to have it fully working disabling the runtime power management > in > the chipidea driver or using sysfs (`echo on > /sys/.../power/control`). > > --- a/drivers/usb/chipidea/ci_hdrc_imx.c > +++ b/drivers/usb/chipidea/ci_hdrc_imx.c > @@ -56,7 +56,7 @@ static const struct ci_hdrc_imx_platform_flag > imx6sx_usb_data = { > }; > > static const struct ci_hdrc_imx_platform_flag imx6ul_usb_data = { > - .flags = CI_HDRC_SUPPORTS_RUNTIME_PM | > + .flags = > > I was digging even more into the topic and I found out that what is happening > is that mxs_phy_disconnect_line() is called. I than tried to remove the > MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS flag. > > --- a/drivers/usb/phy/phy-mxs-usb.c > +++ b/drivers/usb/phy/phy-mxs-usb.c > @@ -178,7 +178,7 @@ static const struct mxs_phy_data imx6sx_phy_data = { > }; > > static const struct mxs_phy_data imx6ul_phy_data = { > - .flags = MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS, > + /*.flags = MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS,*/ > }; > > This commit from NXP downstream kernel seems somehow related > https://github.com/nxp-imx/linux-imx/commit/89ec73836a9b1347743e406d62d > d446dc4365db3 > however it builds on other commits that allow to communicate the actual mode > to > the USB PHY driver and prevent mxs_phy_disconnect_line() to be called for > the > USB host case. > > With that the situation is way better, but while without > `CI_HDRC_SUPPORTS_RUNTIME_PM` it works perfectly, without > `MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS` it does not really work smootly > in case there is a hub in between (~20% of the time the device is not > enumerated after plugging it in). > > When it does not work I see that after plugging in a device runtime resume > function is called, but after that the device is not enumerated on the USB > bus. > It looks like something else is missing. > > It seems like having a pure USB Host interface without having a way to re-read > the VBUS is not really supported in SW at the moment, am I wrong? > Any idea? > > One last comment, even the USB dual role port is not working smoothly, however > I have not investigated this specific case that much because disabling runtime > pm > solves everything also in that case. > > Francesco