From: Peter Chen <peter.chen@kernel.org>
To: Pawel Laszczak <pawell@cadence.com>
Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org, jianhe@ambarella.com,
stable@vger.kernel.org
Subject: Re: [PATCH v2] usb: cdnsp: Fix lack of spin_lock_irqsave/spin_lock_restore
Date: Tue, 14 Dec 2021 19:37:21 +0800 [thread overview]
Message-ID: <20211214113721.GA4527@Peter> (raw)
In-Reply-To: <20211214045527.26823-1-pawell@gli-login.cadence.com>
On 21-12-14 05:55:27, Pawel Laszczak wrote:
> From: Pawel Laszczak <pawell@cadence.com>
>
> Patch puts content of cdnsp_gadget_pullup function inside
> spin_lock_irqsave and spin_lock_restore section.
> This construction is required here to keep the data consistency,
> otherwise some data can be changed e.g. from interrupt context.
>
> Fixes: 3d82904559f4 ("usb: cdnsp: cdns3 Add main part of Cadence USBSSP DRD Driver")
> Reported-by: Ken (Jian) He <jianhe@ambarella.com>
> cc: <stable@vger.kernel.org>
> Signed-off-by: Pawel Laszczak <pawell@cadence.com>
Reviewed-by: Peter Chen <peter.chen@kernel.org>
> --
>
> Changelog:
> v2:
> - added disable_irq/enable_irq as sugester by Peter Chen
>
> drivers/usb/cdns3/cdnsp-gadget.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/drivers/usb/cdns3/cdnsp-gadget.c b/drivers/usb/cdns3/cdnsp-gadget.c
> index f6d231760a6a..e07a65b980af 100644
> --- a/drivers/usb/cdns3/cdnsp-gadget.c
> +++ b/drivers/usb/cdns3/cdnsp-gadget.c
> @@ -1544,15 +1544,27 @@ static int cdnsp_gadget_pullup(struct usb_gadget *gadget, int is_on)
> {
> struct cdnsp_device *pdev = gadget_to_cdnsp(gadget);
> struct cdns *cdns = dev_get_drvdata(pdev->dev);
> + unsigned long flags;
>
> trace_cdnsp_pullup(is_on);
>
> + /*
> + * Disable events handling while controller is being
> + * enabled/disabled.
> + */
> + disable_irq(cdns->dev_irq);
> + spin_lock_irqsave(&pdev->lock, flags);
> +
> if (!is_on) {
> cdnsp_reset_device(pdev);
> cdns_clear_vbus(cdns);
> } else {
> cdns_set_vbus(cdns);
> }
> +
> + spin_unlock_irqrestore(&pdev->lock, flags);
> + enable_irq(cdns->dev_irq);
> +
> return 0;
> }
>
> --
> 2.25.1
>
--
Thanks,
Peter Chen
prev parent reply other threads:[~2021-12-14 11:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-14 4:55 [PATCH v2] usb: cdnsp: Fix lack of spin_lock_irqsave/spin_lock_restore Pawel Laszczak
2021-12-14 11:37 ` Peter Chen [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=20211214113721.GA4527@Peter \
--to=peter.chen@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=jianhe@ambarella.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=pawell@cadence.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox