From: Peter Chen <peter.chen@kernel.org>
To: Pawel Laszczak <pawell@cadence.com>
Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org,
kurahul@cadence.com, stable@vger.kernel.org
Subject: Re: [PATCH] usb: cdnsp: Fix deadlock issue in cdnsp_thread_irq_handler
Date: Sat, 22 May 2021 17:54:32 +0800 [thread overview]
Message-ID: <20210522095432.GA12415@b29397-desktop> (raw)
In-Reply-To: <20210520094224.14099-1-pawell@gli-login.cadence.com>
On 21-05-20 11:42:24, Pawel Laszczak wrote:
> From: Pawel Laszczak <pawell@cadence.com>
>
> Patch fixes the critical issue caused by deadlock which has been detected
> during testing NCM class.
>
> The root cause of issue is spin_lock/spin_unlock instruction instead
> spin_lock_irqsave/spin_lock_irqrestore in cdnsp_thread_irq_handler
> function.
Pawel, would you please explain more about why the deadlock occurs with
current code, and why this patch could fix it?
Peter
>
> Cc: stable@vger.kernel.org
> Fixes: 3d82904559f4 ("usb: cdnsp: cdns3 Add main part of Cadence USBSSP DRD Driver")
> Signed-off-by: Pawel Laszczak <pawell@cadence.com>
> ---
> drivers/usb/cdns3/cdnsp-ring.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/usb/cdns3/cdnsp-ring.c b/drivers/usb/cdns3/cdnsp-ring.c
> index 5f0513c96c04..68972746e363 100644
> --- a/drivers/usb/cdns3/cdnsp-ring.c
> +++ b/drivers/usb/cdns3/cdnsp-ring.c
> @@ -1517,13 +1517,14 @@ irqreturn_t cdnsp_thread_irq_handler(int irq, void *data)
> {
> struct cdnsp_device *pdev = (struct cdnsp_device *)data;
> union cdnsp_trb *event_ring_deq;
> + unsigned long flags;
> int counter = 0;
>
> - spin_lock(&pdev->lock);
> + spin_lock_irqsave(&pdev->lock, flags);
>
> if (pdev->cdnsp_state & (CDNSP_STATE_HALTED | CDNSP_STATE_DYING)) {
> cdnsp_died(pdev);
> - spin_unlock(&pdev->lock);
> + spin_unlock_irqrestore(&pdev->lock, flags);
> return IRQ_HANDLED;
> }
>
> @@ -1539,7 +1540,7 @@ irqreturn_t cdnsp_thread_irq_handler(int irq, void *data)
>
> cdnsp_update_erst_dequeue(pdev, event_ring_deq, 1);
>
> - spin_unlock(&pdev->lock);
> + spin_unlock_irqrestore(&pdev->lock, flags);
>
> return IRQ_HANDLED;
> }
> --
> 2.25.1
>
--
Thanks,
Peter Chen
next prev parent reply other threads:[~2021-05-22 9:54 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-20 9:42 [PATCH] usb: cdnsp: Fix deadlock issue in cdnsp_thread_irq_handler Pawel Laszczak
2021-05-22 9:54 ` Peter Chen [this message]
2021-05-24 10:56 ` Pawel Laszczak
2021-05-25 0:53 ` Peter Chen
2021-05-25 5:11 ` Pawel Laszczak
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=20210522095432.GA12415@b29397-desktop \
--to=peter.chen@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=kurahul@cadence.com \
--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