From: "Jan Petrous (OSS)" <jan.petrous@oss.nxp.com>
Read IRQ resources for all rx/tx channels, to allow Multi-IRQ mode
for platform glue drivers.
Reviewed-by: Matthias Brugger <mbrugger@suse.com>
Signed-off-by: Jan Petrous (OSS) <jan.petrous@oss.nxp.com>
---
.../net/ethernet/stmicro/stmmac/stmmac_platform.c | 38 +++++++++++++++++++++-
1 file changed, 37 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index 8979a50b5507..94854bfb6e0d 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -700,6 +700,9 @@ EXPORT_SYMBOL_GPL(stmmac_pltfr_find_clk);
int stmmac_get_platform_resources(struct platform_device *pdev,
struct stmmac_resources *stmmac_res)
{
+ char name[16];
+ int i;
+
memset(stmmac_res, 0, sizeof(*stmmac_res));
/* Get IRQ information early to have an ability to ask for deferred
@@ -743,7 +746,40 @@ 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);
+
+ /* RX channels irq */
+ for (i = 0; i < MTL_MAX_RX_QUEUES; i++) {
+ scnprintf(name, sizeof(name), "rx-queue-%d", i);
+ stmmac_res->rx_irq[i] = platform_get_irq_byname_optional(pdev,
+ name);
+ if (stmmac_res->rx_irq[i] <= 0) {
+ if (stmmac_res->rx_irq[i] == -EPROBE_DEFER)
+ return -EPROBE_DEFER;
+ dev_dbg(&pdev->dev, "IRQ rx-queue-%d not found\n", i);
+
+ /* Stop on first unset rx-queue-%i property member */
+ break;
+ }
+ }
+
+ /* TX channels irq */
+ for (i = 0; i < MTL_MAX_TX_QUEUES; i++) {
+ scnprintf(name, sizeof(name), "tx-queue-%d", i);
+ stmmac_res->tx_irq[i] = platform_get_irq_byname_optional(pdev,
+ name);
+ if (stmmac_res->tx_irq[i] <= 0) {
+ if (stmmac_res->tx_irq[i] == -EPROBE_DEFER)
+ return -EPROBE_DEFER;
+ dev_dbg(&pdev->dev, "IRQ tx-queue-%d not found\n", i);
+
+ /* Stop on first unset tx-queue-%i property member */
+ break;
+ }
+ }
+
+ return 0;
}
EXPORT_SYMBOL_GPL(stmmac_get_platform_resources);
--
2.47.0
This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
---
net: stmmac: platform: read channels irq
This patch reads IRQ resources for all rx/tx channels to allow Multi-IRQ
mode for platform glue drivers.
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
> index 8979a50b5507..94854bfb6e0d 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
[ ... ]
> + /* RX channels irq */
> + for (i = 0; i < MTL_MAX_RX_QUEUES; i++) {
> + scnprintf(name, sizeof(name), "rx-queue-%d", i);
> + stmmac_res->rx_irq[i] = platform_get_irq_byname_optional(pdev,
> + name);
> + if (stmmac_res->rx_irq[i] <= 0) {
> + if (stmmac_res->rx_irq[i] == -EPROBE_DEFER)
> + return -EPROBE_DEFER;
> + dev_dbg(&pdev->dev, "IRQ rx-queue-%d not found\n", i);
> +
> + /* Stop on first unset rx-queue-%i property member */
> + break;
> + }
> + }
When platform_get_irq_byname_optional() returns a negative error like
-ENXIO, that value is stored in stmmac_res->rx_irq[i] before the break.
In stmmac_request_irq_multi_msi(), the check is:
if (priv->rx_irq[i] == 0)
continue;
ret = request_irq(priv->rx_irq[i], ...);
Should the negative value be cleared before the break? Otherwise if
rx_queues_to_use exceeds the number of defined IRQs, the negative error
code could be passed to request_irq().
> +
> + /* TX channels irq */
> + for (i = 0; i < MTL_MAX_TX_QUEUES; i++) {
> + scnprintf(name, sizeof(name), "tx-queue-%d", i);
> + stmmac_res->tx_irq[i] = platform_get_irq_byname_optional(pdev,
> + name);
> + if (stmmac_res->tx_irq[i] <= 0) {
> + if (stmmac_res->tx_irq[i] == -EPROBE_DEFER)
> + return -EPROBE_DEFER;
> + dev_dbg(&pdev->dev, "IRQ tx-queue-%d not found\n", i);
> +
> + /* Stop on first unset tx-queue-%i property member */
> + break;
> + }
> + }
Same question here for tx_irq[i].
--
pw-bot: cr
© 2016 - 2026 Red Hat, Inc.