mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Fabrice Gasnier <fabrice.gasnier@st.com>
To: Minas Harutyunyan <Minas.Harutyunyan@synopsys.com>,
	"balbi@kernel.org" <balbi@kernel.org>
Cc: "gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-stm32@st-md-mailman.stormreply.com" 
	<linux-stm32@st-md-mailman.stormreply.com>,
	"amelie.delaunay@st.com" <amelie.delaunay@st.com>
Subject: Re: [PATCH 1/4] usb: dwc2: gadget: move gadget resume after the core is in L0 state
Date: Thu, 23 Apr 2020 11:27:33 +0200	[thread overview]
Message-ID: <d1a2ce55-450b-47ea-15f9-a8532000a647@st.com> (raw)
In-Reply-To: <13a35aac-a3c9-df9f-a2b7-64abdbf9463c@synopsys.com>

On 4/22/20 6:16 PM, Minas Harutyunyan wrote:
> Hi Fabrice,
> 
> On 4/22/2020 7:57 PM, Fabrice Gasnier wrote:
>> On 4/22/20 4:48 PM, Minas Harutyunyan wrote:
>>> Hi Fabrice,
>>>
>>> On 4/21/2020 4:32 PM, Fabrice Gasnier wrote:
>>>> When the remote wakeup interrupt is triggered, lx_state is resumed from L2
>>>> to L0 state. But when the gadget resume is called, lx_state is still L2.
>>>> This prevents the resume callback to queue any request. Any attempt
>>>> to queue a request from resume callback will result in:
>>>> - "submit request only in active state" debug message to be issued
>>>> - dwc2_hsotg_ep_queue() returns -EAGAIN
>>>>
>>>> Move the call to resume gadget after the core is put in DWC2_L0 state.
>>>>
>>>> Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
>>>> ---
>>>>    drivers/usb/dwc2/core_intr.c | 10 +++++++---
>>>>    1 file changed, 7 insertions(+), 3 deletions(-)
>>>>
>>>> diff --git a/drivers/usb/dwc2/core_intr.c b/drivers/usb/dwc2/core_intr.c
>>>> index 876ff31..b8ebda5 100644
>>>> --- a/drivers/usb/dwc2/core_intr.c
>>>> +++ b/drivers/usb/dwc2/core_intr.c
>>>> @@ -404,9 +404,11 @@ static void dwc2_handle_wakeup_detected_intr(struct dwc2_hsotg *hsotg)
>>>>    	}
>>>>    
>>>>    	if (dwc2_is_device_mode(hsotg)) {
>>>> +		enum dwc2_lx_state lx_state = hsotg->lx_state;
>>>> +
>>>>    		dev_dbg(hsotg->dev, "DSTS=0x%0x\n",
>>>>    			dwc2_readl(hsotg, DSTS));
>>>> -		if (hsotg->lx_state == DWC2_L2) {
>>>> +		if (lx_state == DWC2_L2) {
>>>>    			u32 dctl = dwc2_readl(hsotg, DCTL);
>>>>    
>>>>    			/* Clear Remote Wakeup Signaling */
>>>> @@ -415,11 +417,13 @@ static void dwc2_handle_wakeup_detected_intr(struct dwc2_hsotg *hsotg)
>>>>    			ret = dwc2_exit_partial_power_down(hsotg, true);
>>>>    			if (ret && (ret != -ENOTSUPP))
>>>>    				dev_err(hsotg->dev, "exit power_down failed\n");
>>>> -
>>>> -			call_gadget(hsotg, resume);
>>>>    		}
>>>>    		/* Change to L0 state */
>>>>    		hsotg->lx_state = DWC2_L0;
>>>> +
>>>> +		/* Gadget may queue new requests upon resume to L0 state */
>>>> +		if (lx_state == DWC2_L2)
>>>> +			call_gadget(hsotg, resume);
>>>>    	} else {
>>>>    		if (hsotg->params.power_down)
>>>>    			return;
>>>>
>>>
>>> What about below patch without introducing additional variable.
>>>
>>> diff --git a/drivers/usb/dwc2/core_intr.c b/drivers/usb/dwc2/core_intr.c
>>> index 876ff31261d5..543865e31c72 100644
>>> --- a/drivers/usb/dwc2/core_intr.c
>>> +++ b/drivers/usb/dwc2/core_intr.c
>>> @@ -416,6 +416,8 @@ static void dwc2_handle_wakeup_detected_intr(struct
>>> dwc2_hsotg *hsotg)
>>>                           if (ret && (ret != -ENOTSUPP))
>>>                                   dev_err(hsotg->dev, "exit power_down
>>> failed\n");
>>>
>>> +                       /* Change to L0 state */
>>> +                       hsotg->lx_state = DWC2_L0;
>>
>> Hi Minas,
>>
>> That was my first approach locally, but I added a variable to avoid do
>> it twice... few lines after.
>>
>> But if you prefer, I can change in V2 ?
>>
>> Please let me know.
>>
>> Thanks,
>> Fabrice
>>
>>>                           call_gadget(hsotg, resume);
>>>                   }
>>>                   /* Change to L0 state */
>>>
>>>
>>> Thanks,
>>> Minas
>>>
> To avoid twice setting lx_state you can add 'else' before second setting.

Hi Minas,

Thanks for your quick answer. Sure, I'll update it in v2.

Also, do you think this can/should be marked as a fix ?
- e.g. add a Fixes tag?

Fixes: f81f46e1f530 ("usb: dwc2: implement hibernation during bus
suspend/resume")

Please advise,
Best Regards,
Fabrice

> 
> diff --git a/drivers/usb/dwc2/core_intr.c b/drivers/usb/dwc2/core_intr.c
> index 876ff31261d5..f59dabd46e60 100644
> --- a/drivers/usb/dwc2/core_intr.c
> +++ b/drivers/usb/dwc2/core_intr.c
> @@ -416,10 +416,14 @@ static void 
> dwc2_handle_wakeup_detected_intr(struct dwc2_hsotg *hsotg)
>                          if (ret && (ret != -ENOTSUPP))
>                                  dev_err(hsotg->dev, "exit power_down 
> failed\n");
> 
> +                       /* Change to L0 state */
> +                       hsotg->lx_state = DWC2_L0;
>                          call_gadget(hsotg, resume);
>                  }
> -               /* Change to L0 state */
> -               hsotg->lx_state = DWC2_L0;
> +               else {
> +                       /* Change to L0 state */
> +                       hsotg->lx_state = DWC2_L0;
> +               }
>          } else {
>                  if (hsotg->params.power_down)
>                          return;
> 
> 
> 
> Am I missed something?
> 
> Thanks,
> Minas
> 

  reply	other threads:[~2020-04-23  9:27 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-21 12:32 [PATCH 0/4] usb: gadget: serial: add supend resume support Fabrice Gasnier
2020-04-21 12:32 ` [PATCH 1/4] usb: dwc2: gadget: move gadget resume after the core is in L0 state Fabrice Gasnier
2020-04-22 14:48   ` Minas Harutyunyan
2020-04-22 15:57     ` Fabrice Gasnier
2020-04-22 16:16       ` Minas Harutyunyan
2020-04-23  9:27         ` Fabrice Gasnier [this message]
2020-04-23 10:35           ` Minas Harutyunyan
2020-04-21 12:32 ` [PATCH 2/4] usb: gadget: u_serial: add suspend resume callbacks Fabrice Gasnier
2020-04-21 12:32 ` [PATCH 3/4] usb: gadget: f_serial: " Fabrice Gasnier
2020-04-21 12:32 ` [PATCH 4/4] usb: gadget: f_acm: " Fabrice Gasnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d1a2ce55-450b-47ea-15f9-a8532000a647@st.com \
    --to=fabrice.gasnier@st.com \
    --cc=Minas.Harutyunyan@synopsys.com \
    --cc=amelie.delaunay@st.com \
    --cc=balbi@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=linux-usb@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®