Skip to contentSkip to conversation

IEP clock module bug fixes

PATCH Applied Meghana Malladi 2 participants 4 messages Dec 23, 2024 – Jan 3, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v5 cover IEP clock module bug fixes

Hi All,
This series has some bug fixes for IEP module needed by PPS and timesync operations.

Patch 1/2 fixes firmware load sequence to run all the firmwares when either of the ethernet interfaces is up. Move all the code common for firmware bringup under common functions.

Patch 2/2 fixes distorted PPS signal when the ethernet interfaces are brough down and up. This patch also fixes enabling PPS signal after bringing the interface up, without disabling PPS.

MD Danish Anwar (1):
net: ti: icssg-prueth: Fix firmware load sequence.

Meghana Malladi (1):
net: ti: icssg-prueth: Fix clearing of IEP_CMP_CFG registers during
iep_init

 drivers/net/ethernet/ti/icssg/icss_iep.c      |   8 +
 drivers/net/ethernet/ti/icssg/icssg_common.c  |  25 --
 drivers/net/ethernet/ti/icssg/icssg_config.c  |  41 ++-
 drivers/net/ethernet/ti/icssg/icssg_config.h  |   1 +
 drivers/net/ethernet/ti/icssg/icssg_prueth.c  | 261 ++++++++++++------
 drivers/net/ethernet/ti/icssg/icssg_prueth.h  |   5 +-
 .../net/ethernet/ti/icssg/icssg_prueth_sr1.c  |  24 +-
 7 files changed, 244 insertions(+), 121 deletions(-)

base-commit: 92c932b9946c1e082406aa0515916adb3e662e24

Signature · 1 line
2.25.1
#1 lore raw

PATCH v5 1/2 net: ti: icssg-prueth: Fix firmware load sequence.

From: MD Danish Anwar <[email protected]>

Timesync related operations are ran in PRU0 cores for both ICSSG SLICE0 and SLICE1. Currently whenever any ICSSG interface comes up we load the respective firmwares to PRU cores and whenever interface goes down, we stop the resective cores. Due to this, when SLICE0 goes down while SLICE1 is still active, PRU0 firmwares are unloaded and PRU0 core is stopped. This results in clock jump for SLICE1 interface as the timesync related operations are no longer running.

As there are interdependencies between SLICE0 and SLICE1 firmwares, fix this by running both PRU0 and PRU1 firmwares as long as at least 1 ICSSG interface is up. Add new flag in prueth struct to check if all firmwares are running and remove the old flag (fw_running).

Use emacs_initialized as reference count to load the firmwares for the first and last interface up/down. Moving init_emac_mode and fw_offload_mode API outside of icssg_config to icssg_common_start API as they need to be called only once per firmware boot.

Change prueth_emac_restart() to return error code and add error prints inside the caller of this functions in case of any failures.

Move prueth_emac_stop() from common to sr1 driver. sr1 and sr2 drivers have different logic handling for stopping the firmwares. While sr1 driver is dependent on emac structure to stop the corresponding pru cores for that slice, for sr2 all the pru cores of both the slices are stopped and is not dependent on emac. So the prueth_emac_stop() function is no longer common and can be moved to sr1 driver.

Fixes c1e0230eeaab ("net: ti: icss-iep: Add IEP driver")

---

Hi all,

This patch is based on net-next tagged next-20241211 v4:https://lore.kernel.org/all/[email protected]/

* Changes since v4 (v5-v4) as suggested by Dan Carpenter <[email protected]> :
- Error patch clean up to prevent partial allocations and freeds.
- Add prueth_start() and prueth_shutdown() as part of error patch clean up.
- Remove prus_running flag as this will be redundant for all pru cores running and remove prueth->prus_running flag check in prueth_iep_settime() as well.
- Add prueth_emac_stop() for sr2 driver with different logic from prueth_emac_stop() in common.c file and move the common function to sr1 driver.
- Add prueth->emacs_initialized check in stop goto label to ensure consistent error handling and to prevent other interface from crashing if one interface bring up failed.

* Changes since v3 (v4-v3):
- Add error handling for prueth_emac_restart() suggested by Roger Quadros <[email protected]>
- Remove fw_running flag as suggested by Roger Quadros <[email protected]> and Diogo Ivo <[email protected]>
- Few cosmetic changes suggested by Kalesh Anakkur Purayil <[email protected]>

 drivers/net/ethernet/ti/icssg/icssg_common.c  |  25 --
 drivers/net/ethernet/ti/icssg/icssg_config.c  |  41 ++-
 drivers/net/ethernet/ti/icssg/icssg_config.h  |   1 +
 drivers/net/ethernet/ti/icssg/icssg_prueth.c  | 261 ++++++++++++------
 drivers/net/ethernet/ti/icssg/icssg_prueth.h  |   5 +-
 .../net/ethernet/ti/icssg/icssg_prueth_sr1.c  |  24 +-
 6 files changed, 236 insertions(+), 121 deletions(-)
drivers/net/ethernet/ti/icssg/icssg_common.c +0 -25
index fdebeb2f84e0..74f0f200a89d 100644
@@ -855,31 +855,6 @@ irqreturn_t prueth_rx_irq(int irq, void *dev_id)
 }
 EXPORT_SYMBOL_GPL(prueth_rx_irq);
 
-void prueth_emac_stop(struct prueth_emac *emac)
-{
-	struct prueth *prueth = emac->prueth;
-	int slice;
-
-	switch (emac->port_id) {
-	case PRUETH_PORT_MII0:
-		slice = ICSS_SLICE0;
-		break;
-	case PRUETH_PORT_MII1:
-		slice = ICSS_SLICE1;
-		break;
-	default:
-		netdev_err(emac->ndev, "invalid port\n");
-		return;
-	}
-
-	emac->fw_running = 0;
-	if (!emac->is_sr1)
-		rproc_shutdown(prueth->txpru[slice]);
-	rproc_shutdown(prueth->rtu[slice]);
-	rproc_shutdown(prueth->pru[slice]);
-}
-EXPORT_SYMBOL_GPL(prueth_emac_stop);
-
 void prueth_cleanup_tx_ts(struct prueth_emac *emac)
 {
 	int i;
drivers/net/ethernet/ti/icssg/icssg_config.c +28 -13

79 lines not on this page · raw message

drivers/net/ethernet/ti/icssg/icssg_config.h +1 -0
index 92c2deaa3068..c884e9fa099e 100644
@@ -55,6 +55,7 @@ struct icssg_rxq_ctx {
 #define ICSSG_FW_MGMT_FDB_CMD_TYPE	0x03
 #define ICSSG_FW_MGMT_CMD_TYPE		0x04
 #define ICSSG_FW_MGMT_PKT		0x80000000
+#define ICSSG_FW_MGMT_FDB_CMD_TYPE_RX_FLOW	0x05
 
 struct icssg_r30_cmd {
 	u32 cmd[4];
drivers/net/ethernet/ti/icssg/icssg_prueth.c +181 -80

416 lines not on this page · raw message

drivers/net/ethernet/ti/icssg/icssg_prueth.h +3 -2
index f5c1d473e9f9..5473315ea204 100644
@@ -140,7 +140,6 @@ struct prueth_rx_chn {
 /* data for each emac port */
 struct prueth_emac {
 	bool is_sr1;
-	bool fw_running;
 	struct prueth *prueth;
 	struct net_device *ndev;
 	u8 mac_addr[6];
@@ -361,6 +360,8 @@ int icssg_set_port_state(struct prueth_emac *emac,
 			 enum icssg_port_state_cmd state);
 void icssg_config_set_speed(struct prueth_emac *emac);
 void icssg_config_half_duplex(struct prueth_emac *emac);
+void icssg_init_emac_mode(struct prueth *prueth);
+void icssg_init_fw_offload_mode(struct prueth *prueth);
 
 /* Buffer queue helpers */
 int icssg_queue_pop(struct prueth *prueth, u8 queue);
@@ -377,6 +378,7 @@ void icssg_vtbl_modify(struct prueth_emac *emac, u8 vid, u8 port_mask,
 		       u8 untag_mask, bool add);
 u16 icssg_get_pvid(struct prueth_emac *emac);
 void icssg_set_pvid(struct prueth *prueth, u8 vid, u8 port);
+int emac_fdb_flow_id_updated(struct prueth_emac *emac);
 #define prueth_napi_to_tx_chn(pnapi) \
 	container_of(pnapi, struct prueth_tx_chn, napi_tx)
 
@@ -407,7 +409,6 @@ void emac_rx_timestamp(struct prueth_emac *emac,
 		       struct sk_buff *skb, u32 *psdata);
 enum netdev_tx icssg_ndo_start_xmit(struct sk_buff *skb, struct net_device *ndev);
 irqreturn_t prueth_rx_irq(int irq, void *dev_id);
-void prueth_emac_stop(struct prueth_emac *emac);
 void prueth_cleanup_tx_ts(struct prueth_emac *emac);
 int icssg_napi_rx_poll(struct napi_struct *napi_rx, int budget);
 int prueth_prepare_rx_chan(struct prueth_emac *emac,
drivers/net/ethernet/ti/icssg/icssg_prueth_sr1.c +23 -1
index 5024f0647a0d..3dc86397c367 100644
@@ -440,7 +440,6 @@ static int prueth_emac_start(struct prueth *prueth, struct prueth_emac *emac)
 		goto halt_pru;
 	}
 
-	emac->fw_running = 1;
 	return 0;
 
 halt_pru:
@@ -449,6 +448,29 @@ static int prueth_emac_start(struct prueth *prueth, struct prueth_emac *emac)
 	return ret;
 }
 
+static void prueth_emac_stop(struct prueth_emac *emac)
+{
+	struct prueth *prueth = emac->prueth;
+	int slice;
+
+	switch (emac->port_id) {
+	case PRUETH_PORT_MII0:
+		slice = ICSS_SLICE0;
+		break;
+	case PRUETH_PORT_MII1:
+		slice = ICSS_SLICE1;
+		break;
+	default:
+		netdev_err(emac->ndev, "invalid port\n");
+		return;
+	}
+
+	if (!emac->is_sr1)
+		rproc_shutdown(prueth->txpru[slice]);
+	rproc_shutdown(prueth->rtu[slice]);
+	rproc_shutdown(prueth->pru[slice]);
+}
+
 /**
  * emac_ndo_open - EMAC device open
  * @ndev: network adapter device
Signature · 1 line
2.25.1
#2 lore raw

PATCH v5 2/2 net: ti: icssg-prueth: Fix clearing of IEP_CMP_CFG registers during iep_init

In reply to Meghana Malladi

When ICSSG interfaces are brought down and brought up again, the pru cores are shut down and booted again, flushing out all the memories and start again in a clean state. Hence it is expected that the IEP_CMP_CFG register needs to be flushed during iep_init() to ensure that the existing residual configuration doesn't cause any unusual behavior. If the register is not cleared, existing IEP_CMP_CFG set for CMP1 will result in SYNC0_OUT signal based on the SYNC_OUT register values.

After bringing the interface up, calling PPS enable doesn't work as the driver believes PPS is already enabled, (iep->pps_enabled is not cleared during interface bring down) and driver will just return true even though there is no signal. Fix this by disabling pps and perout.

Fixes c1e0230eeaab ("net: ti: icss-iep: Add IEP driver")

---

Hi all,

This patch is based on net-next tagged next-20241211
v4: https://lore.kernel.org/all/[email protected]/

* Changes since v4 (v5-v4):
- Removed additional blank line as suggested by Dan Carpenter <[email protected]>
* Changes since v2 (v4-v2):
- Collected Reviewed-by tag from Roger Quadros <[email protected]>

 drivers/net/ethernet/ti/icssg/icss_iep.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/net/ethernet/ti/icssg/icss_iep.c +8 -0
index 5d6d1cf78e93..768578c0d958 100644
@@ -215,6 +215,9 @@ static void icss_iep_enable_shadow_mode(struct icss_iep *iep)
 	for (cmp = IEP_MIN_CMP; cmp < IEP_MAX_CMP; cmp++) {
 		regmap_update_bits(iep->map, ICSS_IEP_CMP_STAT_REG,
 				   IEP_CMP_STATUS(cmp), IEP_CMP_STATUS(cmp));
+
+		regmap_update_bits(iep->map, ICSS_IEP_CMP_CFG_REG,
+				   IEP_CMP_CFG_CMP_EN(cmp), 0);
 	}
 
 	/* enable reset counter on CMP0 event */
@@ -780,6 +783,11 @@ int icss_iep_exit(struct icss_iep *iep)
 	}
 	icss_iep_disable(iep);
 
+	if (iep->pps_enabled)
+		icss_iep_pps_enable(iep, false);
+	else if (iep->perout_enabled)
+		icss_iep_perout_enable(iep, NULL, false);
+
 	return 0;
 }
 EXPORT_SYMBOL_GPL(icss_iep_exit);
Signature · 1 line
2.25.1
#3 lore raw
In reply to Meghana Malladi
This series was applied to netdev/net.git (main) by David S. Miller <[email protected]>:

Hello:

This series was applied to netdev/net.git (main)
by David S. Miller <[email protected]>:

Quoted 9 lines · On Mon, 23 Dec 2024 20:45:48 +0530 you wrote:

Hi All,
This series has some bug fixes for IEP module needed by PPS and timesync operations.

Patch 1/2 fixes firmware load sequence to run all the firmwares when either of the ethernet interfaces is up. Move all the code common for firmware bringup under common functions.

[...]

Here is the summary with links:
- [net,v5,1/2] net: ti: icssg-prueth: Fix firmware load sequence.

    https://git.kernel.org/netdev/net/c/9facce84f406
  - [net,v5,2/2] net: ti: icssg-prueth: Fix clearing of IEP_CMP_CFG registers during iep_init
    https://git.kernel.org/netdev/net/c/9b115361248d

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html