Skip to content

Commit d1a58c0

Browse files
oleremkuba-moo
authored andcommitted
net: dsa: qca: ar9331: reorder MDIO write sequence
In case of this switch we work with 32bit registers on top of 16bit bus. Some registers (for example access to forwarding database) have trigger bit on the first 16bit half of request and the result + configuration of request in the second half. Without this patch, we would trigger database operation and overwrite result in one run. To make it work properly, we should do the second part of transfer before the first one is done. So far, this rule seems to work for all registers on this switch. Fixes: ec6698c ("net: dsa: add support for Atheros AR9331 built-in switch") Signed-off-by: Oleksij Rempel <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Reviewed-by: Vladimir Oltean <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent e3ea110 commit d1a58c0

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

drivers/net/dsa/qca/ar9331.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -837,16 +837,24 @@ static int ar9331_mdio_write(void *ctx, u32 reg, u32 val)
837837
return 0;
838838
}
839839

840-
ret = __ar9331_mdio_write(sbus, AR9331_SW_MDIO_PHY_MODE_REG, reg, val);
840+
/* In case of this switch we work with 32bit registers on top of 16bit
841+
* bus. Some registers (for example access to forwarding database) have
842+
* trigger bit on the first 16bit half of request, the result and
843+
* configuration of request in the second half.
844+
* To make it work properly, we should do the second part of transfer
845+
* before the first one is done.
846+
*/
847+
ret = __ar9331_mdio_write(sbus, AR9331_SW_MDIO_PHY_MODE_REG, reg + 2,
848+
val >> 16);
841849
if (ret < 0)
842850
goto error;
843851

844-
ret = __ar9331_mdio_write(sbus, AR9331_SW_MDIO_PHY_MODE_REG, reg + 2,
845-
val >> 16);
852+
ret = __ar9331_mdio_write(sbus, AR9331_SW_MDIO_PHY_MODE_REG, reg, val);
846853
if (ret < 0)
847854
goto error;
848855

849856
return 0;
857+
850858
error:
851859
dev_err_ratelimited(&sbus->dev, "Bus error. Failed to write register.\n");
852860
return ret;

0 commit comments

Comments
 (0)