mirror of
https://github.com/openwrt/openwrt.git
synced 2026-10-14 00:07:09 +04:00
an7581.dtsi reserves five no-map regions for the NPU and hands all of them to the npu node. Four of them - pkt, tx-pkt, tx-bufid and ba, 110 MiB plus 26 KiB - are consumed only by airoha_npu_wlan_init_memory(), which the mt76 NPU layer calls when it attaches an Airoha-offloaded Wi-Fi chip. To run its firmware and to offload flows the NPU needs the binary region alone, and the driver looks that one up by index rather than by name. Boards that bind no Wi-Fi chip to the NPU therefore lose 110 MiB of DRAM for nothing, and they lose it whether or not the NPU probes at all: the memory is carved out by the reserved-memory node itself. On AN7581 that is both Nokia XG-040G-MD variants. an7583.dtsi already does this correctly and reserves npu_binary only. Move the four regions into a new an7581-npu-wlan.dtsi and include it from the two NPU overlays the Wi-Fi boards already pull in, so that the regions and the full memory-region list follow the Wi-Fi chip instead of the SoC. an7581-evb includes the new overlay directly instead. It declares two mediatek,mt76 nodes with airoha,npu and enables the NPU, but pins no particular chip because the card goes into a PCIe slot, so it is the one board using the offload that pulls in neither NPU overlay. Keep the ba region on all four Wi-Fi boards even though it is described as MT7996-only. It is already optional in the driver, but narrowing it down to MT7996 would change behaviour on Kite, so leave that for a separate change. Verified by building the device trees before and after: the DTBs of an7581-evb, an7581-evb-emmc-eagle, an7581-evb-emmc-kite, an7581-nokia-valyrian and an7581-w1700k-ubi are byte for byte identical, while an7581-nokia_xg-040g-md and an7581-nokia_xg-040g-md-ubi each shrink by 376 bytes and lose the four regions. Tested on a Nokia XG-040G-MD. Reserved memory drops from 197296K to 84400K and MemTotal rises from 325900 kB to 438736 kB, 110 MiB given back. The NPU still comes up on the binary region alone and reports "NPU fw version: 1456.62", so dropping the four regions costs the board neither the NPU nor its flow offloading. Not tested on Wi-Fi hardware, where the argument rests on the DTBs being unchanged. Signed-off-by: Vitaliy Sochnev <sochnev.v.74@gmail.com> Link: https://github.com/openwrt/openwrt/pull/24593 Signed-off-by: Robert Marko <robimarko@gmail.com>