790-v6.4-0012-net-dsa-mt7530-skip-locking-if-MDIO-bus-isn-t-presen.patch 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. From 54d4147a121cec5004a673a58572da346e4458f8 Mon Sep 17 00:00:00 2001
  2. From: Daniel Golle <[email protected]>
  3. Date: Mon, 3 Apr 2023 02:19:28 +0100
  4. Subject: [PATCH 15/16] net: dsa: mt7530: skip locking if MDIO bus isn't
  5. present
  6. As MT7530 and MT7531 internally use 32-bit wide registers, each access
  7. to any register of the switch requires several operations on the MDIO
  8. bus. Hence if there is congruent access, e.g. due to PCS or PHY
  9. polling, this can mess up and interfere with another ongoing register
  10. access sequence.
  11. However, the MDIO bus mutex is only relevant for MDIO-connected
  12. switches. Prepare switches which have there registers directly mapped
  13. into the SoCs register space via MMIO which do not require such
  14. locking. There we can simply use regmap's default locking mechanism.
  15. Hence guard mutex operations to only be performed in case of MDIO
  16. connected switches.
  17. Signed-off-by: Daniel Golle <[email protected]>
  18. Reviewed-by: Andrew Lunn <[email protected]>
  19. Signed-off-by: David S. Miller <[email protected]>
  20. ---
  21. drivers/net/dsa/mt7530.c | 6 ++++--
  22. 1 file changed, 4 insertions(+), 2 deletions(-)
  23. --- a/drivers/net/dsa/mt7530.c
  24. +++ b/drivers/net/dsa/mt7530.c
  25. @@ -144,13 +144,15 @@ err:
  26. static void
  27. mt7530_mutex_lock(struct mt7530_priv *priv)
  28. {
  29. - mutex_lock_nested(&priv->bus->mdio_lock, MDIO_MUTEX_NESTED);
  30. + if (priv->bus)
  31. + mutex_lock_nested(&priv->bus->mdio_lock, MDIO_MUTEX_NESTED);
  32. }
  33. static void
  34. mt7530_mutex_unlock(struct mt7530_priv *priv)
  35. {
  36. - mutex_unlock(&priv->bus->mdio_lock);
  37. + if (priv->bus)
  38. + mutex_unlock(&priv->bus->mdio_lock);
  39. }
  40. static void