]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
net: mdio: mdio-i2c: Hold the i2c bus lock during smbus transactions
authorMaxime Chevallier <maxime.chevallier@bootlin.com>
Fri, 3 Oct 2025 07:03:06 +0000 (09:03 +0200)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 7 Oct 2025 08:44:46 +0000 (10:44 +0200)
commit4dc8b26a3ac2cb79f19f252d9077696d3ef0823a
treee6220b53066e72fc0427f492b21174a0b4ce2356
parentf07f91a36090b54076e89b46f159ea3a4b77fb2b
net: mdio: mdio-i2c: Hold the i2c bus lock during smbus transactions

When accessing an MDIO register using single-byte smbus accesses, we have to
perform 2 consecutive operations targeting the same address,
first accessing the MSB then the LSB of the 16 bit register:

  read_1_byte(addr); <- returns MSB of register at address 'addr'
  read_1_byte(addr); <- returns LSB

Some PHY devices present in SFP such as the Broadcom 5461 don't like
seeing foreign i2c transactions in-between these 2 smbus accesses, and
will return the MSB a second time when trying to read the LSB :

  read_1_byte(addr); <- returns MSB

   i2c_transaction_for_other_device_on_the_bus();

  read_1_byte(addr); <- returns MSB again

Given the already fragile nature of accessing PHYs/SFPs with single-byte
smbus accesses, it's safe to say that this Broadcom PHY may not be the
only one acting like this.

Let's therefore hold the i2c bus lock while performing our smbus
transactions to avoid interleaved accesses.

Fixes: d4bd3aca33c2 ("net: mdio: mdio-i2c: Add support for single-byte SMBus operations")
Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Reviewed-by: Kory Maincent <kory.maincent@bootlin.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://patch.msgid.link/20251003070311.861135-1-maxime.chevallier@bootlin.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/mdio/mdio-i2c.c