From: Rolf Eike Beer <eb@emlix.com>
To: Manivannan Sadhasivam <mani@kernel.org>
Cc: Cristian Ciocaltea <cristian.ciocaltea@gmail.com>,
Lee Jones <lee.jones@linaro.org>,
linux-actions@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: atc260x has broken locking
Date: Wed, 23 Feb 2022 12:07:48 +0100 [thread overview]
Message-ID: <16136311.TfV2VxeR0u@mobilepool36.emlix.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1178 bytes --]
When looking at this functions I found the locking to be broken for the atomic
case (comments stripped):
static void regmap_lock_mutex(void *__mutex)
{
struct mutex *mutex = __mutex;
if (system_state > SYSTEM_RUNNING && irqs_disabled())
mutex_trylock(mutex);
else
mutex_lock(mutex);
}
static void regmap_unlock_mutex(void *__mutex)
{
struct mutex *mutex = __mutex;
mutex_unlock(mutex);
}
When the mutex is already locked and the atomic context is hit then the lock
will not be acquired, this is never noticed, and it afterwards is unlocked
anyway.
The comment says this is inspired from i2c_in_atomic_xfer_mode() to detect the
atomic case, but the important caller __i2c_lock_bus_helper() actually does
check and pass on the return value of mutex_trylock(), which is missing here.
Greetings,
Eike
--
Rolf Eike Beer, emlix GmbH, https://www.emlix.com
Fon +49 551 30664-0, Fax +49 551 30664-11
Gothaer Platz 3, 37083 Göttingen, Germany
Sitz der Gesellschaft: Göttingen, Amtsgericht Göttingen HR B 3160
Geschäftsführung: Heike Jordan, Dr. Uwe Kracke – Ust-IdNr.: DE 205 198 055
emlix - smart embedded open source
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 313 bytes --]
next reply other threads:[~2022-02-23 11:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-23 11:07 Rolf Eike Beer [this message]
2022-02-24 23:14 ` atc260x has broken locking Cristian Ciocaltea
2022-02-25 7:36 ` Rolf Eike Beer
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=16136311.TfV2VxeR0u@mobilepool36.emlix.com \
--to=eb@emlix.com \
--cc=cristian.ciocaltea@gmail.com \
--cc=lee.jones@linaro.org \
--cc=linux-actions@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mani@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