From: Vitaliy Sochnev Date: Fri, 7 Aug 2026 10:09:40 +0000 (+0100) Subject: airoha: an7581: reserve NPU Wi-Fi regions only on Wi-Fi boards X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ab2dc6ab166a97d4e610ce6d1850ab8e66eabdd2;p=thirdparty%2Fopenwrt.git airoha: an7581: reserve NPU Wi-Fi regions only on Wi-Fi boards 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 Link: https://github.com/openwrt/openwrt/pull/24593 Signed-off-by: Robert Marko --- diff --git a/target/linux/airoha/dts/an7581-evb.dts b/target/linux/airoha/dts/an7581-evb.dts index 1d7b1a6a316..4045eb104aa 100644 --- a/target/linux/airoha/dts/an7581-evb.dts +++ b/target/linux/airoha/dts/an7581-evb.dts @@ -8,6 +8,7 @@ #include #include #include "an7581.dtsi" +#include "an7581-npu-wlan.dtsi" / { model = "Airoha AN7581 Evaluation Board"; diff --git a/target/linux/airoha/dts/an7581-npu-mt7992.dtsi b/target/linux/airoha/dts/an7581-npu-mt7992.dtsi index 0985b737349..3ab7051c66a 100644 --- a/target/linux/airoha/dts/an7581-npu-mt7992.dtsi +++ b/target/linux/airoha/dts/an7581-npu-mt7992.dtsi @@ -1,5 +1,7 @@ // SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +#include "an7581-npu-wlan.dtsi" + &npu { firmware-name = "airoha/en7581_npu_rv32.bin", "airoha/en7581_npu_data.bin"; diff --git a/target/linux/airoha/dts/an7581-npu-mt7996.dtsi b/target/linux/airoha/dts/an7581-npu-mt7996.dtsi index 404e159a9ce..24585be6c1d 100644 --- a/target/linux/airoha/dts/an7581-npu-mt7996.dtsi +++ b/target/linux/airoha/dts/an7581-npu-mt7996.dtsi @@ -1,5 +1,7 @@ // SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +#include "an7581-npu-wlan.dtsi" + &npu { firmware-name = "airoha/en7581_MT7996_npu_rv32.bin", "airoha/en7581_MT7996_npu_data.bin"; diff --git a/target/linux/airoha/dts/an7581-npu-wlan.dtsi b/target/linux/airoha/dts/an7581-npu-wlan.dtsi new file mode 100644 index 00000000000..bbb1824fd6c --- /dev/null +++ b/target/linux/airoha/dts/an7581-npu-wlan.dtsi @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) + +/* + * Memory regions used by the NPU Wi-Fi packet offloading only. Boards that + * do not run an Airoha-offloaded Wi-Fi chip must not reserve them: the NPU + * needs the binary region alone to run its firmware and to offload flows. + */ + +/ { + reserved-memory { + #address-cells = <2>; + #size-cells = <2>; + ranges; + + npu_pkt: npu-pkt@8a000000 { + no-map; + reg = <0x0 0x8a000000 0x0 0x2c00000>; + }; + + npu_txpkt: npu-txpkt@8cc00000 { + no-map; + reg = <0x0 0x8cc00000 0x0 0x4000000>; + }; + + npu_txbufid: npu-txbufid@90c00000 { + no-map; + reg = <0x0 0x90c00000 0x0 0x6800>; + }; + + npu_ba: npu-ba@90c06800 { + no-map; + reg = <0x0 0x90c06800 0x0 0x200000>; + }; + }; +}; + +&npu { + memory-region = <&npu_binary>, <&npu_pkt>, <&npu_txpkt>, + <&npu_txbufid>, <&npu_ba>; + memory-region-names = "binary", "pkt", "tx-pkt", + "tx-bufid", "ba"; +}; diff --git a/target/linux/airoha/dts/an7581.dtsi b/target/linux/airoha/dts/an7581.dtsi index fdefa82580b..af5a5f4dae4 100644 --- a/target/linux/airoha/dts/an7581.dtsi +++ b/target/linux/airoha/dts/an7581.dtsi @@ -39,26 +39,6 @@ no-map; reg = <0x0 0x89000000 0x0 0x1000000>; }; - - npu_pkt: npu-pkt@8a000000 { - no-map; - reg = <0x0 0x8a000000 0x0 0x2c00000>; - }; - - npu_txpkt: npu-txpkt@8cc00000 { - no-map; - reg = <0x0 0x8cc00000 0x0 0x4000000>; - }; - - npu_txbufid: npu-txbufid@90c00000 { - no-map; - reg = <0x0 0x90c00000 0x0 0x6800>; - }; - - npu_ba: npu-ba@90c06800 { - no-map; - reg = <0x0 0x90c06800 0x0 0x200000>; - }; }; psci { @@ -904,10 +884,9 @@ , , ; - memory-region = <&npu_binary>, <&npu_pkt>, <&npu_txpkt>, - <&npu_txbufid>, <&npu_ba>; - memory-region-names = "binary", "pkt", "tx-pkt", - "tx-bufid", "ba"; + memory-region = <&npu_binary>; + memory-region-names = "binary"; + status = "disabled"; };