Skip to content

Commit 0858f72

Browse files
committed
i2c: smbus: introduce Write Disable-aware SPD instantiating functions
JIRA: https://issues.redhat.com/browse/RHEL-113184 commit 4d6d35d Author: Yo-Jung (Leo) Lin <leo.lin@canonical.com> Date: Wed Apr 30 19:26:16 2025 +0800 i2c: smbus: introduce Write Disable-aware SPD instantiating functions Some SMBus controllers may restrict writes to addresses where SPD sensors may reside. This may lead to some SPD sensors not functioning correctly, and might need extra handling. Introduce new SPD-instantiating functions that are aware of this, and use them instead. Signed-off-by: Yo-Jung Lin (Leo) <leo.lin@canonical.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Link: https://lore.kernel.org/r/20250430-for-upstream-i801-spd5118-no-instantiate-v2-1-2f54d91ae2c7@canonical.com Signed-off-by: Andi Shyti <andi.shyti@kernel.org> Signed-off-by: Steve Best <sbest@redhat.com>
1 parent dd72051 commit 0858f72

File tree

4 files changed

+26
-7
lines changed

4 files changed

+26
-7
lines changed

drivers/i2c/busses/i2c-i801.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,7 +1180,7 @@ static void i801_probe_optional_targets(struct i801_priv *priv)
11801180
#ifdef CONFIG_I2C_I801_MUX
11811181
if (!priv->mux_pdev)
11821182
#endif
1183-
i2c_register_spd(&priv->adapter);
1183+
i2c_register_spd_write_enable(&priv->adapter);
11841184
}
11851185
#else
11861186
static void __init input_apanel_init(void) {}
@@ -1283,7 +1283,7 @@ static int i801_notifier_call(struct notifier_block *nb, unsigned long action,
12831283
return NOTIFY_DONE;
12841284

12851285
/* Call i2c_register_spd for muxed child segments */
1286-
i2c_register_spd(to_i2c_adapter(dev));
1286+
i2c_register_spd_write_enable(to_i2c_adapter(dev));
12871287

12881288
return NOTIFY_OK;
12891289
}

drivers/i2c/busses/i2c-piix4.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -989,7 +989,7 @@ static int piix4_add_adapter(struct pci_dev *dev, unsigned short smba,
989989
* This would allow the ee1004 to be probed incorrectly.
990990
*/
991991
if (port == 0)
992-
i2c_register_spd(adap);
992+
i2c_register_spd_write_enable(adap);
993993

994994
*padap = adap;
995995
return 0;

drivers/i2c/i2c-smbus.c

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,12 +362,13 @@ EXPORT_SYMBOL_GPL(i2c_free_slave_host_notify_device);
362362
* - Only works on systems with 1 to 8 memory slots
363363
*/
364364
#if IS_ENABLED(CONFIG_DMI)
365-
void i2c_register_spd(struct i2c_adapter *adap)
365+
static void i2c_register_spd(struct i2c_adapter *adap, bool write_disabled)
366366
{
367367
int n, slot_count = 0, dimm_count = 0;
368368
u16 handle;
369369
u8 common_mem_type = 0x0, mem_type;
370370
u64 mem_size;
371+
bool instantiate = true;
371372
const char *name;
372373

373374
while ((handle = dmi_memdev_handle(slot_count)) != 0xffff) {
@@ -428,6 +429,7 @@ void i2c_register_spd(struct i2c_adapter *adap)
428429
case 0x22: /* DDR5 */
429430
case 0x23: /* LPDDR5 */
430431
name = "spd5118";
432+
instantiate = !write_disabled;
431433
break;
432434
default:
433435
dev_info(&adap->dev,
@@ -451,6 +453,9 @@ void i2c_register_spd(struct i2c_adapter *adap)
451453
addr_list[0] = 0x50 + n;
452454
addr_list[1] = I2C_CLIENT_END;
453455

456+
if (!instantiate)
457+
continue;
458+
454459
if (!IS_ERR(i2c_new_scanned_device(adap, &info, addr_list, NULL))) {
455460
dev_info(&adap->dev,
456461
"Successfully instantiated SPD at 0x%hx\n",
@@ -459,7 +464,19 @@ void i2c_register_spd(struct i2c_adapter *adap)
459464
}
460465
}
461466
}
462-
EXPORT_SYMBOL_GPL(i2c_register_spd);
467+
468+
void i2c_register_spd_write_disable(struct i2c_adapter *adap)
469+
{
470+
i2c_register_spd(adap, true);
471+
}
472+
EXPORT_SYMBOL_GPL(i2c_register_spd_write_disable);
473+
474+
void i2c_register_spd_write_enable(struct i2c_adapter *adap)
475+
{
476+
i2c_register_spd(adap, false);
477+
}
478+
EXPORT_SYMBOL_GPL(i2c_register_spd_write_enable);
479+
463480
#endif
464481

465482
MODULE_AUTHOR("Jean Delvare <jdelvare@suse.de>");

include/linux/i2c-smbus.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,11 @@ static inline void i2c_free_slave_host_notify_device(struct i2c_client *client)
4444
#endif
4545

4646
#if IS_ENABLED(CONFIG_I2C_SMBUS) && IS_ENABLED(CONFIG_DMI)
47-
void i2c_register_spd(struct i2c_adapter *adap);
47+
void i2c_register_spd_write_disable(struct i2c_adapter *adap);
48+
void i2c_register_spd_write_enable(struct i2c_adapter *adap);
4849
#else
49-
static inline void i2c_register_spd(struct i2c_adapter *adap) { }
50+
static inline void i2c_register_spd_write_disable(struct i2c_adapter *adap) { }
51+
static inline void i2c_register_spd_write_enable(struct i2c_adapter *adap) { }
5052
#endif
5153

5254
#endif /* _LINUX_I2C_SMBUS_H */

0 commit comments

Comments
 (0)