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>
#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";
// 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";
// 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";
--- /dev/null
+// 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";
+};
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";
};