public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: gadget: u_ether: Set is_suspend flag if remote wakeup fails
@ 2025-02-12 10:08 Prashanth K
  2025-02-14  8:00 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 3+ messages in thread
From: Prashanth K @ 2025-02-12 10:08 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Ferry Toth, Ricardo B Marliere, Kees Cook
  Cc: linux-usb, Elson Roy Serrao, linux-kernel, Prashanth K, stable

Currently while UDC suspends, u_ether attempts to remote wakeup
the host if there are any pending transfers. However, if remote
wakeup fails, the UDC remains suspended but the is_suspend flag
is not set. And since is_suspend flag isn't set, the subsequent
eth_start_xmit() would queue USB requests to suspended UDC.

To fix this, bail out from gether_suspend() only if remote wakeup
operation is successful.

Cc: stable@vger.kernel.org
Fixes: 0a1af6dfa077 ("usb: gadget: f_ecm: Add suspend/resume and remote wakeup support")
Signed-off-by: Prashanth K <prashanth.k@oss.qualcomm.com>
---
 drivers/usb/gadget/function/u_ether.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/function/u_ether.c b/drivers/usb/gadget/function/u_ether.c
index 09e2838917e2..f58590bf5e02 100644
--- a/drivers/usb/gadget/function/u_ether.c
+++ b/drivers/usb/gadget/function/u_ether.c
@@ -1052,8 +1052,8 @@ void gether_suspend(struct gether *link)
 		 * There is a transfer in progress. So we trigger a remote
 		 * wakeup to inform the host.
 		 */
-		ether_wakeup_host(dev->port_usb);
-		return;
+		if (!ether_wakeup_host(dev->port_usb))
+			return;
 	}
 	spin_lock_irqsave(&dev->lock, flags);
 	link->is_suspend = true;
-- 
2.25.1


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

* Re: [PATCH] usb: gadget: u_ether: Set is_suspend flag if remote wakeup fails
  2025-02-12 10:08 [PATCH] usb: gadget: u_ether: Set is_suspend flag if remote wakeup fails Prashanth K
@ 2025-02-14  8:00 ` Greg Kroah-Hartman
  2025-02-14  8:54   ` Prashanth K
  0 siblings, 1 reply; 3+ messages in thread
From: Greg Kroah-Hartman @ 2025-02-14  8:00 UTC (permalink / raw)
  To: Prashanth K
  Cc: Ferry Toth, Ricardo B Marliere, Kees Cook, linux-usb,
	Elson Roy Serrao, linux-kernel, stable

On Wed, Feb 12, 2025 at 03:38:40PM +0530, Prashanth K wrote:
> Currently while UDC suspends, u_ether attempts to remote wakeup
> the host if there are any pending transfers. However, if remote
> wakeup fails, the UDC remains suspended but the is_suspend flag
> is not set. And since is_suspend flag isn't set, the subsequent
> eth_start_xmit() would queue USB requests to suspended UDC.
> 
> To fix this, bail out from gether_suspend() only if remote wakeup
> operation is successful.
> 
> Cc: stable@vger.kernel.org
> Fixes: 0a1af6dfa077 ("usb: gadget: f_ecm: Add suspend/resume and remote wakeup support")
> Signed-off-by: Prashanth K <prashanth.k@oss.qualcomm.com>
> ---
>  drivers/usb/gadget/function/u_ether.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/gadget/function/u_ether.c b/drivers/usb/gadget/function/u_ether.c
> index 09e2838917e2..f58590bf5e02 100644
> --- a/drivers/usb/gadget/function/u_ether.c
> +++ b/drivers/usb/gadget/function/u_ether.c
> @@ -1052,8 +1052,8 @@ void gether_suspend(struct gether *link)
>  		 * There is a transfer in progress. So we trigger a remote
>  		 * wakeup to inform the host.
>  		 */
> -		ether_wakeup_host(dev->port_usb);
> -		return;
> +		if (!ether_wakeup_host(dev->port_usb))
> +			return;

What about the other place in the driver where this function is called
but the return value is ignored?

thanks,

greg k-h

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

* Re: [PATCH] usb: gadget: u_ether: Set is_suspend flag if remote wakeup fails
  2025-02-14  8:00 ` Greg Kroah-Hartman
@ 2025-02-14  8:54   ` Prashanth K
  0 siblings, 0 replies; 3+ messages in thread
From: Prashanth K @ 2025-02-14  8:54 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Ferry Toth, Ricardo B Marliere, Kees Cook, linux-usb,
	Elson Roy Serrao, linux-kernel, stable



On 14-02-25 01:30 pm, Greg Kroah-Hartman wrote:
> On Wed, Feb 12, 2025 at 03:38:40PM +0530, Prashanth K wrote:
>> Currently while UDC suspends, u_ether attempts to remote wakeup
>> the host if there are any pending transfers. However, if remote
>> wakeup fails, the UDC remains suspended but the is_suspend flag
>> is not set. And since is_suspend flag isn't set, the subsequent
>> eth_start_xmit() would queue USB requests to suspended UDC.
>>
>> To fix this, bail out from gether_suspend() only if remote wakeup
>> operation is successful.
>>
>> Cc: stable@vger.kernel.org
>> Fixes: 0a1af6dfa077 ("usb: gadget: f_ecm: Add suspend/resume and remote wakeup support")
>> Signed-off-by: Prashanth K <prashanth.k@oss.qualcomm.com>
>> ---
>>  drivers/usb/gadget/function/u_ether.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/usb/gadget/function/u_ether.c b/drivers/usb/gadget/function/u_ether.c
>> index 09e2838917e2..f58590bf5e02 100644
>> --- a/drivers/usb/gadget/function/u_ether.c
>> +++ b/drivers/usb/gadget/function/u_ether.c
>> @@ -1052,8 +1052,8 @@ void gether_suspend(struct gether *link)
>>  		 * There is a transfer in progress. So we trigger a remote
>>  		 * wakeup to inform the host.
>>  		 */
>> -		ether_wakeup_host(dev->port_usb);
>> -		return;
>> +		if (!ether_wakeup_host(dev->port_usb))
>> +			return;
> 
> What about the other place in the driver where this function is called
> but the return value is ignored?
> 
> thanks,
> 
> greg k-h

Other than above one, eth_start_xmit() tries to remote wakeup host when
we have some data to send from n/w layer. In that case we try to wakeup
host and directly return NETDEV_TX_BUSY to caller. If remote wakeup
succeeds, then resume() would call netif_start_queue() which again lets
n/w layer to queue skb. Hence we don't have to check for ret of
ether_wakeup_host() in that case.

Regards,
Prashanth K

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

end of thread, other threads:[~2025-02-14  8:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-12 10:08 [PATCH] usb: gadget: u_ether: Set is_suspend flag if remote wakeup fails Prashanth K
2025-02-14  8:00 ` Greg Kroah-Hartman
2025-02-14  8:54   ` Prashanth K

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox