mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Meghana Malladi <m-malladi@ti.com>
To: <haokexin@gmail.com>, <jacob.e.keller@intel.com>,
	<m-malladi@ti.com>, <pabeni@redhat.com>, <kuba@kernel.org>,
	<edumazet@kernel.org>, <davem@davemloft.net>,
	<andrew+netdev@lunn.ch>
Cc: <linux-kernel@vger.kernel.org>, <netdev@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>, <srk@ti.com>,
	Vignesh Raghavendra <vigneshr@ti.com>, <danishanwar@ti.com>
Subject: [PATCH net v2 2/2] net: ti: icssg-prueth: Fix R30 command timing and NULL emac dereference
Date: Tue, 27 Oct 2026 18:47:32 +0530	[thread overview]
Message-ID: <20261027131732.3411403-3-m-malladi@ti.com> (raw)
In-Reply-To: <20261027131732.3411403-1-m-malladi@ti.com>

emac_adjust_link() called before prueth_emac_start() caused R30 FORWARD
commands to time out (PRU not running), leaving stale R30 values that made
prueth_emac_restart() fail; fixed by deferring adjust_link until after PRU
starts. icssg_enable_fw_offload() dereferences a NULL second emac slot when
the first port opens before the second is initialized; fixed by checking
emac existence before accessing.

Signed-off-by: Meghana Malladi <m-malladi@ti.com>
---
 drivers/net/ethernet/ti/icssg/icssg_prueth.c | 27 ++++++++++++--------
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth.c b/drivers/net/ethernet/ti/icssg/icssg_prueth.c
index 746afd5d00c9..9afda5da3ca3 100644
--- a/drivers/net/ethernet/ti/icssg/icssg_prueth.c
+++ b/drivers/net/ethernet/ti/icssg/icssg_prueth.c
@@ -213,6 +213,8 @@ static void icssg_enable_fw_offload(struct prueth *prueth)
 
 	for (mac = PRUETH_MAC0; mac < PRUETH_NUM_MACS; mac++) {
 		emac = prueth->emac[mac];
+		if (!emac)
+			continue;
 		if (prueth->is_hsr_offload_mode) {
 			if (emac->ndev->features & NETIF_F_HW_HSR_TAG_RM)
 				icssg_set_port_state(emac, ICSSG_EMAC_HSR_RX_OFFLOAD_ENABLE);
@@ -288,13 +290,22 @@ static int prueth_emac_common_start(struct prueth *prueth)
 		ret = icssg_config(prueth, emac, slice);
 		if (ret)
 			goto disable_class;
+	}
+
+	ret = prueth_emac_start(prueth);
+	if (ret)
+		goto disable_class;
+
+	/* Reset link state and reconfigure after firmware is running.
+	 * Must be done after prueth_emac_start() so that R30 commands
+	 * (e.g. ICSSG_EMAC_PORT_FORWARD from emac_adjust_link) reach
+	 * the PRU firmware instead of timing out with stale R30 values.
+	 */
+	for (slice = 0; slice < PRUETH_NUM_MACS; slice++) {
+		emac = prueth->emac[slice];
+		if (!emac)
+			continue;
 
-		/* Reset link state to force reconfiguration in
-		 * emac_adjust_link(). Without this, if the link was already up
-		 * before restart, emac_adjust_link() won't detect any state
-		 * change and will skip critical configuration like writing
-		 * speed to firmware.
-		 */
 		emac->link = 0;
 
 		mutex_lock(&emac->ndev->phydev->lock);
@@ -302,10 +313,6 @@ static int prueth_emac_common_start(struct prueth *prueth)
 		mutex_unlock(&emac->ndev->phydev->lock);
 	}
 
-	ret = prueth_emac_start(prueth);
-	if (ret)
-		goto disable_class;
-
 	emac = prueth->emac[ICSS_SLICE0] ? prueth->emac[ICSS_SLICE0] :
 	       prueth->emac[ICSS_SLICE1];
 	ret = icss_iep_init(emac->iep, &prueth_iep_clockops,
-- 
2.43.0


  parent reply	other threads:[~2026-10-27 13:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-27 13:17 [PATCH net v2 0/2] Fix switch mode for offload and non-offload cases Meghana Malladi
2026-10-27 13:17 ` [PATCH net v2 1/2] net: ti: icssg-prueth: Fix bridge port_vlan and flooding state Meghana Malladi
2026-10-27 13:17 ` Meghana Malladi [this message]
2026-10-27 13:22 ` [PATCH net v2 0/2] Fix switch mode for offload and non-offload cases netdev-bot+sinfo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261027131732.3411403-3-m-malladi@ti.com \
    --to=m-malladi@ti.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=danishanwar@ti.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=haokexin@gmail.com \
    --cc=jacob.e.keller@intel.com \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=srk@ti.com \
    --cc=vigneshr@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®