diff mbox series

[3/6] usb: bdc: driver may fail to get USB PHY

Message ID 1561064991-16874-4-git-send-email-alcooperx@gmail.com (mailing list archive)
State New, archived
Headers show
Series usb: bdc: Updates and fixes to USB BDC driver | expand

Commit Message

Alan Cooper June 20, 2019, 9:09 p.m. UTC
Initialization order is important for the USB PHY and the PHY clients.
The init order is based on the build order of the drivers in the
makefiles and the PHY drivers are built early to help with
dependencies, but the new SCMI based clock subsystem has the side
effect of making some additional drivers DEFER until the clock
is ready. This is causing the USB PHY driver to defer which is causing
some PHY clients to fail when they try to get the PHY. The fix is to have
the client driver return DEFER when it's "get phy" routine returns DEFER.

Signed-off-by: Al Cooper <alcooperx@gmail.com>
---
 drivers/usb/gadget/udc/bdc/bdc_core.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Chunfeng Yun (云春峰) June 21, 2019, 5:39 a.m. UTC | #1
On Thu, 2019-06-20 at 17:09 -0400, Al Cooper wrote:
> Initialization order is important for the USB PHY and the PHY clients.
> The init order is based on the build order of the drivers in the
> makefiles and the PHY drivers are built early to help with
> dependencies, but the new SCMI based clock subsystem has the side
> effect of making some additional drivers DEFER until the clock
> is ready. This is causing the USB PHY driver to defer which is causing
> some PHY clients to fail when they try to get the PHY. The fix is to have
> the client driver return DEFER when it's "get phy" routine returns DEFER.
> 
> Signed-off-by: Al Cooper <alcooperx@gmail.com>
> ---
>  drivers/usb/gadget/udc/bdc/bdc_core.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/gadget/udc/bdc/bdc_core.c b/drivers/usb/gadget/udc/bdc/bdc_core.c
> index 11a43de6c1c6..c794890d785b 100644
> --- a/drivers/usb/gadget/udc/bdc/bdc_core.c
> +++ b/drivers/usb/gadget/udc/bdc/bdc_core.c
> @@ -543,9 +543,13 @@ static int bdc_probe(struct platform_device *pdev)
>  			dev, dev->of_node, phy_num);
>  		if (IS_ERR(bdc->phys[phy_num])) {
>  			ret = PTR_ERR(bdc->phys[phy_num]);
> +			if (ret == -EPROBE_DEFER) {
> +				dev_dbg(bdc->dev, "DEFER, waiting for PHY\n");
why not disable clock here? when re-probe, will enable clock again.
to me, no need check -EPROBE_DEFFER.
> +				return ret;
> +			}

>  			dev_err(bdc->dev,
>  				"BDC phy specified but not found:%d\n", ret);
> -			return ret;
> +			goto clk_cleanup;
>  		}
>  	}
>
Alan Cooper June 21, 2019, 1:39 p.m. UTC | #2
It's been very useful to have the DEFER debug message so I'd like to
leave in the check for DEFER. I should not be skipping the clock
disable, so I'll "goto clk_cleanup" for both cases.

Thanks
Al

On Fri, Jun 21, 2019 at 1:39 AM Chunfeng Yun <chunfeng.yun@mediatek.com> wrote:
>
> On Thu, 2019-06-20 at 17:09 -0400, Al Cooper wrote:
> > Initialization order is important for the USB PHY and the PHY clients.
> > The init order is based on the build order of the drivers in the
> > makefiles and the PHY drivers are built early to help with
> > dependencies, but the new SCMI based clock subsystem has the side
> > effect of making some additional drivers DEFER until the clock
> > is ready. This is causing the USB PHY driver to defer which is causing
> > some PHY clients to fail when they try to get the PHY. The fix is to have
> > the client driver return DEFER when it's "get phy" routine returns DEFER.
> >
> > Signed-off-by: Al Cooper <alcooperx@gmail.com>
> > ---
> >  drivers/usb/gadget/udc/bdc/bdc_core.c | 6 +++++-
> >  1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/usb/gadget/udc/bdc/bdc_core.c b/drivers/usb/gadget/udc/bdc/bdc_core.c
> > index 11a43de6c1c6..c794890d785b 100644
> > --- a/drivers/usb/gadget/udc/bdc/bdc_core.c
> > +++ b/drivers/usb/gadget/udc/bdc/bdc_core.c
> > @@ -543,9 +543,13 @@ static int bdc_probe(struct platform_device *pdev)
> >                       dev, dev->of_node, phy_num);
> >               if (IS_ERR(bdc->phys[phy_num])) {
> >                       ret = PTR_ERR(bdc->phys[phy_num]);
> > +                     if (ret == -EPROBE_DEFER) {
> > +                             dev_dbg(bdc->dev, "DEFER, waiting for PHY\n");
> why not disable clock here? when re-probe, will enable clock again.
> to me, no need check -EPROBE_DEFFER.
> > +                             return ret;
> > +                     }
>
> >                       dev_err(bdc->dev,
> >                               "BDC phy specified but not found:%d\n", ret);
> > -                     return ret;
> > +                     goto clk_cleanup;
> >               }
> >       }
> >
>
>
diff mbox series

Patch

diff --git a/drivers/usb/gadget/udc/bdc/bdc_core.c b/drivers/usb/gadget/udc/bdc/bdc_core.c
index 11a43de6c1c6..c794890d785b 100644
--- a/drivers/usb/gadget/udc/bdc/bdc_core.c
+++ b/drivers/usb/gadget/udc/bdc/bdc_core.c
@@ -543,9 +543,13 @@  static int bdc_probe(struct platform_device *pdev)
 			dev, dev->of_node, phy_num);
 		if (IS_ERR(bdc->phys[phy_num])) {
 			ret = PTR_ERR(bdc->phys[phy_num]);
+			if (ret == -EPROBE_DEFER) {
+				dev_dbg(bdc->dev, "DEFER, waiting for PHY\n");
+				return ret;
+			}
 			dev_err(bdc->dev,
 				"BDC phy specified but not found:%d\n", ret);
-			return ret;
+			goto clk_cleanup;
 		}
 	}