From: Bjorn Andersson <bjorn.andersson@linaro.org>
To: Evan Green <evgreen@chromium.org>
Cc: Markus Elfring <elfring@users.sourceforge.net>,
Andy Gross <agross@kernel.org>,
linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [RESEND PATCH] soc: qcom: smp2p: Safely acquire spinlock without IRQs
Date: Fri, 16 Oct 2020 12:13:37 -0500 [thread overview]
Message-ID: <20201016171337.GA241575@builder.lan> (raw)
In-Reply-To: <20200929133040.RESEND.1.Ideabf6dcdfc577cf39ce3d95b0e4aa1ac8b38f0c@changeid>
On Tue 29 Sep 15:30 CDT 2020, Evan Green wrote:
> smp2p_update_bits() should disable interrupts when it acquires its
> spinlock. This is important because without the _irqsave, a priority
> inversion can occur.
>
> This function is called both with interrupts enabled in
> qcom_q6v5_request_stop(), and with interrupts disabled in
> ipa_smp2p_panic_notifier(). IRQ handling of spinlocks should be
> consistent to avoid the panic notifier deadlocking because it's
> sitting on the thread that's already got the lock via _request_stop().
>
> Found via lockdep.
>
> Fixes: 50e99641413e7 ("soc: qcom: smp2p: Qualcomm Shared Memory Point to Point")
> Signed-off-by: Evan Green <evgreen@chromium.org>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Regards,
Bjorn
> ---
>
> drivers/soc/qcom/smp2p.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/soc/qcom/smp2p.c b/drivers/soc/qcom/smp2p.c
> index 07183d731d747..a9709aae54abb 100644
> --- a/drivers/soc/qcom/smp2p.c
> +++ b/drivers/soc/qcom/smp2p.c
> @@ -318,15 +318,16 @@ static int qcom_smp2p_inbound_entry(struct qcom_smp2p *smp2p,
> static int smp2p_update_bits(void *data, u32 mask, u32 value)
> {
> struct smp2p_entry *entry = data;
> + unsigned long flags;
> u32 orig;
> u32 val;
>
> - spin_lock(&entry->lock);
> + spin_lock_irqsave(&entry->lock, flags);
> val = orig = readl(entry->value);
> val &= ~mask;
> val |= value;
> writel(val, entry->value);
> - spin_unlock(&entry->lock);
> + spin_unlock_irqrestore(&entry->lock, flags);
>
> if (val != orig)
> qcom_smp2p_kick(entry->smp2p);
> --
> 2.26.2
>
prev parent reply other threads:[~2020-10-16 17:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-29 20:30 [RESEND PATCH] soc: qcom: smp2p: Safely acquire spinlock without IRQs Evan Green
2020-10-16 16:48 ` Stephen Boyd
2020-10-16 17:13 ` Bjorn Andersson [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=20201016171337.GA241575@builder.lan \
--to=bjorn.andersson@linaro.org \
--cc=agross@kernel.org \
--cc=elfring@users.sourceforge.net \
--cc=evgreen@chromium.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@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;
as well as URLs for NNTP newsgroup(s).