Skip to content

ramips: mt7620: reset network blocks on restart - #24724

Open
dormancygrace wants to merge 1 commit into
openwrt:mainfrom
dormancygrace:mt7620-reset
Open

dormancygrace wants to merge 1 commit into
openwrt:mainfrom
dormancygrace:mt7620-reset

Conversation

@dormancygrace

@dormancygrace dormancygrace commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Reset the MT7620 frame engine, embedded switch and PPE together with the system during restart.

A system-only warm reset can leave PDMA unable to consume its first TX descriptor on the next boot. The state survives driver reprobes and separate FE, ESW or PPE reset attempts. The combined reset is the sequence that recovered the hardware during diagnosis.

MT7628 and MT7688 expose the same FE and ESW reset bits, but this failure and the required reset mask have not been verified on those SoCs, and they do not expose the MT7620 PPE reset block. The workaround is therefore deliberately limited to tested MT7620 hardware.

Testing

After rebasing on current OpenWrt main: fresh native prepare, two idempotent refreshes and a complete ramips/mt7620 kernel/module build with Linux 6.18.54. The reset implementation is unchanged; the old hardware tests below predate this rebase.

Tested on MT7620N rev 2 eco 6 with repeated ordinary warm reboots. Ethernet returned after every reboot. This patch was also part of the previously green CI history of #24493 before being split out at reviewer request.

Extracted from: #24493

@openwrt openwrt Bot added the target/ramips pull request/issue for ramips target label Aug 14, 2026

@openwrt-ai openwrt-ai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 new commit. The patch applies cleanly against the v6.18 arch/mips/ralink/reset.c (hunk header @@ -18,18 +18,27 @@ and the diffstat both check out), ralink_soc / MT762X_SOC_MT7620A / MT762X_SOC_MT7620N are already reachable via the existing asm/mach-ralink/ralink_regs.h include, and the FE (bit 21) / ESW (bit 23) bit assignments match resets = <&sysc 21>, <&sysc 23> in target/linux/ramips/dts/mt7620a.dtsi. Commit message matches the diff. Two nits inline.


Generated by Claude Code

dormancygrace added a commit to dormancygrace/openwrt that referenced this pull request Aug 14, 2026
Add a DSA driver for the seven-port switch integrated in MT7620. Keep
the existing swconfig path for device trees without a DSA ports node.

Use RXD4 source-port and TXD4 forced-port metadata with the Ralink DSA
tagger. The programming guide places TXD4 FP_BMAP at bits 27:20; use
that layout instead of the stale unused bits 26:19 definition.

Implement bridge isolation and STP, VLAN filtering, FDB and MDB offload,
ageing, flood controls, phylink, MTU limits, and software-extended
hardware MIB counters. DSA invokes port_stp_state_set() before updating
its cached state, so pass the pending callback state as an override when
recalculating port matrices instead of leaving hardware one transition
behind.

Correct the shared switch MIB enable register and enable all seven port
counters. The old address was inside port 0 counter space, so this also
fixes legacy swconfig initialization.

Register DSA through a bound child of the frame-engine device. This gives
the managed conduit device link the correct lifetime across driver unbind
and reprobe while the switch registers remain owned by the existing GSW
platform device.

Package the driver and tagger as kmod-dsa-mt7620 for per-device opt-in.
This keeps DSA and switchdev out of swconfig-only MT7620 images and
prevents installing the DSA package together with swconfig.

Also make MDIO and frame-engine teardown safe for deferred probes and
runtime reprobes. Replace the legacy MDIO busy loop and -1 return with
readl_poll_timeout_atomic() and its real error, and reset a still-busy
frame engine before freeing DMA rings. Resolve FE and ESW resets by name
so recovery can reset FE alone, and warn if a switch node provides
neither named reset.

The FE-only reset is a stop-path fallback when DMA fails to quiesce
before its rings are freed. It does not recover network blocks left stale
across a system restart; that separate condition is handled by the reset
change linked below.

The netdev is devm-managed, so leave NAPI deletion to free_netdev after
unregister instead of deleting NAPI from fe_remove while the netdev is
still registered.

Tested on an MT7620N rev 2 eco 6 with 100BASE-T traffic, VLAN-aware
hardware bridging, 2026-byte MTU, FDB/MDB offload, pending STP state, and
driver unbind/rebind. The modular driver, tagger, package contents, DSA
image composition, and swconfig-only kernel configuration were also
verified. An independent TP-Link Archer C5 v4 test found no regression
with an external RTL8367S DSA switch using the RTL8_4t tagger.

Warm-reboot recovery was tested with the separate reset change applied
and is not claimed by this DSA commit alone.

Link: https://lists.infradead.org/pipermail/openwrt-devel/2021-December/037379.html

Link: openwrt#23933

Link: openwrt#24242

Link: openwrt#24724

Signed-off-by: Gleb Pesin <[email protected]>
@dormancygrace

Copy link
Copy Markdown
Contributor Author

Addressed the Formality suggestion. The embedded reset patch now has a complete git format-patch mail header with a real Linux v6.18.44 commit ID, and its description was wrapped to the kernel style limit. checkpatch.pl reports zero errors and zero warnings; the code payload is unchanged.

@openwrt-ai openwrt-ai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the changes since 4ad5ccb. The code payload is unchanged; the delta is the From <sha> header line and a new commit-message paragraph.

The new paragraph resolves the earlier MT7628/MT7688 scoping question well. The header-line change went the wrong direction though — see inline. Commit message still matches the diff, the hunk header (@@ -18,18 +18,27 @@) and diffstat (10 insertions, 1 deletion) both still check out against v6.18.44 arch/mips/ralink/reset.c, and CI is green on 04d4145.


Generated by Claude Code

dormancygrace added a commit to dormancygrace/openwrt that referenced this pull request Aug 15, 2026
Add a DSA driver for the seven-port switch integrated in MT7620. Keep
the existing swconfig path for device trees without a DSA ports node.

Use RXD4 source-port and TXD4 forced-port metadata with the Ralink DSA
tagger. The programming guide places TXD4 FP_BMAP at bits 27:20; use
that layout instead of the stale unused bits 26:19 definition.

Implement bridge isolation and STP, VLAN filtering, FDB and MDB offload,
ageing, flood controls, phylink, MTU limits, and software-extended
hardware MIB counters. DSA invokes port_stp_state_set() before updating
its cached state, so pass the pending callback state as an override when
recalculating port matrices instead of leaving hardware one transition
behind.

Correct the shared switch MIB enable register and enable all seven port
counters. The old address was inside port 0 counter space, so this also
fixes legacy swconfig initialization.

Register DSA through a bound child of the frame-engine device. This gives
the managed conduit device link the correct lifetime across driver unbind
and reprobe while the switch registers remain owned by the existing GSW
platform device.

Package the driver and tagger as kmod-dsa-mt7620 for per-device opt-in.
This keeps DSA and switchdev out of swconfig-only MT7620 images and
prevents installing the DSA package together with swconfig.

Also make MDIO and frame-engine teardown safe for deferred probes and
runtime reprobes. Replace the legacy MDIO busy loop and -1 return with
readl_poll_timeout_atomic() and its real error, and reset a still-busy
frame engine before freeing DMA rings. Resolve FE and ESW resets by name
so recovery can reset FE alone, and warn if a switch node provides
neither named reset.

The FE-only reset is a stop-path fallback when DMA fails to quiesce
before its rings are freed. It does not recover network blocks left stale
across a system restart; that separate condition is handled by the reset
change linked below.

The netdev is devm-managed, so leave NAPI deletion to free_netdev after
unregister instead of deleting NAPI from fe_remove while the netdev is
still registered.

Tested on an MT7620N rev 2 eco 6 with 100BASE-T traffic, VLAN-aware
hardware bridging, 2026-byte MTU, FDB/MDB offload, pending STP state, and
driver unbind/rebind. The modular driver, tagger, package contents, DSA
image composition, and swconfig-only kernel configuration were also
verified.

An independent TP-Link Archer C5 v4 test exercised an external RTL8367S
DSA switch using the RTL8_4t tagger as a regression check on the shared
dsa_tag_protocol enum. It found no collision or external-switch
regression; it does not validate the MT7620 integrated-switch path.

Warm-reboot recovery was tested with the separate reset change from
openwrt#24724 applied and is not claimed by this DSA commit.

Link: openwrt#24242
Link: openwrt#24724
Signed-off-by: Gleb Pesin <[email protected]>

@openwrt-ai openwrt-ai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 new commit; no new issues found.

The delta since 04d4145 is exactly the two points raised last round: the nonexistent From 88d7abfc... Mon Sep 17 00:00:00 2001 envelope line is gone, and the MT7628/MT7688 paragraph now uses the same two-space sentence separation as the rest of the description. The code payload is unchanged.

Re-verified against head:

  • The patch applies cleanly to arch/mips/ralink/reset.c in v6.18.44 (patch -p1 --dry-run, no fuzz), and the inner diffstat (1 file changed, 10 insertions(+), 1 deletion(-)) matches the hunk.
  • ralink_soc, MT762X_SOC_MT7620A and MT762X_SOC_MT7620N are all reachable through the existing asm/mach-ralink/ralink_regs.h include (ralink_regs.h:24-30).
  • ramips only carries patches-6.18 and KERNEL_PATCHVER:=6.18, so there is no second patch series needing the same change.
  • Commit message matches the diff.
  • CI is green on 912dd4a (all five ramips subtarget kernel builds plus Check Kernel patches succeeded).

One heads-up so it doesn't cause a second round-trip: the FormalityCheck bot now warns that the patch is "Missing required Git header parameters (From <hash> Mon Sep 17 00:00:00 2001 ...)". The check itself still reports success, and the current form matches how locally-authored patches in this directory are written — 120-1-mips-pci-mt7620-fix-bridge-register-access.patch, 330-mt7620-avoid-direct-jal-in-random-helper.patch, 331-..., 332-..., 808-..., 809-... all start straight at From: (21 of the 46 patches in patches-6.18 omit that line). Re-adding a fabricated SHA to silence the warning would be worse than the warning; leaving it as-is looks right to me, but the maintainer may want to weigh in.


Generated by Claude Code

dormancygrace added a commit to dormancygrace/openwrt that referenced this pull request Aug 18, 2026
Add a DSA driver for the seven-port switch integrated in MT7620. Keep
the existing swconfig path for device trees without a DSA ports node.

Use RXD4 source-port and TXD4 forced-port metadata with the Ralink DSA
tagger. The programming guide places TXD4 FP_BMAP at bits 27:20; use
that layout instead of the stale unused bits 26:19 definition.

Implement bridge isolation and STP, VLAN filtering, FDB and MDB offload,
ageing, flood controls, phylink, MTU limits, and software-extended
hardware MIB counters. DSA invokes port_stp_state_set() before updating
its cached state, so pass the pending callback state as an override when
recalculating port matrices instead of leaving hardware one transition
behind.

Correct the shared switch MIB enable register and enable all seven port
counters. The old address was inside port 0 counter space, so this also
fixes legacy swconfig initialization.

Register DSA through a bound child of the frame-engine device. This gives
the managed conduit device link the correct lifetime across driver unbind
and reprobe while the switch registers remain owned by the existing GSW
platform device.

Package the driver and tagger as kmod-dsa-mt7620 for per-device opt-in.
This keeps DSA and switchdev out of swconfig-only MT7620 images and
prevents installing the DSA package together with swconfig.

Also make MDIO and frame-engine teardown safe for deferred probes and
runtime reprobes. Replace the legacy MDIO busy loop and -1 return with
readl_poll_timeout_atomic() and its real error, and reset a still-busy
frame engine before freeing DMA rings. Resolve FE and ESW resets by name
so recovery can reset FE alone, and warn if a switch node provides
neither named reset.

The FE-only reset is a stop-path fallback when DMA fails to quiesce
before its rings are freed. It does not recover network blocks left stale
across a system restart; that separate condition is handled by the reset
change linked below.

The netdev is devm-managed, so leave NAPI deletion to free_netdev after
unregister instead of deleting NAPI from fe_remove while the netdev is
still registered.

Tested on an MT7620N rev 2 eco 6 with 100BASE-T traffic, VLAN-aware
hardware bridging, 2026-byte MTU, FDB/MDB offload, pending STP state, and
driver unbind/rebind. The modular driver, tagger, package contents, DSA
image composition, and swconfig-only kernel configuration were also
verified.

An independent TP-Link Archer C5 v4 test exercised an external RTL8367S
DSA switch using the RTL8_4t tagger as a regression check on the shared
dsa_tag_protocol enum. It found no collision or external-switch
regression; it does not validate the MT7620 integrated-switch path.

Warm-reboot recovery was tested with the separate reset change from
openwrt#24724 applied and is not claimed by this DSA commit.

Link: openwrt#24242
Link: openwrt#24724
Signed-off-by: Gleb Pesin <[email protected]>
A system-only warm reset can leave the frame-engine PDMA unable to
consume its first TX descriptor on the next boot. The failure survives
driver reprobes and individual FE, ESW and PPE reset attempts.

Reset FE, ESW and PPE together with the system on MT7620. This matches
the combined reset that recovered the hardware during live diagnosis and
passed repeated ordinary warm reboots.

MT7628 and MT7688 expose matching FE and ESW reset bits, but the failure
and required reset mask have not been verified there, and those SoCs do
not expose the MT7620 PPE reset block. Keep the workaround scoped to
tested MT7620 hardware.

Signed-off-by: Gleb Pesin <[email protected]>
Assisted-by: Codex:gpt-6.1-sol
ddimension pushed a commit to ddimension/openwrt-repo that referenced this pull request Nov 7, 2026
config.lte3301 adds lldpd to the LTE3301-M209/Q222 leg: the devices sit
in the test network without a console, and LLDP still reports one to the
switch when its LAN address no longer matches after an upgrade.

The fork branch lte3301 was reset to the PR state (switch under DSA)
plus openwrt/openwrt#24724 and the jbootimage tool from
openwrt/firmware-utils#81; the README says which commit is which.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

target/ramips pull request/issue for ramips target

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants