[PATCH net] net: ti: icssg-prueth: Fix emac link speed handling

MD Danish Anwar posted 1 patch 2 months ago
There is a newer version of this series
drivers/net/ethernet/ti/icssg/icssg_prueth.c | 3 +++
1 file changed, 3 insertions(+)
[PATCH net] net: ti: icssg-prueth: Fix emac link speed handling
Posted by MD Danish Anwar 2 months ago
When link settings are changed emac->speed is populated by
emac_adjust_link(). The link speed and other settings are then written into
the DRAM. However if both ports are brought down after this and brought up
again or if the operating mode is changed and a firmware reload is needed,
the DRAM is cleared by icssg_config(). As a result the link settings are
lost.

Fix this by calling emac_adjust_link() after icssg_config(). This re
populates the settings in the DRAM after a new firmware load.

Fixes: 9facce84f406 ("net: ti: icssg-prueth: Fix firmware load sequence.")
Signed-off-by: MD Danish Anwar <danishanwar@ti.com>
---
NOTE: emac_adjust_link() is defined after prueth_emac_common_start() as a
result to call this from prueth_emac_common_start() I am using forward
declaration of the function. The other alternate is to move the definition
of emac_adjust_link() before prueth_emac_common_start().

 drivers/net/ethernet/ti/icssg/icssg_prueth.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth.c b/drivers/net/ethernet/ti/icssg/icssg_prueth.c
index 2b973d6e2341..8ca0ea768e16 100644
--- a/drivers/net/ethernet/ti/icssg/icssg_prueth.c
+++ b/drivers/net/ethernet/ti/icssg/icssg_prueth.c
@@ -50,6 +50,8 @@
 /* CTRLMMR_ICSSG_RGMII_CTRL register bits */
 #define ICSSG_CTRL_RGMII_ID_MODE                BIT(24)
 
+static void emac_adjust_link(struct net_device *ndev);
+
 static int emac_get_tx_ts(struct prueth_emac *emac,
 			  struct emac_tx_ts_response *rsp)
 {
@@ -229,6 +231,7 @@ static int prueth_emac_common_start(struct prueth *prueth)
 		ret = icssg_config(prueth, emac, slice);
 		if (ret)
 			goto disable_class;
+		emac_adjust_link(emac->ndev);
 	}
 
 	ret = prueth_emac_start(prueth);

base-commit: 759dfc7d04bab1b0b86113f1164dc1fec192b859
-- 
2.34.1
Re: [PATCH net] net: ti: icssg-prueth: Fix emac link speed handling
Posted by Andrew Lunn 2 months ago
On Thu, Jul 31, 2025 at 05:38:12PM +0530, MD Danish Anwar wrote:
> When link settings are changed emac->speed is populated by
> emac_adjust_link(). The link speed and other settings are then written into
> the DRAM. However if both ports are brought down after this and brought up
> again or if the operating mode is changed and a firmware reload is needed,
> the DRAM is cleared by icssg_config(). As a result the link settings are
> lost.
> 
> Fix this by calling emac_adjust_link() after icssg_config(). This re
> populates the settings in the DRAM after a new firmware load.

It is only safe to access phydev members when the phydev lock is
held. When phylib calls emac_adjust_link() it is holding this lock, so
MAC drivers don't need to worry about it. However, if you call it
directly, without the lock, bad things will happen.

    Andrew

---
pw-bot: cr