From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E6F3230E820; Thu, 26 Feb 2026 19:10:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772133048; cv=none; b=NPT3SkIX+BwzW0hgEFtD6yKJSBongtUlikX1CL1HmwebJcnDzckEPFMG7/52naige8C8j7Itk8PtOg8GGnDQQgRRs4fGlmxD1UHkzeXsJalyU5PBPdvDDwWz2vQJ78OGWti77ACaAIxYyv6DB3F/+t8gPijlLRzERUaLLYmV7po= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772133048; c=relaxed/simple; bh=1IzP64jz/SkcJX5dvo8R+ulnS8fQwbekOalpkBEHnII=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Gi9O4ontiPdPbsuNHjeNxnm4agOKEemPOgm955rfcfKG4BGxANlEWavz6qvr95LXA1IdPhSZllUpjysYuXhLeRrLJ/2HAhUik7w5atTLQSC3zaAOyO2Ert5pfR0w146qrl685Emf2heXo+FxA/nExjeDxpNKHHTQeasykqUtqnQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=Uuo9qJeA; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="Uuo9qJeA" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=HjiR1TwqXK5Qwrd2T9B+rxf4jSStXBuyud6ZyusRPjc=; b=Uuo9qJeAxZxhSDQvCG2THyfgn6 goN/SZ5wYmb4g5wzXTMlNaPWkQqKj7uB/6w566SYrPrujxs50sfZYENwPPn3t9yfpjvYbPXUlilqs 8efDz3idaa358SjlUOzL6LOYivhtxwyWu6qwu3GnzrfJyZW8mWfOAmfqaObgWxP9unvufSwvsMrOf edMti+IBUeaF7wa0m+Tt/d92YkneueFcO8a80EDhHf73MxhTIn4vGXNBuZxqaS/gxlDyEiqUPTdNd 5T+8sKrFrKX+VM2XS0Y+YFMS15vuekaYIfoUBiFJ/j1X7MnCd4/6ap/QOzc5nMk2L1DHkyOZq4WYj fIDgys9g==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:50450) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vvgkl-000000008Lp-1Mml; Thu, 26 Feb 2026 19:10:27 +0000 Received: from linux by shell.armlinux.org.uk with local (Exim 4.98.2) (envelope-from ) id 1vvgkg-000000002GM-2Yxa; Thu, 26 Feb 2026 19:10:22 +0000 Date: Thu, 26 Feb 2026 19:10:22 +0000 From: "Russell King (Oracle)" To: jan.petrous@oss.nxp.com Cc: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Alexandre Torgue , Chester Lin , Matthias Brugger , Ghennadi Procopciuc , NXP S32 Linux Team , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Frank Li , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, devicetree@vger.kernel.org, vladimir.oltean@nxp.com, boon.khai.ng@altera.com Subject: Re: [PATCH v7 2/5] net: stmmac: platform: read channels irq Message-ID: References: <20260226-dwmac_multi_irq-v7-0-f8fe3b945bb4@oss.nxp.com> <20260226-dwmac_multi_irq-v7-2-f8fe3b945bb4@oss.nxp.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260226-dwmac_multi_irq-v7-2-f8fe3b945bb4@oss.nxp.com> Sender: Russell King (Oracle) On Thu, Feb 26, 2026 at 09:54:07AM +0100, Jan Petrous via B4 Relay wrote: > From: "Jan Petrous (OSS)" > > Read IRQ resources for all rx/tx channels, to allow Multi-IRQ mode > for platform glue drivers. > > Reviewed-by: Matthias Brugger > Signed-off-by: Jan Petrous (OSS) > --- > .../net/ethernet/stmicro/stmmac/stmmac_platform.c | 46 +++++++++++++++++++++- > 1 file changed, 45 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c > index 5c9fd91a1db9..93bd915ab6eb 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c > @@ -697,9 +697,40 @@ struct clk *stmmac_pltfr_find_clk(struct plat_stmmacenet_data *plat_dat, > } > EXPORT_SYMBOL_GPL(stmmac_pltfr_find_clk); > > +static int stmmac_pltfr_get_queue_irqs(struct platform_device *pdev, > + struct stmmac_resources *stmmac_res, > + bool tx) > +{ > + int *irqs = tx ? &stmmac_res->tx_irq[0] : &stmmac_res->rx_irq[0]; > + char name[16]; > + int i; > + > + /* RX channels irq */ > + STMMAC_FOREACH_MTL_QUEUE(i, MTL_MAX_RX_QUEUES) { You've missed that there are two separate definitions for tx and rx queues - while they are currently the same number, code shouldn't make that assumption. > + scnprintf(name, sizeof(name), "%cx-queue-%d", > + tx ? 't' : 'r', i); I'm not happy with this method of combining the two loops. Maybe instead: static int stmmac_pltfr_get_irq_array(struct platform_device *pdev, const char *fmt, int *irqs, size_t num) { char name[16]; size_t i; for (i = 0; i < num; i++) { if (snprintf(name, sizeof(name), fmt, i) >= sizeof(name)) return -EINVAL; irqs[i] = platform_get_irq_byname_optional(pdev, name); if (irqs[i] == -EPROBE_DEFER) { return irqs[i]; } else if (irqs[i] <= 0) { dev_dbg(&pdev->dev, "IRQ %s not found\n", name); irqs[i] = 0; break; } } return 0; } which has the advantage that it becomes a generic helper for getting an any array of IRQs. > int stmmac_get_platform_resources(struct platform_device *pdev, > struct stmmac_resources *stmmac_res) > { > + int ret; > + > memset(stmmac_res, 0, sizeof(*stmmac_res)); > > /* Get IRQ information early to have an ability to ask for deferred > @@ -735,7 +766,20 @@ int stmmac_get_platform_resources(struct platform_device *pdev, > > stmmac_res->addr = devm_platform_ioremap_resource(pdev, 0); > > - return PTR_ERR_OR_ZERO(stmmac_res->addr); > + if (IS_ERR(stmmac_res->addr)) > + return PTR_ERR(stmmac_res->addr); > + > + /* TX channels irq */ > + ret = stmmac_pltfr_get_queue_irqs(pdev, stmmac_res, true); > + if (ret) > + return ret; > + > + /* RX channels irq */ > + ret = stmmac_pltfr_get_queue_irqs(pdev, stmmac_res, false); > + if (ret) > + return ret; These then become: ret = stmmac_pltfr_get_irq_array(pdev, "tx-queue-%d", stmmac_res->tx_irq, MTL_MAX_TX_QUEUES); if (ret) return ret; ret = stmmac_pltfr_get_irq_array(pdev, "rx-queue-%d", stmmac_res->rx_irq, MTL_MAX_RX_QUEUES); if (ret) return ret; This has the advantage that one can grep for rx-queue to find it, and we also use the correct limit for each queue type. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!