All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Add missing link states in dwc3 gadget wakeup
@ 2021-04-23 13:23 Marcel Hamer
  2021-04-23 14:40 ` Marcel Hamer
  0 siblings, 1 reply; 4+ messages in thread
From: Marcel Hamer @ 2021-04-23 13:23 UTC (permalink / raw)
  To: linux-usb; +Cc: Marcel Hamer

In dwc3_send_gadget_ep_cmd() a check is performed if the gadget needs
waking up. The following condition is checked before calling the
__dwc3_gadget_wakeup() function:

	needs_wakeup = (dwc->link_state == DWC3_LINK_STATE_U1 ||
        		dwc->link_state == DWC3_LINK_STATE_U2 ||
                        dwc->link_state == DWC3_LINK_STATE_U3);

Inside __dwc3_gadget_wakeup() only link_state DWC3_LINK_STATE_U3 is checked
and link state DWC3_LINK_STATE_U1 and DWC3_LINK_STATE_U2 are considered
invalid and generate a warning becaus of the call to:

dev_WARN_ONCE(dwc->dev, ret, "wakeup failed --> %d\n", ret);

because of ret being -EINVAL.

Signed-off-by: Marcel Hamer <marcel@solidxs.se>
---
 drivers/usb/dwc3/gadget.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index c7ef218e7a8c..d05a7d630410 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1972,6 +1972,8 @@ static int __dwc3_gadget_wakeup(struct dwc3 *dwc)
 	switch (link_state) {
 	case DWC3_LINK_STATE_RESET:
 	case DWC3_LINK_STATE_RX_DET:	/* in HS, means Early Suspend */
+	case DWC3_LINK_STATE_U1:
+	case DWC3_LINK_STATE_U2:
 	case DWC3_LINK_STATE_U3:	/* in HS, means SUSPEND */
 	case DWC3_LINK_STATE_RESUME:
 		break;
-- 
2.25.1


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

* Re: [PATCH] Add missing link states in dwc3 gadget wakeup
  2021-04-23 13:23 [PATCH] Add missing link states in dwc3 gadget wakeup Marcel Hamer
@ 2021-04-23 14:40 ` Marcel Hamer
  2021-04-23 15:04   ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: Marcel Hamer @ 2021-04-23 14:40 UTC (permalink / raw)
  To: Marcel Hamer; +Cc: linux-usb

Hello,

I would like to add that I do not have the dwc3 documentation myself,
given it is not publically available. I deduced the patch from active 
debugging on my system.

Please let me know if DWC3_LINK_STATE_U1 and DWC3_LINK_STATE_U2 should
either be removed from the 'needs_wakeup =' line instead. Or if
something else is off with the proposed patch.

Kind regards,

Marcel

On Fri, Apr 23, 2021 at 03:23:14PM +0200, Marcel Hamer wrote:
> In dwc3_send_gadget_ep_cmd() a check is performed if the gadget needs
> waking up. The following condition is checked before calling the
> __dwc3_gadget_wakeup() function:
> 
> 	needs_wakeup = (dwc->link_state == DWC3_LINK_STATE_U1 ||
>         		dwc->link_state == DWC3_LINK_STATE_U2 ||
>                         dwc->link_state == DWC3_LINK_STATE_U3);
> 
> Inside __dwc3_gadget_wakeup() only link_state DWC3_LINK_STATE_U3 is checked
> and link state DWC3_LINK_STATE_U1 and DWC3_LINK_STATE_U2 are considered
> invalid and generate a warning becaus of the call to:
> 
> dev_WARN_ONCE(dwc->dev, ret, "wakeup failed --> %d\n", ret);
> 
> because of ret being -EINVAL.
> 
> Signed-off-by: Marcel Hamer <marcel@solidxs.se>
> ---
>  drivers/usb/dwc3/gadget.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
> index c7ef218e7a8c..d05a7d630410 100644
> --- a/drivers/usb/dwc3/gadget.c
> +++ b/drivers/usb/dwc3/gadget.c
> @@ -1972,6 +1972,8 @@ static int __dwc3_gadget_wakeup(struct dwc3 *dwc)
>  	switch (link_state) {
>  	case DWC3_LINK_STATE_RESET:
>  	case DWC3_LINK_STATE_RX_DET:	/* in HS, means Early Suspend */
> +	case DWC3_LINK_STATE_U1:
> +	case DWC3_LINK_STATE_U2:
>  	case DWC3_LINK_STATE_U3:	/* in HS, means SUSPEND */
>  	case DWC3_LINK_STATE_RESUME:
>  		break;
> -- 
> 2.25.1
> 

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

* Re: [PATCH] Add missing link states in dwc3 gadget wakeup
  2021-04-23 14:40 ` Marcel Hamer
@ 2021-04-23 15:04   ` Greg KH
  2021-04-23 15:10     ` Marcel Hamer
  0 siblings, 1 reply; 4+ messages in thread
From: Greg KH @ 2021-04-23 15:04 UTC (permalink / raw)
  To: Marcel Hamer; +Cc: Marcel Hamer, linux-usb

On Fri, Apr 23, 2021 at 04:40:08PM +0200, Marcel Hamer wrote:
> Hello,
> 
> I would like to add that I do not have the dwc3 documentation myself,
> given it is not publically available. I deduced the patch from active 
> debugging on my system.
> 
> Please let me know if DWC3_LINK_STATE_U1 and DWC3_LINK_STATE_U2 should
> either be removed from the 'needs_wakeup =' line instead. Or if
> something else is off with the proposed patch.

When submitting patches, please use scripts/get_maintainers.pl to know
who to cc: so that they know to pay attention to your commit.  Care to
do that again here and resend it?

Also, you might want to change your subject line to match up with others
for this driver:
	[PATCH] USB: dwc3: add missing link...

thanks,

greg k-h

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

* Re: [PATCH] Add missing link states in dwc3 gadget wakeup
  2021-04-23 15:04   ` Greg KH
@ 2021-04-23 15:10     ` Marcel Hamer
  0 siblings, 0 replies; 4+ messages in thread
From: Marcel Hamer @ 2021-04-23 15:10 UTC (permalink / raw)
  To: Greg KH; +Cc: Marcel Hamer, linux-usb

On Fri, Apr 23, 2021 at 05:04:35PM +0200, Greg KH wrote:
> On Fri, Apr 23, 2021 at 04:40:08PM +0200, Marcel Hamer wrote:
> > Hello,
> > 
> > I would like to add that I do not have the dwc3 documentation myself,
> > given it is not publically available. I deduced the patch from active 
> > debugging on my system.
> > 
> > Please let me know if DWC3_LINK_STATE_U1 and DWC3_LINK_STATE_U2 should
> > either be removed from the 'needs_wakeup =' line instead. Or if
> > something else is off with the proposed patch.
> 
> When submitting patches, please use scripts/get_maintainers.pl to know
> who to cc: so that they know to pay attention to your commit.  Care to
> do that again here and resend it?
> 
> Also, you might want to change your subject line to match up with others
> for this driver:
> 	[PATCH] USB: dwc3: add missing link...
> 
> thanks,
> 
> greg k-h

Absolutely, will resend it. Thanks for the information.

Marcel

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

end of thread, other threads:[~2021-04-23 15:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-23 13:23 [PATCH] Add missing link states in dwc3 gadget wakeup Marcel Hamer
2021-04-23 14:40 ` Marcel Hamer
2021-04-23 15:04   ` Greg KH
2021-04-23 15:10     ` Marcel Hamer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.