From: Simon Horman <horms@kernel.org>
To: Daniel Golle <daniel@makrotopia.org>
Cc: Felix Fietkau <nbd@nbd.name>,
Frank Wunderlich <frank-w@public-files.de>,
Eric Woudstra <ericwouds@gmail.com>,
Elad Yifee <eladwf@gmail.com>,
Bo-Cun Chen <bc-bocun.chen@mediatek.com>,
Sky Huang <skylake.huang@mediatek.com>,
Sean Wang <sean.wang@mediatek.com>,
Lorenzo Bianconi <lorenzo@kernel.org>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Matthias Brugger <matthias.bgg@gmail.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org
Subject: Re: [PATCH net-next v2 3/3] net: ethernet: mtk_eth_soc: use genpool allocator for SRAM
Date: Mon, 30 Jun 2025 17:29:59 +0100 [thread overview]
Message-ID: <20250630162959.GA57523@horms.kernel.org> (raw)
In-Reply-To: <61897c7a3dcc0b2976ec2118226c06c220b00a80.1751229149.git.daniel@makrotopia.org>
On Sun, Jun 29, 2025 at 11:22:44PM +0100, Daniel Golle wrote:
> Use a dedicated "mmio-sram" and the genpool allocator instead of
> open-coding SRAM allocation for DMA rings.
> Keep support for legacy device trees but notify the user via a
> warning to update.
>
> Co-developed-by: Frank Wunderlich <frank-w@public-files.de>
> Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
> Signed-off-by: Daniel Golle <daniel@makrotopia.org>
> ---
> v2: fix return type of mtk_dma_ring_alloc() in case of error
>
> drivers/net/ethernet/mediatek/mtk_eth_soc.c | 120 +++++++++++++-------
> drivers/net/ethernet/mediatek/mtk_eth_soc.h | 4 +-
> 2 files changed, 84 insertions(+), 40 deletions(-)
>
> diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
...
> @@ -5117,16 +5148,27 @@ static int mtk_probe(struct platform_device *pdev)
> err = -EINVAL;
> goto err_destroy_sgmii;
> }
> +
> if (MTK_HAS_CAPS(eth->soc->caps, MTK_SRAM)) {
> - if (mtk_is_netsys_v3_or_greater(eth)) {
> - res_sram = platform_get_resource(pdev, IORESOURCE_MEM, 1);
> - if (!res_sram) {
> - err = -EINVAL;
> - goto err_destroy_sgmii;
> + eth->sram_pool = of_gen_pool_get(pdev->dev.of_node, "sram", 0);
> + if (!eth->sram_pool) {
> + if (!mtk_is_netsys_v3_or_greater(eth)) {
> + /*
> + * Legacy support for missing 'sram' node in DT.
> + * SRAM is actual memory and supports transparent access
> + * just like DRAM. Hence we don't require __iomem being
> + * set and don't need to use accessor functions to read from
> + * or write to SRAM.
> + */
> + eth->sram_base = (void __force *)eth->base +
> + MTK_ETH_SRAM_OFFSET;
> + eth->phy_scratch_ring = res->start + MTK_ETH_SRAM_OFFSET;
> + dev_warn(&pdev->dev,
> + "legacy DT: using hard-coded SRAM offset.\n");
> + } else {
> + dev_err(&pdev->dev, "Could not get SRAM pool\n");
> + return -ENODEV;
Hi Daniel,
Rather than returning, should this
jump to err_destroy_sgmii to avoid leaking resources?
Flagged by Smatch.
> }
> - eth->phy_scratch_ring = res_sram->start;
> - } else {
> - eth->phy_scratch_ring = res->start + MTK_ETH_SRAM_OFFSET;
> }
> }
> }
next prev parent reply other threads:[~2025-06-30 17:46 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-29 22:21 [PATCH net-next v2 0/3] net: ethernet: mtk_eth_soc: improve device tree handling Daniel Golle
2025-06-29 22:21 ` [PATCH net-next v2 1/3] net: ethernet: mtk_eth_soc: improve support for named interrupts Daniel Golle
2025-06-29 22:21 ` [PATCH net-next v2 2/3] net: ethernet: mtk_eth_soc: fix kernel-doc comment Daniel Golle
2025-06-29 22:22 ` [PATCH net-next v2 3/3] net: ethernet: mtk_eth_soc: use genpool allocator for SRAM Daniel Golle
2025-06-30 16:29 ` Simon Horman [this message]
2025-06-30 18:19 ` Daniel Golle
2025-07-01 12:51 ` Simon Horman
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=20250630162959.GA57523@horms.kernel.org \
--to=horms@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=angelogioacchino.delregno@collabora.com \
--cc=bc-bocun.chen@mediatek.com \
--cc=daniel@makrotopia.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=eladwf@gmail.com \
--cc=ericwouds@gmail.com \
--cc=frank-w@public-files.de \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=lorenzo@kernel.org \
--cc=matthias.bgg@gmail.com \
--cc=nbd@nbd.name \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sean.wang@mediatek.com \
--cc=skylake.huang@mediatek.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).