linux/drivers/net/phy
Jonas Jelonek 58b29bdf61 net: sfp: extend SMBus support
Commit 7662abf4db ("net: phy: sfp: Add support for SMBus module access")
added SMBus access for SFP modules, but limited it to single-byte
transfers. As a side effect, hwmon is disabled (16-bit reads cannot be
guaranteed atomic) and a warning is printed.

Many SMBus-only I2C controllers in the wild support more than just
byte access, and SFP cages are often wired to such controllers
rather than to a full-featured I2C controller -- e.g. the SMBus
controllers in the Realtek longan and mango SoCs, which advertise
word access and I2C block reads. Today, they cannot drive an SFP at
all without falling back to the byte-only path.

Extend sfp_smbus_read()/sfp_smbus_write() so that, in addition to
the existing byte access, they also use SMBus word access and SMBus
I2C block access whenever the adapter advertises them. Both
directions are handled in a single read and a single write helper
that pick the largest supported transfer per chunk and fall back as
needed.

I2C-block is preferred unconditionally when available: the protocol
carries any length 1..32, so it can serve every chunk -- including
the 1- and 2-byte tails -- without help from word or byte access.
Note that this requires I2C_FUNC_SMBUS_I2C_BLOCK, which reads a
caller-specified number of bytes. This deviates from the official
SMBus Block Read (length is supplied by the slave) but is widely
supported by Linux I2C controllers/drivers.

Capability matrix this implementation supports:

  - BYTE only:                  works (unchanged behaviour); 1-byte
                                xfers, hwmon disabled.
  - BYTE + WORD:                word for >=2-byte chunks, byte for
                                trailing odd byte.
  - I2C_BLOCK present (with or
    without BYTE/WORD):         block as the universal transport for
                                every chunk.
  - WORD only (no BYTE/BLOCK):  accepted with WARN_ONCE. Even-length
                                transfers work; odd-length transfers
                                (e.g. the 3-byte cotsworks fixup
                                write) hit the BYTE branch which the
                                adapter does not implement, so the
                                xfer returns an error and the
                                operation is aborted. No mainline
                                I2C driver was found to advertise
                                WORD without BYTE; the warning lets
                                us learn about it if it ever shows
                                up.

Adapters with asymmetric R/W capabilities (e.g. only READ_I2C_BLOCK
but not WRITE_I2C_BLOCK) remain functionally correct -- the
per-iteration fallback uses the direction-specific bits -- but the
shared i2c_max_block_size is sized by the all-bits-set check, so a
transfer in the better-supported direction is not upgraded. None of
the mainline I2C bus drivers surveyed during review advertise such
asymmetry; promoting i2c_max_block_size to per-direction sizes can
be revisited if needed.

Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Link: https://patch.msgid.link/20260614133418.2068201-3-jelonek.jonas@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-06-15 14:14:48 -07:00
..
aquantia net: phy: aquantia: use ADVERTISE_XNP for extended next page advertising 2026-04-29 17:30:05 -07:00
mediatek net: phy: mediatek: enable interrupts on AN7581 2026-01-05 16:16:53 -08:00
mscc Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
qcom net: phy: at803x: add RX and TX clock management for IPQ5018 PHY 2026-06-11 15:32:13 -07:00
realtek net: phy: realtek: support MDI swapping for RTL8226-CG 2026-05-20 16:50:24 -07:00
adin.c net: phy: adin: enable configuration of the LP Termination Register 2026-01-15 19:36:04 -08:00
adin1100.c net: phy: adin1100: Simplify register value passing 2025-11-20 18:03:59 -08:00
air_an8801.c net: phy: air_an8801: ensure maximum available speed link use 2026-05-27 18:39:24 -07:00
air_en8811h.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2026-05-28 14:02:21 -07:00
air_phy_lib.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2026-05-28 14:02:21 -07:00
air_phy_lib.h Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2026-05-28 14:02:21 -07:00
amd.c net: phy: Constify struct mdio_device_id 2025-01-14 15:01:32 -08:00
as21xxx.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
ax88796b_rust.rs drivers: net: replace kernel::c_str! with C-Strings 2026-01-05 16:32:39 -08:00
ax88796b.c net: phy: ax88796b: Replace hard-coded values with PHY_ID_MATCH_MODEL() 2025-09-22 16:38:59 -07:00
bcm-cygnus.c net: phy: Constify struct mdio_device_id 2025-01-14 15:01:32 -08:00
bcm-phy-lib.c net: phy: broadcom: Save PHY counters during suspend 2026-05-07 08:36:47 -07:00
bcm-phy-lib.h net: phy: broadcom: Save PHY counters during suspend 2026-05-07 08:36:47 -07:00
bcm-phy-ptp.c net: phy: broadcom: add HW timestamp configuration reporting 2025-11-26 16:56:34 -08:00
bcm7xxx.c net: phy: broadcom: Save PHY counters during suspend 2026-05-07 08:36:47 -07:00
bcm63xx.c net: phy: Constify struct mdio_device_id 2025-01-14 15:01:32 -08:00
bcm87xx.c net: phy: bcm87xx: simplify .match_phy_device OP 2025-05-21 15:56:09 -07:00
bcm54140.c net: phy: move PHY package related code from phy.h to phy_package.c 2025-03-05 19:13:53 -08:00
bcm84881.c net: phy: bcm84881: add LED framework support for BCM84891/BCM84892 2026-04-02 17:59:43 -07:00
broadcom.c net: phy: broadcom: Save PHY counters during suspend 2026-05-07 08:36:47 -07:00
cicada.c net: phy: Constify struct mdio_device_id 2025-01-14 15:01:32 -08:00
cortina.c net: phy: Constify struct mdio_device_id 2025-01-14 15:01:32 -08:00
davicom.c net: phy: Constify struct mdio_device_id 2025-01-14 15:01:32 -08:00
dp83tc811.c net: phy: DP83TC811: add reading of abilities 2026-05-14 15:17:12 +02:00
dp83td510.c net: phy: dp83td510: add MSE interface support for 10BASE-T1L 2025-11-03 18:32:27 -08:00
dp83tg720.c net: phy: dp83tg720: switch to adaptive polling and remove random delays 2025-06-13 18:09:47 -07:00
dp83640_reg.h ptp: dp83640: don't define PAGE0 2021-09-14 20:03:24 -07:00
dp83640.c Convert remaining multi-line kmalloc_obj/flex GFP_KERNEL uses 2026-02-22 08:26:33 -08:00
dp83822.c net: phy: dp83822: Add optional external PHY clock 2026-06-02 11:38:00 -07:00
dp83848.c net: phy: Constify struct mdio_device_id 2025-01-14 15:01:32 -08:00
dp83867.c net: phy: dp83867: add MDI-X management 2026-05-08 15:58:36 -07:00
dp83869.c net: phy: dp83869: fix setting CLK_O_SEL field. 2026-04-28 15:51:55 +02:00
et1011c.c net: phy: Constify struct mdio_device_id 2025-01-14 15:01:32 -08:00
fixed_phy.c net: phy: fixed_phy: replace IDA with a bitmap 2026-01-13 18:58:49 -08:00
icplus.c net: phy: pass PHY driver to .match_phy_device OP 2025-05-21 15:56:09 -07:00
intel-xway.c net: phy: intel-xway: add PHY-level statistics via ethtool 2026-05-12 17:51:29 -07:00
Kconfig net: phy: Introduce Airoha AN8801R Gigabit Ethernet PHY driver 2026-05-27 18:39:24 -07:00
linkmode.c
lxt.c net: phy: Constify struct mdio_device_id 2025-01-14 15:01:32 -08:00
Makefile net: phy: Introduce Airoha AN8801R Gigabit Ethernet PHY driver 2026-05-27 18:39:24 -07:00
marvell-88q2xxx.c net: phy: marvell-88q2xxx: Fix clamped value in mv88q2xxx_hwmon_write 2025-12-04 17:49:31 -08:00
marvell-88x2222.c net: phy: marvell-88x2222: Support SFP through phy_port interface 2026-01-13 18:52:35 -08:00
marvell.c net: phy: marvell: Support SFP through phy_port interface 2026-01-13 18:52:35 -08:00
marvell10g.c net: phy: marvell10g: Support SFP through phy_port 2026-01-13 18:52:35 -08:00
mdio_bus_provider.c Networking changes for 7.1. 2026-04-14 18:36:10 -07:00
mdio_bus.c net: phy: move remaining provider code to mdio_bus_provider.c 2026-03-14 12:23:02 -07:00
mdio_device.c net: phy: make mdio_device.c part of libphy 2026-03-14 12:23:02 -07:00
mdio_devres.c net: fill in MODULE_DESCRIPTION()s for mdio_devres 2024-02-15 08:03:46 -08:00
mdio-open-alliance.h net: phy: phy-c45: add SQI and SQI+ support for OATC14 10Base-T1S PHYs 2025-12-01 15:08:24 -08:00
meson-gxl.c net: phy: Constify struct mdio_device_id 2025-01-14 15:01:32 -08:00
micrel.c net: phy: micrel: expose KSZ87xx low-loss cable tunables 2026-06-11 15:47:56 -07:00
microchip_rds_ptp.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
microchip_rds_ptp.h net: phy: microchip_rds_ptp: Header file library changes for PEROUT 2025-01-16 17:27:56 -08:00
microchip_t1.c net: phy: microchip_t1: Enable pin out specific to lan887x phy for PEROUT signal 2025-01-16 17:27:56 -08:00
microchip_t1s.c net: phy: microchip_t1s: add SQI support for LAN867x Rev.D0 PHYs 2025-12-01 15:08:24 -08:00
microchip.c net: phy: microchip: enable downshift by default on LAN88xx 2026-04-02 18:03:03 -07:00
mii_timestamper.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
motorcomm.c net: phy: motorcomm: Add YT8522 100M RMII PHY support 2026-06-09 17:31:20 -07:00
mxl-86110.c net: phy: mxl-86110: Add power management and soft reset support 2026-01-04 09:53:33 -08:00
mxl-gpy.c net: phy: mxl-gpy: add PHY-level statistics via ethtool 2026-03-17 16:07:40 -07:00
national.c net: phy: Constify struct mdio_device_id 2025-01-14 15:01:32 -08:00
ncn26000.c net: phy: Constify struct mdio_device_id 2025-01-14 15:01:32 -08:00
nxp-c45-tja11xx-macsec.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
nxp-c45-tja11xx.c net: phy: nxp-c45-tja11xx: add HW timestamp configuration reporting 2025-11-26 16:56:34 -08:00
nxp-c45-tja11xx.h net: phy: c45-tja11xx: add support for outputting RMII reference clock 2024-10-15 10:44:52 +02:00
nxp-cbtx.c net: phy: Constify struct mdio_device_id 2025-01-14 15:01:32 -08:00
nxp-tja11xx.c net: phy: pass PHY driver to .match_phy_device OP 2025-05-21 15:56:09 -07:00
open_alliance_helpers.c phy: Add Open Alliance helpers for the PHY framework 2024-08-16 10:16:26 -07:00
open_alliance_helpers.h phy: Add Open Alliance helpers for the PHY framework 2024-08-16 10:16:26 -07:00
phy_caps.c net: ethtool: Add support for 80Gbps speed 2026-01-19 12:09:58 -08:00
phy_device.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2026-06-11 14:33:35 -07:00
phy_led_triggers.c Convert remaining multi-line kmalloc_obj/flex GFP_KERNEL uses 2026-02-22 08:26:33 -08:00
phy_link_topology.c net: ethtool: make dev->hwprov ops-protected 2026-06-09 10:13:04 -07:00
phy_package.c net: phy: update outdated comment for removed phy_package_read/write() 2026-03-24 13:21:28 +01:00
phy_port.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
phy-c45.c net: phy: skip EEE advertisement write when autoneg is disabled 2026-05-19 18:45:16 -07:00
phy-caps.h net: ethtool: Add support for 80Gbps speed 2026-01-19 12:09:58 -08:00
phy-core.c net: ethtool: Add support for 80Gbps speed 2026-01-19 12:09:58 -08:00
phy.c net: phy: add a PHY write barrier when disabling interrupts 2026-04-12 14:19:19 -07:00
phylib-internal.h net: phy: move remaining provider code to mdio_bus_provider.c 2026-03-14 12:23:02 -07:00
phylib.h net: phy: move mmd_phy_read and mmd_phy_write to phylib.h 2026-01-08 13:18:26 +01:00
phylink.c net: phylink: use phylink_expects_phy() in phylink_fwnode_phy_connect() 2026-03-26 18:24:56 -07:00
qsemi.c net: phy: Constify struct mdio_device_id 2025-01-14 15:01:32 -08:00
qt2025.rs drivers: net: replace kernel::c_str! with C-Strings 2026-01-05 16:32:39 -08:00
rockchip.c net: phy: Constify struct mdio_device_id 2025-01-14 15:01:32 -08:00
sfp-bus.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
sfp.c net: sfp: extend SMBus support 2026-06-15 14:14:48 -07:00
sfp.h net: sfp: convert sfp quirks to modify struct sfp_module_support 2025-09-22 16:05:14 -07:00
smsc.c net: phy: smsc: add proper reset flags for LAN8710A 2025-07-30 18:14:11 -07:00
ste10Xp.c net: phy: Constify struct mdio_device_id 2025-01-14 15:01:32 -08:00
stubs.c net: phy: provide phylib stubs for hardware timestamping operations 2023-08-02 19:11:06 -07:00
swphy.c
swphy.h
teranetics.c net: phy: pass PHY driver to .match_phy_device OP 2025-05-21 15:56:09 -07:00
uPD60620.c net: phy: Constify struct mdio_device_id 2025-01-14 15:01:32 -08:00
vitesse.c net: phy: vitesse: add inband caps and configuration 2026-03-12 17:55:33 -07:00
xilinx_gmii2rgmii.c net: phy: Allow loopback speed selection for PHY drivers 2025-03-20 08:45:08 +01:00