phy: marvell: a3700-comphy: Guard missing polarity argument
Subsystems (2)
PATCH 1/1 phy: marvell: a3700-comphy: Guard missing polarity argument
The Armada 3700 COMPHY binding specifies #phy-cells = <1>, so PHY references supply only the port argument. However, mvebu_a3700_comphy_xlate() unconditionally reads args[1] to select TX and RX polarity inversion. The PHY core does not initialize its of_phandle_args structure, and the phandle parser fills only the supplied cells, leaving args[1] uninitialized.
Using the unused cell can program unintended SerDes polarity. On a Turris MOX with a Peridot switch running OpenWrt with Linux 6.18.54, the CPU link reports RX CRC errors and fails to pass traffic. The switch PCS does not record a partner advertisement despite link-up.
Check args_count before reading args[1], leaving polarity inversion disabled when the second argument was not supplied. This does not change the binding or introduce a supported two-cell interface.
The same change restores 2500BASE-X communication on the affected MOX with no CRC errors. Cold boots, reboots and interface down/up cycles were also tested successfully on Linux 6.18.54.
---
GitHub Copilot assisted with comparing the working and failing logs, identifying the unused argument read, preparing the fix and changelog, and checking the patch. The submitter performed the MOX hardware tests.
The reported hardware tests used OpenWrt with Linux 6.18.54. Mainline runtime testing has not been performed. An isolated ARM64 mainline build was attempted on macOS but failed while building host fixdep because the host Clang could not use -fuse-ld=lld; the driver was not compiled. A host C test of the changed expressions with poisoned unused argument slots passed, as did strict checkpatch.
drivers/phy/marvell/phy-mvebu-a3700-comphy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/phy/marvell/phy-mvebu-a3700-comphy.c +2 -2
@@ -1232,8 +1232,8 @@ static struct phy *mvebu_a3700_comphy_xlate(struct device *dev,return ERR_PTR (-EINVAL ); } - lane->invert_tx = args->args[1 ] &BIT (0 ); - lane->invert_rx = args->args[1 ] &BIT (1 ); + lane->invert_tx = args->args_count >1 && (args->args[1 ] &BIT (0 )); + lane->invert_rx = args->args_count >1 && (args->args[1 ] &BIT (1 ));return phy; }
base-commit: 551c722f40809618230001baccf219193e22fc5a
Signature · 1 line
2.54.0 (Apple Git-157)