* [net-next v5 0/3] rework IRQ handling in mtk_eth_soc @ 2025-06-18 13:07 Frank Wunderlich 2025-06-18 13:07 ` [net-next v5 1/3] net: ethernet: mtk_eth_soc: support named IRQs Frank Wunderlich ` (2 more replies) 0 siblings, 3 replies; 11+ messages in thread From: Frank Wunderlich @ 2025-06-18 13:07 UTC (permalink / raw) To: Felix Fietkau, Sean Wang, Lorenzo Bianconi, Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Matthias Brugger, AngeloGioacchino Del Regno Cc: Frank Wunderlich, netdev, linux-kernel, linux-arm-kernel, linux-mediatek, Simon Horman, Daniel Golle, arinc.unal From: Frank Wunderlich <frank-w@public-files.de> This series introduces named IRQs while keeping the index based way for older dts. Further it makes some cleanup like adding consts for index access and avoids loading first IRQ which was not used on non SHARED_INT SoCs. changes: v5: - fixed typo and add linebreak in description of patch 1 - moved comments from previous patch #3 to patch #1 with changes suggested by simon - rename consts to be compatible with upcoming RSS/LRO changes MTK_ETH_IRQ_SHARED => MTK_FE_IRQ_SHARED MTK_ETH_IRQ_TX => MTK_FE_IRQ_TX MTK_ETH_IRQ_RX => MTK_FE_IRQ_RX MTK_ETH_IRQ_MAX => MTK_FE_IRQ_NUM - change commit title and description in patch 3 v4: - calculate max from last (rx) irq index and use it for array size too - drop >2 condition as max is already 2 and drop the else continue - update comment to explain which IRQs are taken in legacy way v3: added patches - #2 (add constants for irq index) - #3 (skip first IRQ on ! MTK_SHARED_INT) to the v2 non-series patch https://patchwork.kernel.org/project/netdevbpf/patch/20250615084521.32329-1-linux@fw-web.de/ Tested on BPI-R4/mt7988 with IRQ names and BPI-R2/mt7623 and BPI-R3/mt7986 with upstreamed dts via index-mode. I do not have any MTK_SHARED_INT (mt7621/mt7628) boards to testing. Frank Wunderlich (3): net: ethernet: mtk_eth_soc: support named IRQs net: ethernet: mtk_eth_soc: add consts for irq index net: ethernet: mtk_eth_soc: skip first IRQ if not used drivers/net/ethernet/mediatek/mtk_eth_soc.c | 62 +++++++++++++++------ drivers/net/ethernet/mediatek/mtk_eth_soc.h | 7 ++- 2 files changed, 51 insertions(+), 18 deletions(-) -- 2.43.0 ^ permalink raw reply [flat|nested] 11+ messages in thread
* [net-next v5 1/3] net: ethernet: mtk_eth_soc: support named IRQs 2025-06-18 13:07 [net-next v5 0/3] rework IRQ handling in mtk_eth_soc Frank Wunderlich @ 2025-06-18 13:07 ` Frank Wunderlich 2025-06-18 13:55 ` Daniel Golle 2025-06-18 13:07 ` [net-next v5 2/3] net: ethernet: mtk_eth_soc: add consts for irq index Frank Wunderlich 2025-06-18 13:07 ` [net-next v5 3/3] net: ethernet: mtk_eth_soc: skip first IRQ if not used Frank Wunderlich 2 siblings, 1 reply; 11+ messages in thread From: Frank Wunderlich @ 2025-06-18 13:07 UTC (permalink / raw) To: Felix Fietkau, Sean Wang, Lorenzo Bianconi, Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Matthias Brugger, AngeloGioacchino Del Regno Cc: Frank Wunderlich, netdev, linux-kernel, linux-arm-kernel, linux-mediatek, Simon Horman, Daniel Golle, arinc.unal From: Frank Wunderlich <frank-w@public-files.de> Add named interrupts and keep index based fallback for existing devicetrees. Currently only rx and tx IRQs are defined to be used with mt7988, but later extended with RSS/LRO support. Signed-off-by: Frank Wunderlich <frank-w@public-files.de> Reviewed-by: Simon Horman <horms@kernel.org> --- v5: - fix typo in description - add comments from previous patch #3 with changes suggested by simon v2: - move irqs loading part into own helper function - reduce indentation - place mtk_get_irqs helper before the irq_handler (note for simon) --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 46 ++++++++++++++++----- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index b76d35069887..39b673ed7495 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -3337,6 +3337,37 @@ static void mtk_tx_timeout(struct net_device *dev, unsigned int txqueue) schedule_work(ð->pending_work); } +static int mtk_get_irqs(struct platform_device *pdev, struct mtk_eth *eth) +{ + int i; + + /* future SoCs beginning with MT7988 should use named IRQs in dts */ + eth->irq[1] = platform_get_irq_byname(pdev, "tx"); + eth->irq[2] = platform_get_irq_byname(pdev, "rx"); + if (eth->irq[1] >= 0 && eth->irq[2] >= 0) + return 0; + + /* legacy way: + * On MTK_SHARED_INT SoCs (MT7621 + MT7628) the first IRQ is taken + * from devicetree and used for both RX and TX - it is shared. + * On SoCs with non-shared IRQs the first entry is not used, + * the second is for TX, and the third is for RX. + */ + for (i = 0; i < 3; i++) { + if (MTK_HAS_CAPS(eth->soc->caps, MTK_SHARED_INT) && i > 0) + eth->irq[i] = eth->irq[0]; + else + eth->irq[i] = platform_get_irq(pdev, i); + + if (eth->irq[i] < 0) { + dev_err(&pdev->dev, "no IRQ%d resource found\n", i); + return -ENXIO; + } + } + + return 0; +} + static irqreturn_t mtk_handle_irq_rx(int irq, void *_eth) { struct mtk_eth *eth = _eth; @@ -5106,17 +5137,10 @@ static int mtk_probe(struct platform_device *pdev) } } - for (i = 0; i < 3; i++) { - if (MTK_HAS_CAPS(eth->soc->caps, MTK_SHARED_INT) && i > 0) - eth->irq[i] = eth->irq[0]; - else - eth->irq[i] = platform_get_irq(pdev, i); - if (eth->irq[i] < 0) { - dev_err(&pdev->dev, "no IRQ%d resource found\n", i); - err = -ENXIO; - goto err_wed_exit; - } - } + err = mtk_get_irqs(pdev, eth); + if (err) + goto err_wed_exit; + for (i = 0; i < ARRAY_SIZE(eth->clks); i++) { eth->clks[i] = devm_clk_get(eth->dev, mtk_clks_source_name[i]); -- 2.43.0 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [net-next v5 1/3] net: ethernet: mtk_eth_soc: support named IRQs 2025-06-18 13:07 ` [net-next v5 1/3] net: ethernet: mtk_eth_soc: support named IRQs Frank Wunderlich @ 2025-06-18 13:55 ` Daniel Golle 2025-06-18 14:50 ` Frank Wunderlich 0 siblings, 1 reply; 11+ messages in thread From: Daniel Golle @ 2025-06-18 13:55 UTC (permalink / raw) To: Frank Wunderlich Cc: Felix Fietkau, Sean Wang, Lorenzo Bianconi, Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Matthias Brugger, AngeloGioacchino Del Regno, Frank Wunderlich, netdev, linux-kernel, linux-arm-kernel, linux-mediatek, Simon Horman, arinc.unal On Wed, Jun 18, 2025 at 03:07:12PM +0200, Frank Wunderlich wrote: > From: Frank Wunderlich <frank-w@public-files.de> > > Add named interrupts and keep index based fallback for existing > devicetrees. > > Currently only rx and tx IRQs are defined to be used with mt7988, but > later extended with RSS/LRO support. > > Signed-off-by: Frank Wunderlich <frank-w@public-files.de> > Reviewed-by: Simon Horman <horms@kernel.org> > > +static int mtk_get_irqs(struct platform_device *pdev, struct mtk_eth *eth) > +{ > + int i; > + > + /* future SoCs beginning with MT7988 should use named IRQs in dts */ > + eth->irq[1] = platform_get_irq_byname(pdev, "tx"); > + eth->irq[2] = platform_get_irq_byname(pdev, "rx"); > + if (eth->irq[1] >= 0 && eth->irq[2] >= 0) > + return 0; I'd rather extend that logic and fall back to the legacy way only in case of -ENXIO. Ie. add here: if (eth->irq[1] != -ENXIO) return eth->irq[1]; if (eth->irq[2] != -ENXIO) return eth->irq[2]; Maybe also output a warning at this point in case MTK_SHARED_INT is no set, to recommend users to update their device tree to named interrupts. > + > + /* legacy way: > + * On MTK_SHARED_INT SoCs (MT7621 + MT7628) the first IRQ is taken > + * from devicetree and used for both RX and TX - it is shared. > + * On SoCs with non-shared IRQs the first entry is not used, > + * the second is for TX, and the third is for RX. > + */ > + for (i = 0; i < 3; i++) { > + if (MTK_HAS_CAPS(eth->soc->caps, MTK_SHARED_INT) && i > 0) > + eth->irq[i] = eth->irq[0]; > + else > + eth->irq[i] = platform_get_irq(pdev, i); > + > + if (eth->irq[i] < 0) { > + dev_err(&pdev->dev, "no IRQ%d resource found\n", i); > + return -ENXIO; > + } > + } > + > + return 0; > +} > + > static irqreturn_t mtk_handle_irq_rx(int irq, void *_eth) > { > struct mtk_eth *eth = _eth; > @@ -5106,17 +5137,10 @@ static int mtk_probe(struct platform_device *pdev) > } > } > > - for (i = 0; i < 3; i++) { > - if (MTK_HAS_CAPS(eth->soc->caps, MTK_SHARED_INT) && i > 0) > - eth->irq[i] = eth->irq[0]; > - else > - eth->irq[i] = platform_get_irq(pdev, i); > - if (eth->irq[i] < 0) { > - dev_err(&pdev->dev, "no IRQ%d resource found\n", i); > - err = -ENXIO; > - goto err_wed_exit; > - } > - } > + err = mtk_get_irqs(pdev, eth); > + if (err) > + goto err_wed_exit; > + > for (i = 0; i < ARRAY_SIZE(eth->clks); i++) { > eth->clks[i] = devm_clk_get(eth->dev, > mtk_clks_source_name[i]); > -- > 2.43.0 > > ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [net-next v5 1/3] net: ethernet: mtk_eth_soc: support named IRQs 2025-06-18 13:55 ` Daniel Golle @ 2025-06-18 14:50 ` Frank Wunderlich 0 siblings, 0 replies; 11+ messages in thread From: Frank Wunderlich @ 2025-06-18 14:50 UTC (permalink / raw) To: Daniel Golle Cc: Felix Fietkau, Sean Wang, Lorenzo Bianconi, Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Matthias Brugger, AngeloGioacchino Del Regno, Frank Wunderlich, netdev, linux-kernel, linux-arm-kernel, linux-mediatek, Simon Horman, arinc.unal Am 18. Juni 2025 15:55:45 MESZ schrieb Daniel Golle <daniel@makrotopia.org>: >On Wed, Jun 18, 2025 at 03:07:12PM +0200, Frank Wunderlich wrote: >> From: Frank Wunderlich <frank-w@public-files.de> >> >> Add named interrupts and keep index based fallback for existing >> devicetrees. >> >> Currently only rx and tx IRQs are defined to be used with mt7988, but >> later extended with RSS/LRO support. >> >> Signed-off-by: Frank Wunderlich <frank-w@public-files.de> >> Reviewed-by: Simon Horman <horms@kernel.org> >> >> +static int mtk_get_irqs(struct platform_device *pdev, struct mtk_eth *eth) >> +{ >> + int i; >> + >> + /* future SoCs beginning with MT7988 should use named IRQs in dts */ >> + eth->irq[1] = platform_get_irq_byname(pdev, "tx"); >> + eth->irq[2] = platform_get_irq_byname(pdev, "rx"); >> + if (eth->irq[1] >= 0 && eth->irq[2] >= 0) >> + return 0; > >I'd rather extend that logic and fall back to the legacy way only in case >of -ENXIO. Ie. add here: > >if (eth->irq[1] != -ENXIO) > return eth->irq[1]; > >if (eth->irq[2] != -ENXIO) > return eth->irq[2]; I would do this later after the consts are used instead of index numbers,just to not add lines that are changed later again.Better adding the lines already with the consts. >Maybe also output a warning at this point in case MTK_SHARED_INT is no >set, to recommend users to update their device tree to named interrupts. I understand the reason behind (documentation which irq is used for which purpose),but previous devicetrees of non-shared SoCs using at least the reserved irq 0. Mt7986 has 0 and 3 defined in dts. That could be tricky in binding, so my way was starting with irq names now for new additions and leaving existing dts as they are. Maybe i should add the mt7988 ethernet binding change from my dts series here... regards Frank ^ permalink raw reply [flat|nested] 11+ messages in thread
* [net-next v5 2/3] net: ethernet: mtk_eth_soc: add consts for irq index 2025-06-18 13:07 [net-next v5 0/3] rework IRQ handling in mtk_eth_soc Frank Wunderlich 2025-06-18 13:07 ` [net-next v5 1/3] net: ethernet: mtk_eth_soc: support named IRQs Frank Wunderlich @ 2025-06-18 13:07 ` Frank Wunderlich 2025-06-18 14:23 ` Daniel Golle 2025-06-18 13:07 ` [net-next v5 3/3] net: ethernet: mtk_eth_soc: skip first IRQ if not used Frank Wunderlich 2 siblings, 1 reply; 11+ messages in thread From: Frank Wunderlich @ 2025-06-18 13:07 UTC (permalink / raw) To: Felix Fietkau, Sean Wang, Lorenzo Bianconi, Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Matthias Brugger, AngeloGioacchino Del Regno Cc: Frank Wunderlich, netdev, linux-kernel, linux-arm-kernel, linux-mediatek, Simon Horman, Daniel Golle, arinc.unal From: Frank Wunderlich <frank-w@public-files.de> Use consts instead of fixed integers for accessing IRQ array. Signed-off-by: Frank Wunderlich <frank-w@public-files.de> Reviewed-by: Simon Horman <horms@kernel.org> --- v5: - rename consts to be compatible with upcoming RSS/LRO changes MTK_ETH_IRQ_SHARED => MTK_FE_IRQ_SHARED MTK_ETH_IRQ_TX => MTK_FE_IRQ_TX MTK_ETH_IRQ_RX => MTK_FE_IRQ_RX MTK_ETH_IRQ_MAX => MTK_FE_IRQ_NUM v4: - calculate max from last (rx) irq index and use it for array size too --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 22 ++++++++++----------- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 7 ++++++- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index 39b673ed7495..875e477a987b 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -3342,9 +3342,9 @@ static int mtk_get_irqs(struct platform_device *pdev, struct mtk_eth *eth) int i; /* future SoCs beginning with MT7988 should use named IRQs in dts */ - eth->irq[1] = platform_get_irq_byname(pdev, "tx"); - eth->irq[2] = platform_get_irq_byname(pdev, "rx"); - if (eth->irq[1] >= 0 && eth->irq[2] >= 0) + eth->irq[MTK_FE_IRQ_TX] = platform_get_irq_byname(pdev, "tx"); + eth->irq[MTK_FE_IRQ_RX] = platform_get_irq_byname(pdev, "rx"); + if (eth->irq[MTK_FE_IRQ_TX] >= 0 && eth->irq[MTK_FE_IRQ_RX] >= 0) return 0; /* legacy way: @@ -3353,9 +3353,9 @@ static int mtk_get_irqs(struct platform_device *pdev, struct mtk_eth *eth) * On SoCs with non-shared IRQs the first entry is not used, * the second is for TX, and the third is for RX. */ - for (i = 0; i < 3; i++) { + for (i = 0; i < MTK_FE_IRQ_NUM; i++) { if (MTK_HAS_CAPS(eth->soc->caps, MTK_SHARED_INT) && i > 0) - eth->irq[i] = eth->irq[0]; + eth->irq[i] = eth->irq[MTK_FE_IRQ_SHARED]; else eth->irq[i] = platform_get_irq(pdev, i); @@ -3421,7 +3421,7 @@ static void mtk_poll_controller(struct net_device *dev) mtk_tx_irq_disable(eth, MTK_TX_DONE_INT); mtk_rx_irq_disable(eth, eth->soc->rx.irq_done_mask); - mtk_handle_irq_rx(eth->irq[2], dev); + mtk_handle_irq_rx(eth->irq[MTK_FE_IRQ_RX], dev); mtk_tx_irq_enable(eth, MTK_TX_DONE_INT); mtk_rx_irq_enable(eth, eth->soc->rx.irq_done_mask); } @@ -4907,7 +4907,7 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) eth->netdev[id]->features |= eth->soc->hw_features; eth->netdev[id]->ethtool_ops = &mtk_ethtool_ops; - eth->netdev[id]->irq = eth->irq[0]; + eth->netdev[id]->irq = eth->irq[MTK_FE_IRQ_SHARED]; eth->netdev[id]->dev.of_node = np; if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628)) @@ -5184,17 +5184,17 @@ static int mtk_probe(struct platform_device *pdev) } if (MTK_HAS_CAPS(eth->soc->caps, MTK_SHARED_INT)) { - err = devm_request_irq(eth->dev, eth->irq[0], + err = devm_request_irq(eth->dev, eth->irq[MTK_FE_IRQ_SHARED], mtk_handle_irq, 0, dev_name(eth->dev), eth); } else { - err = devm_request_irq(eth->dev, eth->irq[1], + err = devm_request_irq(eth->dev, eth->irq[MTK_FE_IRQ_TX], mtk_handle_irq_tx, 0, dev_name(eth->dev), eth); if (err) goto err_free_dev; - err = devm_request_irq(eth->dev, eth->irq[2], + err = devm_request_irq(eth->dev, eth->irq[MTK_FE_IRQ_RX], mtk_handle_irq_rx, 0, dev_name(eth->dev), eth); } @@ -5240,7 +5240,7 @@ static int mtk_probe(struct platform_device *pdev) } else netif_info(eth, probe, eth->netdev[i], "mediatek frame engine at 0x%08lx, irq %d\n", - eth->netdev[i]->base_addr, eth->irq[0]); + eth->netdev[i]->base_addr, eth->irq[MTK_FE_IRQ_SHARED]); } /* we run 2 devices on the same DMA ring so we need a dummy device diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h index 6f72a8c8ae1e..8cdf1317dff5 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h @@ -642,6 +642,11 @@ #define MTK_MAC_FSM(x) (0x1010C + ((x) * 0x100)) +#define MTK_FE_IRQ_SHARED 0 +#define MTK_FE_IRQ_TX 1 +#define MTK_FE_IRQ_RX 2 +#define MTK_FE_IRQ_NUM (MTK_FE_IRQ_RX + 1) + struct mtk_rx_dma { unsigned int rxd1; unsigned int rxd2; @@ -1292,7 +1297,7 @@ struct mtk_eth { struct net_device *dummy_dev; struct net_device *netdev[MTK_MAX_DEVS]; struct mtk_mac *mac[MTK_MAX_DEVS]; - int irq[3]; + int irq[MTK_FE_IRQ_NUM]; u32 msg_enable; unsigned long sysclk; struct regmap *ethsys; -- 2.43.0 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [net-next v5 2/3] net: ethernet: mtk_eth_soc: add consts for irq index 2025-06-18 13:07 ` [net-next v5 2/3] net: ethernet: mtk_eth_soc: add consts for irq index Frank Wunderlich @ 2025-06-18 14:23 ` Daniel Golle 0 siblings, 0 replies; 11+ messages in thread From: Daniel Golle @ 2025-06-18 14:23 UTC (permalink / raw) To: Frank Wunderlich Cc: Felix Fietkau, Sean Wang, Lorenzo Bianconi, Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Matthias Brugger, AngeloGioacchino Del Regno, Frank Wunderlich, netdev, linux-kernel, linux-arm-kernel, linux-mediatek, Simon Horman, arinc.unal On Wed, Jun 18, 2025 at 03:07:13PM +0200, Frank Wunderlich wrote: > From: Frank Wunderlich <frank-w@public-files.de> > > Use consts instead of fixed integers for accessing IRQ array. > > Signed-off-by: Frank Wunderlich <frank-w@public-files.de> > Reviewed-by: Simon Horman <horms@kernel.org> Reviewed-by: Daniel Golle <daniel@makrotopia.org> > --- > v5: > - rename consts to be compatible with upcoming RSS/LRO changes > MTK_ETH_IRQ_SHARED => MTK_FE_IRQ_SHARED > MTK_ETH_IRQ_TX => MTK_FE_IRQ_TX > MTK_ETH_IRQ_RX => MTK_FE_IRQ_RX > MTK_ETH_IRQ_MAX => MTK_FE_IRQ_NUM > v4: > - calculate max from last (rx) irq index and use it for array size too > --- > drivers/net/ethernet/mediatek/mtk_eth_soc.c | 22 ++++++++++----------- > drivers/net/ethernet/mediatek/mtk_eth_soc.h | 7 ++++++- > 2 files changed, 17 insertions(+), 12 deletions(-) > > diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c > index 39b673ed7495..875e477a987b 100644 > --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c > +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c > @@ -3342,9 +3342,9 @@ static int mtk_get_irqs(struct platform_device *pdev, struct mtk_eth *eth) > int i; > > /* future SoCs beginning with MT7988 should use named IRQs in dts */ > - eth->irq[1] = platform_get_irq_byname(pdev, "tx"); > - eth->irq[2] = platform_get_irq_byname(pdev, "rx"); > - if (eth->irq[1] >= 0 && eth->irq[2] >= 0) > + eth->irq[MTK_FE_IRQ_TX] = platform_get_irq_byname(pdev, "tx"); > + eth->irq[MTK_FE_IRQ_RX] = platform_get_irq_byname(pdev, "rx"); > + if (eth->irq[MTK_FE_IRQ_TX] >= 0 && eth->irq[MTK_FE_IRQ_RX] >= 0) > return 0; > > /* legacy way: > @@ -3353,9 +3353,9 @@ static int mtk_get_irqs(struct platform_device *pdev, struct mtk_eth *eth) > * On SoCs with non-shared IRQs the first entry is not used, > * the second is for TX, and the third is for RX. > */ > - for (i = 0; i < 3; i++) { > + for (i = 0; i < MTK_FE_IRQ_NUM; i++) { > if (MTK_HAS_CAPS(eth->soc->caps, MTK_SHARED_INT) && i > 0) > - eth->irq[i] = eth->irq[0]; > + eth->irq[i] = eth->irq[MTK_FE_IRQ_SHARED]; > else > eth->irq[i] = platform_get_irq(pdev, i); > > @@ -3421,7 +3421,7 @@ static void mtk_poll_controller(struct net_device *dev) > > mtk_tx_irq_disable(eth, MTK_TX_DONE_INT); > mtk_rx_irq_disable(eth, eth->soc->rx.irq_done_mask); > - mtk_handle_irq_rx(eth->irq[2], dev); > + mtk_handle_irq_rx(eth->irq[MTK_FE_IRQ_RX], dev); > mtk_tx_irq_enable(eth, MTK_TX_DONE_INT); > mtk_rx_irq_enable(eth, eth->soc->rx.irq_done_mask); > } > @@ -4907,7 +4907,7 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) > eth->netdev[id]->features |= eth->soc->hw_features; > eth->netdev[id]->ethtool_ops = &mtk_ethtool_ops; > > - eth->netdev[id]->irq = eth->irq[0]; > + eth->netdev[id]->irq = eth->irq[MTK_FE_IRQ_SHARED]; > eth->netdev[id]->dev.of_node = np; > > if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628)) > @@ -5184,17 +5184,17 @@ static int mtk_probe(struct platform_device *pdev) > } > > if (MTK_HAS_CAPS(eth->soc->caps, MTK_SHARED_INT)) { > - err = devm_request_irq(eth->dev, eth->irq[0], > + err = devm_request_irq(eth->dev, eth->irq[MTK_FE_IRQ_SHARED], > mtk_handle_irq, 0, > dev_name(eth->dev), eth); > } else { > - err = devm_request_irq(eth->dev, eth->irq[1], > + err = devm_request_irq(eth->dev, eth->irq[MTK_FE_IRQ_TX], > mtk_handle_irq_tx, 0, > dev_name(eth->dev), eth); > if (err) > goto err_free_dev; > > - err = devm_request_irq(eth->dev, eth->irq[2], > + err = devm_request_irq(eth->dev, eth->irq[MTK_FE_IRQ_RX], > mtk_handle_irq_rx, 0, > dev_name(eth->dev), eth); > } > @@ -5240,7 +5240,7 @@ static int mtk_probe(struct platform_device *pdev) > } else > netif_info(eth, probe, eth->netdev[i], > "mediatek frame engine at 0x%08lx, irq %d\n", > - eth->netdev[i]->base_addr, eth->irq[0]); > + eth->netdev[i]->base_addr, eth->irq[MTK_FE_IRQ_SHARED]); > } > > /* we run 2 devices on the same DMA ring so we need a dummy device > diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h > index 6f72a8c8ae1e..8cdf1317dff5 100644 > --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h > +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h > @@ -642,6 +642,11 @@ > > #define MTK_MAC_FSM(x) (0x1010C + ((x) * 0x100)) > > +#define MTK_FE_IRQ_SHARED 0 > +#define MTK_FE_IRQ_TX 1 > +#define MTK_FE_IRQ_RX 2 > +#define MTK_FE_IRQ_NUM (MTK_FE_IRQ_RX + 1) > + > struct mtk_rx_dma { > unsigned int rxd1; > unsigned int rxd2; > @@ -1292,7 +1297,7 @@ struct mtk_eth { > struct net_device *dummy_dev; > struct net_device *netdev[MTK_MAX_DEVS]; > struct mtk_mac *mac[MTK_MAX_DEVS]; > - int irq[3]; > + int irq[MTK_FE_IRQ_NUM]; > u32 msg_enable; > unsigned long sysclk; > struct regmap *ethsys; > -- > 2.43.0 > ^ permalink raw reply [flat|nested] 11+ messages in thread
* [net-next v5 3/3] net: ethernet: mtk_eth_soc: skip first IRQ if not used 2025-06-18 13:07 [net-next v5 0/3] rework IRQ handling in mtk_eth_soc Frank Wunderlich 2025-06-18 13:07 ` [net-next v5 1/3] net: ethernet: mtk_eth_soc: support named IRQs Frank Wunderlich 2025-06-18 13:07 ` [net-next v5 2/3] net: ethernet: mtk_eth_soc: add consts for irq index Frank Wunderlich @ 2025-06-18 13:07 ` Frank Wunderlich 2025-06-18 17:41 ` Daniel Golle 2025-06-19 10:03 ` Simon Horman 2 siblings, 2 replies; 11+ messages in thread From: Frank Wunderlich @ 2025-06-18 13:07 UTC (permalink / raw) To: Felix Fietkau, Sean Wang, Lorenzo Bianconi, Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Matthias Brugger, AngeloGioacchino Del Regno Cc: Frank Wunderlich, netdev, linux-kernel, linux-arm-kernel, linux-mediatek, Simon Horman, Daniel Golle, arinc.unal From: Frank Wunderlich <frank-w@public-files.de> On SoCs without MTK_SHARED_INT capability (all except mt7621 and mt7628) platform_get_irq() is called for the first IRQ (eth->irq[0]) but it is never used. Skip the first IRQ and reduce the IRQ-count to 2. Signed-off-by: Frank Wunderlich <frank-w@public-files.de> --- v5: - change commit title and description v4: - drop >2 condition as max is already 2 and drop the else continue - update comment to explain which IRQs are taken in legacy way --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 12 ++++++++---- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index 875e477a987b..7990c84b2b56 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -3354,10 +3354,14 @@ static int mtk_get_irqs(struct platform_device *pdev, struct mtk_eth *eth) * the second is for TX, and the third is for RX. */ for (i = 0; i < MTK_FE_IRQ_NUM; i++) { - if (MTK_HAS_CAPS(eth->soc->caps, MTK_SHARED_INT) && i > 0) - eth->irq[i] = eth->irq[MTK_FE_IRQ_SHARED]; - else - eth->irq[i] = platform_get_irq(pdev, i); + if (MTK_HAS_CAPS(eth->soc->caps, MTK_SHARED_INT)) { + if (i == 0) + eth->irq[MTK_FE_IRQ_SHARED] = platform_get_irq(pdev, i); + else + eth->irq[i] = eth->irq[MTK_FE_IRQ_SHARED]; + } else { + eth->irq[i] = platform_get_irq(pdev, i + 1); + } if (eth->irq[i] < 0) { dev_err(&pdev->dev, "no IRQ%d resource found\n", i); diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h index 8cdf1317dff5..9261c0e13b59 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h @@ -643,8 +643,8 @@ #define MTK_MAC_FSM(x) (0x1010C + ((x) * 0x100)) #define MTK_FE_IRQ_SHARED 0 -#define MTK_FE_IRQ_TX 1 -#define MTK_FE_IRQ_RX 2 +#define MTK_FE_IRQ_TX 0 +#define MTK_FE_IRQ_RX 1 #define MTK_FE_IRQ_NUM (MTK_FE_IRQ_RX + 1) struct mtk_rx_dma { -- 2.43.0 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [net-next v5 3/3] net: ethernet: mtk_eth_soc: skip first IRQ if not used 2025-06-18 13:07 ` [net-next v5 3/3] net: ethernet: mtk_eth_soc: skip first IRQ if not used Frank Wunderlich @ 2025-06-18 17:41 ` Daniel Golle 2025-06-19 10:03 ` Simon Horman 1 sibling, 0 replies; 11+ messages in thread From: Daniel Golle @ 2025-06-18 17:41 UTC (permalink / raw) To: Frank Wunderlich Cc: Felix Fietkau, Sean Wang, Lorenzo Bianconi, Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Matthias Brugger, AngeloGioacchino Del Regno, Frank Wunderlich, netdev, linux-kernel, linux-arm-kernel, linux-mediatek, Simon Horman, arinc.unal On Wed, Jun 18, 2025 at 03:07:14PM +0200, Frank Wunderlich wrote: > From: Frank Wunderlich <frank-w@public-files.de> > > On SoCs without MTK_SHARED_INT capability (all except mt7621 and > mt7628) platform_get_irq() is called for the first IRQ (eth->irq[0]) > but it is never used. I know that technically MTK_SHARED_INT is a capability flag, but it's rather a non-capability. Hardware having dedicated interrupts for RX and TX is "more capable" than (older, legacy) hardware with just one shared interrupt for both... So maybe better: "On SoCs with dedicated RX and TX interrupts (all except MT7621 and MT7628) ..." Reading the datasheet of some recent MediaTek SoC it is worth noting that there are 4 interrupts assigned to the frame engine and the FE_INT_GRP register can be used to assign functions to them. So technically, calling them RX and TX in DT is wrong, becaues they are fe_int0, fe_int1, fe_int2 and fe_int3, which are then assigned one or more functions by the driver using that FE_INT_GRP register. However, it's the driver then assigns QDMA TX to fe_int1 and RX to fe_int2 while leaving fe_int0 and fe_int3 unsued. That's what the magic value 0x21021000 which is written to FE_INT_GRP register does. On MT7988 and newer, in addition to those 4 frame engine interrupts there are **another 4** interrupts for PDMA, typically used to service 4 RX rings while one of the fe_int* is used to indicate TX done. > Skip the first IRQ and reduce the IRQ-count to 2. > > Signed-off-by: Frank Wunderlich <frank-w@public-files.de> > --- > v5: > - change commit title and description > v4: > - drop >2 condition as max is already 2 and drop the else continue > - update comment to explain which IRQs are taken in legacy way > --- > drivers/net/ethernet/mediatek/mtk_eth_soc.c | 12 ++++++++---- > drivers/net/ethernet/mediatek/mtk_eth_soc.h | 4 ++-- > 2 files changed, 10 insertions(+), 6 deletions(-) > > diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c > index 875e477a987b..7990c84b2b56 100644 > --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c > +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c > @@ -3354,10 +3354,14 @@ static int mtk_get_irqs(struct platform_device *pdev, struct mtk_eth *eth) > * the second is for TX, and the third is for RX. > */ > for (i = 0; i < MTK_FE_IRQ_NUM; i++) { > - if (MTK_HAS_CAPS(eth->soc->caps, MTK_SHARED_INT) && i > 0) > - eth->irq[i] = eth->irq[MTK_FE_IRQ_SHARED]; > - else > - eth->irq[i] = platform_get_irq(pdev, i); > + if (MTK_HAS_CAPS(eth->soc->caps, MTK_SHARED_INT)) { > + if (i == 0) This would make it even more readable: if (i == MTK_FE_IRQ_SHARED) Other than that looks good to me: Reviewed-by: Daniel Golle <daniel@makrotopia.org> > + eth->irq[MTK_FE_IRQ_SHARED] = platform_get_irq(pdev, i); > + else > + eth->irq[i] = eth->irq[MTK_FE_IRQ_SHARED]; > + } else { > + eth->irq[i] = platform_get_irq(pdev, i + 1); > + } > > if (eth->irq[i] < 0) { > dev_err(&pdev->dev, "no IRQ%d resource found\n", i); > diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h > index 8cdf1317dff5..9261c0e13b59 100644 > --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h > +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h > @@ -643,8 +643,8 @@ > #define MTK_MAC_FSM(x) (0x1010C + ((x) * 0x100)) > > #define MTK_FE_IRQ_SHARED 0 > -#define MTK_FE_IRQ_TX 1 > -#define MTK_FE_IRQ_RX 2 > +#define MTK_FE_IRQ_TX 0 > +#define MTK_FE_IRQ_RX 1 > #define MTK_FE_IRQ_NUM (MTK_FE_IRQ_RX + 1) > > struct mtk_rx_dma { > -- > 2.43.0 > > ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [net-next v5 3/3] net: ethernet: mtk_eth_soc: skip first IRQ if not used 2025-06-18 13:07 ` [net-next v5 3/3] net: ethernet: mtk_eth_soc: skip first IRQ if not used Frank Wunderlich 2025-06-18 17:41 ` Daniel Golle @ 2025-06-19 10:03 ` Simon Horman 2025-06-19 10:32 ` Aw: " Frank Wunderlich 1 sibling, 1 reply; 11+ messages in thread From: Simon Horman @ 2025-06-19 10:03 UTC (permalink / raw) To: Frank Wunderlich Cc: Felix Fietkau, Sean Wang, Lorenzo Bianconi, Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Matthias Brugger, AngeloGioacchino Del Regno, Frank Wunderlich, netdev, linux-kernel, linux-arm-kernel, linux-mediatek, Daniel Golle, arinc.unal On Wed, Jun 18, 2025 at 03:07:14PM +0200, Frank Wunderlich wrote: > From: Frank Wunderlich <frank-w@public-files.de> > > On SoCs without MTK_SHARED_INT capability (all except mt7621 and > mt7628) platform_get_irq() is called for the first IRQ (eth->irq[0]) > but it is never used. > Skip the first IRQ and reduce the IRQ-count to 2. > > Signed-off-by: Frank Wunderlich <frank-w@public-files.de> > --- > v5: > - change commit title and description > v4: > - drop >2 condition as max is already 2 and drop the else continue > - update comment to explain which IRQs are taken in legacy way Reviewed-by: Simon Horman <horms@kernel.org> ^ permalink raw reply [flat|nested] 11+ messages in thread
* Aw: Re: [net-next v5 3/3] net: ethernet: mtk_eth_soc: skip first IRQ if not used 2025-06-19 10:03 ` Simon Horman @ 2025-06-19 10:32 ` Frank Wunderlich 2025-06-19 12:51 ` Simon Horman 0 siblings, 1 reply; 11+ messages in thread From: Frank Wunderlich @ 2025-06-19 10:32 UTC (permalink / raw) To: horms, linux Cc: nbd, sean.wang, lorenzo, andrew+netdev, davem, edumazet, kuba, pabeni, matthias.bgg, angelogioacchino.delregno, netdev, linux-kernel, linux-arm-kernel, linux-mediatek, daniel, arinc.unal Hi Simon > Gesendet: Donnerstag, 19. Juni 2025 um 12:03 > Von: "Simon Horman" <horms@kernel.org> > Betreff: Re: [net-next v5 3/3] net: ethernet: mtk_eth_soc: skip first IRQ if not used > > On Wed, Jun 18, 2025 at 03:07:14PM +0200, Frank Wunderlich wrote: > > From: Frank Wunderlich <frank-w@public-files.de> > > > > On SoCs without MTK_SHARED_INT capability (all except mt7621 and > > mt7628) platform_get_irq() is called for the first IRQ (eth->irq[0]) > > but it is never used. > > Skip the first IRQ and reduce the IRQ-count to 2. > > > > Signed-off-by: Frank Wunderlich <frank-w@public-files.de> > > --- > > v5: > > - change commit title and description > > v4: > > - drop >2 condition as max is already 2 and drop the else continue > > - update comment to explain which IRQs are taken in legacy way > > Reviewed-by: Simon Horman <horms@kernel.org> thank you very much i guess RB is still valid with changes requested by Daniel? net: ethernet: mtk_eth_soc: skip first IRQ if not used On SoCs with dedicated RX and TX interrupts (all except MT7621 and MT7628) platform_get_irq() is called for the first IRQ (eth->irq[0]) but it is never used. Skip the first IRQ and reduce the IRQ-count to 2. code (changed condition "if (i == MTK_FE_IRQ_SHARED)") for (i = 0; i < MTK_FE_IRQ_NUM; i++) { - if (MTK_HAS_CAPS(eth->soc->caps, MTK_SHARED_INT) && i > 0) - eth->irq[i] = eth->irq[MTK_FE_IRQ_SHARED]; - else - eth->irq[i] = platform_get_irq(pdev, i); + if (MTK_HAS_CAPS(eth->soc->caps, MTK_SHARED_INT)) { + if (i == MTK_FE_IRQ_SHARED) + eth->irq[MTK_FE_IRQ_SHARED] = platform_get_irq(pdev, i); + else + eth->irq[i] = eth->irq[MTK_FE_IRQ_SHARED]; + } else { + eth->irq[i] = platform_get_irq(pdev, i + 1); + } regards Frank ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Re: [net-next v5 3/3] net: ethernet: mtk_eth_soc: skip first IRQ if not used 2025-06-19 10:32 ` Aw: " Frank Wunderlich @ 2025-06-19 12:51 ` Simon Horman 0 siblings, 0 replies; 11+ messages in thread From: Simon Horman @ 2025-06-19 12:51 UTC (permalink / raw) To: Frank Wunderlich Cc: linux, nbd, sean.wang, lorenzo, andrew+netdev, davem, edumazet, kuba, pabeni, matthias.bgg, angelogioacchino.delregno, netdev, linux-kernel, linux-arm-kernel, linux-mediatek, daniel, arinc.unal On Thu, Jun 19, 2025 at 10:32:05AM +0000, Frank Wunderlich wrote: > Hi Simon > > > Gesendet: Donnerstag, 19. Juni 2025 um 12:03 > > Von: "Simon Horman" <horms@kernel.org> > > Betreff: Re: [net-next v5 3/3] net: ethernet: mtk_eth_soc: skip first IRQ if not used > > > > On Wed, Jun 18, 2025 at 03:07:14PM +0200, Frank Wunderlich wrote: > > > From: Frank Wunderlich <frank-w@public-files.de> > > > > > > On SoCs without MTK_SHARED_INT capability (all except mt7621 and > > > mt7628) platform_get_irq() is called for the first IRQ (eth->irq[0]) > > > but it is never used. > > > Skip the first IRQ and reduce the IRQ-count to 2. > > > > > > Signed-off-by: Frank Wunderlich <frank-w@public-files.de> > > > --- > > > v5: > > > - change commit title and description > > > v4: > > > - drop >2 condition as max is already 2 and drop the else continue > > > - update comment to explain which IRQs are taken in legacy way > > > > Reviewed-by: Simon Horman <horms@kernel.org> > > thank you very much > > i guess RB is still valid with changes requested by Daniel? Yes, thanks for asking. ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2025-06-19 12:51 UTC | newest] Thread overview: 11+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2025-06-18 13:07 [net-next v5 0/3] rework IRQ handling in mtk_eth_soc Frank Wunderlich 2025-06-18 13:07 ` [net-next v5 1/3] net: ethernet: mtk_eth_soc: support named IRQs Frank Wunderlich 2025-06-18 13:55 ` Daniel Golle 2025-06-18 14:50 ` Frank Wunderlich 2025-06-18 13:07 ` [net-next v5 2/3] net: ethernet: mtk_eth_soc: add consts for irq index Frank Wunderlich 2025-06-18 14:23 ` Daniel Golle 2025-06-18 13:07 ` [net-next v5 3/3] net: ethernet: mtk_eth_soc: skip first IRQ if not used Frank Wunderlich 2025-06-18 17:41 ` Daniel Golle 2025-06-19 10:03 ` Simon Horman 2025-06-19 10:32 ` Aw: " Frank Wunderlich 2025-06-19 12:51 ` Simon Horman
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).