From: Minas Harutyunyan <Minas.Harutyunyan@synopsys.com>
To: Jun Chen <ptchentw@gmail.com>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>
Cc: Jun Chen <jun.chen@vatics.com>
Subject: Re: [PATCH] usb: dwc2: gadget: stall handshakes returned by control pipes in status stage
Date: Thu, 28 Nov 2019 12:46:43 +0000 [thread overview]
Message-ID: <da692cfb-2d23-cc24-8313-f1c836a9aa6b@synopsys.com> (raw)
In-Reply-To: <1572516292-23969-1-git-send-email-ptchentw@gmail.com>
Hi Jun,
On 10/31/2019 2:04 PM, Jun Chen wrote:
> From: Jun Chen <jun.chen@vatics.com>
>
> According to USB2.0 spec 8.5.3, "If the control sequence
> has no Data stage, then it consists of a Setup stage
> followed by a Status stage consisting of an IN transaction."
>
> But when doing control read in some HOST (like MS Windows),
> after a SETUP transaction with no Data stage, the sequence
> stay in the Status stage of an OUT transaction until timeout.
>
Could you please provide debug log of above scenario?
> This patch Stall both IN and OUT on ep0 in status stage,
> fix the unhandling state when we got an error command
> with zero length control read request.
>
> It's also based on the USB2.0 spec 8.5.3.4,
> "The protocol STALL condition lasts until the receipt of
> the next SETUP transaction, and the function will return
> STALL in response to any IN or OUT transaction on the pipe
> until the SETUP transaction is received."
>
> Signed-off-by: Jun Chen <jun.chen@vatics.com>
> ---
> drivers/usb/dwc2/gadget.c | 33 ++++++++++++++++++++-------------
> 1 file changed, 20 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
> index 6be10e496..73b5944 100644
> --- a/drivers/usb/dwc2/gadget.c
> +++ b/drivers/usb/dwc2/gadget.c
> @@ -1853,23 +1853,30 @@ static void dwc2_hsotg_stall_ep0(struct dwc2_hsotg *hsotg)
> struct dwc2_hsotg_ep *ep0 = hsotg->eps_out[0];
> u32 reg;
> u32 ctrl;
> + u32 direction;
>
> - dev_dbg(hsotg->dev, "ep0 stall (dir=%d)\n", ep0->dir_in);
> - reg = (ep0->dir_in) ? DIEPCTL0 : DOEPCTL0;
> + direction = ep0->dir_in;
> + do {
> + dev_dbg(hsotg->dev, "ep0 stall (dir=%d)\n", ep0->dir_in);
> + reg = (ep0->dir_in) ? DIEPCTL0 : DOEPCTL0;
>
> - /*
> - * DxEPCTL_Stall will be cleared by EP once it has
> - * taken effect, so no need to clear later.
> - */
> + /*
> + * DxEPCTL_Stall will be cleared by EP once it has
> + * taken effect, so no need to clear later.
> + */
>
> - ctrl = dwc2_readl(hsotg, reg);
> - ctrl |= DXEPCTL_STALL;
> - ctrl |= DXEPCTL_CNAK;
> - dwc2_writel(hsotg, ctrl, reg);
> + ctrl = dwc2_readl(hsotg, reg);
> + ctrl |= DXEPCTL_STALL;
> + ctrl |= DXEPCTL_CNAK;
> + dwc2_writel(hsotg, ctrl, reg);
>
> - dev_dbg(hsotg->dev,
> - "written DXEPCTL=0x%08x to %08x (DXEPCTL=0x%08x)\n",
> - ctrl, reg, dwc2_readl(hsotg, reg));
> + dev_dbg(hsotg->dev,
> + "written DXEPCTL=0x%08x to %08x (DXEPCTL=0x%08x)\n",
> + ctrl, reg, dwc2_readl(hsotg, reg));
> +
> + if (hsotg->ep0_state == DWC2_EP0_STATUS_IN)
> + ep0->dir_in = (ep0->dir_in == 1) ? 0 : 1;
> + } while (ep0->dir_in != direction);
>
> /*
> * complete won't be called, so we enqueue
>
Thanks,
Minas
next prev parent reply other threads:[~2019-11-28 12:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-31 10:04 [PATCH] usb: dwc2: gadget: stall handshakes returned by control pipes in status stage Jun Chen
2019-11-28 12:46 ` Minas Harutyunyan [this message]
[not found] ` <CADY+QgtWY2Hsw-D6jMC5bGCj6A1BL4DFu6dZgFwNgxwJrFXn4A@mail.gmail.com>
2019-12-02 11:53 ` Minas Harutyunyan
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=da692cfb-2d23-cc24-8313-f1c836a9aa6b@synopsys.com \
--to=minas.harutyunyan@synopsys.com \
--cc=jun.chen@vatics.com \
--cc=linux-usb@vger.kernel.org \
--cc=ptchentw@gmail.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;
as well as URLs for NNTP newsgroup(s).