linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] usb: dwc3: support continuous runtime PM with dual role
@ 2020-03-18  8:35 Martin Kepplinger
  2020-03-18  8:35 ` [PATCH 2/2] dt-bindings: usb: dwc3: add optional extcon description Martin Kepplinger
  2020-03-18 11:13 ` [PATCH 1/2] usb: dwc3: support continuous runtime PM with dual role Roger Quadros
  0 siblings, 2 replies; 5+ messages in thread
From: Martin Kepplinger @ 2020-03-18  8:35 UTC (permalink / raw)
  To: balbi, robh
  Cc: gregkh, linux-usb, devicetree, linux-kernel, Martin Kepplinger

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

Signed-off-by: Martin Kepplinger <martin.kepplinger@puri.sm>
---
 drivers/usb/dwc3/core.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index edc17155cb2b..7743c4de82e9 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -196,11 +196,16 @@ void dwc3_set_mode(struct dwc3 *dwc, u32 mode)
 {
 	unsigned long flags;
 
+	pm_runtime_get(dwc->dev);
+
 	spin_lock_irqsave(&dwc->lock, flags);
 	dwc->desired_dr_role = mode;
 	spin_unlock_irqrestore(&dwc->lock, flags);
 
 	queue_work(system_freezable_wq, &dwc->drd_work);
+
+	pm_runtime_mark_last_busy(dwc->dev);
+	pm_runtime_put_autosuspend(dwc->dev);
 }
 
 u32 dwc3_core_fifo_space(struct dwc3_ep *dep, u8 type)
-- 
2.20.1


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

* [PATCH 2/2] dt-bindings: usb: dwc3: add optional extcon description
  2020-03-18  8:35 [PATCH 1/2] usb: dwc3: support continuous runtime PM with dual role Martin Kepplinger
@ 2020-03-18  8:35 ` Martin Kepplinger
  2020-03-30 23:04   ` Rob Herring
  2020-03-18 11:13 ` [PATCH 1/2] usb: dwc3: support continuous runtime PM with dual role Roger Quadros
  1 sibling, 1 reply; 5+ messages in thread
From: Martin Kepplinger @ 2020-03-18  8:35 UTC (permalink / raw)
  To: balbi, robh
  Cc: gregkh, linux-usb, devicetree, linux-kernel, Martin Kepplinger

the dwc3 drd module already hooks up an extcon device if described in DT.

Signed-off-by: Martin Kepplinger <martin.kepplinger@puri.sm>
---
 Documentation/devicetree/bindings/usb/dwc3.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt b/Documentation/devicetree/bindings/usb/dwc3.txt
index 9946ff9ba735..9aa0cefbf5f6 100644
--- a/Documentation/devicetree/bindings/usb/dwc3.txt
+++ b/Documentation/devicetree/bindings/usb/dwc3.txt
@@ -31,6 +31,8 @@ Exception for clocks:
     "xlnx,zynqmp-dwc3"
 
 Optional properties:
+ - extcon: phandle for the extcon device dwc3 DRD uses to detect
+   connect/disconnect events.
  - usb-phy : array of phandle for the PHY device.  The first element
    in the array is expected to be a handle to the USB2/HS PHY and
    the second element is expected to be a handle to the USB3/SS PHY
-- 
2.20.1


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

* Re: [PATCH 1/2] usb: dwc3: support continuous runtime PM with dual role
  2020-03-18  8:35 [PATCH 1/2] usb: dwc3: support continuous runtime PM with dual role Martin Kepplinger
  2020-03-18  8:35 ` [PATCH 2/2] dt-bindings: usb: dwc3: add optional extcon description Martin Kepplinger
@ 2020-03-18 11:13 ` Roger Quadros
  2020-03-18 11:16   ` Martin Kepplinger
  1 sibling, 1 reply; 5+ messages in thread
From: Roger Quadros @ 2020-03-18 11:13 UTC (permalink / raw)
  To: Martin Kepplinger, balbi, robh
  Cc: gregkh, linux-usb, devicetree, linux-kernel

Martin,

On 18/03/2020 10:35, Martin Kepplinger wrote:
> The DRD module calls dwc3_set_mode() on role switches, i.e. when a device is
> being pugged in. In order to support continuous runtime power management when
> plugging in / unplugging a cable, we need to call pm_runtime_get() in this path.
> 
> Signed-off-by: Martin Kepplinger <martin.kepplinger@puri.sm>
> ---
>   drivers/usb/dwc3/core.c | 5 +++++
>   1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> index edc17155cb2b..7743c4de82e9 100644
> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c
> @@ -196,11 +196,16 @@ void dwc3_set_mode(struct dwc3 *dwc, u32 mode)
>   {
>   	unsigned long flags;
>   
> +	pm_runtime_get(dwc->dev);
> +
>   	spin_lock_irqsave(&dwc->lock, flags);
>   	dwc->desired_dr_role = mode;
>   	spin_unlock_irqrestore(&dwc->lock, flags);
>   
>   	queue_work(system_freezable_wq, &dwc->drd_work);

We are not touching any IP registers and just scheduling
the drd_work in this function so it doesn't make sense to do pm_runtime_get here.

How about dong pm_runtime_get/put in __dwc3_set_mode()?

> +
> +	pm_runtime_mark_last_busy(dwc->dev);
> +	pm_runtime_put_autosuspend(dwc->dev);
>   }
>   
>   u32 dwc3_core_fifo_space(struct dwc3_ep *dep, u8 type)
> 

-- 
cheers,
-roger

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

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

* Re: [PATCH 1/2] usb: dwc3: support continuous runtime PM with dual role
  2020-03-18 11:13 ` [PATCH 1/2] usb: dwc3: support continuous runtime PM with dual role Roger Quadros
@ 2020-03-18 11:16   ` Martin Kepplinger
  0 siblings, 0 replies; 5+ messages in thread
From: Martin Kepplinger @ 2020-03-18 11:16 UTC (permalink / raw)
  To: Roger Quadros, balbi, robh; +Cc: gregkh, linux-usb, devicetree, linux-kernel



On 18.03.20 12:13, Roger Quadros wrote:
> Martin,
> 
> On 18/03/2020 10:35, Martin Kepplinger wrote:
>> The DRD module calls dwc3_set_mode() on role switches, i.e. when a
>> device is
>> being pugged in. In order to support continuous runtime power
>> management when
>> plugging in / unplugging a cable, we need to call pm_runtime_get() in
>> this path.
>>
>> Signed-off-by: Martin Kepplinger <martin.kepplinger@puri.sm>
>> ---
>>   drivers/usb/dwc3/core.c | 5 +++++
>>   1 file changed, 5 insertions(+)
>>
>> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
>> index edc17155cb2b..7743c4de82e9 100644
>> --- a/drivers/usb/dwc3/core.c
>> +++ b/drivers/usb/dwc3/core.c
>> @@ -196,11 +196,16 @@ void dwc3_set_mode(struct dwc3 *dwc, u32 mode)
>>   {
>>       unsigned long flags;
>>   +    pm_runtime_get(dwc->dev);
>> +
>>       spin_lock_irqsave(&dwc->lock, flags);
>>       dwc->desired_dr_role = mode;
>>       spin_unlock_irqrestore(&dwc->lock, flags);
>>         queue_work(system_freezable_wq, &dwc->drd_work);
> 
> We are not touching any IP registers and just scheduling
> the drd_work in this function so it doesn't make sense to do
> pm_runtime_get here.
> 
> How about dong pm_runtime_get/put in __dwc3_set_mode()?

That would be more accurate indeed. I'll move it over there. thanks for
having a look!

                           martin


> 
>> +
>> +    pm_runtime_mark_last_busy(dwc->dev);
>> +    pm_runtime_put_autosuspend(dwc->dev);
>>   }
>>     u32 dwc3_core_fifo_space(struct dwc3_ep *dep, u8 type)
>>
> 

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

* Re: [PATCH 2/2] dt-bindings: usb: dwc3: add optional extcon description
  2020-03-18  8:35 ` [PATCH 2/2] dt-bindings: usb: dwc3: add optional extcon description Martin Kepplinger
@ 2020-03-30 23:04   ` Rob Herring
  0 siblings, 0 replies; 5+ messages in thread
From: Rob Herring @ 2020-03-30 23:04 UTC (permalink / raw)
  To: Martin Kepplinger; +Cc: balbi, gregkh, linux-usb, devicetree, linux-kernel

On Wed, Mar 18, 2020 at 09:35:08AM +0100, Martin Kepplinger wrote:
> the dwc3 drd module already hooks up an extcon device if described in DT.
> 
> Signed-off-by: Martin Kepplinger <martin.kepplinger@puri.sm>
> ---
>  Documentation/devicetree/bindings/usb/dwc3.txt | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt b/Documentation/devicetree/bindings/usb/dwc3.txt
> index 9946ff9ba735..9aa0cefbf5f6 100644
> --- a/Documentation/devicetree/bindings/usb/dwc3.txt
> +++ b/Documentation/devicetree/bindings/usb/dwc3.txt
> @@ -31,6 +31,8 @@ Exception for clocks:
>      "xlnx,zynqmp-dwc3"
>  
>  Optional properties:
> + - extcon: phandle for the extcon device dwc3 DRD uses to detect
> +   connect/disconnect events.

This is deprecated in favor of usb-connector binding. I guess fine to 
document it, but needs a big fat deprecated, do not use message.

>   - usb-phy : array of phandle for the PHY device.  The first element
>     in the array is expected to be a handle to the USB2/HS PHY and
>     the second element is expected to be a handle to the USB3/SS PHY
> -- 
> 2.20.1
> 

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

end of thread, other threads:[~2020-03-30 23:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-18  8:35 [PATCH 1/2] usb: dwc3: support continuous runtime PM with dual role Martin Kepplinger
2020-03-18  8:35 ` [PATCH 2/2] dt-bindings: usb: dwc3: add optional extcon description Martin Kepplinger
2020-03-30 23:04   ` Rob Herring
2020-03-18 11:13 ` [PATCH 1/2] usb: dwc3: support continuous runtime PM with dual role Roger Quadros
2020-03-18 11:16   ` Martin Kepplinger

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