All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] usb: dwc3: support continuous runtime PM with dual role
@ 2020-03-19 10:02 Martin Kepplinger
  2020-04-05 11:43 ` Martin Kepplinger
  2020-04-24  7:48 ` Roger Quadros
  0 siblings, 2 replies; 6+ messages in thread
From: Martin Kepplinger @ 2020-03-19 10:02 UTC (permalink / raw)
  To: balbi
  Cc: gregkh, sergei.shtylyov, rogerq, linux-usb, linux-kernel,
	Martin Kepplinger

The DRD module calls dwc3_set_mode() on role switches, i.e. when a device is
being plugged in. In order to support continuous runtime power management when
plugging in / unplugging a cable, we need to call pm_runtime_get_sync() in
this path.

Signed-off-by: Martin Kepplinger <martin.kepplinger@puri.sm>
---


revision history
----------------
v3: call pm_runtime_get_sync() and fix commit message typo (thanks Sergei)
v2: move pm_rumtime calls into workqueue (thanks Roger)
    remove unrelated documentation patch
    https://lore.kernel.org/linux-usb/7a085229-68a7-d700-1781-14225863a228@cogentembedded.com/T/
v1: https://lore.kernel.org/linux-usb/ef22f8de-9bfd-c1d5-111c-696f1336dbda@puri.sm/T/


 drivers/usb/dwc3/core.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 1d85c42b9c67..da93faef74a6 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -121,17 +121,19 @@ static void __dwc3_set_mode(struct work_struct *work)
 	if (dwc->dr_mode != USB_DR_MODE_OTG)
 		return;
 
+	pm_runtime_get_sync(dwc->dev);
+
 	if (dwc->current_dr_role == DWC3_GCTL_PRTCAP_OTG)
 		dwc3_otg_update(dwc, 0);
 
 	if (!dwc->desired_dr_role)
-		return;
+		goto out;
 
 	if (dwc->desired_dr_role == dwc->current_dr_role)
-		return;
+		goto out;
 
 	if (dwc->desired_dr_role == DWC3_GCTL_PRTCAP_OTG && dwc->edev)
-		return;
+		goto out;
 
 	switch (dwc->current_dr_role) {
 	case DWC3_GCTL_PRTCAP_HOST:
@@ -190,6 +192,9 @@ static void __dwc3_set_mode(struct work_struct *work)
 		break;
 	}
 
+out:
+	pm_runtime_mark_last_busy(dwc->dev);
+	pm_runtime_put_autosuspend(dwc->dev);
 }
 
 void dwc3_set_mode(struct dwc3 *dwc, u32 mode)
-- 
2.20.1


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

* Re: [PATCH v3] usb: dwc3: support continuous runtime PM with dual role
  2020-03-19 10:02 [PATCH v3] usb: dwc3: support continuous runtime PM with dual role Martin Kepplinger
@ 2020-04-05 11:43 ` Martin Kepplinger
  2020-04-24  7:42   ` Martin Kepplinger
  2020-04-24  7:48 ` Roger Quadros
  1 sibling, 1 reply; 6+ messages in thread
From: Martin Kepplinger @ 2020-04-05 11:43 UTC (permalink / raw)
  To: balbi; +Cc: gregkh, sergei.shtylyov, rogerq, linux-usb, linux-kernel

On 19.03.20 11:02, Martin Kepplinger wrote:
> The DRD module calls dwc3_set_mode() on role switches, i.e. when a device is
> being plugged in. In order to support continuous runtime power management when
> plugging in / unplugging a cable, we need to call pm_runtime_get_sync() in
> this path.
> 
> Signed-off-by: Martin Kepplinger <martin.kepplinger@puri.sm>
> ---
> 
> 
> revision history
> ----------------
> v3: call pm_runtime_get_sync() and fix commit message typo (thanks Sergei)
> v2: move pm_rumtime calls into workqueue (thanks Roger)
>     remove unrelated documentation patch
>     https://lore.kernel.org/linux-usb/7a085229-68a7-d700-1781-14225863a228@cogentembedded.com/T/
> v1: https://lore.kernel.org/linux-usb/ef22f8de-9bfd-c1d5-111c-696f1336dbda@puri.sm/T/
> 
> 
>  drivers/usb/dwc3/core.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> index 1d85c42b9c67..da93faef74a6 100644
> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c
> @@ -121,17 +121,19 @@ static void __dwc3_set_mode(struct work_struct *work)
>  	if (dwc->dr_mode != USB_DR_MODE_OTG)
>  		return;
>  
> +	pm_runtime_get_sync(dwc->dev);
> +
>  	if (dwc->current_dr_role == DWC3_GCTL_PRTCAP_OTG)
>  		dwc3_otg_update(dwc, 0);
>  
>  	if (!dwc->desired_dr_role)
> -		return;
> +		goto out;
>  
>  	if (dwc->desired_dr_role == dwc->current_dr_role)
> -		return;
> +		goto out;
>  
>  	if (dwc->desired_dr_role == DWC3_GCTL_PRTCAP_OTG && dwc->edev)
> -		return;
> +		goto out;
>  
>  	switch (dwc->current_dr_role) {
>  	case DWC3_GCTL_PRTCAP_HOST:
> @@ -190,6 +192,9 @@ static void __dwc3_set_mode(struct work_struct *work)
>  		break;
>  	}
>  
> +out:
> +	pm_runtime_mark_last_busy(dwc->dev);
> +	pm_runtime_put_autosuspend(dwc->dev);
>  }
>  
>  void dwc3_set_mode(struct dwc3 *dwc, u32 mode)
> 

any objections or other thoughts about this? I'm using it successfully.

thanks,

                           martin

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

* Re: [PATCH v3] usb: dwc3: support continuous runtime PM with dual role
  2020-04-05 11:43 ` Martin Kepplinger
@ 2020-04-24  7:42   ` Martin Kepplinger
  0 siblings, 0 replies; 6+ messages in thread
From: Martin Kepplinger @ 2020-04-24  7:42 UTC (permalink / raw)
  To: balbi; +Cc: gregkh, sergei.shtylyov, rogerq, linux-usb, linux-kernel

On 05.04.20 13:43, Martin Kepplinger wrote:
> On 19.03.20 11:02, Martin Kepplinger wrote:
>> The DRD module calls dwc3_set_mode() on role switches, i.e. when a device is
>> being plugged in. In order to support continuous runtime power management when
>> plugging in / unplugging a cable, we need to call pm_runtime_get_sync() in
>> this path.
>>
>> Signed-off-by: Martin Kepplinger <martin.kepplinger@puri.sm>
>> ---
>>
>>
>> revision history
>> ----------------
>> v3: call pm_runtime_get_sync() and fix commit message typo (thanks Sergei)
>> v2: move pm_rumtime calls into workqueue (thanks Roger)
>>     remove unrelated documentation patch
>>     https://lore.kernel.org/linux-usb/7a085229-68a7-d700-1781-14225863a228@cogentembedded.com/T/
>> v1: https://lore.kernel.org/linux-usb/ef22f8de-9bfd-c1d5-111c-696f1336dbda@puri.sm/T/
>>
>>
>>  drivers/usb/dwc3/core.c | 11 ++++++++---
>>  1 file changed, 8 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
>> index 1d85c42b9c67..da93faef74a6 100644
>> --- a/drivers/usb/dwc3/core.c
>> +++ b/drivers/usb/dwc3/core.c
>> @@ -121,17 +121,19 @@ static void __dwc3_set_mode(struct work_struct *work)
>>  	if (dwc->dr_mode != USB_DR_MODE_OTG)
>>  		return;
>>  
>> +	pm_runtime_get_sync(dwc->dev);
>> +
>>  	if (dwc->current_dr_role == DWC3_GCTL_PRTCAP_OTG)
>>  		dwc3_otg_update(dwc, 0);
>>  
>>  	if (!dwc->desired_dr_role)
>> -		return;
>> +		goto out;
>>  
>>  	if (dwc->desired_dr_role == dwc->current_dr_role)
>> -		return;
>> +		goto out;
>>  
>>  	if (dwc->desired_dr_role == DWC3_GCTL_PRTCAP_OTG && dwc->edev)
>> -		return;
>> +		goto out;
>>  
>>  	switch (dwc->current_dr_role) {
>>  	case DWC3_GCTL_PRTCAP_HOST:
>> @@ -190,6 +192,9 @@ static void __dwc3_set_mode(struct work_struct *work)
>>  		break;
>>  	}
>>  
>> +out:
>> +	pm_runtime_mark_last_busy(dwc->dev);
>> +	pm_runtime_put_autosuspend(dwc->dev);
>>  }
>>  
>>  void dwc3_set_mode(struct dwc3 *dwc, u32 mode)
>>
> 
> any objections or other thoughts about this? I'm using it successfully.
> 
> thanks,
> 
>                            martin
> 

Again I want to remind of this change in case it has gotten overlooked.

thanks,
                             martin

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

* Re: [PATCH v3] usb: dwc3: support continuous runtime PM with dual role
  2020-03-19 10:02 [PATCH v3] usb: dwc3: support continuous runtime PM with dual role Martin Kepplinger
  2020-04-05 11:43 ` Martin Kepplinger
@ 2020-04-24  7:48 ` Roger Quadros
  2020-05-05  9:44   ` Martin Kepplinger
  1 sibling, 1 reply; 6+ messages in thread
From: Roger Quadros @ 2020-04-24  7:48 UTC (permalink / raw)
  To: Martin Kepplinger, balbi; +Cc: gregkh, sergei.shtylyov, linux-usb, linux-kernel



On 19/03/2020 12:02, Martin Kepplinger wrote:
> The DRD module calls dwc3_set_mode() on role switches, i.e. when a device is
> being plugged in. In order to support continuous runtime power management when
> plugging in / unplugging a cable, we need to call pm_runtime_get_sync() in
> this path.
> 
> Signed-off-by: Martin Kepplinger <martin.kepplinger@puri.sm>

Reviewed-by: Roger Quadros <rogerq@ti.com>


cheers,
-roger

> ---
> 
> 
> revision history
> ----------------
> v3: call pm_runtime_get_sync() and fix commit message typo (thanks Sergei)
> v2: move pm_rumtime calls into workqueue (thanks Roger)
>      remove unrelated documentation patch
>      https://lore.kernel.org/linux-usb/7a085229-68a7-d700-1781-14225863a228@cogentembedded.com/T/
> v1: https://lore.kernel.org/linux-usb/ef22f8de-9bfd-c1d5-111c-696f1336dbda@puri.sm/T/
> 
> 
>   drivers/usb/dwc3/core.c | 11 ++++++++---
>   1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> index 1d85c42b9c67..da93faef74a6 100644
> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c
> @@ -121,17 +121,19 @@ static void __dwc3_set_mode(struct work_struct *work)
>   	if (dwc->dr_mode != USB_DR_MODE_OTG)
>   		return;
>   
> +	pm_runtime_get_sync(dwc->dev);
> +
>   	if (dwc->current_dr_role == DWC3_GCTL_PRTCAP_OTG)
>   		dwc3_otg_update(dwc, 0);
>   
>   	if (!dwc->desired_dr_role)
> -		return;
> +		goto out;
>   
>   	if (dwc->desired_dr_role == dwc->current_dr_role)
> -		return;
> +		goto out;
>   
>   	if (dwc->desired_dr_role == DWC3_GCTL_PRTCAP_OTG && dwc->edev)
> -		return;
> +		goto out;
>   
>   	switch (dwc->current_dr_role) {
>   	case DWC3_GCTL_PRTCAP_HOST:
> @@ -190,6 +192,9 @@ static void __dwc3_set_mode(struct work_struct *work)
>   		break;
>   	}
>   
> +out:
> +	pm_runtime_mark_last_busy(dwc->dev);
> +	pm_runtime_put_autosuspend(dwc->dev);
>   }
>   
>   void dwc3_set_mode(struct dwc3 *dwc, u32 mode)
> 

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

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

* Re: [PATCH v3] usb: dwc3: support continuous runtime PM with dual role
  2020-04-24  7:48 ` Roger Quadros
@ 2020-05-05  9:44   ` Martin Kepplinger
  2020-05-14 10:40     ` Felipe Balbi
  0 siblings, 1 reply; 6+ messages in thread
From: Martin Kepplinger @ 2020-05-05  9:44 UTC (permalink / raw)
  To: Roger Quadros, balbi; +Cc: gregkh, sergei.shtylyov, linux-usb, linux-kernel

On 24.04.20 09:48, Roger Quadros wrote:
> 
> 
> On 19/03/2020 12:02, Martin Kepplinger wrote:
>> The DRD module calls dwc3_set_mode() on role switches, i.e. when a
>> device is
>> being plugged in. In order to support continuous runtime power
>> management when
>> plugging in / unplugging a cable, we need to call
>> pm_runtime_get_sync() in
>> this path.
>>
>> Signed-off-by: Martin Kepplinger <martin.kepplinger@puri.sm>
> 
> Reviewed-by: Roger Quadros <rogerq@ti.com>
> 
> 

thank you very much Roger. Anything else that is holding this back?

                      martin


> cheers,
> -roger
> 
>> ---
>>
>>
>> revision history
>> ----------------
>> v3: call pm_runtime_get_sync() and fix commit message typo (thanks
>> Sergei)
>> v2: move pm_rumtime calls into workqueue (thanks Roger)
>>      remove unrelated documentation patch
>>     
>> https://lore.kernel.org/linux-usb/7a085229-68a7-d700-1781-14225863a228@cogentembedded.com/T/
>>
>> v1:
>> https://lore.kernel.org/linux-usb/ef22f8de-9bfd-c1d5-111c-696f1336dbda@puri.sm/T/
>>
>>
>>
>>   drivers/usb/dwc3/core.c | 11 ++++++++---
>>   1 file changed, 8 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
>> index 1d85c42b9c67..da93faef74a6 100644
>> --- a/drivers/usb/dwc3/core.c
>> +++ b/drivers/usb/dwc3/core.c
>> @@ -121,17 +121,19 @@ static void __dwc3_set_mode(struct work_struct
>> *work)
>>       if (dwc->dr_mode != USB_DR_MODE_OTG)
>>           return;
>>   +    pm_runtime_get_sync(dwc->dev);
>> +
>>       if (dwc->current_dr_role == DWC3_GCTL_PRTCAP_OTG)
>>           dwc3_otg_update(dwc, 0);
>>         if (!dwc->desired_dr_role)
>> -        return;
>> +        goto out;
>>         if (dwc->desired_dr_role == dwc->current_dr_role)
>> -        return;
>> +        goto out;
>>         if (dwc->desired_dr_role == DWC3_GCTL_PRTCAP_OTG && dwc->edev)
>> -        return;
>> +        goto out;
>>         switch (dwc->current_dr_role) {
>>       case DWC3_GCTL_PRTCAP_HOST:
>> @@ -190,6 +192,9 @@ static void __dwc3_set_mode(struct work_struct *work)
>>           break;
>>       }
>>   +out:
>> +    pm_runtime_mark_last_busy(dwc->dev);
>> +    pm_runtime_put_autosuspend(dwc->dev);
>>   }
>>     void dwc3_set_mode(struct dwc3 *dwc, u32 mode)
>>
> 

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

* Re: [PATCH v3] usb: dwc3: support continuous runtime PM with dual role
  2020-05-05  9:44   ` Martin Kepplinger
@ 2020-05-14 10:40     ` Felipe Balbi
  0 siblings, 0 replies; 6+ messages in thread
From: Felipe Balbi @ 2020-05-14 10:40 UTC (permalink / raw)
  To: Martin Kepplinger, Roger Quadros
  Cc: gregkh, sergei.shtylyov, linux-usb, linux-kernel

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

Martin Kepplinger <martin.kepplinger@puri.sm> writes:

> On 24.04.20 09:48, Roger Quadros wrote:
>> 
>> 
>> On 19/03/2020 12:02, Martin Kepplinger wrote:
>>> The DRD module calls dwc3_set_mode() on role switches, i.e. when a
>>> device is
>>> being plugged in. In order to support continuous runtime power
>>> management when
>>> plugging in / unplugging a cable, we need to call
>>> pm_runtime_get_sync() in
>>> this path.
>>>
>>> Signed-off-by: Martin Kepplinger <martin.kepplinger@puri.sm>
>> 
>> Reviewed-by: Roger Quadros <rogerq@ti.com>
>> 
>> 
>
> thank you very much Roger. Anything else that is holding this back?

Merge window is holding it back :-) It has been in my tree for weeks:

https://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git/commit/?h=testing/next&id=c2cd3452d5f8b66d49a73138fba5baadd5b489bd

Gotta wait for the next merge window for new features to be merged.

-- 
balbi

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

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

end of thread, other threads:[~2020-05-14 10:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-19 10:02 [PATCH v3] usb: dwc3: support continuous runtime PM with dual role Martin Kepplinger
2020-04-05 11:43 ` Martin Kepplinger
2020-04-24  7:42   ` Martin Kepplinger
2020-04-24  7:48 ` Roger Quadros
2020-05-05  9:44   ` Martin Kepplinger
2020-05-14 10:40     ` Felipe Balbi

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.