From: Jia-Ju Bai <baijiaju1990@gmail.com>
To: davem@davemloft.net, kuba@kernel.org, grygorii.strashko@ti.com,
vladimir.oltean@nxp.com, vigneshr@ti.com,
yangyingliang@huawei.com
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [BUG] net: ti: possible deadlock in cpts_ptp_gettimeex() and cpts_overflow_check()
Date: Mon, 7 Feb 2022 22:43:03 +0800 [thread overview]
Message-ID: <1f27fa76-49b9-6b53-de71-d72d076bb745@gmail.com> (raw)
Hello,
My static analysis tool reports a possible deadlock in the ti driver in
Linux 5.16:
cpts_ptp_gettimeex()
mutex_lock(&cpts->ptp_clk_mutex); --> Line 260 (Lock A)
cpts_update_cur_time()
wait_for_completion_timeout(&cpts->ts_push_complete, HZ); --> Line
210 (Wait X)
cpts_overflow_check()
mutex_lock(&cpts->ptp_clk_mutex); --> Line 411 (Lock A)
cpts_update_cur_time()
cpts_fifo_read()
complete(&cpts->ts_push_complete); --> Line 142 (Wake X)
When cpts_ptp_gettimeex() is executed, "Wait X" is performed by holding
"Lock A". If cpts_overflow_check() is executed at this time, "Wake X"
cannot be performed to wake up "Wait X" in cpts_ptp_gettimeex(), because
"Lock A" has been already hold by cpts_ptp_gettimeex(), 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 :)
Best wishes,
Jia-Ju Bai
reply other threads:[~2022-02-07 15:12 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1f27fa76-49b9-6b53-de71-d72d076bb745@gmail.com \
--to=baijiaju1990@gmail.com \
--cc=davem@davemloft.net \
--cc=grygorii.strashko@ti.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=vigneshr@ti.com \
--cc=vladimir.oltean@nxp.com \
--cc=yangyingliang@huawei.com \
/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
all inboxes | Powered by JetHome®