linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: dwc3: gadget: Remove check for bounded driver
@ 2021-02-04  4:14 Thinh Nguyen
  2021-02-05  9:26 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 5+ messages in thread
From: Thinh Nguyen @ 2021-02-04  4:14 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, linux-usb; +Cc: John Youn

The check for bounded gadget driver in dwc3_gadget_start() was to
prevent going through the initialization again without any cleanup. With
a recent update, the UDC framework guarantees this won't happen while
the UDC is started. Also, this check doesn't prevent requesting threaded
irq to the same dev_id, which will mess up the irq freeing logic. Let's
remove it.

Signed-off-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
---
 drivers/usb/dwc3/gadget.c | 19 ++-----------------
 1 file changed, 2 insertions(+), 17 deletions(-)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 86f257f12d45..6a18e822fa98 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -2370,7 +2370,7 @@ static int dwc3_gadget_start(struct usb_gadget *g,
 {
 	struct dwc3		*dwc = gadget_to_dwc(g);
 	unsigned long		flags;
-	int			ret = 0;
+	int			ret;
 	int			irq;
 
 	irq = dwc->irq_gadget;
@@ -2379,29 +2379,14 @@ static int dwc3_gadget_start(struct usb_gadget *g,
 	if (ret) {
 		dev_err(dwc->dev, "failed to request irq #%d --> %d\n",
 				irq, ret);
-		goto err0;
+		return ret;
 	}
 
 	spin_lock_irqsave(&dwc->lock, flags);
-	if (dwc->gadget_driver) {
-		dev_err(dwc->dev, "%s is already bound to %s\n",
-				dwc->gadget->name,
-				dwc->gadget_driver->driver.name);
-		ret = -EBUSY;
-		goto err1;
-	}
-
 	dwc->gadget_driver	= driver;
 	spin_unlock_irqrestore(&dwc->lock, flags);
 
 	return 0;
-
-err1:
-	spin_unlock_irqrestore(&dwc->lock, flags);
-	free_irq(irq, dwc);
-
-err0:
-	return ret;
 }
 
 static void __dwc3_gadget_stop(struct dwc3 *dwc)

base-commit: d021e0694d77ee3cdc5d3fca2c8d53ae7575499a
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] usb: dwc3: gadget: Remove check for bounded driver
  2021-02-04  4:14 [PATCH] usb: dwc3: gadget: Remove check for bounded driver Thinh Nguyen
@ 2021-02-05  9:26 ` Greg Kroah-Hartman
  2021-02-05  9:39   ` Thinh Nguyen
  0 siblings, 1 reply; 5+ messages in thread
From: Greg Kroah-Hartman @ 2021-02-05  9:26 UTC (permalink / raw)
  To: Thinh Nguyen; +Cc: Felipe Balbi, linux-usb, John Youn

On Wed, Feb 03, 2021 at 08:14:37PM -0800, Thinh Nguyen wrote:
> The check for bounded gadget driver in dwc3_gadget_start() was to
> prevent going through the initialization again without any cleanup. With
> a recent update, the UDC framework guarantees this won't happen while
> the UDC is started. Also, this check doesn't prevent requesting threaded
> irq to the same dev_id, which will mess up the irq freeing logic. Let's
> remove it.

What "recent update" caused this?  Is this a fix for something that
needs to be backported?  If so, can you provide a "Fixes:" tag on here?
Or is this just a general cleanup that is good to do now.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] usb: dwc3: gadget: Remove check for bounded driver
  2021-02-05  9:26 ` Greg Kroah-Hartman
@ 2021-02-05  9:39   ` Thinh Nguyen
  2021-02-05  9:41     ` Greg Kroah-Hartman
  0 siblings, 1 reply; 5+ messages in thread
From: Thinh Nguyen @ 2021-02-05  9:39 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Thinh Nguyen; +Cc: Felipe Balbi, linux-usb, John Youn

Greg Kroah-Hartman wrote:
> On Wed, Feb 03, 2021 at 08:14:37PM -0800, Thinh Nguyen wrote:
>> The check for bounded gadget driver in dwc3_gadget_start() was to
>> prevent going through the initialization again without any cleanup. With
>> a recent update, the UDC framework guarantees this won't happen while
>> the UDC is started. Also, this check doesn't prevent requesting threaded
>> irq to the same dev_id, which will mess up the irq freeing logic. Let's
>> remove it.
> What "recent update" caused this?  Is this a fix for something that
> needs to be backported?  If so, can you provide a "Fixes:" tag on here?
> Or is this just a general cleanup that is good to do now.
>
> thanks,
>
> greg k-h

It's general cleanup. The "recent update" is not in mainline yet but on
your "usb-next" branch so I'm not sure how to properly reference it.

But here's the commit on your branch I was referring to: 49d08cfc7830
("usb: udc: core: Introduce started state")

No need to backport this because it doesn't fix anything.

Thanks,
Thinh


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] usb: dwc3: gadget: Remove check for bounded driver
  2021-02-05  9:39   ` Thinh Nguyen
@ 2021-02-05  9:41     ` Greg Kroah-Hartman
  2021-02-05  9:55       ` Thinh Nguyen
  0 siblings, 1 reply; 5+ messages in thread
From: Greg Kroah-Hartman @ 2021-02-05  9:41 UTC (permalink / raw)
  To: Thinh Nguyen; +Cc: Felipe Balbi, linux-usb, John Youn

On Fri, Feb 05, 2021 at 09:39:37AM +0000, Thinh Nguyen wrote:
> Greg Kroah-Hartman wrote:
> > On Wed, Feb 03, 2021 at 08:14:37PM -0800, Thinh Nguyen wrote:
> >> The check for bounded gadget driver in dwc3_gadget_start() was to
> >> prevent going through the initialization again without any cleanup. With
> >> a recent update, the UDC framework guarantees this won't happen while
> >> the UDC is started. Also, this check doesn't prevent requesting threaded
> >> irq to the same dev_id, which will mess up the irq freeing logic. Let's
> >> remove it.
> > What "recent update" caused this?  Is this a fix for something that
> > needs to be backported?  If so, can you provide a "Fixes:" tag on here?
> > Or is this just a general cleanup that is good to do now.
> >
> > thanks,
> >
> > greg k-h
> 
> It's general cleanup. The "recent update" is not in mainline yet but on
> your "usb-next" branch so I'm not sure how to properly reference it.
> 
> But here's the commit on your branch I was referring to: 49d08cfc7830
> ("usb: udc: core: Introduce started state")

Please refer to this commit just like this, as the id is not going to
change.  Can you redo this patch with that information in it?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] usb: dwc3: gadget: Remove check for bounded driver
  2021-02-05  9:41     ` Greg Kroah-Hartman
@ 2021-02-05  9:55       ` Thinh Nguyen
  0 siblings, 0 replies; 5+ messages in thread
From: Thinh Nguyen @ 2021-02-05  9:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Thinh Nguyen; +Cc: Felipe Balbi, linux-usb, John Youn

Greg Kroah-Hartman wrote:
> On Fri, Feb 05, 2021 at 09:39:37AM +0000, Thinh Nguyen wrote:
>> Greg Kroah-Hartman wrote:
>>> On Wed, Feb 03, 2021 at 08:14:37PM -0800, Thinh Nguyen wrote:
>>>> The check for bounded gadget driver in dwc3_gadget_start() was to
>>>> prevent going through the initialization again without any cleanup. With
>>>> a recent update, the UDC framework guarantees this won't happen while
>>>> the UDC is started. Also, this check doesn't prevent requesting threaded
>>>> irq to the same dev_id, which will mess up the irq freeing logic. Let's
>>>> remove it.
>>> What "recent update" caused this?  Is this a fix for something that
>>> needs to be backported?  If so, can you provide a "Fixes:" tag on here?
>>> Or is this just a general cleanup that is good to do now.
>>>
>>> thanks,
>>>
>>> greg k-h
>> It's general cleanup. The "recent update" is not in mainline yet but on
>> your "usb-next" branch so I'm not sure how to properly reference it.
>>
>> But here's the commit on your branch I was referring to: 49d08cfc7830
>> ("usb: udc: core: Introduce started state")
> Please refer to this commit just like this, as the id is not going to
> change.  Can you redo this patch with that information in it?
>
> thanks,
>
> greg k-h

Will do.

Thanks,
Thinh

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-02-05 23:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-04  4:14 [PATCH] usb: dwc3: gadget: Remove check for bounded driver Thinh Nguyen
2021-02-05  9:26 ` Greg Kroah-Hartman
2021-02-05  9:39   ` Thinh Nguyen
2021-02-05  9:41     ` Greg Kroah-Hartman
2021-02-05  9:55       ` Thinh Nguyen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).