777-v6.2-05-net-dsa-qca8k-improve-mdio-master-read-write-by-usin.patch 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. From a4165830ca237f2b3318faf62562bce8ce12a389 Mon Sep 17 00:00:00 2001
  2. From: Christian Marangi <[email protected]>
  3. Date: Thu, 29 Dec 2022 17:33:36 +0100
  4. Subject: [PATCH 5/5] net: dsa: qca8k: improve mdio master read/write by using
  5. single lo/hi
  6. Improve mdio master read/write by using singe mii read/write lo/hi.
  7. In a read and write we need to poll the mdio master regs in a busy loop
  8. to check for a specific bit present in the upper half of the reg. We can
  9. ignore the other half since it won't contain useful data. This will save
  10. an additional useless read for each read and write operation.
  11. In a read operation the returned data is present in the mdio master reg
  12. lower half. We can ignore the other half since it won't contain useful
  13. data. This will save an additional useless read for each read operation.
  14. In a read operation it's needed to just set the hi half of the mdio
  15. master reg as the lo half will be replaced by the result. This will save
  16. an additional useless write for each read operation.
  17. Tested-by: Ronald Wahl <[email protected]>
  18. Signed-off-by: Christian Marangi <[email protected]>
  19. Signed-off-by: David S. Miller <[email protected]>
  20. ---
  21. drivers/net/dsa/qca/qca8k-8xxx.c | 12 ++++++------
  22. 1 file changed, 6 insertions(+), 6 deletions(-)
  23. --- a/drivers/net/dsa/qca/qca8k-8xxx.c
  24. +++ b/drivers/net/dsa/qca/qca8k-8xxx.c
  25. @@ -743,9 +743,9 @@ qca8k_mdio_busy_wait(struct mii_bus *bus
  26. qca8k_split_addr(reg, &r1, &r2, &page);
  27. - ret = read_poll_timeout(qca8k_mii_read32, ret1, !(val & mask), 0,
  28. + ret = read_poll_timeout(qca8k_mii_read_hi, ret1, !(val & mask), 0,
  29. QCA8K_BUSY_WAIT_TIMEOUT * USEC_PER_MSEC, false,
  30. - bus, 0x10 | r2, r1, &val);
  31. + bus, 0x10 | r2, r1 + 1, &val);
  32. /* Check if qca8k_read has failed for a different reason
  33. * before returnting -ETIMEDOUT
  34. @@ -787,7 +787,7 @@ qca8k_mdio_write(struct qca8k_priv *priv
  35. exit:
  36. /* even if the busy_wait timeouts try to clear the MASTER_EN */
  37. - qca8k_mii_write32(bus, 0x10 | r2, r1, 0);
  38. + qca8k_mii_write_hi(bus, 0x10 | r2, r1 + 1, 0);
  39. mutex_unlock(&bus->mdio_lock);
  40. @@ -817,18 +817,18 @@ qca8k_mdio_read(struct qca8k_priv *priv,
  41. if (ret)
  42. goto exit;
  43. - qca8k_mii_write32(bus, 0x10 | r2, r1, val);
  44. + qca8k_mii_write_hi(bus, 0x10 | r2, r1 + 1, val);
  45. ret = qca8k_mdio_busy_wait(bus, QCA8K_MDIO_MASTER_CTRL,
  46. QCA8K_MDIO_MASTER_BUSY);
  47. if (ret)
  48. goto exit;
  49. - ret = qca8k_mii_read32(bus, 0x10 | r2, r1, &val);
  50. + ret = qca8k_mii_read_lo(bus, 0x10 | r2, r1, &val);
  51. exit:
  52. /* even if the busy_wait timeouts try to clear the MASTER_EN */
  53. - qca8k_mii_write32(bus, 0x10 | r2, r1, 0);
  54. + qca8k_mii_write_hi(bus, 0x10 | r2, r1 + 1, 0);
  55. mutex_unlock(&bus->mdio_lock);