Heiner Kallweit
e2852a0246
i2c: core: Lock address during client device instantiation
...
[ Upstream commit 8d3cefaf659265aa82b0373a563fdb9d16a2b947 ]
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 >
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com >
Signed-off-by: Sasha Levin <sashal@kernel.org >
2024-10-17 15:22:04 +02:00
..
2024-03-15 10:48:13 -04:00
2024-03-06 14:45:14 +00:00
2024-08-29 17:30:43 +02:00
2024-06-12 11:03:39 +02:00
2024-02-23 09:12:40 +01:00
2023-11-20 11:52:08 +01:00
2024-09-18 19:23:05 +02:00
2024-06-16 13:41:35 +02:00
2024-02-23 09:12:49 +01:00
2024-04-03 15:19:33 +02:00
2024-05-17 11:55:54 +02:00
2024-06-21 14:35:51 +02:00
2024-09-12 11:10:21 +02:00
2024-08-29 17:30:17 +02:00
2024-05-17 11:56:10 +02:00
2024-08-29 17:30:52 +02:00
2024-10-17 15:21:19 +02:00
2024-06-12 11:03:08 +02:00
2024-01-31 16:17:00 -08:00
2024-01-25 15:27:42 -08:00
2024-08-29 17:30:15 +02:00
2024-06-12 11:03:08 +02:00
2024-08-14 13:53:01 +02:00
2024-10-17 15:21:48 +02:00
2024-04-27 17:07:17 +02:00
2024-07-18 13:18:34 +02:00
2024-08-29 17:30:17 +02:00
2024-07-18 13:18:34 +02:00
2024-03-06 14:45:19 +00:00
2024-08-19 06:00:07 +02:00
2024-02-23 09:12:51 +01:00
2024-01-25 15:27:37 -08:00
2024-08-14 13:52:57 +02:00
2024-07-05 09:31:59 +02:00
2024-07-18 13:18:31 +02:00
2024-05-17 11:56:20 +02:00
2024-02-23 09:12:51 +01:00
2024-02-23 09:12:28 +01:00
2024-06-12 11:03:34 +02:00
2024-03-15 10:48:21 -04:00
2024-04-03 15:19:28 +02:00
2023-12-13 18:39:03 +01:00
2024-08-29 17:30:14 +02:00
2023-12-20 17:00:20 +01:00
2024-01-01 12:39:08 +00:00
2024-10-17 15:21:32 +02:00
2024-06-12 11:03:21 +02:00
2024-04-10 16:28:32 +02:00
2024-01-01 12:39:05 +00:00
2024-03-26 18:21:02 -04:00
2024-05-17 11:56:16 +02:00
2024-02-16 19:06:24 +01:00
2024-07-05 09:32:00 +02:00
2024-05-02 16:29:29 +02:00
2023-11-28 17:07:18 +00:00
2024-01-05 15:18:38 +01:00
2024-03-26 18:20:23 -04:00
2024-10-17 15:21:10 +02:00
2024-10-17 15:22:03 +02:00
2024-02-23 09:12:51 +01:00
2024-07-05 09:31:47 +02:00
2024-10-17 15:21:17 +02:00
2024-07-25 09:49:20 +02:00
2024-09-08 07:53:10 +02:00
2024-07-11 12:47:14 +02:00
2023-11-28 17:06:54 +00:00
2024-05-17 11:56:07 +02:00
2024-04-03 15:19:42 +02:00
2024-01-10 17:10:33 +01:00
2023-12-03 07:32:07 +01:00
2024-01-25 15:27:22 -08:00
2024-02-16 19:06:30 +01:00
2024-05-17 11:55:52 +02:00
2024-08-03 08:49:29 +02:00
2023-11-20 11:52:04 +01:00
2024-09-08 07:53:09 +02:00
2024-05-17 11:56:08 +02:00
2024-10-17 15:22:04 +02:00
2023-11-20 11:52:16 +01:00
2024-07-05 09:31:48 +02:00
2024-08-29 17:30:43 +02:00
2024-02-23 09:12:38 +01:00
2024-03-26 18:20:22 -04:00
2024-03-26 18:20:22 -04:00
2024-05-25 16:21:31 +02:00
2023-12-13 18:39:17 +01:00
2024-02-05 20:12:49 +00:00
2023-12-08 08:51:20 +01:00
2024-04-17 11:18:28 +02:00
2024-08-29 17:30:17 +02:00
2024-08-03 08:49:05 +02:00
2023-10-25 12:03:16 +02:00
2024-01-01 12:38:52 +00:00
2024-06-27 13:46:22 +02:00
2024-01-01 12:38:58 +00:00
2023-12-13 18:39:17 +01:00
2024-08-11 12:35:53 +02:00
2024-04-03 15:19:51 +02:00
2024-07-11 12:47:16 +02:00
2024-01-31 16:17:01 -08:00
2024-03-01 13:26:36 +01:00
2024-07-25 09:49:07 +02:00
2023-12-20 17:00:26 +01:00
2024-05-17 11:55:51 +02:00
2024-09-12 11:10:17 +02:00
2024-07-18 13:18:31 +02:00
2024-06-27 13:46:23 +02:00
2024-01-05 15:18:40 +01:00
2024-03-26 18:20:52 -04:00
2024-07-11 12:47:04 +02:00
2024-01-05 15:18:29 +01:00
2024-01-10 17:10:27 +01:00
2023-11-20 11:51:55 +01:00
2024-01-25 15:27:51 -08:00
2024-03-06 14:45:08 +00:00
2024-03-06 14:45:17 +00:00
2024-04-03 15:19:34 +02:00
2024-06-12 11:03:17 +02:00
2024-07-05 09:31:50 +02:00
2024-08-03 08:49:05 +02:00
2024-09-04 13:24:59 +02:00
2024-01-10 17:10:32 +01:00
2024-08-14 13:52:46 +02:00
2024-08-03 08:49:46 +02:00
2024-02-23 09:12:51 +01:00
2024-08-03 08:49:41 +02:00
2024-08-29 17:30:18 +02:00
2024-01-31 16:17:09 -08:00
2024-03-26 18:20:28 -04:00
2023-11-08 14:11:02 +01:00
2024-02-23 09:12:51 +01:00
2024-06-12 11:03:21 +02:00
2024-08-14 13:52:50 +02:00
2024-01-05 15:18:40 +01:00
2023-11-28 17:07:03 +00:00
2024-04-13 13:05:25 +02:00
2024-04-13 13:05:07 +02:00
2023-12-13 18:39:17 +01:00
2024-04-03 15:19:35 +02:00
2024-01-31 16:17:02 -08:00
2024-02-23 09:12:51 +01:00
2024-10-17 15:21:10 +02:00
2024-04-10 16:28:34 +02:00
2024-07-11 12:47:16 +02:00
2024-06-21 14:36:00 +02:00
2024-06-12 11:03:32 +02:00
2024-05-17 11:55:56 +02:00
2024-08-29 17:30:28 +02:00
2024-06-16 13:41:42 +02:00
2024-03-01 13:26:36 +01:00
2024-02-23 09:12:51 +01:00
2024-01-10 17:10:27 +01:00
2024-02-23 09:12:51 +01:00
2023-12-13 18:39:08 +01:00
2023-11-28 17:06:57 +00:00
2024-03-01 13:26:32 +01:00
2024-05-17 11:56:24 +02:00
2024-04-27 17:07:10 +02:00
2024-07-05 09:31:59 +02:00
2024-08-11 12:35:51 +02:00
2024-08-03 08:49:34 +02:00
2024-05-17 11:56:13 +02:00
2024-08-14 13:52:54 +02:00
2024-06-27 13:46:17 +02:00
2024-04-17 11:18:23 +02:00
2024-08-29 17:30:56 +02:00
2024-10-17 15:21:46 +02:00
2024-10-17 15:21:12 +02:00
2023-11-20 11:52:04 +01:00
2024-04-03 15:19:46 +02:00
2024-09-18 19:23:04 +02:00
2023-11-20 11:52:17 +01:00
2023-11-28 17:06:55 +00:00
2024-10-17 15:21:26 +02:00