From: Aswath Govindraju <a-govindraju@ti.com>
To: Pawel Laszczak <pawell@cadence.com>, <peter.chen@kernel.org>
Cc: <rogerq@kernel.org>, <gregkh@linuxfoundation.org>,
<felipe.balbi@linux.intel.com>, <linux-usb@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <stable@vger.kernel.org>
Subject: Re: [PATCH] usb: cdns3: fix race condition before setting doorbell
Date: Tue, 7 Sep 2021 12:58:32 +0530 [thread overview]
Message-ID: <774df0ea-76e5-b8e2-9bd6-55e4b1cc09f4@ti.com> (raw)
In-Reply-To: <20210907062619.34622-1-pawell@gli-login.cadence.com>
On 07/09/21 11:56 am, Pawel Laszczak wrote:
> From: Pawel Laszczak <pawell@cadence.com>
>
> For DEV_VER_V3 version there exist race condition between clearing
> ep_sts.EP_STS_TRBERR and setting ep_cmd.EP_CMD_DRDY bit.
> Setting EP_CMD_DRDY will be ignored by controller when
> EP_STS_TRBERR is set. So, between these two instructions we have
> a small time gap in which the EP_STSS_TRBERR can be set. In such case
> the transfer will not start after setting doorbell.
>
> Fixes: 7733f6c32e36 ("usb: cdns3: Add Cadence USB3 DRD Driver")
> cc: <stable@vger.kernel.org> # 5.12.x
> Signed-off-by: Pawel Laszczak <pawell@cadence.com>
> ---
Reviewed-by: Aswath Govindraju <a-govindraju@ti.com>
Tested-by: Aswath Govindraju <a-govindraju@ti.com>
> drivers/usb/cdns3/cdns3-gadget.c | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/drivers/usb/cdns3/cdns3-gadget.c b/drivers/usb/cdns3/cdns3-gadget.c
> index 80aaab159e58..e9769fab21ea 100644
> --- a/drivers/usb/cdns3/cdns3-gadget.c
> +++ b/drivers/usb/cdns3/cdns3-gadget.c
> @@ -1100,6 +1100,19 @@ static int cdns3_ep_run_stream_transfer(struct cdns3_endpoint *priv_ep,
> return 0;
> }
>
> +static void cdns3_rearm_drdy_if_needed(struct cdns3_endpoint *priv_ep)
> +{
> + struct cdns3_device *priv_dev = priv_ep->cdns3_dev;
> +
> + if (priv_dev->dev_ver < DEV_VER_V3)
> + return;
> +
> + if (readl(&priv_dev->regs->ep_sts) & EP_STS_TRBERR) {
> + writel(EP_STS_TRBERR, &priv_dev->regs->ep_sts);
> + writel(EP_CMD_DRDY, &priv_dev->regs->ep_cmd);
> + }
> +}
> +
> /**
> * cdns3_ep_run_transfer - start transfer on no-default endpoint hardware
> * @priv_ep: endpoint object
> @@ -1351,6 +1364,7 @@ static int cdns3_ep_run_transfer(struct cdns3_endpoint *priv_ep,
> /*clearing TRBERR and EP_STS_DESCMIS before seting DRDY*/
> writel(EP_STS_TRBERR | EP_STS_DESCMIS, &priv_dev->regs->ep_sts);
> writel(EP_CMD_DRDY, &priv_dev->regs->ep_cmd);
> + cdns3_rearm_drdy_if_needed(priv_ep);
> trace_cdns3_doorbell_epx(priv_ep->name,
> readl(&priv_dev->regs->ep_traddr));
> }
>
prev parent reply other threads:[~2021-09-07 7:28 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-07 6:26 Pawel Laszczak
2021-09-07 7:28 ` Aswath Govindraju [this message]
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=774df0ea-76e5-b8e2-9bd6-55e4b1cc09f4@ti.com \
--to=a-govindraju@ti.com \
--cc=felipe.balbi@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=pawell@cadence.com \
--cc=peter.chen@kernel.org \
--cc=rogerq@kernel.org \
--cc=stable@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®