public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] i2c: i801: Do not instantiate spd5118 under SPD Write Disable
@ 2025-05-28  8:23 Yo-Jung (Leo) Lin
  2025-05-28 23:59 ` kernel test robot
  0 siblings, 1 reply; 3+ messages in thread
From: Yo-Jung (Leo) Lin @ 2025-05-28  8:23 UTC (permalink / raw)
  To: Jean Delvare, Andi Shyti, Wolfram Sang
  Cc: Guenter Roeck, Chia-Lin Kao (AceLan), linux-i2c, linux-kernel,
	Yo-Jung Lin (Leo)

If SPD Write Disable bit in the SMBus is enabled, writing data to
addresses from 0x50 to 0x57 is forbidden. This may lead to the
following issues for spd5118 devices:

  1) Writes to the sensor hwmon sysfs attributes will always result
     in ENXIO.

  2) During system-wide resume, errors may occur during regcache sync,
     resulting in the following error messages:

     kernel: spd5118 1-0050: failed to write b = 0: -6
     kernel: spd5118 1-0050: pm: dpm_run_callback(): spd5118_resume [spd5118] returns -6
     kernel: spd5118 1-0050: pm: failed to resume async: error -6

  3) nvmem won't be usable, because writing to the page selector becomes
     impossible.

Also, BIOS vendors may choose to set the page to a value != 0 after a board
reset. This will make the sensor not functional unless its MR11 register
can be changed, which is impossible due to writes being disabled.

To address these issues, don't instantiate it at all if the SPD Write Disable
bit is set.

Signed-off-by: Yo-Jung Lin (Leo) <leo.lin@canonical.com>
---
This is intended to be the fixed version of the second patch in the
following patch series[1]:

[PATCH v2 0/2] i2c: i801: don't instantiate spd5118 under SPD Write Disable

The original version got reverted due to breaking i386 defconfig build.
However the first patch in that series didn't. To avoid the first patch in
the series being repeatedly sent and applied, this is sent as a separate
patch. 

Also not pulling Reviewed-by from Guenter because the patch differs from
what was originally reviewed.

[1] https://lore.kernel.org/all/20250430-for-upstream-i801-spd5118-no-instantiate-v2-0-2f54d91ae2c7@canonical.com/
---
 drivers/i2c/busses/i2c-i801.c | 28 +++++++++++++++++++++++-----
 1 file changed, 23 insertions(+), 5 deletions(-)

diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index a7f89946dad4..de17532402b9 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -1157,6 +1157,27 @@ static void dmi_check_onboard_devices(const struct dmi_header *dm, void *adap)
 	}
 }
 
+static void __i801_register_spd(struct i801_priv *priv)
+{
+	if (priv->original_hstcfg & SMBHSTCFG_SPD_WD)
+		i2c_register_spd_write_disable(&priv->adapter);
+	else
+		i2c_register_spd_write_enable(&priv->adapter);
+}
+
+#ifdef CONFIG_I2C_I801_MUX
+static void i801_register_spd(struct i801_priv *priv)
+{
+	if (!priv->mux_pdev)
+		__i801_register_spd(priv);
+}
+#else
+static void i801_register_spd(struct i801_priv *priv)
+{
+	__i801_register_spd(priv);
+}
+#endif
+
 /* Register optional targets */
 static void i801_probe_optional_targets(struct i801_priv *priv)
 {
@@ -1177,10 +1198,7 @@ static void i801_probe_optional_targets(struct i801_priv *priv)
 		dmi_walk(dmi_check_onboard_devices, &priv->adapter);
 
 	/* Instantiate SPD EEPROMs unless the SMBus is multiplexed */
-#ifdef CONFIG_I2C_I801_MUX
-	if (!priv->mux_pdev)
-#endif
-		i2c_register_spd_write_enable(&priv->adapter);
+	i801_register_spd(priv);
 }
 #else
 static void __init input_apanel_init(void) {}
@@ -1283,7 +1301,7 @@ static int i801_notifier_call(struct notifier_block *nb, unsigned long action,
 		return NOTIFY_DONE;
 
 	/* Call i2c_register_spd for muxed child segments */
-	i2c_register_spd_write_enable(to_i2c_adapter(dev));
+	__i801_register_spd(priv);
 
 	return NOTIFY_OK;
 }

---
base-commit: 176e917e010cb7dcc605f11d2bc33f304292482b
change-id: 20250526-for-upstream-not-instantiate-spd5118-463225b346a0

Best regards,
-- 
Yo-Jung (Leo) Lin <leo.lin@canonical.com>


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-05-29  3:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-28  8:23 [PATCH] i2c: i801: Do not instantiate spd5118 under SPD Write Disable Yo-Jung (Leo) Lin
2025-05-28 23:59 ` kernel test robot
2025-05-29  3:54   ` Yo-Jung (Leo) Lin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox