Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: dsa: seville: ignore mscc-miim read errors from Lynx PCS

During the refactoring in the commit below, vsc9953_mdio_read() was
replaced with mscc_miim_read(), which has one extra step: it checks for
the MSCC_MIIM_DATA_ERROR bits before returning the result.

On T1040RDB, there are 8 QSGMII PCSes belonging to the switch, and they
are organized in 2 groups. First group responds to MDIO addresses 4-7
because QSGMIIACR1[MDEV_PORT] is 1, and the second group responds to
MDIO addresses 8-11 because QSGMIIBCR1[MDEV_PORT] is 2. I have double
checked that these values are correctly set in the SERDES, as well as
PCCR1[QSGMA_CFG] and PCCR1[QSGMB_CFG] are both 0b01.

mscc_miim_read: phyad 8 reg 0x1 MIIM_DATA 0x2d
mscc_miim_read: phyad 8 reg 0x5 MIIM_DATA 0x5801
mscc_miim_read: phyad 8 reg 0x1 MIIM_DATA 0x2d
mscc_miim_read: phyad 8 reg 0x5 MIIM_DATA 0x5801
mscc_miim_read: phyad 9 reg 0x1 MIIM_DATA 0x2d
mscc_miim_read: phyad 9 reg 0x5 MIIM_DATA 0x5801
mscc_miim_read: phyad 9 reg 0x1 MIIM_DATA 0x2d
mscc_miim_read: phyad 9 reg 0x5 MIIM_DATA 0x5801
mscc_miim_read: phyad 10 reg 0x1 MIIM_DATA 0x2d
mscc_miim_read: phyad 10 reg 0x5 MIIM_DATA 0x5801
mscc_miim_read: phyad 10 reg 0x1 MIIM_DATA 0x2d
mscc_miim_read: phyad 10 reg 0x5 MIIM_DATA 0x5801
mscc_miim_read: phyad 11 reg 0x1 MIIM_DATA 0x2d
mscc_miim_read: phyad 11 reg 0x5 MIIM_DATA 0x5801
mscc_miim_read: phyad 11 reg 0x1 MIIM_DATA 0x2d
mscc_miim_read: phyad 11 reg 0x5 MIIM_DATA 0x5801
mscc_miim_read: phyad 4 reg 0x1 MIIM_DATA 0x3002d, ERROR
mscc_miim_read: phyad 4 reg 0x5 MIIM_DATA 0x3da01, ERROR
mscc_miim_read: phyad 5 reg 0x1 MIIM_DATA 0x3002d, ERROR
mscc_miim_read: phyad 5 reg 0x5 MIIM_DATA 0x35801, ERROR
mscc_miim_read: phyad 5 reg 0x1 MIIM_DATA 0x3002d, ERROR
mscc_miim_read: phyad 5 reg 0x5 MIIM_DATA 0x35801, ERROR
mscc_miim_read: phyad 6 reg 0x1 MIIM_DATA 0x3002d, ERROR
mscc_miim_read: phyad 6 reg 0x5 MIIM_DATA 0x35801, ERROR
mscc_miim_read: phyad 6 reg 0x1 MIIM_DATA 0x3002d, ERROR
mscc_miim_read: phyad 6 reg 0x5 MIIM_DATA 0x35801, ERROR
mscc_miim_read: phyad 7 reg 0x1 MIIM_DATA 0x3002d, ERROR
mscc_miim_read: phyad 7 reg 0x5 MIIM_DATA 0x35801, ERROR
mscc_miim_read: phyad 7 reg 0x1 MIIM_DATA 0x3002d, ERROR
mscc_miim_read: phyad 7 reg 0x5 MIIM_DATA 0x35801, ERROR

As can be seen, the data in MIIM_DATA is still valid despite having the
MSCC_MIIM_DATA_ERROR bits set. The driver as introduced in commit
84705fc16552 ("net: dsa: felix: introduce support for Seville VSC9953
switch") was ignoring these bits, perhaps deliberately (although
unbeknownst to me).

This is an old IP and the hardware team cannot seem to be able to help
me track down a plausible reason for these failures. I'll keep
investigating, but in the meantime, this is a direct regression which
must be restored to a working state.

The only thing I can do is keep ignoring the errors as before.

Fixes: b99658452355 ("net: dsa: ocelot: felix: utilize shared mscc-miim driver for indirect MDIO access")
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Vladimir Oltean and committed by
David S. Miller
0322ef49 3fa10563

+9 -6
+2 -2
drivers/net/dsa/ocelot/seville_vsc9953.c
··· 893 893 894 894 rc = mscc_miim_setup(dev, &bus, "VSC9953 internal MDIO bus", 895 895 ocelot->targets[GCB], 896 - ocelot->map[GCB][GCB_MIIM_MII_STATUS & REG_MASK]); 897 - 896 + ocelot->map[GCB][GCB_MIIM_MII_STATUS & REG_MASK], 897 + true); 898 898 if (rc) { 899 899 dev_err(dev, "failed to setup MDIO bus\n"); 900 900 return rc;
+6 -3
drivers/net/mdio/mdio-mscc-miim.c
··· 52 52 struct mscc_miim_dev { 53 53 struct regmap *regs; 54 54 int mii_status_offset; 55 + bool ignore_read_errors; 55 56 struct regmap *phy_regs; 56 57 const struct mscc_miim_info *info; 57 58 struct clk *clk; ··· 136 135 goto out; 137 136 } 138 137 139 - if (val & MSCC_MIIM_DATA_ERROR) { 138 + if (!miim->ignore_read_errors && !!(val & MSCC_MIIM_DATA_ERROR)) { 140 139 ret = -EIO; 141 140 goto out; 142 141 } ··· 213 212 }; 214 213 215 214 int mscc_miim_setup(struct device *dev, struct mii_bus **pbus, const char *name, 216 - struct regmap *mii_regmap, int status_offset) 215 + struct regmap *mii_regmap, int status_offset, 216 + bool ignore_read_errors) 217 217 { 218 218 struct mscc_miim_dev *miim; 219 219 struct mii_bus *bus; ··· 236 234 237 235 miim->regs = mii_regmap; 238 236 miim->mii_status_offset = status_offset; 237 + miim->ignore_read_errors = ignore_read_errors; 239 238 240 239 *pbus = bus; 241 240 ··· 288 285 return dev_err_probe(dev, PTR_ERR(phy_regmap), 289 286 "Unable to create phy register regmap\n"); 290 287 291 - ret = mscc_miim_setup(dev, &bus, "mscc_miim", mii_regmap, 0); 288 + ret = mscc_miim_setup(dev, &bus, "mscc_miim", mii_regmap, 0, false); 292 289 if (ret < 0) { 293 290 dev_err(dev, "Unable to setup the MDIO bus\n"); 294 291 return ret;
+1 -1
include/linux/mdio/mdio-mscc-miim.h
··· 14 14 15 15 int mscc_miim_setup(struct device *device, struct mii_bus **bus, 16 16 const char *name, struct regmap *mii_regmap, 17 - int status_offset); 17 + int status_offset, bool ignore_read_errors); 18 18 19 19 #endif