735-v5.14-17-net-dsa-qca8k-clear-MASTER_EN-after-phy-read-write.patch 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. From 63c33bbfeb6842a956a0eb12901e28eb335bdb18 Mon Sep 17 00:00:00 2001
  2. From: Ansuel Smith <[email protected]>
  3. Date: Fri, 14 May 2021 23:00:07 +0200
  4. Subject: [PATCH] net: dsa: qca8k: clear MASTER_EN after phy read/write
  5. Clear MDIO_MASTER_EN bit from MDIO_MASTER_CTRL after read/write
  6. operation. The MDIO_MASTER_EN bit is not reset after read/write
  7. operation and the next operation can be wrongly interpreted by the
  8. switch as a mdio operation. This cause a production of wrong/garbage
  9. data from the switch and underfined bheavior. (random port drop,
  10. unplugged port flagged with link up, wrong port speed)
  11. Also on driver remove the MASTER_CTRL can be left set and cause the
  12. malfunction of any next driver using the mdio device.
  13. Signed-off-by: Ansuel Smith <[email protected]>
  14. Signed-off-by: David S. Miller <[email protected]>
  15. ---
  16. drivers/net/dsa/qca8k.c | 14 ++++++++++++--
  17. 1 file changed, 12 insertions(+), 2 deletions(-)
  18. --- a/drivers/net/dsa/qca8k.c
  19. +++ b/drivers/net/dsa/qca8k.c
  20. @@ -649,8 +649,14 @@ qca8k_mdio_write(struct qca8k_priv *priv
  21. if (ret)
  22. return ret;
  23. - return qca8k_busy_wait(priv, QCA8K_MDIO_MASTER_CTRL,
  24. - QCA8K_MDIO_MASTER_BUSY);
  25. + ret = qca8k_busy_wait(priv, QCA8K_MDIO_MASTER_CTRL,
  26. + QCA8K_MDIO_MASTER_BUSY);
  27. +
  28. + /* even if the busy_wait timeouts try to clear the MASTER_EN */
  29. + qca8k_reg_clear(priv, QCA8K_MDIO_MASTER_CTRL,
  30. + QCA8K_MDIO_MASTER_EN);
  31. +
  32. + return ret;
  33. }
  34. static int
  35. @@ -685,6 +691,10 @@ qca8k_mdio_read(struct qca8k_priv *priv,
  36. val &= QCA8K_MDIO_MASTER_DATA_MASK;
  37. + /* even if the busy_wait timeouts try to clear the MASTER_EN */
  38. + qca8k_reg_clear(priv, QCA8K_MDIO_MASTER_CTRL,
  39. + QCA8K_MDIO_MASTER_EN);
  40. +
  41. return val;
  42. }