]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
airoha: an7581: reserve NPU Wi-Fi regions only on Wi-Fi boards
authorVitaliy Sochnev <sochnev.v.74@gmail.com>
Fri, 7 Aug 2026 10:09:40 +0000 (11:09 +0100)
committerRobert Marko <robimarko@gmail.com>
Tue, 11 Aug 2026 10:14:23 +0000 (12:14 +0200)
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>
target/linux/airoha/dts/an7581-evb.dts
target/linux/airoha/dts/an7581-npu-mt7992.dtsi
target/linux/airoha/dts/an7581-npu-mt7996.dtsi
target/linux/airoha/dts/an7581-npu-wlan.dtsi [new file with mode: 0644]
target/linux/airoha/dts/an7581.dtsi

index 1d7b1a6a31654fec3a6dfff50b5906624022a1f8..4045eb104aafc1fedc6adc673539751f86a78e53 100644 (file)
@@ -8,6 +8,7 @@
 #include <dt-bindings/gpio/gpio.h>
 #include <dt-bindings/input/input.h>
 #include "an7581.dtsi"
+#include "an7581-npu-wlan.dtsi"
 
 / {
        model = "Airoha AN7581 Evaluation Board";
index 0985b7373491d40ef5dd014db647cab75adb2ade..3ab7051c66ad1fb1a7a01a65124778ad3aedfb0e 100644 (file)
@@ -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";
index 404e159a9ce61b433ad862e43ef9a1445de50664..24585be6c1dfda6547470c1c35038aa28aa8069f 100644 (file)
@@ -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 (file)
index 0000000..bbb1824
--- /dev/null
@@ -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";
+};
index fdefa82580b02e2b310913d45c59ecb85f5cc4e1..af5a5f4dae49ee9d313df9a2a7f87137f103d90e 100644 (file)
                        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 {
                                     <GIC_SPI 121 IRQ_TYPE_LEVEL_HIGH>,
                                     <GIC_SPI 122 IRQ_TYPE_LEVEL_HIGH>,
                                     <GIC_SPI 123 IRQ_TYPE_LEVEL_HIGH>;
-                       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";
                };