diff mbox

[3/9] usb: dwc2/gadget: fix support for soft_connect udc framework feature

Message ID 20141017154630.GQ26260@saruman (mailing list archive)
State New, archived
Headers show

Commit Message

Felipe Balbi Oct. 17, 2014, 3:46 p.m. UTC
Hi,

On Fri, Oct 17, 2014 at 10:44:35AM -0500, Felipe Balbi wrote:
> On Fri, Oct 17, 2014 at 12:43:48PM +0200, Marek Szyprowski wrote:
> > Hello,
> > 
> > On 2014-10-16 15:36, Felipe Balbi wrote:
> > >On Thu, Oct 16, 2014 at 02:57:59PM +0200, Marek Szyprowski wrote:
> > >>Enabling and disabling usb gadget by writing to
> > >>/sys/class/udc/*hsotg/soft_connect results in calling udc_start/udc_stop
> > >>functions with the same usb gadget driver, so the driver should not WARN
> > >>about such case.
> > >>
> > >>Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
> > >>---
> > >>  drivers/usb/dwc2/gadget.c | 2 +-
> > >>  1 file changed, 1 insertion(+), 1 deletion(-)
> > >>
> > >>diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
> > >>index 8870e38c1d82..37fda4c03397 100644
> > >>--- a/drivers/usb/dwc2/gadget.c
> > >>+++ b/drivers/usb/dwc2/gadget.c
> > >>@@ -2892,7 +2892,7 @@ static int s3c_hsotg_udc_start(struct usb_gadget *gadget,
> > >>  		return -EINVAL;
> > >>  	}
> > >>-	WARN_ON(hsotg->driver);
> > >>+	WARN_ON(hsotg->driver && hsotg->driver != driver);
> > >the bug is in your ->udc_stop(). You should clear hsotg->driver to NULL
> > >there.
> > 
> > Ok, I will change udc_stop() to always zero hsotg->driver, like other udc
> > drivers. I was a bit confused by the fact that udc core passes driver to
> > udc_stop(), when called from soft_connect and NULL on gadget removal.
> 
> That can probably be cleaned up, I'll go have a look on all UDCs and
> make sure I won't break anything.

looks like chipidea is the only one still using that argument, if you
make your patch look like below:


I'll remove the argument.

Comments

Felipe Balbi Oct. 17, 2014, 3:49 p.m. UTC | #1
On Fri, Oct 17, 2014 at 10:46:30AM -0500, Felipe Balbi wrote:
> Hi,
> 
> On Fri, Oct 17, 2014 at 10:44:35AM -0500, Felipe Balbi wrote:
> > On Fri, Oct 17, 2014 at 12:43:48PM +0200, Marek Szyprowski wrote:
> > > Hello,
> > > 
> > > On 2014-10-16 15:36, Felipe Balbi wrote:
> > > >On Thu, Oct 16, 2014 at 02:57:59PM +0200, Marek Szyprowski wrote:
> > > >>Enabling and disabling usb gadget by writing to
> > > >>/sys/class/udc/*hsotg/soft_connect results in calling udc_start/udc_stop
> > > >>functions with the same usb gadget driver, so the driver should not WARN
> > > >>about such case.
> > > >>
> > > >>Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
> > > >>---
> > > >>  drivers/usb/dwc2/gadget.c | 2 +-
> > > >>  1 file changed, 1 insertion(+), 1 deletion(-)
> > > >>
> > > >>diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
> > > >>index 8870e38c1d82..37fda4c03397 100644
> > > >>--- a/drivers/usb/dwc2/gadget.c
> > > >>+++ b/drivers/usb/dwc2/gadget.c
> > > >>@@ -2892,7 +2892,7 @@ static int s3c_hsotg_udc_start(struct usb_gadget *gadget,
> > > >>  		return -EINVAL;
> > > >>  	}
> > > >>-	WARN_ON(hsotg->driver);
> > > >>+	WARN_ON(hsotg->driver && hsotg->driver != driver);
> > > >the bug is in your ->udc_stop(). You should clear hsotg->driver to NULL
> > > >there.
> > > 
> > > Ok, I will change udc_stop() to always zero hsotg->driver, like other udc
> > > drivers. I was a bit confused by the fact that udc core passes driver to
> > > udc_stop(), when called from soft_connect and NULL on gadget removal.
> > 
> > That can probably be cleaned up, I'll go have a look on all UDCs and
> > make sure I won't break anything.
> 
> looks like chipidea is the only one still using that argument, if you

meant dwc2
Felipe Balbi Oct. 17, 2014, 4:02 p.m. UTC | #2
On Fri, Oct 17, 2014 at 10:49:25AM -0500, Felipe Balbi wrote:
> On Fri, Oct 17, 2014 at 10:46:30AM -0500, Felipe Balbi wrote:
> > Hi,
> > 
> > On Fri, Oct 17, 2014 at 10:44:35AM -0500, Felipe Balbi wrote:
> > > On Fri, Oct 17, 2014 at 12:43:48PM +0200, Marek Szyprowski wrote:
> > > > Hello,
> > > > 
> > > > On 2014-10-16 15:36, Felipe Balbi wrote:
> > > > >On Thu, Oct 16, 2014 at 02:57:59PM +0200, Marek Szyprowski wrote:
> > > > >>Enabling and disabling usb gadget by writing to
> > > > >>/sys/class/udc/*hsotg/soft_connect results in calling udc_start/udc_stop
> > > > >>functions with the same usb gadget driver, so the driver should not WARN
> > > > >>about such case.
> > > > >>
> > > > >>Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
> > > > >>---
> > > > >>  drivers/usb/dwc2/gadget.c | 2 +-
> > > > >>  1 file changed, 1 insertion(+), 1 deletion(-)
> > > > >>
> > > > >>diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
> > > > >>index 8870e38c1d82..37fda4c03397 100644
> > > > >>--- a/drivers/usb/dwc2/gadget.c
> > > > >>+++ b/drivers/usb/dwc2/gadget.c
> > > > >>@@ -2892,7 +2892,7 @@ static int s3c_hsotg_udc_start(struct usb_gadget *gadget,
> > > > >>  		return -EINVAL;
> > > > >>  	}
> > > > >>-	WARN_ON(hsotg->driver);
> > > > >>+	WARN_ON(hsotg->driver && hsotg->driver != driver);
> > > > >the bug is in your ->udc_stop(). You should clear hsotg->driver to NULL
> > > > >there.
> > > > 
> > > > Ok, I will change udc_stop() to always zero hsotg->driver, like other udc
> > > > drivers. I was a bit confused by the fact that udc core passes driver to
> > > > udc_stop(), when called from soft_connect and NULL on gadget removal.
> > > 
> > > That can probably be cleaned up, I'll go have a look on all UDCs and
> > > make sure I won't break anything.
> > 
> > looks like chipidea is the only one still using that argument, if you
> 
> meant dwc2

Hmm, there are still a few other gadgets relying on that argument. It'll
take a little more effort to remove it.
Felipe Balbi Oct. 17, 2014, 5:07 p.m. UTC | #3
On Fri, Oct 17, 2014 at 11:02:34AM -0500, Felipe Balbi wrote:
> On Fri, Oct 17, 2014 at 10:49:25AM -0500, Felipe Balbi wrote:
> > On Fri, Oct 17, 2014 at 10:46:30AM -0500, Felipe Balbi wrote:
> > > Hi,
> > > 
> > > On Fri, Oct 17, 2014 at 10:44:35AM -0500, Felipe Balbi wrote:
> > > > On Fri, Oct 17, 2014 at 12:43:48PM +0200, Marek Szyprowski wrote:
> > > > > Hello,
> > > > > 
> > > > > On 2014-10-16 15:36, Felipe Balbi wrote:
> > > > > >On Thu, Oct 16, 2014 at 02:57:59PM +0200, Marek Szyprowski wrote:
> > > > > >>Enabling and disabling usb gadget by writing to
> > > > > >>/sys/class/udc/*hsotg/soft_connect results in calling udc_start/udc_stop
> > > > > >>functions with the same usb gadget driver, so the driver should not WARN
> > > > > >>about such case.
> > > > > >>
> > > > > >>Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
> > > > > >>---
> > > > > >>  drivers/usb/dwc2/gadget.c | 2 +-
> > > > > >>  1 file changed, 1 insertion(+), 1 deletion(-)
> > > > > >>
> > > > > >>diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
> > > > > >>index 8870e38c1d82..37fda4c03397 100644
> > > > > >>--- a/drivers/usb/dwc2/gadget.c
> > > > > >>+++ b/drivers/usb/dwc2/gadget.c
> > > > > >>@@ -2892,7 +2892,7 @@ static int s3c_hsotg_udc_start(struct usb_gadget *gadget,
> > > > > >>  		return -EINVAL;
> > > > > >>  	}
> > > > > >>-	WARN_ON(hsotg->driver);
> > > > > >>+	WARN_ON(hsotg->driver && hsotg->driver != driver);
> > > > > >the bug is in your ->udc_stop(). You should clear hsotg->driver to NULL
> > > > > >there.
> > > > > 
> > > > > Ok, I will change udc_stop() to always zero hsotg->driver, like other udc
> > > > > drivers. I was a bit confused by the fact that udc core passes driver to
> > > > > udc_stop(), when called from soft_connect and NULL on gadget removal.
> > > > 
> > > > That can probably be cleaned up, I'll go have a look on all UDCs and
> > > > make sure I won't break anything.
> > > 
> > > looks like chipidea is the only one still using that argument, if you
> > 
> > meant dwc2
> 
> Hmm, there are still a few other gadgets relying on that argument. It'll
> take a little more effort to remove it.

Alright, just pending your bug fix. I have fixed all other drivers. Will
send out shortly.
diff mbox

Patch

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 7b5856f..ac14328 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -2934,8 +2934,7 @@  static int s3c_hsotg_udc_stop(struct usb_gadget *gadget,
 
 	spin_lock_irqsave(&hsotg->lock, flags);
 
-	if (!driver)
-		hsotg->driver = NULL;
+	hsotg->driver = NULL;
 
 	hsotg->gadget.speed = USB_SPEED_UNKNOWN;