public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v5 net 0/3] net: enetc: safely reinitialize TX BD ring when it has unsent frames
@ 2026-03-13  9:46 Wei Fang
  2026-03-13  9:46 ` [PATCH v5 net 1/3] net: enetc: reset PIR and CIR if they are not equal when initializing TX ring Wei Fang
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Wei Fang @ 2026-03-13  9:46 UTC (permalink / raw)
  To: claudiu.manoil, vladimir.oltean, xiaoning.wang, andrew+netdev,
	davem, edumazet, kuba, pabeni, linux, Frank.Li, horms,
	saikrishnag
  Cc: netdev, linux-kernel, imx

Currently the driver does not reset the producer index register (PIR) and
consumer index register (CIR) when initializing a TX BD ring. The driver
only reads the PIR and CIR and initializes the software indexes. If the
TX BD ring is reinitialized when it still contains unsent frames, its PIR
and CIR will not be equal after the reinitialization. However, the BDs
between CIR and PIR have been freed and become invalid and this can lead
to a hardware malfunction, causing the TX BD ring will not work properly.

Since the PIR and CIR are sofeware-configurable on ENETC v4. Therefore,
the driver must reset them if they are not equal when reinitializing
the TX BD ring.

However, resetting the PIR and CIR alone is insufficient, it cannot
completely solve the problem. When a link-down event occurs while the TX
BD ring is transmitting frames, subsequent reinitialization of the TX BD
ring may cause it to malfunction. Because enetc4_pl_mac_link_down() only
clears PMa_COMMAND_CONFIG[TX_EN] to disable MAC transmit data path. It
doesn't set PORT[TXDIS] to 1 to flush the TX BD ring. Therefore, it is
not safe to reinitialize the TX BD ring at this point.

To safely reinitialize the TX BD ring after a link-down event, we checked
with the NETC IP team, a proper Ethernet MAC graceful stop is necessary.
Therefore, add the Ethernet MAC graceful stop to the link-down event
handler enetc4_pl_mac_link_down(). Note that this patch set is not
applicable to ENETC v1 (LS1028A).

---
v5:
1. Add patch 3
2. Correct the typo in commit message of patch 1
v4 link: https://lore.kernel.org/imx/20260312095415.669128-1-wei.fang@nxp.com/
v4:
Correct the offset of ENETC4_PSR
v3 link: https://lore.kernel.org/imx/20260311084105.3982037-1-wei.fang@nxp.com/
v3:
1. Split the v2 patch into two parts
2. Update the comments regarding PIR and CIR in enetc_setup_txbdr()
3. Use read_poll_timeout() instead of the while loop
v2 link: https://lore.kernel.org/imx/20260309030412.2716984-1-wei.fang@nxp.com/
v2:
1. Remove unused register macros (ENETC_SISR and SISR_TX_BUSY)
2. Remove spurious semicolon from enetc4_mac_wait_rx_empty()
---

Wei Fang (3):
  net: enetc: reset PIR and CIR if they are not equal when initializing
    TX ring
  net: enetc: add graceful stop to safely reinitialize the TX Ring
  net: enetc: do not access non-existent registers on pseudo MAC

 drivers/net/ethernet/freescale/enetc/enetc.c  |  13 +-
 .../net/ethernet/freescale/enetc/enetc4_hw.h  |  11 ++
 .../net/ethernet/freescale/enetc/enetc4_pf.c  | 118 +++++++++++++++---
 3 files changed, 127 insertions(+), 15 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2026-03-24  1:55 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-13  9:46 [PATCH v5 net 0/3] net: enetc: safely reinitialize TX BD ring when it has unsent frames Wei Fang
2026-03-13  9:46 ` [PATCH v5 net 1/3] net: enetc: reset PIR and CIR if they are not equal when initializing TX ring Wei Fang
2026-03-16 14:12   ` Claudiu Manoil
2026-03-13  9:46 ` [PATCH v5 net 2/3] net: enetc: add graceful stop to safely reinitialize the TX Ring Wei Fang
2026-03-16 14:13   ` Claudiu Manoil
2026-03-13  9:46 ` [PATCH v5 net 3/3] net: enetc: do not access non-existent registers on pseudo MAC Wei Fang
2026-03-16 14:13   ` Claudiu Manoil
2026-03-17  2:15     ` Wei Fang
2026-03-17 10:32       ` Claudiu Manoil
2026-03-23 10:40 ` [PATCH v5 net 0/3] net: enetc: safely reinitialize TX BD ring when it has unsent frames Wei Fang
2026-03-23 21:37   ` Jakub Kicinski
2026-03-24  1:55     ` Wei Fang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox