All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pawel Laszczak <pawell@cadence.com>
To: Peter Chen <peter.chen@nxp.com>,
	"balbi@kernel.org" <balbi@kernel.org>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>
Cc: "linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"linux-imx@nxp.com" <linux-imx@nxp.com>,
	"rogerq@ti.com" <rogerq@ti.com>,
	"jun.li@nxp.com" <jun.li@nxp.com>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: RE: [PATCH 3/3] usb: cdns3: ep0: add spinlock for cdns3_check_new_setup
Date: Tue, 23 Jun 2020 06:46:36 +0000	[thread overview]
Message-ID: <DM6PR07MB5529B0947299C70C31551838DD940@DM6PR07MB5529.namprd07.prod.outlook.com> (raw)
In-Reply-To: <20200623030918.8409-4-peter.chen@nxp.com>

>
>The other thread may access other endpoints when the cdns3_check_new_setup
>is handling, add spinlock to protect it.
>
>Cc: <stable@vger.kernel.org>
>Fixes: 7733f6c32e36 ("usb: cdns3: Add Cadence USB3 DRD Driver")
>Signed-off-by: Peter Chen <peter.chen@nxp.com>

Reviewed-by: Pawel Laszczak <pawell@cadence.com>

>---
> drivers/usb/cdns3/ep0.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
>diff --git a/drivers/usb/cdns3/ep0.c b/drivers/usb/cdns3/ep0.c
>index 74a1ff5000ba..5aa69980e7ff 100644
>--- a/drivers/usb/cdns3/ep0.c
>+++ b/drivers/usb/cdns3/ep0.c
>@@ -705,15 +705,17 @@ static int cdns3_gadget_ep0_queue(struct usb_ep *ep,
> 	int ret = 0;
> 	u8 zlp = 0;
>
>+	spin_lock_irqsave(&priv_dev->lock, flags);
> 	trace_cdns3_ep0_queue(priv_dev, request);
>
> 	/* cancel the request if controller receive new SETUP packet. */
>-	if (cdns3_check_new_setup(priv_dev))
>+	if (cdns3_check_new_setup(priv_dev)) {
>+		spin_unlock_irqrestore(&priv_dev->lock, flags);
> 		return -ECONNRESET;
>+	}
>
> 	/* send STATUS stage. Should be called only for SET_CONFIGURATION */
> 	if (priv_dev->ep0_stage == CDNS3_STATUS_STAGE) {
>-		spin_lock_irqsave(&priv_dev->lock, flags);
> 		cdns3_select_ep(priv_dev, 0x00);
>
> 		erdy_sent = !priv_dev->hw_configured_flag;
>@@ -738,7 +740,6 @@ static int cdns3_gadget_ep0_queue(struct usb_ep *ep,
> 		return 0;
> 	}
>
>-	spin_lock_irqsave(&priv_dev->lock, flags);
> 	if (!list_empty(&priv_ep->pending_req_list)) {
> 		dev_err(priv_dev->dev,
> 			"can't handle multiple requests for ep0\n");
>--
>2.17.1


      reply	other threads:[~2020-06-23  6:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-23  3:09 [PATCH 0/3] usb: cdns3: bug-fixes for usb-linus Peter Chen
2020-06-23  3:09 ` [PATCH 1/3] usb: cdns3: ep0: fix the test mode set incorrectly Peter Chen
2020-06-23  6:45   ` Pawel Laszczak
2020-06-23  7:01     ` Peter Chen
2020-06-23  7:22       ` Pawel Laszczak
2020-06-23  3:09 ` [PATCH 2/3] usb: cdns3: trace: using correct dir value Peter Chen
2020-06-23  6:46   ` Pawel Laszczak
2020-06-23  3:09 ` [PATCH 3/3] usb: cdns3: ep0: add spinlock for cdns3_check_new_setup Peter Chen
2020-06-23  6:46   ` Pawel Laszczak [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=DM6PR07MB5529B0947299C70C31551838DD940@DM6PR07MB5529.namprd07.prod.outlook.com \
    --to=pawell@cadence.com \
    --cc=balbi@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jun.li@nxp.com \
    --cc=linux-imx@nxp.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=peter.chen@nxp.com \
    --cc=rogerq@ti.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.