linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: gadget: f_acm: don't disable disabled EP
@ 2020-05-28 18:30 Michał Mirosław
  2020-05-29  8:10 ` Peter Chen
  0 siblings, 1 reply; 8+ messages in thread
From: Michał Mirosław @ 2020-05-28 18:30 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Robert Baldyga; +Cc: linux-usb, linux-kernel

Make debugging real problems easier by not trying to disable an EP that
was not yet enabled.

Fixes: 4aab757ca44a ("usb: gadget: f_acm: eliminate abuse of ep->driver data")
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
 drivers/usb/gadget/function/f_acm.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/gadget/function/f_acm.c b/drivers/usb/gadget/function/f_acm.c
index 200596ea9557..46647bfac2ef 100644
--- a/drivers/usb/gadget/function/f_acm.c
+++ b/drivers/usb/gadget/function/f_acm.c
@@ -425,9 +425,11 @@ static int acm_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
 	/* we know alt == 0, so this is an activation or a reset */
 
 	if (intf == acm->ctrl_id) {
-		dev_vdbg(&cdev->gadget->dev,
-				"reset acm control interface %d\n", intf);
-		usb_ep_disable(acm->notify);
+		if (acm->notify->enabled) {
+			dev_vdbg(&cdev->gadget->dev,
+					"reset acm control interface %d\n", intf);
+			usb_ep_disable(acm->notify);
+		}
 
 		if (!acm->notify->desc)
 			if (config_ep_by_speed(cdev->gadget, f, acm->notify))
-- 
2.20.1


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

* Re: [PATCH] usb: gadget: f_acm: don't disable disabled EP
  2020-05-28 18:30 [PATCH] usb: gadget: f_acm: don't disable disabled EP Michał Mirosław
@ 2020-05-29  8:10 ` Peter Chen
  2020-05-29 13:55   ` Michał Mirosław
  0 siblings, 1 reply; 8+ messages in thread
From: Peter Chen @ 2020-05-29  8:10 UTC (permalink / raw)
  To: Michał Mirosław
  Cc: Felipe Balbi, Greg Kroah-Hartman, Robert Baldyga, linux-usb,
	linux-kernel

On 20-05-28 20:30:28, Michał Mirosław wrote:
> Make debugging real problems easier by not trying to disable an EP that
> was not yet enabled.
> 
> Fixes: 4aab757ca44a ("usb: gadget: f_acm: eliminate abuse of ep->driver data")
> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> ---
>  drivers/usb/gadget/function/f_acm.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/usb/gadget/function/f_acm.c b/drivers/usb/gadget/function/f_acm.c
> index 200596ea9557..46647bfac2ef 100644
> --- a/drivers/usb/gadget/function/f_acm.c
> +++ b/drivers/usb/gadget/function/f_acm.c
> @@ -425,9 +425,11 @@ static int acm_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
>  	/* we know alt == 0, so this is an activation or a reset */
>  
>  	if (intf == acm->ctrl_id) {
> -		dev_vdbg(&cdev->gadget->dev,
> -				"reset acm control interface %d\n", intf);
> -		usb_ep_disable(acm->notify);
> +		if (acm->notify->enabled) {
> +			dev_vdbg(&cdev->gadget->dev,
> +					"reset acm control interface %d\n", intf);
> +			usb_ep_disable(acm->notify);
> +		}

But it does not fix any issues, the usb_ep_disable checks 'enabled' flag.

-- 

Thanks,
Peter Chen

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

* Re: [PATCH] usb: gadget: f_acm: don't disable disabled EP
  2020-05-29  8:10 ` Peter Chen
@ 2020-05-29 13:55   ` Michał Mirosław
  2020-05-30  1:03     ` Peter Chen
  0 siblings, 1 reply; 8+ messages in thread
From: Michał Mirosław @ 2020-05-29 13:55 UTC (permalink / raw)
  To: Peter Chen
  Cc: Felipe Balbi, Greg Kroah-Hartman, Robert Baldyga, linux-usb,
	linux-kernel

On Fri, May 29, 2020 at 08:10:40AM +0000, Peter Chen wrote:
> On 20-05-28 20:30:28, Michał Mirosław wrote:
> > Make debugging real problems easier by not trying to disable an EP that
> > was not yet enabled.
> > 
> > Fixes: 4aab757ca44a ("usb: gadget: f_acm: eliminate abuse of ep->driver data")
> > Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> > ---
> >  drivers/usb/gadget/function/f_acm.c | 8 +++++---
> >  1 file changed, 5 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/usb/gadget/function/f_acm.c b/drivers/usb/gadget/function/f_acm.c
> > index 200596ea9557..46647bfac2ef 100644
> > --- a/drivers/usb/gadget/function/f_acm.c
> > +++ b/drivers/usb/gadget/function/f_acm.c
> > @@ -425,9 +425,11 @@ static int acm_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
> >  	/* we know alt == 0, so this is an activation or a reset */
> >  
> >  	if (intf == acm->ctrl_id) {
> > -		dev_vdbg(&cdev->gadget->dev,
> > -				"reset acm control interface %d\n", intf);
> > -		usb_ep_disable(acm->notify);
> > +		if (acm->notify->enabled) {
> > +			dev_vdbg(&cdev->gadget->dev,
> > +					"reset acm control interface %d\n", intf);
> > +			usb_ep_disable(acm->notify);
> > +		}
> 
> But it does not fix any issues, the usb_ep_disable checks 'enabled' flag.

It generates spurious trace events if you enable them.

Best Regards,
Michał Mirosław

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

* RE: [PATCH] usb: gadget: f_acm: don't disable disabled EP
  2020-05-29 13:55   ` Michał Mirosław
@ 2020-05-30  1:03     ` Peter Chen
  2020-05-30 17:15       ` Michał Mirosław
  2020-07-01  6:53       ` Felipe Balbi
  0 siblings, 2 replies; 8+ messages in thread
From: Peter Chen @ 2020-05-30  1:03 UTC (permalink / raw)
  To: Michał Mirosław
  Cc: Felipe Balbi, Greg Kroah-Hartman, linux-usb, linux-kernel

 
> > > @@ -425,9 +425,11 @@ static int acm_set_alt(struct usb_function *f, unsigned
> intf, unsigned alt)
> > >  	/* we know alt == 0, so this is an activation or a reset */
> > >
> > >  	if (intf == acm->ctrl_id) {
> > > -		dev_vdbg(&cdev->gadget->dev,
> > > -				"reset acm control interface %d\n", intf);
> > > -		usb_ep_disable(acm->notify);
> > > +		if (acm->notify->enabled) {
> > > +			dev_vdbg(&cdev->gadget->dev,
> > > +					"reset acm control interface %d\n", intf);
> > > +			usb_ep_disable(acm->notify);
> > > +		}
> >
> > But it does not fix any issues, the usb_ep_disable checks 'enabled' flag.
> 
> It generates spurious trace events if you enable them.
> 

You mean the trace events from core.c? If it is, we could try to improve it
and indicate it is already enabled or disabled.

Peter

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

* Re: [PATCH] usb: gadget: f_acm: don't disable disabled EP
  2020-05-30  1:03     ` Peter Chen
@ 2020-05-30 17:15       ` Michał Mirosław
  2020-06-01  3:53         ` Peter Chen
  2020-07-01  6:54         ` Felipe Balbi
  2020-07-01  6:53       ` Felipe Balbi
  1 sibling, 2 replies; 8+ messages in thread
From: Michał Mirosław @ 2020-05-30 17:15 UTC (permalink / raw)
  To: Peter Chen; +Cc: Felipe Balbi, Greg Kroah-Hartman, linux-usb, linux-kernel

On Sat, May 30, 2020 at 01:03:17AM +0000, Peter Chen wrote:
>  
> > > > @@ -425,9 +425,11 @@ static int acm_set_alt(struct usb_function *f, unsigned
> > intf, unsigned alt)
> > > >  	/* we know alt == 0, so this is an activation or a reset */
> > > >
> > > >  	if (intf == acm->ctrl_id) {
> > > > -		dev_vdbg(&cdev->gadget->dev,
> > > > -				"reset acm control interface %d\n", intf);
> > > > -		usb_ep_disable(acm->notify);
> > > > +		if (acm->notify->enabled) {
> > > > +			dev_vdbg(&cdev->gadget->dev,
> > > > +					"reset acm control interface %d\n", intf);
> > > > +			usb_ep_disable(acm->notify);
> > > > +		}
> > >
> > > But it does not fix any issues, the usb_ep_disable checks 'enabled' flag.
> > 
> > It generates spurious trace events if you enable them.
> You mean the trace events from core.c? If it is, we could try to improve it
> and indicate it is already enabled or disabled.

It is indicated in return code, but the problem is that this generates
noise and wastes debugging time. The problem I was seeing manifested
itself as disabling disabled EPs and desync of EP state between core
and UDC driver. The patch avoids the noise and makes the code obvious.
(This check was there at some point in time, BTW.)

Best Regards,
Michał Mirosław

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

* Re: [PATCH] usb: gadget: f_acm: don't disable disabled EP
  2020-05-30 17:15       ` Michał Mirosław
@ 2020-06-01  3:53         ` Peter Chen
  2020-07-01  6:54         ` Felipe Balbi
  1 sibling, 0 replies; 8+ messages in thread
From: Peter Chen @ 2020-06-01  3:53 UTC (permalink / raw)
  To: Michał Mirosław
  Cc: Felipe Balbi, Greg Kroah-Hartman, linux-usb, linux-kernel

On 20-05-30 19:15:52, Michał Mirosław wrote:
> On Sat, May 30, 2020 at 01:03:17AM +0000, Peter Chen wrote:
> >  
> > > > > @@ -425,9 +425,11 @@ static int acm_set_alt(struct usb_function *f, unsigned
> > > intf, unsigned alt)
> > > > >  	/* we know alt == 0, so this is an activation or a reset */
> > > > >
> > > > >  	if (intf == acm->ctrl_id) {
> > > > > -		dev_vdbg(&cdev->gadget->dev,
> > > > > -				"reset acm control interface %d\n", intf);
> > > > > -		usb_ep_disable(acm->notify);
> > > > > +		if (acm->notify->enabled) {
> > > > > +			dev_vdbg(&cdev->gadget->dev,
> > > > > +					"reset acm control interface %d\n", intf);
> > > > > +			usb_ep_disable(acm->notify);
> > > > > +		}
> > > >
> > > > But it does not fix any issues, the usb_ep_disable checks 'enabled' flag.
> > > 
> > > It generates spurious trace events if you enable them.
> > You mean the trace events from core.c? If it is, we could try to improve it
> > and indicate it is already enabled or disabled.
> 
> It is indicated in return code, but the problem is that this generates
> noise and wastes debugging time. The problem I was seeing manifested
> itself as disabling disabled EPs and desync of EP state between core
> and UDC driver. The patch avoids the noise and makes the code obvious.
> (This check was there at some point in time, BTW.)
> 

Reviewed-by: Peter Chen <peter.chen@nxp.com>



-- 

Thanks,
Peter Chen

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

* RE: [PATCH] usb: gadget: f_acm: don't disable disabled EP
  2020-05-30  1:03     ` Peter Chen
  2020-05-30 17:15       ` Michał Mirosław
@ 2020-07-01  6:53       ` Felipe Balbi
  1 sibling, 0 replies; 8+ messages in thread
From: Felipe Balbi @ 2020-07-01  6:53 UTC (permalink / raw)
  To: Peter Chen, Michał Mirosław
  Cc: Greg Kroah-Hartman, linux-usb, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 917 bytes --]

Peter Chen <peter.chen@nxp.com> writes:

>  
>> > > @@ -425,9 +425,11 @@ static int acm_set_alt(struct usb_function *f, unsigned
>> intf, unsigned alt)
>> > >  	/* we know alt == 0, so this is an activation or a reset */
>> > >
>> > >  	if (intf == acm->ctrl_id) {
>> > > -		dev_vdbg(&cdev->gadget->dev,
>> > > -				"reset acm control interface %d\n", intf);
>> > > -		usb_ep_disable(acm->notify);
>> > > +		if (acm->notify->enabled) {
>> > > +			dev_vdbg(&cdev->gadget->dev,
>> > > +					"reset acm control interface %d\n", intf);
>> > > +			usb_ep_disable(acm->notify);
>> > > +		}
>> >
>> > But it does not fix any issues, the usb_ep_disable checks 'enabled' flag.
>> 
>> It generates spurious trace events if you enable them.
>> 
>
> You mean the trace events from core.c? If it is, we could try to improve it
> and indicate it is already enabled or disabled.

I agree :-)

-- 
balbi

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

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

* Re: [PATCH] usb: gadget: f_acm: don't disable disabled EP
  2020-05-30 17:15       ` Michał Mirosław
  2020-06-01  3:53         ` Peter Chen
@ 2020-07-01  6:54         ` Felipe Balbi
  1 sibling, 0 replies; 8+ messages in thread
From: Felipe Balbi @ 2020-07-01  6:54 UTC (permalink / raw)
  To: Michał Mirosław, Peter Chen
  Cc: Greg Kroah-Hartman, linux-usb, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1493 bytes --]

Michał Mirosław <mirq-linux@rere.qmqm.pl> writes:

> On Sat, May 30, 2020 at 01:03:17AM +0000, Peter Chen wrote:
>>  
>> > > > @@ -425,9 +425,11 @@ static int acm_set_alt(struct usb_function *f, unsigned
>> > intf, unsigned alt)
>> > > >  	/* we know alt == 0, so this is an activation or a reset */
>> > > >
>> > > >  	if (intf == acm->ctrl_id) {
>> > > > -		dev_vdbg(&cdev->gadget->dev,
>> > > > -				"reset acm control interface %d\n", intf);
>> > > > -		usb_ep_disable(acm->notify);
>> > > > +		if (acm->notify->enabled) {
>> > > > +			dev_vdbg(&cdev->gadget->dev,
>> > > > +					"reset acm control interface %d\n", intf);
>> > > > +			usb_ep_disable(acm->notify);
>> > > > +		}
>> > >
>> > > But it does not fix any issues, the usb_ep_disable checks 'enabled' flag.
>> > 
>> > It generates spurious trace events if you enable them.
>> You mean the trace events from core.c? If it is, we could try to improve it
>> and indicate it is already enabled or disabled.
>
> It is indicated in return code, but the problem is that this generates
> noise and wastes debugging time. The problem I was seeing manifested
> itself as disabling disabled EPs and desync of EP state between core
> and UDC driver. The patch avoids the noise and makes the code obvious.
> (This check was there at some point in time, BTW.)

I agree with this as well. But still, $subject doesn't look like a
candidate for the -rc :-) I'll apply it for the next merge window.

-- 
balbi

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

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

end of thread, other threads:[~2020-07-01  6:54 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-28 18:30 [PATCH] usb: gadget: f_acm: don't disable disabled EP Michał Mirosław
2020-05-29  8:10 ` Peter Chen
2020-05-29 13:55   ` Michał Mirosław
2020-05-30  1:03     ` Peter Chen
2020-05-30 17:15       ` Michał Mirosław
2020-06-01  3:53         ` Peter Chen
2020-07-01  6:54         ` Felipe Balbi
2020-07-01  6:53       ` Felipe Balbi

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).