diff mbox

usb: musb: Fix locking errors for host only mode

Message ID 1471560038-6243-1-git-send-email-tony@atomide.com (mailing list archive)
State New, archived
Headers show

Commit Message

Tony Lindgren Aug. 18, 2016, 10:40 p.m. UTC
If we have USB gadgets disabled and USB_MUSB_HOST set, we get
errors "possible irq lock inverssion dependency detected"
errors during boot.

Let's fix the issue by adding start_musb flag and start
the controller after we're out of the spinlock protected
section.

Reported-by: Ladislav Michl <ladis@linux-mips.org>
Tested-by: Ladislav Michl <ladis@linux-mips.org>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 drivers/usb/musb/musb_virthub.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Bin Liu Aug. 24, 2016, 6:46 p.m. UTC | #1
Hi,

On Thu, Aug 18, 2016 at 03:40:38PM -0700, Tony Lindgren wrote:
> If we have USB gadgets disabled and USB_MUSB_HOST set, we get
> errors "possible irq lock inverssion dependency detected"
> errors during boot.

On which platform was this issue found? I am trying to replicate the
issue on am335x, but have no luck yet - musb-hdrc does not load at all
when usb gadget support is disabled.

Regards,
-Bin.

> 
> Let's fix the issue by adding start_musb flag and start
> the controller after we're out of the spinlock protected
> section.
> 
> Reported-by: Ladislav Michl <ladis@linux-mips.org>
> Tested-by: Ladislav Michl <ladis@linux-mips.org>
> Signed-off-by: Tony Lindgren <tony@atomide.com>
> ---
>  drivers/usb/musb/musb_virthub.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/musb/musb_virthub.c b/drivers/usb/musb/musb_virthub.c
> index 192248f..fe08e77 100644
> --- a/drivers/usb/musb/musb_virthub.c
> +++ b/drivers/usb/musb/musb_virthub.c
> @@ -290,6 +290,7 @@ int musb_hub_control(
>  	u32		temp;
>  	int		retval = 0;
>  	unsigned long	flags;
> +	bool		start_musb = false;
>  
>  	spin_lock_irqsave(&musb->lock, flags);
>  
> @@ -390,7 +391,7 @@ int musb_hub_control(
>  			 * logic relating to VBUS power-up.
>  			 */
>  			if (!hcd->self.is_b_host && musb_has_gadget(musb))
> -				musb_start(musb);
> +				start_musb = true;
>  			break;
>  		case USB_PORT_FEAT_RESET:
>  			musb_port_reset(musb, true);
> @@ -451,5 +452,9 @@ error:
>  		retval = -EPIPE;
>  	}
>  	spin_unlock_irqrestore(&musb->lock, flags);
> +
> +	if (start_musb)
> +		musb_start(musb);
> +
>  	return retval;
>  }
> -- 
> 2.8.1
> 
--
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 Aug. 24, 2016, 7:15 p.m. UTC | #2
* Bin Liu <b-liu@ti.com> [160824 11:47]:
> Hi,
> 
> On Thu, Aug 18, 2016 at 03:40:38PM -0700, Tony Lindgren wrote:
> > If we have USB gadgets disabled and USB_MUSB_HOST set, we get
> > errors "possible irq lock inverssion dependency detected"
> > errors during boot.
> 
> On which platform was this issue found? I am trying to replicate the
> issue on am335x, but have no luck yet - musb-hdrc does not load at all
> when usb gadget support is disabled.

It seems to be with a built-in MUSB and gadgets in the .config,
I'll forward you the one I got earlier from Ladis.

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 Aug. 24, 2016, 7:29 p.m. UTC | #3
* Tony Lindgren <tony@atomide.com> [160824 12:17]:
> * Bin Liu <b-liu@ti.com> [160824 11:47]:
> > Hi,
> > 
> > On Thu, Aug 18, 2016 at 03:40:38PM -0700, Tony Lindgren wrote:
> > > If we have USB gadgets disabled and USB_MUSB_HOST set, we get
> > > errors "possible irq lock inverssion dependency detected"
> > > errors during boot.
> > 
> > On which platform was this issue found? I am trying to replicate the
> > issue on am335x, but have no luck yet - musb-hdrc does not load at all
> > when usb gadget support is disabled.
> 
> It seems to be with a built-in MUSB and gadgets in the .config,
> I'll forward you the one I got earlier from Ladis.

And probably specifically CONFIG_USB_MUSB_HOST=y.

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
Bin Liu Aug. 24, 2016, 7:33 p.m. UTC | #4
On Wed, Aug 24, 2016 at 12:29:26PM -0700, Tony Lindgren wrote:
> * Tony Lindgren <tony@atomide.com> [160824 12:17]:
> > * Bin Liu <b-liu@ti.com> [160824 11:47]:
> > > Hi,
> > > 
> > > On Thu, Aug 18, 2016 at 03:40:38PM -0700, Tony Lindgren wrote:
> > > > If we have USB gadgets disabled and USB_MUSB_HOST set, we get
> > > > errors "possible irq lock inverssion dependency detected"
> > > > errors during boot.
> > > 
> > > On which platform was this issue found? I am trying to replicate the
> > > issue on am335x, but have no luck yet - musb-hdrc does not load at all
> > > when usb gadget support is disabled.
> > 
> > It seems to be with a built-in MUSB and gadgets in the .config,
> > I'll forward you the one I got earlier from Ladis.
> 
> And probably specifically CONFIG_USB_MUSB_HOST=y.

yes, I had gadget support disabled and CONFIG_USB_MUSB_HOST=y, but
MUSB_HDRC=m. I will try your .config once I have time.

Thanks,
-Bin.

> 
> 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
Bin Liu Aug. 25, 2016, 5:18 p.m. UTC | #5
Hi,

On Thu, Aug 18, 2016 at 03:40:38PM -0700, Tony Lindgren wrote:
> If we have USB gadgets disabled and USB_MUSB_HOST set, we get
> errors "possible irq lock inverssion dependency detected"
> errors during boot.
> 
> Let's fix the issue by adding start_musb flag and start
> the controller after we're out of the spinlock protected
> section.
> 
> Reported-by: Ladislav Michl <ladis@linux-mips.org>
> Tested-by: Ladislav Michl <ladis@linux-mips.org>
> Signed-off-by: Tony Lindgren <tony@atomide.com>

Signed-off-by: Bin Liu <b-liu@ti.com>

Regards,
-Bin.

> ---
>  drivers/usb/musb/musb_virthub.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/musb/musb_virthub.c b/drivers/usb/musb/musb_virthub.c
> index 192248f..fe08e77 100644
> --- a/drivers/usb/musb/musb_virthub.c
> +++ b/drivers/usb/musb/musb_virthub.c
> @@ -290,6 +290,7 @@ int musb_hub_control(
>  	u32		temp;
>  	int		retval = 0;
>  	unsigned long	flags;
> +	bool		start_musb = false;
>  
>  	spin_lock_irqsave(&musb->lock, flags);
>  
> @@ -390,7 +391,7 @@ int musb_hub_control(
>  			 * logic relating to VBUS power-up.
>  			 */
>  			if (!hcd->self.is_b_host && musb_has_gadget(musb))
> -				musb_start(musb);
> +				start_musb = true;
>  			break;
>  		case USB_PORT_FEAT_RESET:
>  			musb_port_reset(musb, true);
> @@ -451,5 +452,9 @@ error:
>  		retval = -EPIPE;
>  	}
>  	spin_unlock_irqrestore(&musb->lock, flags);
> +
> +	if (start_musb)
> +		musb_start(musb);
> +
>  	return retval;
>  }
> -- 
> 2.8.1
> 
--
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 Aug. 26, 2016, 2:39 p.m. UTC | #6
Hi,

* Bin Liu <b-liu@ti.com> [160825 10:19]:
> Hi,
> 
> On Thu, Aug 18, 2016 at 03:40:38PM -0700, Tony Lindgren wrote:
> > If we have USB gadgets disabled and USB_MUSB_HOST set, we get
> > errors "possible irq lock inverssion dependency detected"
> > errors during boot.
> > 
> > Let's fix the issue by adding start_musb flag and start
> > the controller after we're out of the spinlock protected
> > section.
> > 
> > Reported-by: Ladislav Michl <ladis@linux-mips.org>
> > Tested-by: Ladislav Michl <ladis@linux-mips.org>
> > Signed-off-by: Tony Lindgren <tony@atomide.com>
> 
> Signed-off-by: Bin Liu <b-liu@ti.com>

Bin, your Signed-off-by here suggests you've committed this to
a fixes branch somewhere but I can't see it in next. Are you
going to send a pull request for it or what's the plan?
Just wondering.. Also added Greg to Cc.

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
Bin Liu Aug. 26, 2016, 2:56 p.m. UTC | #7
On Fri, Aug 26, 2016 at 07:39:05AM -0700, Tony Lindgren wrote:
> Hi,
> 
> * Bin Liu <b-liu@ti.com> [160825 10:19]:
> > Hi,
> > 
> > On Thu, Aug 18, 2016 at 03:40:38PM -0700, Tony Lindgren wrote:
> > > If we have USB gadgets disabled and USB_MUSB_HOST set, we get
> > > errors "possible irq lock inverssion dependency detected"
> > > errors during boot.
> > > 
> > > Let's fix the issue by adding start_musb flag and start
> > > the controller after we're out of the spinlock protected
> > > section.
> > > 
> > > Reported-by: Ladislav Michl <ladis@linux-mips.org>
> > > Tested-by: Ladislav Michl <ladis@linux-mips.org>
> > > Signed-off-by: Tony Lindgren <tony@atomide.com>
> > 
> > Signed-off-by: Bin Liu <b-liu@ti.com>
> 
> Bin, your Signed-off-by here suggests you've committed this to
> a fixes branch somewhere but I can't see it in next. Are you
> going to send a pull request for it or what's the plan?
> Just wondering.. Also added Greg to Cc.

I don't have a public git repo to host my musb maintenance work yet, and
I don't have a plan to create one since there aren't many musb patches
from the community.  So far I have been managing all the patches in my
local tree, and sending patch bombs to Greg. Your this patch will be
sent to Greg today or tomorrow.

> 
> Regards,
> 
> Tony

Regards,
-Bin.

--
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 Aug. 26, 2016, 2:57 p.m. UTC | #8
* Bin Liu <b-liu@ti.com> [160826 07:57]:
> On Fri, Aug 26, 2016 at 07:39:05AM -0700, Tony Lindgren wrote:
> > Hi,
> > 
> > * Bin Liu <b-liu@ti.com> [160825 10:19]:
> > > Hi,
> > > 
> > > On Thu, Aug 18, 2016 at 03:40:38PM -0700, Tony Lindgren wrote:
> > > > If we have USB gadgets disabled and USB_MUSB_HOST set, we get
> > > > errors "possible irq lock inverssion dependency detected"
> > > > errors during boot.
> > > > 
> > > > Let's fix the issue by adding start_musb flag and start
> > > > the controller after we're out of the spinlock protected
> > > > section.
> > > > 
> > > > Reported-by: Ladislav Michl <ladis@linux-mips.org>
> > > > Tested-by: Ladislav Michl <ladis@linux-mips.org>
> > > > Signed-off-by: Tony Lindgren <tony@atomide.com>
> > > 
> > > Signed-off-by: Bin Liu <b-liu@ti.com>
> > 
> > Bin, your Signed-off-by here suggests you've committed this to
> > a fixes branch somewhere but I can't see it in next. Are you
> > going to send a pull request for it or what's the plan?
> > Just wondering.. Also added Greg to Cc.
> 
> I don't have a public git repo to host my musb maintenance work yet, and
> I don't have a plan to create one since there aren't many musb patches
> from the community.  So far I have been managing all the patches in my
> local tree, and sending patch bombs to Greg. Your this patch will be
> sent to Greg today or tomorrow.

OK so no need for me to do anything then. Thanks for the update.

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
Bin Liu Aug. 26, 2016, 3:14 p.m. UTC | #9
On Fri, Aug 26, 2016 at 07:57:39AM -0700, Tony Lindgren wrote:
> * Bin Liu <b-liu@ti.com> [160826 07:57]:
> > On Fri, Aug 26, 2016 at 07:39:05AM -0700, Tony Lindgren wrote:
> > > Hi,
> > > 
> > > * Bin Liu <b-liu@ti.com> [160825 10:19]:
> > > > Hi,
> > > > 
> > > > On Thu, Aug 18, 2016 at 03:40:38PM -0700, Tony Lindgren wrote:
> > > > > If we have USB gadgets disabled and USB_MUSB_HOST set, we get
> > > > > errors "possible irq lock inverssion dependency detected"
> > > > > errors during boot.
> > > > > 
> > > > > Let's fix the issue by adding start_musb flag and start
> > > > > the controller after we're out of the spinlock protected
> > > > > section.
> > > > > 
> > > > > Reported-by: Ladislav Michl <ladis@linux-mips.org>
> > > > > Tested-by: Ladislav Michl <ladis@linux-mips.org>
> > > > > Signed-off-by: Tony Lindgren <tony@atomide.com>
> > > > 
> > > > Signed-off-by: Bin Liu <b-liu@ti.com>
> > > 
> > > Bin, your Signed-off-by here suggests you've committed this to
> > > a fixes branch somewhere but I can't see it in next. Are you
> > > going to send a pull request for it or what's the plan?
> > > Just wondering.. Also added Greg to Cc.
> > 
> > I don't have a public git repo to host my musb maintenance work yet, and
> > I don't have a plan to create one since there aren't many musb patches
> > from the community.  So far I have been managing all the patches in my
> > local tree, and sending patch bombs to Greg. Your this patch will be
> > sent to Greg today or tomorrow.
> 
> OK so no need for me to do anything then. Thanks for the update.

No, nothing no your side now, the patch is good to go ;)

BTY, sorry for beeing slow on reviewing patches lately. There are a
few critical things in my work coming up during my vacation.
(maintaining musb is not part of my paid job...)

> 
> Tony

Regards,
-Bin.
--
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 Aug. 26, 2016, 3:25 p.m. UTC | #10
* Bin Liu <b-liu@ti.com> [160826 08:15]:
> 
> BTY, sorry for beeing slow on reviewing patches lately. There are a
> few critical things in my work coming up during my vacation.
> (maintaining musb is not part of my paid job...)

No problem, we all know how that goes.

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/musb_virthub.c b/drivers/usb/musb/musb_virthub.c
index 192248f..fe08e77 100644
--- a/drivers/usb/musb/musb_virthub.c
+++ b/drivers/usb/musb/musb_virthub.c
@@ -290,6 +290,7 @@  int musb_hub_control(
 	u32		temp;
 	int		retval = 0;
 	unsigned long	flags;
+	bool		start_musb = false;
 
 	spin_lock_irqsave(&musb->lock, flags);
 
@@ -390,7 +391,7 @@  int musb_hub_control(
 			 * logic relating to VBUS power-up.
 			 */
 			if (!hcd->self.is_b_host && musb_has_gadget(musb))
-				musb_start(musb);
+				start_musb = true;
 			break;
 		case USB_PORT_FEAT_RESET:
 			musb_port_reset(musb, true);
@@ -451,5 +452,9 @@  error:
 		retval = -EPIPE;
 	}
 	spin_unlock_irqrestore(&musb->lock, flags);
+
+	if (start_musb)
+		musb_start(musb);
+
 	return retval;
 }