Re: [PATCH] usb: dwc3: qcom: Defer dwc3-qcom probe if dwc3 isn't probed properly

Matthias Kaehlcke
2022-07-14T15:53:33Z

On Thu, Jul 14, 2022 at 05:02:09PM +0200, Greg Kroah-Hartman wrote:
> On Thu, Jul 14, 2022 at 08:25:16PM +0530, Krishna Kurapati wrote:
> > On SC7180 devices, it is observed that dwc3 probing is deferred
> > because device_links_check_suppliers() finds that '88e3000.phy'
> > isn't ready yet.
> >
> > As a part of its probe call, dwc3-qcom driver checks if dwc3 core
> > is wakeup capable or not. If the dwc3 core is wakeup capable, driver
> > configures dwc-qcom's power domain to be always ON. Also it configures
> > dp/dm interrupts accordingly to support wakeup from system suspend.
> >
> > More info regarding the same can be found at:
> > commit d9be8d5c5b03 ("usb: dwc3: qcom: Keep power domain on to retain controller status"
> > commit 6895ea55c385 ("usb: dwc3: qcom: Configure wakeup interrupts during suspend")
> >
> > In the event, dwc3 probe gets deferred and is processed after dwc3-qcom
> > probe, driver ends up reading the wakeup capability of dwc3 core as false
> > leading to instability in suspend/resume path.
> >
> > To avoid this scenario, ensure dwc3_probe is successful by checking
> > if appropriate driver is assigned to it or not after the of_platform_populate
> > call. If it isn't then defer dwc3-qcom probe as well.
> >
> > Signed-off-by: Krishna Kurapati <quic_kriskura@quicinc.com>
> > ---
> > drivers/usb/dwc3/dwc3-qcom.c | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> > diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
> > index 7703655..096d1414 100644
> > --- a/drivers/usb/dwc3/dwc3-qcom.c
> > +++ b/drivers/usb/dwc3/dwc3-qcom.c
> > @@ -722,6 +722,9 @@ static int dwc3_qcom_of_register_core(struct platform_device *pdev)
> > dev_err(dev, "failed to get dwc3 platform device\n");
> > }
> >
> > + if (!qcom->dwc3->dev.driver)
> > + return -EPROBE_DEFER;
> > +
>
> Why not limit this check to a device type like your changelog mentions?

It is not an sc7180 specific issue. It can occur on any platform where the
dwc3 core has supplies that aren't ready when the dwc3-qcom driver probes.

It won't blow up right away since it requires 'wakeup-source' to be set for
the dwc3 core, which currently is only the case for 'usb@a600000' of the
sc7280 AFAIK (I set it for sc7180 in my tree for testing, which is when I
found the issue this patch intends to address).