From: Wolfram Sang <wsa+renesas@sang-engineering.com>
To: Heiner Kallweit <hkallweit1@gmail.com>
Cc: Wolfram Sang <wsa@kernel.org>,
"linux-i2c@vger.kernel.org" <linux-i2c@vger.kernel.org>,
Krzysztof Piotr Oledzki <ole@ans.pl>
Subject: Re: [PATCH v2] i2c: core: Lock address during client device instantiation
Date: Mon, 26 Aug 2024 15:20:05 +0200 [thread overview]
Message-ID: <ZsyBBevhURS-WR2E@shikoro> (raw)
In-Reply-To: <32a2d535-d7c8-47da-a42f-b41d3fae972f@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1541 bytes --]
On Thu, Aug 15, 2024 at 09:44:50PM +0200, Heiner Kallweit wrote:
> Krzysztof reported an issue [0] which is caused by parallel attempts to
> instantiate the same I2C client device. This can happen if driver
> supports auto-detection, but certain devices are also instantiated
> explicitly.
> The original change isn't actually wrong, it just revealed that I2C core
> isn't prepared yet to handle this scenario.
> Calls to i2c_new_client_device() can be nested, therefore we can't use a
> simple mutex here. Parallel instantiation of devices at different addresses
> is ok, so we just have to prevent parallel instantiation at the same address.
> We can use a bitmap with one bit per 7-bit I2C client address, and atomic
> bit operations to set/check/clear bits.
> Now a parallel attempt to instantiate a device at the same address will
> result in -EBUSY being returned, avoiding the "sysfs: cannot create duplicate
> filename" splash.
>
> Note: This patch version includes small cosmetic changes to the Tested-by
> version, only functional change is that address locking is supported
> for slave addresses too.
>
> [0] https://lore.kernel.org/linux-i2c/9479fe4e-eb0c-407e-84c0-bd60c15baf74@ans.pl/T/#m12706546e8e2414d8f1a0dc61c53393f731685cc
>
> Fixes: caba40ec3531 ("eeprom: at24: Probe for DDR3 thermal sensor in the SPD case")
> Cc: stable@vger.kernel.org
> Tested-by: Krzysztof Piotr Oledzki <ole@ans.pl>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Applied to for-next, thanks!
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
prev parent reply other threads:[~2024-08-26 13:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-15 19:44 [PATCH v2] i2c: core: Lock address during client device instantiation Heiner Kallweit
2024-08-15 23:10 ` Dmitry Torokhov
2024-08-16 6:12 ` Heiner Kallweit
2024-08-26 13:20 ` Wolfram Sang [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=ZsyBBevhURS-WR2E@shikoro \
--to=wsa+renesas@sang-engineering.com \
--cc=hkallweit1@gmail.com \
--cc=linux-i2c@vger.kernel.org \
--cc=ole@ans.pl \
--cc=wsa@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