Repository navigation
econet: en751221: fix delivery of odd interrupts - #26744
ShorterKing wants to merge 1 commit into
Conversation
In the MIPS interrupt compatibility mode, the EN751221 interrupt controller presents the number of the pending interrupt plus one, in binary, on the CPU interrupt lines IP2-IP7. The device tree chains it to IP2 only, so the odd-numbered interrupts never reach the CPU on their own. The QDMA (21), xHCI (17) and the first PCIe port (23) are serviced only when an even-numbered interrupt, normally the next timer tick, runs the handler. On a Nokia G-140W-C this delayed received packets by up to 10 ms whenever the device was not busy, and ping round-trip times to it cycled through 1-11 ms. Add a kernel patch that chains the controller to every CPU line listed in its "interrupts" property, and list IP2-IP6 in the device tree. IP7 is left out: the CPU can also signal its own timer on it, and only the unused hwirq 31 would need it. With it, ping round-trip times to the device are below 1 ms, and the pending bit of the QDMA interrupt is no longer found set while the CPU runs other code. Signed-off-by: Akshat Singh <[email protected]>
045e474 to
fa24136
Compare
|
You can send it, I'll give it a test when you do. |
|
it ended up a bit different from this pr. mainline has your VEIC mode now, so the chaining only goes in the non-VEIC path and VEIC is untouched. this board's 34kc doesn't report VEIC though (no veic in /proc/cpuinfo), asked you about that in the cover letter. if VEIC can be turned on here I'd rather backport that to openwrt than carry this. |
|
your Tested-by is on 2/3 now, thanks for testing. also a correction to my comment above. the 34kc here does report VEIC. my kernel was built without CONFIG_CPU_MIPSR2_IRQ_EI, so cpu_has_veic was 0 at build time and /proc/cpuinfo could never show it. an SMP build shows veic on the g-140w-c. the fix still matters for openwrt because the en751221 kernel is built without IRQ_EI and always takes the non-VEIC path. |
The Nokia G-140W-C is a GPON ONT with four gigabit LAN ports and
dual-band Wi-Fi, which ISPs in India such as ACT Fibernet and Tata Play
Fiber supply.
Hardware:
- SoC: EcoNet EN7526G (EN751221 family), MIPS 34Kc, 2 threads, 900 MHz
- RAM: 512 MiB DDR3 (Linux can use the first 0x1b800000 bytes)
- Flash: 256 MiB SPI-NAND (Winbond W25M02GV or Toshiba TC58CVG1S3H)
with the vendor BMT
- Ethernet: 4x 1 GbE on ports 1-4 of the MT7530 module in the SoC,
linked over TRGMII to the on-die switch
- Wi-Fi 2.4 GHz: MT7592 (mt7603), 2x2 802.11n, on PCIe RC0
- Wi-Fi 5 GHz: MT7612E (mt76x2), 2x2 802.11ac, on PCIe RC1
- USB: 2 ports (xHCI)
- LEDs: power, PON, LOS, Internet, phone and USB on GPIOs; 2.4 GHz
WLAN on the MT7592 LED pin
- Buttons: reset (GPIO 0), LED on/off (GPIO 5)
- Serial: 3-pin header at the board edge next to the USB ports. From
the pin marked with an arrow: TX, RX, GND. 3.3 V, 115200 8N1
- Power: 12 V DC, 1.5 A
Not supported: GPON and VoIP (closed vendor drivers).
MAC addresses, from the base address at 0x3e in the "ri" partition
(the value the stock ritool reports as MACAddress):
- LAN: base
- WAN: base + 1
- 2.4 GHz: base + 9
- 5 GHz: base + 0xd
The flash layout and bootloader match the Nokia G-240G-E. OpenWrt goes
into firmware slot A ("tclinux"): a 4 MiB TRX kernel followed by UBI.
Stock stays in slot B, and en75_chboot switches between them. LAN4 is
the WAN port.
Unlike on the G-240G-E, the bootloader loads its second stage (the
"bootram", with the bldr> prompt) from the slot it boots: an LZMA blob
after the kernel and rootfs in the slot's TRX, whose length is in the
TRX header. Without it the bootloader crashes and only falls back to
the other slot after nine failed boots. The bootram is Nokia's code, so
the image doesn't carry it: sysupgrade copies it from the router, from
slot A or else from the stock firmware in slot B, puts it at 0x3e0000
after the kernel and updates the TRX header to match. The image check
fails if no bootram can be found.
The bootloader also counts boots in the "flag" partition and switches
to the other slot when the count reaches nine. Stock clears it once it
has booted, and an init script does the same for OpenWrt.
The Wi-Fi calibration, a 512-byte EEPROM table per radio, exists only
as two files in the stock settings, on the UBIFS volume of the "config"
partition; the radios' efuses are nearly empty. sysupgrade copies the
tables into a static UBI volume, "calibration", next to the root
filesystem, and the device tree passes them to mt76 as NVMEM cells. To
read them it attaches the stock UBI, which is read-only in the device
tree, and mounts it read-only. The volume has to exist before
rootfs_data, which takes all the free space: if it is missing,
rootfs_data is removed first, since nand_do_upgrade recreates it.
Slot A has no BMT remapping. With it, a read error in old stock data
makes the BMT driver remap the block, and the bootloader redoes such a
remap on every boot once UBI has erased the replacement block, wiping
UBI data. Test images had remapped blocks 36-58 of the reference unit
that way, so UBI starts at block 59.
GRO is off on the switch ports by default. econet-eth has no checksum or
scatter-gather offload, so the CPU would split and checksum every merged
packet again before forwarding it: downloads through the device ran at
97 Mbit/s with GRO and 111 Mbit/s without.
Installation, over the serial console:
1. Connect a PC to LAN1, LAN2 or LAN3 and leave LAN4 (WAN) unplugged.
2. Power on the router and press any key within 1 second to get the
bldr> prompt. On some ISP units the prompt is password-protected,
and the ISP has to provide the password.
3. Run "xmdm 80020000 <image size in hex>" and send
openwrt-econet-en751221-nokia_g140w-c-initramfs-kernel.bin with
XMODEM-CRC right away (it takes about 18 minutes), then run
"jump 80020000".
4. OpenWrt comes up at 192.168.1.1. Back up the partitions, for
example with "cat /dev/mtdN" over SSH.
5. Copy openwrt-econet-en751221-nokia_g140w-c-squashfs-sysupgrade.bin
to /tmp and run "sysupgrade -n" with it. Before writing, it copies
the bootram and the Wi-Fi calibration from the router and selects
slot A with en75_chboot.
There is no factory image, since slot A needs the bootram, which only
the router has.
Reverting to stock: "en75_chboot factory; reboot" boots the stock
firmware from slot B with its old settings. To return, boot the
initramfs image as above and run "en75_chboot openwrt" and power-cycle,
or run sysupgrade again.
Tested on two G-140W-C units. With the DSA support from the commits
before this one, from a RAM-booted image (an earlier version of it on
the first unit):
- first unit: a client on LAN1 and LAN4 as WAN with DHCP, the WAN
LEDs, routing a 100 Mbit/s line at full speed, and 50 reloads of the
switch drivers, each followed by a clean TRGMII link
- second unit: a client on LAN1 and LAN4 as WAN with DHCP, TCP from
the device to the client at 177 Mbit/s, and 10 reloads of the switch
drivers with all TRGMII lanes calibrated each time and no CRC errors
or drops on the CPU port
The full-speed routing needs the RX alignment change in econet_eth PR
openwrt#17: without it, emulated unaligned header accesses limit routing to
about 60 Mbit/s.
The second unit then ran it installed in slot A, with econet_eth PR openwrt#17,
512 RX descriptors and the interrupt fix from OpenWrt PR openwrt#26744 on top,
after a sysupgrade -n from the earlier setup below: it booted from flash
with the same TRGMII calibration and routed for an hour with no new
kernel warnings and no CRC errors or drops on the CPU port.
Before that, with the same device support on an earlier switch driver
setup, installed in slot A: Wi-Fi on both bands, both USB ports (storage
and Android tethering), booting from flash with settings kept across
reboots and the boot count cleared on each boot, sysupgrade of the
installed system with settings kept, switching to stock with en75_chboot
factory and back, and a sysupgrade from the RAM-booted initramfs that
created the calibration volume, after which both radios used the same
calibration as with the tables in the device tree. On the second unit,
which had never run OpenWrt, that install went the same way from its
stock firmware in slot A.
Signed-off-by: Akshat Singh <[email protected]>
The Nokia G-140W-C is a GPON ONT with four gigabit LAN ports and
dual-band Wi-Fi, which ISPs in India such as ACT Fibernet and Tata Play
Fiber supply.
Hardware:
- SoC: EcoNet EN7526G (EN751221 family), MIPS 34Kc, 2 threads, 900 MHz
- RAM: 512 MiB DDR3 (Linux can use the first 0x1b800000 bytes)
- Flash: 256 MiB SPI-NAND (Winbond W25M02GV or Toshiba TC58CVG1S3H)
with the vendor BMT
- Ethernet: 4x 1 GbE on ports 1-4 of the MT7530 module in the SoC,
linked over TRGMII to the on-die switch
- Wi-Fi 2.4 GHz: MT7592 (mt7603), 2x2 802.11n, on PCIe RC0
- Wi-Fi 5 GHz: MT7612E (mt76x2), 2x2 802.11ac, on PCIe RC1
- USB: 2 ports (xHCI)
- LEDs: power, PON, LOS, Internet, phone and USB on GPIOs; 2.4 GHz
WLAN on the MT7592 LED pin
- Buttons: reset (GPIO 0), LED on/off (GPIO 5)
- Serial: 3-pin header at the board edge next to the USB ports. From
the pin marked with an arrow: TX, RX, GND. 3.3 V, 115200 8N1
- Power: 12 V DC, 1.5 A
Not supported: GPON and VoIP (closed vendor drivers).
MAC addresses, from the base address at 0x3e in the "ri" partition
(the value the stock ritool reports as MACAddress):
- LAN: base
- WAN: base + 1
- 2.4 GHz: base + 9
- 5 GHz: base + 0xd
The flash layout and bootloader match the Nokia G-240G-E. OpenWrt goes
into firmware slot A ("tclinux"): a 4 MiB TRX kernel followed by UBI.
Stock stays in slot B, and en75_chboot switches between them. LAN4 is
the WAN port.
Unlike on the G-240G-E, the bootloader loads its second stage (the
"bootram", with the bldr> prompt) from the slot it boots: an LZMA blob
after the kernel and rootfs in the slot's TRX, whose length is in the
TRX header. Without it the bootloader crashes and only falls back to
the other slot after nine failed boots. The bootram is Nokia's code, so
the image doesn't carry it: sysupgrade copies it from the router, from
slot A or else from the stock firmware in slot B, puts it at 0x3e0000
after the kernel and updates the TRX header to match. The image check
fails if no bootram can be found.
The bootloader also counts boots in the "flag" partition and switches
to the other slot when the count reaches nine. Stock clears it once it
has booted, and an init script does the same for OpenWrt.
The Wi-Fi calibration, a 512-byte EEPROM table per radio, exists only
as two files in the stock settings, on the UBIFS volume of the "config"
partition; the radios' efuses are nearly empty. sysupgrade copies the
tables into a static UBI volume, "calibration", next to the root
filesystem, and the device tree passes them to mt76 as NVMEM cells. To
read them it attaches the stock UBI, which is read-only in the device
tree, and mounts it read-only. The volume has to exist before
rootfs_data, which takes all the free space: if it is missing,
rootfs_data is removed first, since nand_do_upgrade recreates it.
Slot A has no BMT remapping. With it, a read error in old stock data
makes the BMT driver remap the block, and the bootloader redoes such a
remap on every boot once UBI has erased the replacement block, wiping
UBI data. Test images had remapped blocks 36-58 of the reference unit
that way, so UBI starts at block 59.
GRO is off on the switch ports by default. econet-eth has no checksum or
scatter-gather offload, so the CPU would split and checksum every merged
packet again before forwarding it: downloads through the device ran at
97 Mbit/s with GRO and 111 Mbit/s without.
Installation, over the serial console:
1. Connect a PC to LAN1, LAN2 or LAN3 and leave LAN4 (WAN) unplugged.
2. Power on the router and press any key within 1 second to get the
bldr> prompt. On some ISP units the prompt is password-protected,
and the ISP has to provide the password.
3. Run "xmdm 80020000 <image size in hex>" and send
openwrt-econet-en751221-nokia_g140w-c-initramfs-kernel.bin with
XMODEM-CRC right away (it takes about 18 minutes), then run
"jump 80020000".
4. OpenWrt comes up at 192.168.1.1. Back up the partitions, for
example with "cat /dev/mtdN" over SSH.
5. Copy openwrt-econet-en751221-nokia_g140w-c-squashfs-sysupgrade.bin
to /tmp and run "sysupgrade -n" with it. Before writing, it copies
the bootram and the Wi-Fi calibration from the router and selects
slot A with en75_chboot.
There is no factory image, since slot A needs the bootram, which only
the router has.
Reverting to stock: "en75_chboot factory; reboot" boots the stock
firmware from slot B with its old settings. To return, boot the
initramfs image as above and run "en75_chboot openwrt" and power-cycle,
or run sysupgrade again.
Tested on two G-140W-C units. With the DSA support from the commits
before this one, from a RAM-booted image (an earlier version of it on
the first unit):
- first unit: a client on LAN1 and LAN4 as WAN with DHCP, the WAN
LEDs, routing a 100 Mbit/s line at full speed, and 50 reloads of the
switch drivers, each followed by a clean TRGMII link
- second unit: a client on LAN1 and LAN4 as WAN with DHCP, TCP from
the device to the client at 177 Mbit/s, and 10 reloads of the switch
drivers with all TRGMII lanes calibrated each time and no CRC errors
or drops on the CPU port
The full-speed routing needs the RX alignment change in econet_eth PR
openwrt#17: without it, emulated unaligned header accesses limit routing to
about 60 Mbit/s.
The second unit then ran it installed in slot A, with econet_eth PR openwrt#17,
512 RX descriptors and the interrupt fix from OpenWrt PR openwrt#26744 on top,
after a sysupgrade -n from the earlier setup below: it booted from flash
with the same TRGMII calibration and routed for an hour with no new
kernel warnings and no CRC errors or drops on the CPU port.
Before that, with the same device support on an earlier switch driver
setup, installed in slot A: Wi-Fi on both bands, both USB ports (storage
and Android tethering), booting from flash with settings kept across
reboots and the boot count cleared on each boot, sysupgrade of the
installed system with settings kept, switching to stock with en75_chboot
factory and back, and a sysupgrade from the RAM-booted initramfs that
created the calibration volume, after which both radios used the same
calibration as with the tables in the device tree. On the second unit,
which had never run OpenWrt, that install went the same way from its
stock firmware in slot A.
Signed-off-by: Akshat Singh <[email protected]>
the en751221 intc doesn't give each source its own cpu line. it puts the number of the pending irq plus one, in binary, on IP2-IP7, but the dtsi only chains it to IP2. so odd numbered irqs never interrupt the cpu on their own. they only get handled when an even one happens to run the handler, which on a quiet box is the next timer tick. that hits the qdma (21), xhci (17) and the first pcie port (23).
on a nokia g-140w-c (en7526g) this delayed rx by up to 10ms, ping to the router kept cycling through 1-11ms. with this it's under 1ms, and the qdma pending bit isn't found set anymore while the cpu is busy with other stuff.
the patch chains the handler to every line listed in "interrupts" and the dtsi now lists IP2-IP6. IP7 is left out because the cpu timer can use it too and only hwirq 31 (unused) would need it.
tested on the g-140w-c, it's been running on my home router for a couple days. I think this is also the 10-11ms ping sawtooth on the archer c5v in cjdelisle/econet_eth#15, and maybe why the tx done irq looked unreliable in cjdelisle/econet_eth#12.
one thing: the dt binding (econet,en751221-intc.yaml) says interrupts maxItems: 1, so for mainline the binding needs a bump too. @cjdelisle it's your driver, want me to send this to the kernel or would you rather take it?