Skip to content

net: enetc: safely reinitialize TX BD ring when it has unsent frames

Wei Fang imx lkml netdev 6 versions – Applied

Status from this message: This series was applied to netdev/net.git (main)

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v5 Latest posting 2/23 patches 1 replyApplied 3/3
  2. v5 posting 1/23 patches 8 repliesSuperseded
  3. v42 patches 2 repliesSuperseded
Earlier versions · 3
VersionPostedPatchesRepliesStatus
v32 patches2 repliesSuperseded
v21 patch2 repliesSuperseded
v11 patch3 repliesSuperseded

Changes in v5 from the cover letter

1. Add patch 3
2. Correct the typo in commit message of patch 1
v4 link: https://lore.kernel.org/imx/[email protected]/

Patches in v5 posting 2/2 All 3 applied

#Subject and filesSizeRepliesApplied
1/3net: enetc: reset PIR and CIR if they are not equal when initializing TX ringdrivers/net/ethernet/freescale/enetc/enetc.c+12 -10 repliesApplied
2/3net: enetc: add graceful stop to safely reinitialize the TX Ringdrivers/net/ethernet/freescale/enetc/enetc4_hw.h drivers/net/ethernet/freescale/enetc/enetc4_pf.c+108 -140 repliesApplied
3/3net: enetc: do not access non-existent registers on pseudo MACdrivers/net/ethernet/freescale/enetc/enetc4_pf.c+7 -00 repliesApplied

Reviews trailers per patch

All 3 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchClaudiu ManoilSimon Horman
SeriesR-b
1/3R-b
2/3R-b
3/3T-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v5 thread

Cover letter [PATCH v5 RESEND net 0/3] net: enetc: safely reinitialize TX BD ring when it has unsent frames

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 link: https://lore.kernel.org/netdev/[email protected]/
v5:
1. Add patch 3
2. Correct the typo in commit message of patch 1
v4 link: https://lore.kernel.org/imx/[email protected]/
v4:
Correct the offset of ENETC4_PSR
v3 link: https://lore.kernel.org/imx/[email protected]/
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/[email protected]/
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(-)
Signature · 1 line
2.34.1