diff mbox series

[RFC,1/8] dt-bindings: usb: qcom,dwc3: Add bindings to enable runtime

Message ID 20231017131851.8299-2-quic_kriskura@quicinc.com (mailing list archive)
State Not Applicable
Headers show
Series Enable runtime suspend resume for QCOM devices | expand

Commit Message

Krishna Kurapati PSSNV Oct. 17, 2023, 1:18 p.m. UTC
Add enable-rt binding to let the device register vendor hooks to
core and facilitate runtime suspend and resume.

Signed-off-by: Krishna Kurapati <quic_kriskura@quicinc.com>
---
 Documentation/devicetree/bindings/usb/qcom,dwc3.yaml | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Krzysztof Kozlowski Oct. 17, 2023, 5:19 p.m. UTC | #1
On 17/10/2023 15:18, Krishna Kurapati wrote:
> Add enable-rt binding to let the device register vendor hooks to
> core and facilitate runtime suspend and resume.
> 
> Signed-off-by: Krishna Kurapati <quic_kriskura@quicinc.com>
> ---
>  Documentation/devicetree/bindings/usb/qcom,dwc3.yaml | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/usb/qcom,dwc3.yaml b/Documentation/devicetree/bindings/usb/qcom,dwc3.yaml
> index cb50261c6a36..788d9c510abc 100644
> --- a/Documentation/devicetree/bindings/usb/qcom,dwc3.yaml
> +++ b/Documentation/devicetree/bindings/usb/qcom,dwc3.yaml
> @@ -151,6 +151,11 @@ properties:
>        HS/FS/LS modes are supported.
>      type: boolean
>  
> +  qcom,enable-rt:
> +    description:
> +      If present, register vendor hooks to facilitate runtime suspend/resume

You described the desired Linux feature or behavior, not the actual
hardware. The bindings are about the latter, so instead you need to
rephrase the property and its description to match actual hardware
capabilities/features/configuration etc.

Best regards,
Krzysztof
Krishna Kurapati PSSNV Oct. 17, 2023, 5:46 p.m. UTC | #2
On 10/17/2023 10:49 PM, Krzysztof Kozlowski wrote:
> On 17/10/2023 15:18, Krishna Kurapati wrote:
>> Add enable-rt binding to let the device register vendor hooks to
>> core and facilitate runtime suspend and resume.
>>
>> Signed-off-by: Krishna Kurapati <quic_kriskura@quicinc.com>
>> ---
>>   Documentation/devicetree/bindings/usb/qcom,dwc3.yaml | 5 +++++
>>   1 file changed, 5 insertions(+)
>>
>> diff --git a/Documentation/devicetree/bindings/usb/qcom,dwc3.yaml b/Documentation/devicetree/bindings/usb/qcom,dwc3.yaml
>> index cb50261c6a36..788d9c510abc 100644
>> --- a/Documentation/devicetree/bindings/usb/qcom,dwc3.yaml
>> +++ b/Documentation/devicetree/bindings/usb/qcom,dwc3.yaml
>> @@ -151,6 +151,11 @@ properties:
>>         HS/FS/LS modes are supported.
>>       type: boolean
>>   
>> +  qcom,enable-rt:
>> +    description:
>> +      If present, register vendor hooks to facilitate runtime suspend/resume
> 
> You described the desired Linux feature or behavior, not the actual
> hardware. The bindings are about the latter, so instead you need to
> rephrase the property and its description to match actual hardware
> capabilities/features/configuration etc.
> 

Hi Krzysztof,

  Thanks for the review. Although it sounds like its a Linux property, 
internally what it does is configuring qscratch registers properly when 
(dr_mode == OTG)

  Would it be fine to rephrase the property name to 
"qcom,config-qscratch" and to make it dependent on dr_mode and 
usb-role-switch properties ? Would it be possible to make such a 
dependency in bindings ?

Regards,
Krishna,
Krzysztof Kozlowski Oct. 18, 2023, 6:09 a.m. UTC | #3
On 17/10/2023 19:46, Krishna Kurapati PSSNV wrote:
> 
> 
> On 10/17/2023 10:49 PM, Krzysztof Kozlowski wrote:
>> On 17/10/2023 15:18, Krishna Kurapati wrote:
>>> Add enable-rt binding to let the device register vendor hooks to
>>> core and facilitate runtime suspend and resume.
>>>
>>> Signed-off-by: Krishna Kurapati <quic_kriskura@quicinc.com>
>>> ---
>>>   Documentation/devicetree/bindings/usb/qcom,dwc3.yaml | 5 +++++
>>>   1 file changed, 5 insertions(+)
>>>
>>> diff --git a/Documentation/devicetree/bindings/usb/qcom,dwc3.yaml b/Documentation/devicetree/bindings/usb/qcom,dwc3.yaml
>>> index cb50261c6a36..788d9c510abc 100644
>>> --- a/Documentation/devicetree/bindings/usb/qcom,dwc3.yaml
>>> +++ b/Documentation/devicetree/bindings/usb/qcom,dwc3.yaml
>>> @@ -151,6 +151,11 @@ properties:
>>>         HS/FS/LS modes are supported.
>>>       type: boolean
>>>   
>>> +  qcom,enable-rt:
>>> +    description:
>>> +      If present, register vendor hooks to facilitate runtime suspend/resume
>>
>> You described the desired Linux feature or behavior, not the actual
>> hardware. The bindings are about the latter, so instead you need to
>> rephrase the property and its description to match actual hardware
>> capabilities/features/configuration etc.
>>
> 
> Hi Krzysztof,
> 
>   Thanks for the review. Although it sounds like its a Linux property, 
> internally what it does is configuring qscratch registers properly when 
> (dr_mode == OTG)

That's not what you wrote. You wrote "register vendor hooks". Really,
this is nothing to do with hardware.

> 
>   Would it be fine to rephrase the property name to 
> "qcom,config-qscratch" and to make it dependent on dr_mode and 
> usb-role-switch properties ? Would it be possible to make such a 
> dependency in bindings ?

Examples are in: example-schema or my talk.

Best regards,
Krzysztof
Caleb Connolly Nov. 2, 2023, 4:33 p.m. UTC | #4
On 17/10/2023 14:18, Krishna Kurapati wrote:
> Add enable-rt binding to let the device register vendor hooks to
> core and facilitate runtime suspend and resume.

Hi Krishna,

 From reading through these patches, it's not clear to me why this 
behaviour should be conditional on a new devicetree property. Are there 
some platforms where this behaviour would be undesirable? And if so then 
would it be possible to determine this based on the QSCRATCH registers?
> 
> Signed-off-by: Krishna Kurapati <quic_kriskura@quicinc.com>
> ---
>   Documentation/devicetree/bindings/usb/qcom,dwc3.yaml | 5 +++++
>   1 file changed, 5 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/usb/qcom,dwc3.yaml b/Documentation/devicetree/bindings/usb/qcom,dwc3.yaml
> index cb50261c6a36..788d9c510abc 100644
> --- a/Documentation/devicetree/bindings/usb/qcom,dwc3.yaml
> +++ b/Documentation/devicetree/bindings/usb/qcom,dwc3.yaml
> @@ -151,6 +151,11 @@ properties:
>         HS/FS/LS modes are supported.
>       type: boolean
>   
> +  qcom,enable-rt:
> +    description:
> +      If present, register vendor hooks to facilitate runtime suspend/resume
> +    type: boolean

A Krzysztof pointed out, properties should define the hardware 
behaviour, not tot the implementation details. For this case the 
hardware isn't wired up to vbus, so maybe something like "qcom,no-vbus"?
> +
>     wakeup-source: true
>   
>   # Required child node:
Krishna Kurapati PSSNV Nov. 2, 2023, 5:02 p.m. UTC | #5
On 11/2/2023 10:03 PM, Caleb Connolly wrote:
> 
> 
> On 17/10/2023 14:18, Krishna Kurapati wrote:
>> Add enable-rt binding to let the device register vendor hooks to
>> core and facilitate runtime suspend and resume.
> 
> Hi Krishna,
> 
>  From reading through these patches, it's not clear to me why this 
> behaviour should be conditional on a new devicetree property. Are there 
> some platforms where this behaviour would be undesirable? And if so then 
> would it be possible to determine this based on the QSCRATCH registers?
>>

Hi Caleb,

   There are two types of platforms, some use extcon and some use 
role-switch to deliver vbus/id notifications. Extcon targets already 
have this qscratch modifications present today in vbus and id handlers. 
But for role-switch based targets we don't have any way to get this 
notification to dwc3-qcom. In this implementation, I wanted to get those 
notications from core to glue and for this we implenented vendor hooks.

The property added has been used to do two things:

1. Register glue's vendor hooks to core driver
2. Do runtime_allow for glue (and by default for core as the dt is not 
flattened)

In case of extcon, we don't want to register vendor hooks as 
notifications are not necessary.

For xhci, we opted to enable runtime from userspace.

>> Signed-off-by: Krishna Kurapati <quic_kriskura@quicinc.com>
>> ---
>>   Documentation/devicetree/bindings/usb/qcom,dwc3.yaml | 5 +++++
>>   1 file changed, 5 insertions(+)
>>
>> diff --git a/Documentation/devicetree/bindings/usb/qcom,dwc3.yaml 
>> b/Documentation/devicetree/bindings/usb/qcom,dwc3.yaml
>> index cb50261c6a36..788d9c510abc 100644
>> --- a/Documentation/devicetree/bindings/usb/qcom,dwc3.yaml
>> +++ b/Documentation/devicetree/bindings/usb/qcom,dwc3.yaml
>> @@ -151,6 +151,11 @@ properties:
>>         HS/FS/LS modes are supported.
>>       type: boolean
>> +  qcom,enable-rt:
>> +    description:
>> +      If present, register vendor hooks to facilitate runtime 
>> suspend/resume
>> +    type: boolean
> 
> A Krzysztof pointed out, properties should define the hardware 
> behaviour, not tot the implementation details. For this case the 
> hardware isn't wired up to vbus, so maybe something like "qcom,no-vbus"?
>> +

On all targets, vbus is not routed to hardware. This vbus toggle 
indication is given to controller via qscratch only.

Regards,
Krishna,
Caleb Connolly Nov. 2, 2023, 6:40 p.m. UTC | #6
> Hi Caleb,
> 
>    There are two types of platforms, some use extcon and some use 
> role-switch to deliver vbus/id notifications. Extcon targets already 
> have this qscratch modifications present today in vbus and id handlers. 
> But for role-switch based targets we don't have any way to get this 
> notification to dwc3-qcom. In this implementation, I wanted to get those 
> notications from core to glue and for this we implenented vendor hooks.
> 
> The property added has been used to do two things:
> 
> 1. Register glue's vendor hooks to core driver
> 2. Do runtime_allow for glue (and by default for core as the dt is not 
> flattened)
> 
> In case of extcon, we don't want to register vendor hooks as 
> notifications are not necessary.

Could it just be enabled when role_switch is present then?
> 
> For xhci, we opted to enable runtime from userspace.

>>>         HS/FS/LS modes are supported.
>>>       type: boolean
>>> +  qcom,enable-rt:
>>> +    description:
>>> +      If present, register vendor hooks to facilitate runtime 
>>> suspend/resume
>>> +    type: boolean
>>
>> A Krzysztof pointed out, properties should define the hardware 
>> behaviour, not tot the implementation details. For this case the 
>> hardware isn't wired up to vbus, so maybe something like "qcom,no-vbus"?
>>> +
> 
> On all targets, vbus is not routed to hardware. This vbus toggle 
> indication is given to controller via qscratch only.
> 
> Regards,
> Krishna,
Krishna Kurapati PSSNV Nov. 3, 2023, 5:34 a.m. UTC | #7
On 11/3/2023 12:10 AM, Caleb Connolly wrote:
>> Hi Caleb,
>>
>>    There are two types of platforms, some use extcon and some use 
>> role-switch to deliver vbus/id notifications. Extcon targets already 
>> have this qscratch modifications present today in vbus and id 
>> handlers. But for role-switch based targets we don't have any way to 
>> get this notification to dwc3-qcom. In this implementation, I wanted 
>> to get those notications from core to glue and for this we implenented 
>> vendor hooks.
>>
>> The property added has been used to do two things:
>>
>> 1. Register glue's vendor hooks to core driver
>> 2. Do runtime_allow for glue (and by default for core as the dt is not 
>> flattened)
>>
>> In case of extcon, we don't want to register vendor hooks as 
>> notifications are not necessary.
> 
> Could it just be enabled when role_switch is present then?
>>

So we would register vendor hooks when usb-role-switch is present but 
don't do runtime allow, and leave that option to user space right ?
I think it would work and we can do away with the binding completely.

Will wait for comments from other folks as well on this approach.

Thanks for the review,
Krishna,
Caleb Connolly Nov. 3, 2023, 2:56 p.m. UTC | #8
On 03/11/2023 05:34, Krishna Kurapati PSSNV wrote:
> 
> 
> On 11/3/2023 12:10 AM, Caleb Connolly wrote:
>>> Hi Caleb,
>>>
>>>    There are two types of platforms, some use extcon and some use
>>> role-switch to deliver vbus/id notifications. Extcon targets already
>>> have this qscratch modifications present today in vbus and id
>>> handlers. But for role-switch based targets we don't have any way to
>>> get this notification to dwc3-qcom. In this implementation, I wanted
>>> to get those notications from core to glue and for this we
>>> implenented vendor hooks.
>>>
>>> The property added has been used to do two things:
>>>
>>> 1. Register glue's vendor hooks to core driver
>>> 2. Do runtime_allow for glue (and by default for core as the dt is
>>> not flattened)
>>>
>>> In case of extcon, we don't want to register vendor hooks as
>>> notifications are not necessary.
>>
>> Could it just be enabled when role_switch is present then?
>>>
> 
> So we would register vendor hooks when usb-role-switch is present but
> don't do runtime allow, and leave that option to user space right ?
> I think it would work and we can do away with the binding completely.

Can we still enable runtime suspend? Maybe someone else wants to chime
in here, but I'd guess that it's preferable to have it enabled by
default, particularly for devices like phones. Or are there side effects
from this?
> 
> Will wait for comments from other folks as well on this approach.

Sounds good, thanks!
> 
> Thanks for the review,
> Krishna,
Krishna Kurapati PSSNV Nov. 3, 2023, 6:24 p.m. UTC | #9
On 11/3/2023 8:26 PM, Caleb Connolly wrote:
> 
> 
> On 03/11/2023 05:34, Krishna Kurapati PSSNV wrote:
>>
>>
>> On 11/3/2023 12:10 AM, Caleb Connolly wrote:
>>>> Hi Caleb,
>>>>
>>>>     There are two types of platforms, some use extcon and some use
>>>> role-switch to deliver vbus/id notifications. Extcon targets already
>>>> have this qscratch modifications present today in vbus and id
>>>> handlers. But for role-switch based targets we don't have any way to
>>>> get this notification to dwc3-qcom. In this implementation, I wanted
>>>> to get those notications from core to glue and for this we
>>>> implenented vendor hooks.
>>>>
>>>> The property added has been used to do two things:
>>>>
>>>> 1. Register glue's vendor hooks to core driver
>>>> 2. Do runtime_allow for glue (and by default for core as the dt is
>>>> not flattened)
>>>>
>>>> In case of extcon, we don't want to register vendor hooks as
>>>> notifications are not necessary.
>>>
>>> Could it just be enabled when role_switch is present then?
>>>>
>>
>> So we would register vendor hooks when usb-role-switch is present but
>> don't do runtime allow, and leave that option to user space right ?
>> I think it would work and we can do away with the binding completely.
> 
> Can we still enable runtime suspend? Maybe someone else wants to chime
> in here, but I'd guess that it's preferable to have it enabled by
> default, particularly for devices like phones. Or are there side effects
> from this?
>>

AFAIK, I don't see any side effects whether we enable runtime from user 
space or do runtime_allow() here in kernel itself and leave qscratch 
config to vendor hooks.

But leaving it enabled by default, we do this for almost all targets in 
downstream today. So I guess there would be no side effects.

Regards,
Krishna,
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/usb/qcom,dwc3.yaml b/Documentation/devicetree/bindings/usb/qcom,dwc3.yaml
index cb50261c6a36..788d9c510abc 100644
--- a/Documentation/devicetree/bindings/usb/qcom,dwc3.yaml
+++ b/Documentation/devicetree/bindings/usb/qcom,dwc3.yaml
@@ -151,6 +151,11 @@  properties:
       HS/FS/LS modes are supported.
     type: boolean
 
+  qcom,enable-rt:
+    description:
+      If present, register vendor hooks to facilitate runtime suspend/resume
+    type: boolean
+
   wakeup-source: true
 
 # Required child node: