From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
To: Elson Roy Serrao <quic_eserrao@quicinc.com>
Cc: "gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
"balbi@kernel.org" <balbi@kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
"quic_wcheng@quicinc.com" <quic_wcheng@quicinc.com>,
"quic_jackp@quicinc.com" <quic_jackp@quicinc.com>
Subject: Re: [PATCH v7 2/5] usb: dwc3: Add remote wakeup handling
Date: Fri, 10 Mar 2023 23:21:28 +0000 [thread overview]
Message-ID: <20230310232125.7dbwynzxziyd3l3y@synopsys.com> (raw)
In-Reply-To: <1678393499-7366-3-git-send-email-quic_eserrao@quicinc.com>
On Thu, Mar 09, 2023, Elson Roy Serrao wrote:
> An usb device can initate a remote wakeup and bring the link out of
> suspend as dictated by the DEVICE_REMOTE_WAKEUP feature selector.
> Add support to handle this packet and set the remote wakeup capability.
>
> Some hosts may take longer time to initiate the resume signaling after
> device triggers a remote wakeup. So add async support to the wakeup API
> by enabling link status change events.
>
> Signed-off-by: Elson Roy Serrao <quic_eserrao@quicinc.com>
> ---
> drivers/usb/dwc3/core.h | 2 ++
> drivers/usb/dwc3/ep0.c | 5 ++++
> drivers/usb/dwc3/gadget.c | 76 +++++++++++++++++++++++++++++++++++++++++++----
> 3 files changed, 77 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
> index b1bd631..416e0ef 100644
> --- a/drivers/usb/dwc3/core.h
> +++ b/drivers/usb/dwc3/core.h
> @@ -1113,6 +1113,7 @@ struct dwc3_scratchpad_array {
> * 3 - Reserved
> * @dis_metastability_quirk: set to disable metastability quirk.
> * @dis_split_quirk: set to disable split boundary.
> + * @wakeup_configured: set if the device is configured for remote wakeup.
> * @imod_interval: set the interrupt moderation interval in 250ns
> * increments or 0 to disable.
> * @max_cfg_eps: current max number of IN eps used across all USB configs.
> @@ -1331,6 +1332,7 @@ struct dwc3 {
>
> unsigned dis_split_quirk:1;
> unsigned async_callbacks:1;
> + unsigned wakeup_configured:1;
>
> u16 imod_interval;
>
> diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c
> index 61de693..442d8fe 100644
> --- a/drivers/usb/dwc3/ep0.c
> +++ b/drivers/usb/dwc3/ep0.c
> @@ -356,6 +356,9 @@ static int dwc3_ep0_handle_status(struct dwc3 *dwc,
> usb_status |= 1 << USB_DEV_STAT_U1_ENABLED;
> if (reg & DWC3_DCTL_INITU2ENA)
> usb_status |= 1 << USB_DEV_STAT_U2_ENABLED;
> + } else {
> + usb_status |= dwc->gadget->wakeup_armed <<
> + USB_DEVICE_REMOTE_WAKEUP;
> }
>
> break;
> @@ -476,6 +479,8 @@ static int dwc3_ep0_handle_device(struct dwc3 *dwc,
>
> switch (wValue) {
> case USB_DEVICE_REMOTE_WAKEUP:
> + if (dwc->wakeup_configured)
> + dwc->gadget->wakeup_armed = set;
We should set ret = -EINVAL in the else case so the device will respond
with a protocol STALL rejecting the request rather than silently
accepting it.
Thanks,
Thinh
next prev parent reply other threads:[~2023-03-10 23:21 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-09 20:24 [PATCH v7 0/5] Add function suspend/resume and remote wakeup support Elson Roy Serrao
2023-03-09 20:24 ` [PATCH v7 1/5] usb: gadget: Properly configure the device for remote wakeup Elson Roy Serrao
2023-03-09 20:24 ` [PATCH v7 2/5] usb: dwc3: Add remote wakeup handling Elson Roy Serrao
2023-03-10 23:21 ` Thinh Nguyen [this message]
2023-03-09 20:24 ` [PATCH v7 3/5] usb: gadget: Add function wakeup support Elson Roy Serrao
2023-03-10 23:17 ` Thinh Nguyen
2023-03-09 20:24 ` [PATCH v7 4/5] usb: dwc3: Add function suspend and " Elson Roy Serrao
2023-03-09 20:24 ` [PATCH v7 5/5] usb: gadget: f_ecm: Add suspend/resume and remote " Elson Roy Serrao
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=20230310232125.7dbwynzxziyd3l3y@synopsys.com \
--to=thinh.nguyen@synopsys.com \
--cc=balbi@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=quic_eserrao@quicinc.com \
--cc=quic_jackp@quicinc.com \
--cc=quic_wcheng@quicinc.com \
/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®