diff mbox series

[v2,1/2] usb: dwc3: gadget: Avoid controller stop in .suspend if !softconnect

Message ID 20230502162133.148821-2-rogerq@kernel.org (mailing list archive)
State New, archived
Headers show
Series usb: dwc3: gadget: Improve dwc3_gadget_suspend/resume | expand

Commit Message

Roger Quadros May 2, 2023, 4:21 p.m. UTC
If softconnect is not set it means the controller has not started,
so no point in stopping it in dwc3_gadget_suspend()

Cc: stable@vger.kernel.org # 5.16
Fixes: 8217f07a5023 ("usb: dwc3: gadget: Avoid starting DWC3 gadget during UDC unbind")
Signed-off-by: Roger Quadros <rogerq@kernel.org>
---
 drivers/usb/dwc3/gadget.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Thinh Nguyen May 2, 2023, 9:17 p.m. UTC | #1
On Tue, May 02, 2023, Roger Quadros wrote:
> If softconnect is not set it means the controller has not started,
> so no point in stopping it in dwc3_gadget_suspend()
> 
> Cc: stable@vger.kernel.org # 5.16
> Fixes: 8217f07a5023 ("usb: dwc3: gadget: Avoid starting DWC3 gadget during UDC unbind")

If the reason for this patch is as mentioned in the commit message, then
I don't think this is a fix patch that needs to be backported to stable.
The reason why we needed to check both dwc->gadget_driver and
dwc->softconnect is because of a potential race between resume and
unbind. Would there be a similar case in dwc_gadget_suspend where a
potential race may occur? If not, I don't think we need this patch.

Thanks,
Thinh

> Signed-off-by: Roger Quadros <rogerq@kernel.org>
> ---
>  drivers/usb/dwc3/gadget.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
> index c0ca4d12f95d..b5170374cd18 100644
> --- a/drivers/usb/dwc3/gadget.c
> +++ b/drivers/usb/dwc3/gadget.c
> @@ -4656,7 +4656,7 @@ int dwc3_gadget_suspend(struct dwc3 *dwc)
>  {
>  	unsigned long flags;
>  
> -	if (!dwc->gadget_driver)
> +	if (!dwc->gadget_driver || !dwc->softconnect)
>  		return 0;
>  
>  	dwc3_gadget_run_stop(dwc, false);
> -- 
> 2.34.1
>
Roger Quadros May 3, 2023, 9:28 a.m. UTC | #2
On 03/05/2023 00:17, Thinh Nguyen wrote:
> On Tue, May 02, 2023, Roger Quadros wrote:
>> If softconnect is not set it means the controller has not started,
>> so no point in stopping it in dwc3_gadget_suspend()
>>
>> Cc: stable@vger.kernel.org # 5.16
>> Fixes: 8217f07a5023 ("usb: dwc3: gadget: Avoid starting DWC3 gadget during UDC unbind")
> 
> If the reason for this patch is as mentioned in the commit message, then
> I don't think this is a fix patch that needs to be backported to stable.
> The reason why we needed to check both dwc->gadget_driver and
> dwc->softconnect is because of a potential race between resume and
> unbind. Would there be a similar case in dwc_gadget_suspend where a
> potential race may occur? If not, I don't think we need this patch.

OK. I agree.

> 
> Thanks,
> Thinh
> 
>> Signed-off-by: Roger Quadros <rogerq@kernel.org>
>> ---
>>  drivers/usb/dwc3/gadget.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
>> index c0ca4d12f95d..b5170374cd18 100644
>> --- a/drivers/usb/dwc3/gadget.c
>> +++ b/drivers/usb/dwc3/gadget.c
>> @@ -4656,7 +4656,7 @@ int dwc3_gadget_suspend(struct dwc3 *dwc)
>>  {
>>  	unsigned long flags;
>>  
>> -	if (!dwc->gadget_driver)
>> +	if (!dwc->gadget_driver || !dwc->softconnect)
>>  		return 0;
>>  
>>  	dwc3_gadget_run_stop(dwc, false);
>> -- 
>> 2.34.1

cheers,
-roger
diff mbox series

Patch

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index c0ca4d12f95d..b5170374cd18 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -4656,7 +4656,7 @@  int dwc3_gadget_suspend(struct dwc3 *dwc)
 {
 	unsigned long flags;
 
-	if (!dwc->gadget_driver)
+	if (!dwc->gadget_driver || !dwc->softconnect)
 		return 0;
 
 	dwc3_gadget_run_stop(dwc, false);