diff mbox

[08/15] usb: musb: Improve PM runtime and phy handling for 2430 glue layer

Message ID 1463014396-4095-9-git-send-email-tony@atomide.com (mailing list archive)
State New, archived
Headers show

Commit Message

Tony Lindgren May 12, 2016, 12:53 a.m. UTC
This simplifies things and allows idling both MUSB and PHY
when nothing is configured. Let's just return early from PM
runtime if musb is not yet initialized.

Let's also warn if PHY is not configured.

Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 drivers/usb/musb/omap2430.c | 30 +++++++++++++++++++-----------
 1 file changed, 19 insertions(+), 11 deletions(-)

Comments

Laurent Pinchart Sept. 9, 2016, 5:08 p.m. UTC | #1
Hi Tony,

On Wednesday 11 May 2016 17:53:09 Tony Lindgren wrote:
> This simplifies things and allows idling both MUSB and PHY
> when nothing is configured. Let's just return early from PM
> runtime if musb is not yet initialized.
> 
> Let's also warn if PHY is not configured.

git bisect pointed out to this patch today when I tried to find out what broke 
nfsroot over USB ethernet gadget on my Panda board :-/ Could you help me 
debugging and fixing that ?

> Signed-off-by: Tony Lindgren <tony@atomide.com>
> ---
>  drivers/usb/musb/omap2430.c | 30 +++++++++++++++++++-----------
>  1 file changed, 19 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
> index 02d40bc..eb0f332 100644
> --- a/drivers/usb/musb/omap2430.c
> +++ b/drivers/usb/musb/omap2430.c
> @@ -435,6 +435,7 @@ static int omap2430_musb_init(struct musb *musb)
>  		return PTR_ERR(musb->phy);
>  	}
>  	musb->isr = omap2430_musb_interrupt;
> +	phy_init(musb->phy);
> 
>  	/*
>  	 * Enable runtime PM for musb parent (this driver). We can't
> @@ -471,8 +472,6 @@ static int omap2430_musb_init(struct musb *musb)
>  	if (glue->status != MUSB_UNKNOWN)
>  		omap_musb_set_mailbox(glue);
> 
> -	phy_init(musb->phy);
> -	phy_power_on(musb->phy);
>  	pm_runtime_put(glue->dev);
>  	return 0;
> 
> @@ -489,6 +488,9 @@ static void omap2430_musb_enable(struct musb *musb)
>  	struct musb_hdrc_platform_data *pdata = dev_get_platdata(dev);
>  	struct omap_musb_board_data *data = pdata->board_data;
> 
> +	if (!WARN_ON(!musb->phy))
> +		phy_power_on(musb->phy);
> +
>  	omap2430_set_power(musb, true, glue->cable_connected);
> 
>  	switch (glue->status) {
> @@ -526,6 +528,9 @@ static void omap2430_musb_disable(struct musb *musb)
>  	struct device *dev = musb->controller;
>  	struct omap2430_glue *glue = dev_get_drvdata(dev->parent);
> 
> +	if (!WARN_ON(!musb->phy))
> +		phy_power_off(musb->phy);
> +
>  	if (glue->status != MUSB_UNKNOWN)
>  		omap_control_usb_set_mode(glue->control_otghs,
>  			USB_MODE_DISCONNECT);
> @@ -535,11 +540,14 @@ static void omap2430_musb_disable(struct musb *musb)
> 
>  static int omap2430_musb_exit(struct musb *musb)
>  {
> -	del_timer_sync(&musb_idle_timer);
> +	struct device *dev = musb->controller;
> +	struct omap2430_glue *glue = dev_get_drvdata(dev->parent);
> 
> +	del_timer_sync(&musb_idle_timer);
>  	omap2430_low_level_exit(musb);
> -	phy_power_off(musb->phy);
>  	phy_exit(musb->phy);
> +	musb->phy = NULL;
> +	cancel_work_sync(&glue->omap_musb_mailbox_work);
> 
>  	return 0;
>  }
> @@ -707,7 +715,6 @@ static int omap2430_remove(struct platform_device *pdev)
> struct musb *musb = glue_to_musb(glue);
> 
>  	pm_runtime_get_sync(glue->dev);
> -	cancel_work_sync(&glue->omap_musb_mailbox_work);
>  	platform_device_unregister(glue->musb);
>  	omap2430_set_power(musb, false, false);
>  	pm_runtime_put_sync(glue->dev);
> @@ -723,12 +730,13 @@ static int omap2430_runtime_suspend(struct device
> *dev) struct omap2430_glue		*glue = dev_get_drvdata(dev);
>  	struct musb			*musb = glue_to_musb(glue);
> 
> -	if (musb) {
> -		musb->context.otg_interfsel = musb_readl(musb->mregs,
> -				OTG_INTERFSEL);
> +	if (!musb)
> +		return 0;
> 
> -		omap2430_low_level_exit(musb);
> -	}
> +	musb->context.otg_interfsel = musb_readl(musb->mregs,
> +						 OTG_INTERFSEL);
> +
> +	omap2430_low_level_exit(musb);
> 
>  	return 0;
>  }
> @@ -739,7 +747,7 @@ static int omap2430_runtime_resume(struct device *dev)
>  	struct musb			*musb = glue_to_musb(glue);
> 
>  	if (!musb)
> -		return -EPROBE_DEFER;
> +		return 0;
> 
>  	omap2430_low_level_init(musb);
>  	musb_writel(musb->mregs, OTG_INTERFSEL,
Tony Lindgren Sept. 9, 2016, 5:24 p.m. UTC | #2
* Laurent Pinchart <laurent.pinchart@ideasonboard.com> [160909 10:08]:
> Hi Tony,
> 
> On Wednesday 11 May 2016 17:53:09 Tony Lindgren wrote:
> > This simplifies things and allows idling both MUSB and PHY
> > when nothing is configured. Let's just return early from PM
> > runtime if musb is not yet initialized.
> > 
> > Let's also warn if PHY is not configured.
> 
> git bisect pointed out to this patch today when I tried to find out what broke 
> nfsroot over USB ethernet gadget on my Panda board :-/ Could you help me 
> debugging and fixing that ?

OK, do you have commit 2c5575401e34 ("usb: musb: Fix locking errors for
host only mode")? That's now in v4.8-rc5. Or which kernel are we talking
about here?

Regards,

Tony
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Laurent Pinchart Sept. 9, 2016, 6:33 p.m. UTC | #3
Hi Tony,

On Friday 09 Sep 2016 10:24:47 Tony Lindgren wrote:
> * Laurent Pinchart <laurent.pinchart@ideasonboard.com> [160909 10:08]:
> > On Wednesday 11 May 2016 17:53:09 Tony Lindgren wrote:
> > > This simplifies things and allows idling both MUSB and PHY
> > > when nothing is configured. Let's just return early from PM
> > > runtime if musb is not yet initialized.
> > > 
> > > Let's also warn if PHY is not configured.
> > 
> > git bisect pointed out to this patch today when I tried to find out what
> > broke nfsroot over USB ethernet gadget on my Panda board :-/ Could you
> > help me debugging and fixing that ?
> 
> OK, do you have commit 2c5575401e34 ("usb: musb: Fix locking errors for
> host only mode")? That's now in v4.8-rc5. Or which kernel are we talking
> about here?

I've originally ran into the issue on v4.8-rc2. I've then bisected the issue 
to this commit, and confirmed that both v4.7 and v4.8-rc5 are broken.
Laurent Pinchart Sept. 9, 2016, 7:24 p.m. UTC | #4
Hi Tony,

On Friday 09 Sep 2016 21:33:35 Laurent Pinchart wrote:
> On Friday 09 Sep 2016 10:24:47 Tony Lindgren wrote:
> > * Laurent Pinchart <laurent.pinchart@ideasonboard.com> [160909 10:08]:
> > > On Wednesday 11 May 2016 17:53:09 Tony Lindgren wrote:
> > > > This simplifies things and allows idling both MUSB and PHY
> > > > when nothing is configured. Let's just return early from PM
> > > > runtime if musb is not yet initialized.
> > > > 
> > > > Let's also warn if PHY is not configured.
> > > 
> > > git bisect pointed out to this patch today when I tried to find out what
> > > broke nfsroot over USB ethernet gadget on my Panda board :-/ Could you
> > > help me debugging and fixing that ?
> > 
> > OK, do you have commit 2c5575401e34 ("usb: musb: Fix locking errors for
> > host only mode")? That's now in v4.8-rc5. Or which kernel are we talking
> > about here?
> 
> I've originally ran into the issue on v4.8-rc2. I've then bisected the issue
> to this commit, and confirmed that both v4.7 and v4.8-rc5 are broken.

"[PATCH v2] musb: omap2430: do not assume balanced enable()/disable()login 
register mail settings" (https://patchwork.kernel.org/patch/9261611/) fixes 
the issue.
Tony Lindgren Sept. 9, 2016, 8:05 p.m. UTC | #5
* Laurent Pinchart <laurent.pinchart@ideasonboard.com> [160909 12:24]:
> Hi Tony,
> 
> On Friday 09 Sep 2016 21:33:35 Laurent Pinchart wrote:
> > On Friday 09 Sep 2016 10:24:47 Tony Lindgren wrote:
> > > * Laurent Pinchart <laurent.pinchart@ideasonboard.com> [160909 10:08]:
> > > > On Wednesday 11 May 2016 17:53:09 Tony Lindgren wrote:
> > > > > This simplifies things and allows idling both MUSB and PHY
> > > > > when nothing is configured. Let's just return early from PM
> > > > > runtime if musb is not yet initialized.
> > > > > 
> > > > > Let's also warn if PHY is not configured.
> > > > 
> > > > git bisect pointed out to this patch today when I tried to find out what
> > > > broke nfsroot over USB ethernet gadget on my Panda board :-/ Could you
> > > > help me debugging and fixing that ?
> > > 
> > > OK, do you have commit 2c5575401e34 ("usb: musb: Fix locking errors for
> > > host only mode")? That's now in v4.8-rc5. Or which kernel are we talking
> > > about here?
> > 
> > I've originally ran into the issue on v4.8-rc2. I've then bisected the issue
> > to this commit, and confirmed that both v4.7 and v4.8-rc5 are broken.
> 
> "[PATCH v2] musb: omap2430: do not assume balanced enable()/disable()login 
> register mail settings" (https://patchwork.kernel.org/patch/9261611/) fixes 
> the issue.

Oh it's a different issue then. Sounds like it's probably related to
drivers/phy vs drivers/usb/phy. Will take a look on my panda.

Tony



Regards,

Tony
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Tony Lindgren Sept. 9, 2016, 8:08 p.m. UTC | #6
* Laurent Pinchart <laurent.pinchart@ideasonboard.com> [160909 11:33]:
> Hi Tony,
> 
> On Friday 09 Sep 2016 10:24:47 Tony Lindgren wrote:
> > * Laurent Pinchart <laurent.pinchart@ideasonboard.com> [160909 10:08]:
> > > On Wednesday 11 May 2016 17:53:09 Tony Lindgren wrote:
> > > > This simplifies things and allows idling both MUSB and PHY
> > > > when nothing is configured. Let's just return early from PM
> > > > runtime if musb is not yet initialized.
> > > > 
> > > > Let's also warn if PHY is not configured.
> > > 
> > > git bisect pointed out to this patch today when I tried to find out what
> > > broke nfsroot over USB ethernet gadget on my Panda board :-/ Could you
> > > help me debugging and fixing that ?
> > 
> > OK, do you have commit 2c5575401e34 ("usb: musb: Fix locking errors for
> > host only mode")? That's now in v4.8-rc5. Or which kernel are we talking
> > about here?
> 
> I've originally ran into the issue on v4.8-rc2. I've then bisected the issue 
> to this commit, and confirmed that both v4.7 and v4.8-rc5 are broken.

OK yeah sounds like this is some legacy phy related breakage. Will
take a look.

Thanks,

Tony
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index 02d40bc..eb0f332 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -435,6 +435,7 @@  static int omap2430_musb_init(struct musb *musb)
 		return PTR_ERR(musb->phy);
 	}
 	musb->isr = omap2430_musb_interrupt;
+	phy_init(musb->phy);
 
 	/*
 	 * Enable runtime PM for musb parent (this driver). We can't
@@ -471,8 +472,6 @@  static int omap2430_musb_init(struct musb *musb)
 	if (glue->status != MUSB_UNKNOWN)
 		omap_musb_set_mailbox(glue);
 
-	phy_init(musb->phy);
-	phy_power_on(musb->phy);
 	pm_runtime_put(glue->dev);
 	return 0;
 
@@ -489,6 +488,9 @@  static void omap2430_musb_enable(struct musb *musb)
 	struct musb_hdrc_platform_data *pdata = dev_get_platdata(dev);
 	struct omap_musb_board_data *data = pdata->board_data;
 
+	if (!WARN_ON(!musb->phy))
+		phy_power_on(musb->phy);
+
 	omap2430_set_power(musb, true, glue->cable_connected);
 
 	switch (glue->status) {
@@ -526,6 +528,9 @@  static void omap2430_musb_disable(struct musb *musb)
 	struct device *dev = musb->controller;
 	struct omap2430_glue *glue = dev_get_drvdata(dev->parent);
 
+	if (!WARN_ON(!musb->phy))
+		phy_power_off(musb->phy);
+
 	if (glue->status != MUSB_UNKNOWN)
 		omap_control_usb_set_mode(glue->control_otghs,
 			USB_MODE_DISCONNECT);
@@ -535,11 +540,14 @@  static void omap2430_musb_disable(struct musb *musb)
 
 static int omap2430_musb_exit(struct musb *musb)
 {
-	del_timer_sync(&musb_idle_timer);
+	struct device *dev = musb->controller;
+	struct omap2430_glue *glue = dev_get_drvdata(dev->parent);
 
+	del_timer_sync(&musb_idle_timer);
 	omap2430_low_level_exit(musb);
-	phy_power_off(musb->phy);
 	phy_exit(musb->phy);
+	musb->phy = NULL;
+	cancel_work_sync(&glue->omap_musb_mailbox_work);
 
 	return 0;
 }
@@ -707,7 +715,6 @@  static int omap2430_remove(struct platform_device *pdev)
 	struct musb *musb = glue_to_musb(glue);
 
 	pm_runtime_get_sync(glue->dev);
-	cancel_work_sync(&glue->omap_musb_mailbox_work);
 	platform_device_unregister(glue->musb);
 	omap2430_set_power(musb, false, false);
 	pm_runtime_put_sync(glue->dev);
@@ -723,12 +730,13 @@  static int omap2430_runtime_suspend(struct device *dev)
 	struct omap2430_glue		*glue = dev_get_drvdata(dev);
 	struct musb			*musb = glue_to_musb(glue);
 
-	if (musb) {
-		musb->context.otg_interfsel = musb_readl(musb->mregs,
-				OTG_INTERFSEL);
+	if (!musb)
+		return 0;
 
-		omap2430_low_level_exit(musb);
-	}
+	musb->context.otg_interfsel = musb_readl(musb->mregs,
+						 OTG_INTERFSEL);
+
+	omap2430_low_level_exit(musb);
 
 	return 0;
 }
@@ -739,7 +747,7 @@  static int omap2430_runtime_resume(struct device *dev)
 	struct musb			*musb = glue_to_musb(glue);
 
 	if (!musb)
-		return -EPROBE_DEFER;
+		return 0;
 
 	omap2430_low_level_init(musb);
 	musb_writel(musb->mregs, OTG_INTERFSEL,