From: Manivannan Sadhasivam <mani@kernel.org>
To: Daniel Thompson <daniel.thompson@linaro.org>
Cc: Jia-Ju Bai <baijiaju1990@gmail.com>,
hemantk@codeaurora.org, bbhatt@codeaurora.org,
loic.poulain@linaro.org, jhugo@codeaurora.org,
linux-arm-msm@vger.kernel.org,
linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [BUG] bus: mhi: possible deadlock in mhi_pm_disable_transition() and mhi_async_power_up()
Date: Mon, 7 Feb 2022 12:15:04 +0530 [thread overview]
Message-ID: <20220207064504.GC1905@thinkpad> (raw)
In-Reply-To: <20220201171540.2udq3x6r2swctzau@maple.lan>
On Tue, Feb 01, 2022 at 05:15:40PM +0000, Daniel Thompson wrote:
> On Sat, Jan 29, 2022 at 10:56:30AM +0800, Jia-Ju Bai wrote:
> > Hello,
> >
> > My static analysis tool reports a possible deadlock in the mhi driver in
> > Linux 5.10:
> >
> > mhi_async_power_up()
> > mutex_lock(&mhi_cntrl->pm_mutex); --> Line 933 (Lock A)
> > wait_event_timeout(mhi_cntrl->state_event, ...) --> Line 985 (Wait X)
> > mutex_unlock(&mhi_cntrl->pm_mutex); --> Line 1040 (Unlock A)
> >
> > mhi_pm_disable_transition()
> > mutex_lock(&mhi_cntrl->pm_mutex); --> Line 463 (Lock A)
> > wake_up_all(&mhi_cntrl->state_event); --> Line 474 (Wake X)
> > mutex_unlock(&mhi_cntrl->pm_mutex); --> Line 524 (Unlock A)
> > wake_up_all(&mhi_cntrl->state_event); --> Line 526 (Wake X)
> >
> > When mhi_async_power_up() is executed, "Wait X" is performed by holding
> > "Lock A". If mhi_pm_disable_transition() is concurrently executed at this
> > time, "Wake X" cannot be performed to wake up "Wait X" in
> > mhi_async_power_up(), because "Lock A" is already hold by
> > mhi_async_power_up(), causing a possible deadlock.
> > I find that "Wait X" is performed with a timeout, to relieve the possible
> > deadlock; but I think this timeout can cause inefficient execution.
> >
> > I am not quite sure whether this possible problem is real and how to fix it
> > if it is real.
> > Any feedback would be appreciated, thanks :)
>
> Interesting find but I think it would be better to run your tool
> against more recent kernels to confirm any problem reports. In this
> case the code you mention looks like it was removed in v5.17-rc1
> (and should eventually make its way to the stable kernels too).
>
Hmm, looks like the commit didn't apply cleanly to 5.10:
https://www.spinics.net/lists/stable/msg526754.html
Let send the fix up version.
Thanks,
Mani
>
> Daniel.
next prev parent reply other threads:[~2022-02-07 7:03 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-29 2:56 [BUG] bus: mhi: possible deadlock in mhi_pm_disable_transition() and mhi_async_power_up() Jia-Ju Bai
2022-02-01 17:15 ` Daniel Thompson
2022-02-06 15:34 ` Jia-Ju Bai
2022-02-07 8:34 ` Manivannan Sadhasivam
2022-02-07 6:45 ` Manivannan Sadhasivam [this message]
2022-02-07 6:39 ` Manivannan Sadhasivam
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=20220207064504.GC1905@thinkpad \
--to=mani@kernel.org \
--cc=baijiaju1990@gmail.com \
--cc=bbhatt@codeaurora.org \
--cc=daniel.thompson@linaro.org \
--cc=hemantk@codeaurora.org \
--cc=jhugo@codeaurora.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=loic.poulain@linaro.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.