From: Lorenzo Bianconi <lorenzo@kernel.org>
To: Chris Scott <gilroyscott1970@gmail.com>
Cc: netdev@vger.kernel.org, andrew+netdev@lunn.ch,
davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
pabeni@redhat.com, robh@kernel.org, krzk+dt@kernel.org,
conor+dt@kernel.org, matthias.bgg@gmail.com,
angelogioacchino.delregno@collabora.com,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org, pawlik.dan@gmail.com,
zhengping.zhang@airoha.com
Subject: Re: [RFC net-next 2/3] net: airoha: npu: attach a coherent pool in the NPU window
Date: Mon, 26 Oct 2026 08:48:24 +0100 [thread overview]
Message-ID: <at8FyOLeaMlpS7mR@lore-desk> (raw)
In-Reply-To: <20261024154150.45733-3-gilroyscott1970@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 4109 bytes --]
> The EN7581 NPU can only address host DRAM at 0x80000000-0xbfffffff;
> higher addresses alias the lower 1 GiB. The coherent buffers allocated
> on the NPU device are all shared with the NPU: since mt76 uses the NPU
> device as dma_dev, these are the NPU TX/RX descriptor rings, the HW-RRO
> ba_bitmap/addr_elem/msdu_pg/session buffers and the NPU TXD buffers.
> On a 2 GiB board nothing keeps them below 0xc0000000; they normally
> land there only because of early-boot allocation order. With low DRAM
> reserved away on W1700K the SoC hangs right after mt7996 firmware load.
>
> If the NPU node has an optional "dma" reserved-memory region, attach it
> as the device coherent pool so all of these come from the window. The
> next patch moves the mailbox buffers to coherent memory as well.
>
> Unlike a restricted-dma-pool this leaves streaming mappings alone.
> Packet buffers are passed through to the WiFi DMA engine: on W1700K
> with 96% of TX skbs and ~20% of RX page_pool buffers above 0xc0000000,
> host-path traffic and sha256 file round-trips stay intact, at the same
> throughput as without a pool, whereas a restricted-dma-pool (swiotlb
> bouncing) costs ~22% of host-path TX.
>
> A device coherent pool has no fallback once full; mt76 and the mailbox
> use ~10.7 MiB with MT7996, so the DT region should be 16 MiB.
>
> This patch was written with the help of Claude (Anthropic, claude-
> opus-5-5).
>
> Link: https://lore.kernel.org/r/atCRsquzA1UxSpCc@mediatek.com
> Tested-by: Daniel Pawlik <pawlik.dan@gmail.com>
> Signed-off-by: Chris Scott <gilroyscott1970@gmail.com>
> ---
> drivers/net/ethernet/airoha/airoha_npu.c | 18 ++++++++++++++++++
> 1 file changed, 18 insertions(+)
>
> diff --git a/drivers/net/ethernet/airoha/airoha_npu.c b/drivers/net/ethernet/airoha/airoha_npu.c
> index 4d3195eb00..069fd60680 100644
> --- a/drivers/net/ethernet/airoha/airoha_npu.c
> +++ b/drivers/net/ethernet/airoha/airoha_npu.c
> @@ -693,6 +693,11 @@ static const struct regmap_config regmap_config = {
> .disable_locking = true,
> };
>
> +static void airoha_npu_rmem_release(void *data)
> +{
> + of_reserved_mem_device_release(data);
> +}
> +
> static int airoha_npu_probe(struct platform_device *pdev)
> {
> struct device *dev = &pdev->dev;
> @@ -776,6 +781,19 @@ static int airoha_npu_probe(struct platform_device *pdev)
> if (err)
> return err;
>
> + if (of_property_match_string(dev->of_node, "memory-region-names",
> + "dma") >= 0) {
> + err = of_reserved_mem_device_init_by_name(dev, dev->of_node,
> + "dma");
> + if (err)
> + return err;
> +
> + err = devm_add_action_or_reset(dev, airoha_npu_rmem_release,
> + dev);
> + if (err)
> + return err;
> + }
nit: what about creating a dedicated routine for both firmware and dma
memory regions. Something like:
diff --git a/drivers/net/ethernet/airoha/airoha_npu.c b/drivers/net/ethernet/airoha/airoha_npu.c
index 4d3195eb00f7..9c9c754f82c7 100644
--- a/drivers/net/ethernet/airoha/airoha_npu.c
+++ b/drivers/net/ethernet/airoha/airoha_npu.c
@@ -693,6 +693,23 @@ static const struct regmap_config regmap_config = {
.disable_locking = true,
};
+static int airoha_npu_reserve_mem_region(struct device *dev,
+ struct resource *res)
+{
+ int err;
+
+ err = of_reserved_mem_region_to_resource(dev->of_node, 0, res);
+ if (err)
+ return err;
+
+ if (of_property_match_string(dev->of_node, "memory-region-names",
+ "dma" >= 0)) {
+ ...
+ }
+
+ return 0;
+}
+
static int airoha_npu_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
@@ -729,7 +746,7 @@ static int airoha_npu_probe(struct platform_device *pdev)
if (IS_ERR(npu->regmap))
return PTR_ERR(npu->regmap);
- err = of_reserved_mem_region_to_resource(dev->of_node, 0, &res);
+ err = airoha_npu_reserve_mem_region(dev, &res);
if (err)
return err;
Regards,
Lorenzo
> +
> err = airoha_npu_run_firmware(dev, base, &res);
> if (err)
> return err;
> --
> 2.53.0
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2026-10-26 7:48 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-24 15:41 [RFC net-next 0/3] net: airoha: npu: keep NPU-shared DMA buffers in the NPU window Chris Scott
2026-10-24 15:41 ` [RFC net-next 1/3] dt-bindings: net: airoha: npu: add DMA pool memory region Chris Scott
2026-10-25 15:42 ` sashiko-bot
2026-10-24 15:41 ` [RFC net-next 2/3] net: airoha: npu: attach a coherent pool in the NPU window Chris Scott
2026-10-26 7:48 ` Lorenzo Bianconi [this message]
2026-10-27 5:10 ` Chris Scott
2026-10-24 15:41 ` [RFC net-next 3/3] net: airoha: npu: use coherent memory for mailbox messages Chris Scott
2026-10-26 7:50 ` Lorenzo Bianconi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=at8FyOLeaMlpS7mR@lore-desk \
--to=lorenzo@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=angelogioacchino.delregno@collabora.com \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@kernel.org \
--cc=gilroyscott1970@gmail.com \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pawlik.dan@gmail.com \
--cc=robh@kernel.org \
--cc=zhengping.zhang@airoha.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.