790-27-v6.9-net-dsa-mt7530-improve-code-path-for-setting-up-port.patch 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. From 0f03d9bfa1da1d26cb950e4b35b1ff7b9be1828f Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Ar=C4=B1n=C3=A7=20=C3=9CNAL?= <[email protected]>
  3. Date: Mon, 22 Jan 2024 08:35:56 +0300
  4. Subject: [PATCH 27/48] net: dsa: mt7530: improve code path for setting up port
  5. 5
  6. MIME-Version: 1.0
  7. Content-Type: text/plain; charset=UTF-8
  8. Content-Transfer-Encoding: 8bit
  9. There're two code paths for setting up port 5:
  10. mt7530_setup()
  11. -> mt7530_setup_port5()
  12. mt753x_phylink_mac_config()
  13. -> mt753x_mac_config()
  14. -> mt7530_mac_config()
  15. -> mt7530_setup_port5()
  16. Currently mt7530_setup_port5() from mt7530_setup() always runs. If port 5
  17. is used as a CPU, DSA, or user port, mt7530_setup_port5() from
  18. mt753x_phylink_mac_config() won't run. That is because priv->p5_interface
  19. set on mt7530_setup_port5() will match state->interface on
  20. mt753x_phylink_mac_config() which will stop running mt7530_setup_port5()
  21. again.
  22. Therefore, mt7530_setup_port5() will never run from
  23. mt753x_phylink_mac_config().
  24. Address this by not running mt7530_setup_port5() from mt7530_setup() if
  25. port 5 is used as a CPU, DSA, or user port. This driver isn't in the
  26. dsa_switches_apply_workarounds[] array so phylink will always be present.
  27. To keep the cases where port 5 isn't controlled by phylink working as
  28. before, preserve the mt7530_setup_port5() call from mt7530_setup().
  29. Do not set priv->p5_intf_sel to P5_DISABLED. It is already set to that when
  30. "priv" is allocated.
  31. Move setting the interface to a more specific location. It's supposed to be
  32. overwritten if PHY muxing is detected.
  33. Improve the comment which explains the process.
  34. Signed-off-by: Arınç ÜNAL <[email protected]>
  35. Reviewed-by: Vladimir Oltean <[email protected]>
  36. Link: https://lore.kernel.org/r/20240122-for-netnext-mt7530-improvements-1-v3-5-042401f2b279@arinc9.com
  37. Signed-off-by: Jakub Kicinski <[email protected]>
  38. ---
  39. drivers/net/dsa/mt7530.c | 17 ++++++++---------
  40. 1 file changed, 8 insertions(+), 9 deletions(-)
  41. --- a/drivers/net/dsa/mt7530.c
  42. +++ b/drivers/net/dsa/mt7530.c
  43. @@ -2353,16 +2353,15 @@ mt7530_setup(struct dsa_switch *ds)
  44. return ret;
  45. /* Setup port 5 */
  46. - priv->p5_intf_sel = P5_DISABLED;
  47. - interface = PHY_INTERFACE_MODE_NA;
  48. -
  49. if (!dsa_is_unused_port(ds, 5)) {
  50. priv->p5_intf_sel = P5_INTF_SEL_GMAC5;
  51. - ret = of_get_phy_mode(dsa_to_port(ds, 5)->dn, &interface);
  52. - if (ret && ret != -ENODEV)
  53. - return ret;
  54. } else {
  55. - /* Scan the ethernet nodes. look for GMAC1, lookup used phy */
  56. + /* Scan the ethernet nodes. Look for GMAC1, lookup the used PHY.
  57. + * Set priv->p5_intf_sel to the appropriate value if PHY muxing
  58. + * is detected.
  59. + */
  60. + interface = PHY_INTERFACE_MODE_NA;
  61. +
  62. for_each_child_of_node(dn, mac_np) {
  63. if (!of_device_is_compatible(mac_np,
  64. "mediatek,eth-mac"))
  65. @@ -2393,6 +2392,8 @@ mt7530_setup(struct dsa_switch *ds)
  66. of_node_put(phy_node);
  67. break;
  68. }
  69. +
  70. + mt7530_setup_port5(ds, interface);
  71. }
  72. #ifdef CONFIG_GPIOLIB
  73. @@ -2403,8 +2404,6 @@ mt7530_setup(struct dsa_switch *ds)
  74. }
  75. #endif /* CONFIG_GPIOLIB */
  76. - mt7530_setup_port5(ds, interface);
  77. -
  78. /* Flush the FDB table */
  79. ret = mt7530_fdb_cmd(priv, MT7530_FDB_FLUSH, NULL);
  80. if (ret < 0)