Re: [PATCH v3] usb: dwc3: support continuous runtime PM with dual role

From: Martin Kepplinger
Date: Tue May 05 2020 - 05:44:48 EST


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@xxxxxxx>
>
> Reviewed-by: Roger Quadros <rogerq@xxxxxx>
>
>

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@xxxxxxxxxxxxxxxxxx/T/
>>
>> v1:
>> https://lore.kernel.org/linux-usb/ef22f8de-9bfd-c1d5-111c-696f1336dbda@xxxxxxx/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)
>>
>