net: stmmac: Fixes bundle #1
Subsystems (5)
cover net: stmmac: Fixes bundle #1
Even a mere glance at the STMMAC driver code reveals multiple problematic parts. Here just the brightest of them: intermix of the platform-specific, runtime and even LLDD-specific (Hello Intel) parameters defined in the platform data, redundant (sometimes up to four) parameters defining a device feature state, very unfortunate DW MAC id (MAC100, GMAC, QoS, X-GMAC) and versioning interface, too bulky and clumsy HW-abstraction interface with non-unified function prototypes accepting device-dependent arguments instead of taking a single HW descriptor or STMMAC driver private data aside with algo-dependent parameters, non-unified declarations and definitions spread out between four header files "stmmac.h", "stmmac_platform.h", <linux/stmmac.h>, common.h, hwif.h, code snippet duplicated all over the driver code (i.e. DMA descriptors ring access), and so on and so forth.
All of that makes the STMMAC driver very hard to read, maintain and update. Thus any more-or-less complicated change not only turns to be larger than it could be (which besides makes it harder to review) but also may have higher risks to break things in unexpected places of the driver. Therefore at the very least the code cleanup suggests itself here.
At first we didn't want to change the driver much in a hope to add Baikal SoC GMAC and X-GMAC (based on the DW GMAC and X-GMAC IP-cores) support with as less modifications as possible. But the more features we developed the more problems we discovered including actual bugs (currently there are three fixes patchset we managed to collect). So after a lot of thoughts we decided first to provide a series of patchsets with bug fixes, cleanups, optimizations and refactoring of the driver parts thus having a driver more ready to be updated with our versions DW GMAC/X-GMAC features and getting more stable, simpler to read and maintain code after all.
All the work which was done in regards to the announced alterations (and yet to be done) is split up into a set of more-or-less coherent patchsets which will be submitted one after another upon review process advance. The only exception is the DT-bindings series which contains independent changes and can be delivered before ahead the rest of the patchsets.
This patchset is the first one in the series of updates implemented in the framework of activity to simplify the DW MAC/STMMAC driver code and provide Baikal GMAC/X-GMAC support after all:
+> [1: In-review v1]: net: stmmac: Fixes bundle #1
+> Link: ---you are looking at it---
[2: Stalled v1]: net: stmmac: Fixes bundle #2
Link: ---not submitted yet---
[3: Stalled v1]: net: stmmac: Fixes bundle #3
Link: ---not submitted yet---
[4: Stalled v1]: dt-bindings: net: dwmac: Extend clocks, props desc and constraints
Link: ---not submitted yet---
[5: Stalled v1]: dt-bindings: net: dwmac: Fix MTL queues and AXI-bus props
Link: ---not submitted yet---
[6: Stalled v1]: net: stmmac: Generic platform res, props and DMA cleanups
Link: ---not submitted yet---
[7: Stalled v1]: net: stmmac: Generic platform rst, phy and clk cleanups
Link: ---not submitted yet---
[8: Stalled v1]: net: stmmac: Main driver code cleanups bundle #1
Link: ---not submitted yet---
[9: Stalled v1]: net: stmmac: Main driver code cleanups bundle #2
Link: ---not submitted yet---
[10: Stalled v1]: net: stmmac: DW MAC HW info init refactoring
Link: ---not submitted yet---
[11: Stalled v1]: net: stmmac: Convert to using HW capabilities bundle #1
Link: ---not submitted yet---
[12: Stalled v1]: net: stmmac: Convert to using HW capabilities bundle #2
Link: ---not submitted yet---
[13: Stalled v1]: net: stmmac: Convert to using HW capabilities bundle #3
Link: ---not submitted yet---
[14: Stalled v1]: net: stmmac: Convert to using HW capabilities bundle #4
Link: ---not submitted yet---
[15: Stalled v1]: net: stmmac: Unify/simplify HW-interface
Link: ---not submitted yet---
[16: Stalled v1]: net: stmmac: Norm/Enh/etc DMA descriptor init fixes
Link: ---not submitted yet---
[17: Stalled v1]: net: stmmac: Norm/Enh/etc DMA descriptor init cleanups
Link: ---not submitted yet---
[18: Stalled v1]: net: stmmac: Main driver code cleanups bundle #3
Link: ---not submitted yet---
[..: In-prep] to be continued (IRQ handling refactoring, SW-reset-less config,
generic GPIO support, ARP offload support, In-band RGMII link state, etc)
[..: In-prep] to be continued (Baikal-{T,M,L,S} SoCs GMAC, X-GMAC and XPCS
support)
Here is a short summary of what is introduced in this patchset.
The series starts with a fix, which I submitted two years ago. It concerns the RTL8211E PHY working in the LPI-mode with the RX clock gating. In particular it was discovered that disabling RXC in LPI (EEE) causes RTL8211E PHY partial freeze until the next MDIO read operation from the PHY CSRs. We suggest to fix that problem by dummy reading from the MMD Data register each time the PC1R.10 bit is intended to be set. See the patch log for more details.
Afterwards a set of the DW (G)MAC chain-mode fixes go. In particular the first fix concerns setting the LS flag for jumbos if not the last segment of the payload is passed within skb (similar fix was provided for the ring mode sometime ago). The second patch fixes the invalid DMA descriptors pointer calculation for jumbo frame transmission procedure. The third modification prevents the global chain-mode flag modification for the Sun8i NICs. Final update makes sure that ATDS flag (Extended Enhanced DMA descriptors support is activated) is set no matter whether ring or chain mode is activated.
Then two fixes of the data corruption and memory leaks are introduced. The first one concerns the SKB saved in the Rx-state cache, which left available after the NIC re-open cycle thus causing improper reception of the first frame. The second patch fixes the Rx DMA descriptors memory left allocated on the Tx DMA descriptors allocation failure.
Afterwards the Rx-mitigation algorithm fix is provided. Currently it turned out to be malfunction since the Rx interrupt is only triggered based on the Rx watchdog timer meanwhile it is supposed to be triggered either by the watchdog timer or after receiving a defined number of frames.
Then a fix of the buf_sz kernel module parameter goes. In particular it converts the parameter to indicating the minimal value of the Rx DMA buffers size instead of being completely useless.
The next patch fixes the inconsistency in the DW GMAC v4.10 DMA ops descriptor, which for unknown reason was initialized with the pointer to dwmac4_disable_dma_irq() procedure instead of using the dedicated for v4.10 dwmac410_disable_dma_irq() method. That didn't cause any problem because the modified bits matches in both IP-core revisions, but for consistency we suggest to fix that.
The patchset continues with the PTP-part of the driver fix. The corresponding patch prevents the stmmac_ptp_register() procedure from modifying the fields of the ptp_clock_info static structure instance.
Finally the series is closed with a patch fixing the Loongson PCI MAC glue-driver, which erroneously accepts the zero IRQ number as valid (see of_irq_get*() semantics for details).
Serge Semin (13):
net: phy: realtek: Fix events detection failure in LPI mode
net: stmmac: Omit last desc flag for non-linear jumbos in chain-mode
net: stmmac: Fix extended descriptors usage for jumbos in chain-mode
net: stmmac: dwmac-sun8i: Don't modify chain-mode module parameter
net: stmmac: Enable ATDS for chain-mode
net: stmmac: Free temporary Rx SKB on request
net: stmmac: Free Rx descs on Tx allocation failure
net: stmmac: Fix Rx IC bit setting procedure for Rx-mitigation
net: stmmac: Remove default maxmtu DT-platform setting
net: stmmac: Make buf_sz module parameter useful
net: stmmac: gmac4: Use dwmac410_disable_dma_irq for DW MAC v4.10 DMA
net: stmmac: Stop overriding the PTP clock info static instance
net: dwmac-loongson: Perceive zero IRQ as invalid
.../net/ethernet/stmicro/stmmac/chain_mode.c | 14 +++++-- .../ethernet/stmicro/stmmac/dwmac-loongson.c | 6 +-- .../net/ethernet/stmicro/stmmac/dwmac4_dma.c | 2 +- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 39 +++++++++---------- .../ethernet/stmicro/stmmac/stmmac_platform.c | 5 --- .../net/ethernet/stmicro/stmmac/stmmac_ptp.c | 19 ++++----- drivers/net/phy/realtek.c | 37 ++++++++++++++++++ 7 files changed, 77 insertions(+), 45 deletions(-)
Signature · 1 line
2.39.2
PATCH 1/13 net: phy: realtek: Fix events detection failure in LPI mode
It has been noticed that RTL8211E PHY stops detecting and reporting events (cable plugging in/out, link state changes, etc) when EEE is successfully advertised and "RXC stopping in LPI" is enabled. The freeze happens right after 3.0.10 bit (PC1R "Clock Stop Enable" register) is set. At the same time LED2 stops blinking as if EEE mode has been disabled, interrupt pin doesn't change its state (signal tested by oscilloscope). Notably the network traffic still flows through the PHY with no obvious problem as long as a network cable is connected. But if any MDIO read/write procedure is performed after the "RXC stop in LPI" mode is enabled (even from a non-existent device on the MDIO bus) the PHY gets to be unfrozen, LED2 starts blinking and PHY interrupts happens again (even which have happened during the freeze). The problem has been noticed on RTL8211E PHY working together with DW GMAC 3.73a MAC and reporting its event via a dedicated DW MAC GPIO-IRQ signal. (Obviously the problem has been unnoticed in the polling mode, since it gets naturally fixed by the periodic MDIO read procedure from the PHY status register - BMSR.)
In order to fix that problem we suggest to locally re-implement the MMD write method for RTL8211E PHY and perform a dummy read right after the PC1R register is accessed to enable the RXC stopping in LPI mode.
---
Original patch:
--- drivers/net/phy/realtek.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)
drivers/net/phy/realtek.c +37 -0
@@ -637,6 +637,42 @@ static int rtl822x_write_mmd(struct phy_device *phydev, int devnum, u16 regnum,return ret; } +static int rtl8211e_write_mmd (struct phy_device *phydev,int devnum,u16 regnum, +u16 val) +{ +int ret; + +/* Write to the MMD registers by using the standard control/data pair. +* The only difference is that we need to perform a dummy read after +* the PC1R.CLKSTOP_EN bit is set. It's required to workaround an issue +* of a partial core freeze so LED2 stops blinking in EEE mode, PHY +* stops detecting the link change and raising IRQs until any read from +* its registers performed. That happens only if and right after the PHY +* is enabled to stop RXC in LPI mode. +*/ + ret =__phy_write (phydev,MII_MMD_CTRL , devnum); +if (ret) +return ret; + + ret =__phy_write (phydev,MII_MMD_DATA , regnum); +if (ret) +return ret; + + ret =__phy_write (phydev,MII_MMD_CTRL , devnum |MII_MMD_CTRL_NOINCR ); +if (ret) +return ret; + + ret =__phy_write (phydev,MII_MMD_DATA , val); +if (ret) +return ret; + +if (devnum ==MDIO_MMD_PCS && regnum ==MDIO_CTRL1 && + val &MDIO_PCS_CTRL1_CLKSTOP_EN ) + ret =__phy_read (phydev,MII_MMD_DATA ); + +return ret <0 ? ret :0 ; +} +static int rtl822x_get_features (struct phy_device *phydev) {int val;
@@ -919,6 +955,7 @@ static struct phy_driver realtek_drvs[] = { .resume = genphy_resume, .read_page = rtl821x_read_page, .write_page = rtl821x_write_page, + .write_mmd = rtl8211e_write_mmd, }, { PHY_ID_MATCH_EXACT(0x001cc916), .name = "RTL8211F Gigabit Ethernet",
Signature · 1 line
2.39.2
Andrew Lunn
maintainerRe: [PATCH net 01/13] net: phy: realtek: Fix events detection failure in LPI mode
Quoted 2 lines
Signed-off-by Serge Semin <[email protected]>Reviewed-by Andrew Lunn <[email protected]>
Since this is for net, you need to provide a Fixes: tag.
Andrew
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH net 01/13] net: phy: realtek: Fix events detection failure in LPI mode
Hi Andrew
Quoted 4 lines · Andrew Lunn
Quoted 2 lines
Signed-off-by Serge Semin <[email protected]>Reviewed-by Andrew Lunn <[email protected]>Since this is for net, you need to provide a Fixes: tag.
Hm, for some reason I was sure that all the patches in this series were equipped with the Fixes-tags. Anyway since the patch fixes the particular device malfunction then it's relevant to the commit initially adding the device support:
I'll add that tag on v2. Thanks for reminding.
-Serge(y)
Quoted 2 lines
Andrew
PATCH 2/13 net: stmmac: Omit last desc flag for non-linear jumbos in chain-mode
In reply to Serge SeminIndeed similar to the ring mode we need not to set the LS flag in a Tx DMA descriptor of the last chunk of the linear jumbo-SKB data if it's supposed to have additional fragments attached. That buffers will be used to initialized further Tx DMA descriptors later in the common stmmac_rx() code. The LS flag will be set for the last of them then.
A similar fix has been introduced for the ring-mode in the commit 58f2ce6f6161 ("net: stmmac: fix jumbo frame sending with non-linear skbs"). But for some reason it hasn't been done for the chained descriptors.
--- drivers/net/ethernet/stmicro/stmmac/chain_mode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/chain_mode.c +2 -1
@@ -73,7 +73,8 @@ static int jumbo_frm(void *p, struct sk_buff *skb, int csum) tx_q->tx_skbuff_dma[entry].len = len;/* last descriptor can be set now */ stmmac_prepare_tx_desc (priv, desc,0 , len, csum, -STMMAC_CHAIN_MODE ,1 , true, skb->len); +STMMAC_CHAIN_MODE ,1 , + !skb_is_nonlinear (skb), skb->len); len =0 ; } }
Signature · 1 line
2.39.2
PATCH 3/13 net: stmmac: Fix extended descriptors usage for jumbos in chain-mode
In reply to Serge SeminIf a DW MAC NIC is synthesized to support the extended descriptors, then the driver uses dma_etx pointer to keep an array of once in the Tx DMA Queue structures. For some reason the specific to the chained-mode jumbo_frm() referred to the dma_tx pointer of DMA Tx Queue descriptor in any case, which of course was initialized with NULL for the DW MACs expecting extended descriptors being specified. So any attempt to send a Jumbo frame in chain-mode caused "Unable to handle kernel paging request at virtual address" kernel crash. Fix that by selecting a proper descriptor pointer depending on whether the NIC supports extended descriptors or not.
---
Yeah, that Normal/Enhanced access pattern really annoying. Food for thoughts about a more thorough cleanup of the driver.
--- drivers/net/ethernet/stmicro/stmmac/chain_mode.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/chain_mode.c +9 -2
@@ -24,7 +24,10 @@ static int jumbo_frm(void *p, struct sk_buff *skb, int csum)unsigned int i =1 , len;struct dma_desc *desc; - desc = tx_q->dma_tx + entry; +if (priv->extend_desc) + desc = (struct dma_desc *)(tx_q->dma_etx + entry); +else + desc = tx_q->dma_tx + entry;if (priv->plat->enh_desc) bmax = BUF_SIZE_8KiB;
@@ -47,7 +50,11 @@ static int jumbo_frm(void *p, struct sk_buff *skb, int csum)while (len !=0 ) { tx_q->tx_skbuff[entry] =NULL ; entry =STMMAC_GET_ENTRY (entry, priv->dma_conf.dma_tx_size); - desc = tx_q->dma_tx + entry; + +if (priv->extend_desc) + desc = (struct dma_desc *)(tx_q->dma_etx + entry); +else + desc = tx_q->dma_tx + entry;if (len > bmax) { des2 = dma_map_single(priv->device,
Signature · 1 line
2.39.2
PATCH 4/13 net: stmmac: dwmac-sun8i: Don't modify chain-mode module parameter
In reply to Serge SeminDoing so activates the chain-mode for any DW MAC-based NIC on the platform no matter with what parameter the module is loaded. Even if there is no any other network controller on the SoC it is logically incorrect.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +3 -2
@@ -6806,8 +6806,9 @@ static int stmmac_hw_init(struct stmmac_priv *priv)/* dwmac-sun8i only work in chain mode */ if (priv->plat->has_sun8i) - chain_mode =1 ; - priv->chain_mode = chain_mode; + priv->chain_mode =1 ; +else + priv->chain_mode = chain_mode;/* Initialize HW Interface */ ret =stmmac_hwif_init (priv);
Signature · 1 line
2.39.2
PATCH 5/13 net: stmmac: Enable ATDS for chain-mode
In reply to Serge SeminIt wasn't stated why the Alternate Descriptor Size shouldn't have been changed for the chained DMA descriptors, while the original commit did introduce some chain_mode.c modifications. So the ATDS-related change in commit c24602ef8664 ("stmmac: support extend descriptors") seems contradicting. Anyway from the DW MAC/GMAC hardware point of view there is no such limitation - whether the chained descriptors can't be used together with the extended alternate descriptors. Moreover not setting the BUS_MODE.ATDS flag will cause the driver malfunction in the framework of the IPC Full Checksum and Advanced Timestamp feature, since the later features require the additional 4-7 dwords of the DMA descriptor to set some flags and a timestamp. So to speak in order to have all these features working correctly in the chained mode too let's make sure the ATDS flag is set irrespectively from the DMA descriptors mode.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +2 -5
@@ -2907,7 +2907,6 @@ static int stmmac_init_dma_engine(struct stmmac_priv *priv)struct stmmac_rx_queue *rx_q;struct stmmac_tx_queue *tx_q;u32 chan =0 ; -int atds =0 ;int ret =0 ;if (!priv->plat->dma_cfg || !priv->plat->dma_cfg->pbl) {
@@ -2915,9 +2914,6 @@ static int stmmac_init_dma_engine(struct stmmac_priv *priv)return -EINVAL ; } -if (priv->extend_desc && (priv->mode ==STMMAC_RING_MODE )) - atds =1 ; - ret =stmmac_reset (priv, priv->ioaddr);if (ret) {dev_err (priv->device,"Failed to reset the dma\n" );
@@ -2925,7 +2921,8 @@ static int stmmac_init_dma_engine(struct stmmac_priv *priv) }/* DMA Configuration */ -stmmac_dma_init (priv, priv->ioaddr, priv->plat->dma_cfg, atds); +stmmac_dma_init (priv, priv->ioaddr, priv->plat->dma_cfg, + priv->extend_desc);if (priv->plat->axi)stmmac_axi (priv, priv->ioaddr, priv->plat->axi);
Signature · 1 line
2.39.2
Re: [PATCH net 05/13] net: stmmac: Enable ATDS for chain-mode
Quoted 56 lines · Serge Semin
It wasn't stated why the Alternate Descriptor Size shouldn't have been changed for the chained DMA descriptors, while the original commit did introduce some
chain_mode.cmodifications. So the ATDS-related change in commitc24602ef8664("stmmac: support extend descriptors") seems contradicting. Anyway from the DW MAC/GMAC hardware point of view there is no such limitation - whether the chained descriptors can't be used together with the extended alternate descriptors. Moreover not setting the BUS_MODE.ATDS flag will cause the driver malfunction in the framework of the IPC Full Checksum and Advanced Timestamp feature, since the later features require the additional 4-7 dwords of the DMA descriptor to set some flags and a timestamp. So to speak in order to have all these features working correctly in the chained mode too let's make sure the ATDS flag is set irrespectively from the DMA descriptors mode.Fixes c24602ef8664 ("stmmac: support extend descriptors")Signed-off-by Serge Semin <[email protected]>--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +2
-5@@ -2907,7 +2907,6 @@ static int stmmac_init_dma_engine(struct stmmac_priv *priv)struct stmmac_rx_queue *rx_q;struct stmmac_tx_queue *tx_q;u32 chan =0 ; -int atds =0 ;int ret =0 ;if (!priv->plat->dma_cfg || !priv->plat->dma_cfg->pbl) {@@ -2915,9 +2914,6 @@ static int stmmac_init_dma_engine(struct stmmac_priv *priv)return -EINVAL ; } -if (priv->extend_desc && (priv->mode ==STMMAC_RING_MODE )) - atds =1 ; - ret =stmmac_reset (priv, priv->ioaddr);if (ret) {dev_err (priv->device,"Failed to reset the dma\n" );@@ -2925,7 +2921,8 @@ static int stmmac_init_dma_engine(struct stmmac_priv *priv) }/* DMA Configuration */ -stmmac_dma_init (priv, priv->ioaddr, priv->plat->dma_cfg, atds); +stmmac_dma_init (priv, priv->ioaddr, priv->plat->dma_cfg, + priv->extend_desc);if (priv->plat->axi)stmmac_axi (priv, priv->ioaddr, priv->plat->axi);Signature · 1 line
2.39.2
Looks fine, thanks.
PATCH 6/13 net: stmmac: Free temporary Rx SKB on request
In reply to Serge SeminIn case if an incoming frame couldn't be finished in one stmmac_rx() method call an SKB used to collect data so far will be saved in the corresponding Rx-queue state buffer. If the network device is closed before the frame is completed the preserved SKB will be utilized on the next network interface link uprising cycle right on the first frame reception, which will cause having a confused set of SKB data. Let's free the allocated Rx SKB then when all Rx-buffers are requested to be freed.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +4 -0
@@ -1545,6 +1545,10 @@ static void dma_free_rx_skbufs(struct stmmac_priv *priv,for (i =0 ; i < dma_conf->dma_rx_size; i++)stmmac_free_rx_buffer (priv, rx_q, i); + +if (rx_q->state_saved) +dev_kfree_skb (rx_q->state.skb); + rx_q->state_saved = false; } static int stmmac_alloc_rx_buffers(struct stmmac_priv *priv,
Signature · 1 line
2.39.2
Re: [PATCH net 06/13] net: stmmac: Free temporary Rx SKB on request
Quoted 33 lines · Serge Semin
In case if an incoming frame couldn't be finished in one
stmmac_rx()method call an SKB used to collect data so far will be saved in the corresponding Rx-queue state buffer. If the network device is closed before the frame is completed the preserved SKB will be utilized on the next network interface link uprising cycle right on the first frame reception, which will cause having a confused set of SKB data. Let's free the allocated Rx SKB then when all Rx-buffers are requested to be freed.Fixes ec222003bd94 ("net: stmmac: Prepare to add Split Header support")Signed-off-by Serge Semin <[email protected]>--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +4
-0@@ -1545,6 +1545,10 @@ static void dma_free_rx_skbufs(struct stmmac_priv *priv,for (i =0 ; i < dma_conf->dma_rx_size; i++)stmmac_free_rx_buffer (priv, rx_q, i); + +if (rx_q->state_saved) +dev_kfree_skb (rx_q->state.skb); + rx_q->state_saved = false; } static int stmmac_alloc_rx_buffers(struct stmmac_priv *priv,Signature · 1 line
2.39.2
LGTM, thanks.
PATCH 7/13 net: stmmac: Free Rx descs on Tx allocation failure
In reply to Serge SeminIndeed in accordance with the alloc_dma_desc_resources() method logic the Rx descriptors will be left allocated if Tx descriptors allocation fails. Fix it by calling the free_dma_rx_desc_resources() in case if the alloc_dma_tx_desc_resources() method returns non-zero value.
While at it refactor the method a bit. Just move the Rx descriptors allocation method invocation out of the local variables declaration block and discard a pointless comment from there.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +4 -2
@@ -2182,13 +2182,15 @@ static int alloc_dma_tx_desc_resources(struct stmmac_priv *priv,static int alloc_dma_desc_resources (struct stmmac_priv *priv,struct stmmac_dma_conf *dma_conf) { -/* RX Allocation */ -int ret =alloc_dma_rx_desc_resources (priv, dma_conf); +int ret; + ret =alloc_dma_rx_desc_resources (priv, dma_conf);if (ret)return ret; ret =alloc_dma_tx_desc_resources (priv, dma_conf); +if (ret) +free_dma_rx_desc_resources (priv, dma_conf);return ret; }
Signature · 1 line
2.39.2
Re: [PATCH net 07/13] net: stmmac: Free Rx descs on Tx allocation failure
Quoted 9 lines · Serge Semin
Indeed in accordance with the
alloc_dma_desc_resources()method logic the Rx descriptors will be left allocated if Tx descriptors allocation fails. Fix it by calling thefree_dma_rx_desc_resources()in case if thealloc_dma_tx_desc_resources()method returns non-zero value.While at it refactor the method a bit. Just move the Rx descriptors allocation method invocation out of the local variables declaration block and discard a pointless comment from there.
LGTM, Thanks.
Quoted 32 lines
Fixes 71fedb0198cb ("net: stmmac: break some functions into RX and TX scopes")Signed-off-by Serge Semin <[email protected]>--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +4
-2@@ -2182,13 +2182,15 @@ static int alloc_dma_tx_desc_resources(struct stmmac_priv *priv,static int alloc_dma_desc_resources (struct stmmac_priv *priv,struct stmmac_dma_conf *dma_conf) { -/* RX Allocation */ -int ret =alloc_dma_rx_desc_resources (priv, dma_conf); +int ret; + ret =alloc_dma_rx_desc_resources (priv, dma_conf);if (ret)return ret; ret =alloc_dma_tx_desc_resources (priv, dma_conf); +if (ret) +free_dma_rx_desc_resources (priv, dma_conf);return ret; }Signature · 1 line
2.39.2
PATCH 8/13 net: stmmac: Fix Rx IC bit setting procedure for Rx-mitigation
In reply to Serge SeminThe WDT-less Rx-traffic mitigation is simple: enable the Rx-descriptor Completion interrupt only when a particular number of descriptors handled by the NIC. Alas it's broken now because the data variable rx_count_frames is always set to zero due to commit 6fa9d691b91a ("net: stmmac: Prevent divide-by-zero") (++rx_count_frames + rx_coal_frames > rx_coal_frames always if no overflow happens). So Rx IC will be enabled for each descriptor as soon as rx_coal_frames is non-zero or there is no Rx WDT available, which basically disables the Rx-mitigation in the framework of the number of received frames part. Fix that by discarding the statement:rx_q->rx_count_frames += priv->rx_coal_frames.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 -- 1 file changed, 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +0 -2
@@ -4627,7 +4627,6 @@ static inline void stmmac_rx_refill(struct stmmac_priv *priv, u32 queue)stmmac_refill_desc3 (priv, rx_q, p); rx_q->rx_count_frames++; - rx_q->rx_count_frames += priv->rx_coal_frames[queue];if (rx_q->rx_count_frames > priv->rx_coal_frames[queue]) rx_q->rx_count_frames =0 ;
@@ -4967,7 +4966,6 @@ static bool stmmac_rx_refill_zc(struct stmmac_priv *priv, u32 queue, u32 budget)stmmac_refill_desc3 (priv, rx_q, rx_desc); rx_q->rx_count_frames++; - rx_q->rx_count_frames += priv->rx_coal_frames[queue];if (rx_q->rx_count_frames > priv->rx_coal_frames[queue]) rx_q->rx_count_frames =0 ;
Signature · 1 line
2.39.2
PATCH 9/13 net: stmmac: Remove default maxmtu DT-platform setting
In reply to Serge SeminInitializing maxmtu platform parameter in the stmmac_probe_config_dt() method by default makes being pointless the DW MAC-specific maximum MTU selection algorithm implemented in the stmmac_dvr_probe() method. At least for xGMAC we'll always have a frame MTU limited with 9000 while it supports units up to 16KB. Let's remove the default initialization of the maxmtu platform setting then. We don't replace it with setting the maxmtu with some greater value because a default maximum MTU is calculated later in the stmmac_dvr_probe() anyway. That would have been a pointless limitation too. Instead from now the main STMMAC driver code will consider the out of bounds maxmtu value as invalid and will silently replace it with a maximum MTU value specific to the corresponding DW MAC.
Note this alteration will only affect the xGMAC IP-cores due to the way the MTU autodetecion algorithm is implemented. So from now the driver will permit DW xGMACs to handle frames up to 16KB length (XGMAC_JUMBO_LEN). As before DW GMAC IP-cores of v4.0 and higher and IP-cores with enhanced descriptor support will be able to work with frames up to 8KB (JUMBO_LEN). The rest of the NICs will support frames of SKB_MAX_HEAD(NET_SKB_PAD + NET_IP_ALIGN) size.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 ---- drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 5 ----- 2 files changed, 9 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +0 -4
@@ -7252,10 +7252,6 @@ int stmmac_dvr_probe(struct device *device,if ((priv->plat->maxmtu < ndev->max_mtu) && (priv->plat->maxmtu >= ndev->min_mtu)) ndev->max_mtu = priv->plat->maxmtu; -else if (priv->plat->maxmtu < ndev->min_mtu) -dev_warn (priv->device, -"%s: warning: maxmtu having invalid value (%d)\n" , - __func__, priv->plat->maxmtu);if (flow_ctrl) priv->flow_ctrl =FLOW_AUTO ;/* RX/TX pause on */
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +0 -5
@@ -468,11 +468,6 @@ stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac) plat->en_tx_lpi_clockgating =of_property_read_bool (np,"snps,en-tx-lpi-clockgating" ); -/* Set the maxmtu to a default of JUMBO_LEN in case the -* parameter is not present in the device tree. -*/ - plat->maxmtu =JUMBO_LEN ; -/* Set default value for multicast hash bins */ plat->multicast_filter_bins =HASH_TABLE_SIZE ;
Signature · 1 line
2.39.2
Re: [PATCH net 09/13] net: stmmac: Remove default maxmtu DT-platform setting
Quoted 32 lines · Serge Semin
Initializing maxmtu platform parameter in the
stmmac_probe_config_dt()method by default makes being pointless the DW MAC-specific maximum MTU selection algorithm implemented in thestmmac_dvr_probe()method. At least for xGMAC we'll always have a frame MTU limited with 9000 while it supports units up to 16KB. Let's remove the default initialization of the maxmtu platform setting then. We don't replace it with setting the maxmtu with some greater value because a default maximum MTU is calculated later in thestmmac_dvr_probe()anyway. That would have been a pointless limitation too. Instead from now the main STMMAC driver code will consider the out of bounds maxmtu value as invalid and will silently replace it with a maximum MTU value specific to the corresponding DW MAC.Note this alteration will only affect the xGMAC IP-cores due to the way the MTU autodetecion algorithm is implemented. So from now the driver will permit DW xGMACs to handle frames up to 16KB length (
XGMAC_JUMBO_LEN). As before DW GMAC IP-cores of v4.0 and higher and IP-cores with enhanced descriptor support will be able to work with frames up to 8KB (JUMBO_LEN). The rest of the NICs will support frames ofSKB_MAX_HEAD(NET_SKB_PAD + NET_IP_ALIGN)size.Fixes 7d9e6c5afab6 ("net: stmmac: Integrate XGMAC into main driver flow")Signed-off-by Serge Semin <[email protected]>--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 ---- drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 5 ----- 2 files changed, 9 deletions(-)drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +0
-0
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c int stmmac_dvr_probe(struct device *device, · line 7258
Quoted 7 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +0
-4@@ -7252,10 +7252,6 @@ int stmmac_dvr_probe(struct device *device,if ((priv->plat->maxmtu < ndev->max_mtu) && (priv->plat->maxmtu >= ndev->min_mtu)) ndev->max_mtu = priv->plat->maxmtu; -else if (priv->plat->maxmtu < ndev->min_mtu) -dev_warn (priv->device, -"%s: warning: maxmtu having invalid value (%d)\n" , - __func__, priv->plat->maxmtu);
Looks fine but by removing plat->maxmtu = JUMBO_LEN; you eliminate the case of dev_warn here or you remove dev_warn since the driver will be able to fix the mtu value?
Quoted 23 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +0
-0if (flow_ctrl) priv->flow_ctrl =FLOW_AUTO ;/* RX/TX pause on */ drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +0
-5@@ -468,11 +468,6 @@ stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac) plat->en_tx_lpi_clockgating =of_property_read_bool (np,"snps,en-tx-lpi-clockgating" ); -/* Set the maxmtu to a default of JUMBO_LEN in case the -* parameter is not present in the device tree. -*/ - plat->maxmtu =JUMBO_LEN ; -/* Set default value for multicast hash bins */ plat->multicast_filter_bins =HASH_TABLE_SIZE ;Signature · 1 line
2.39.2
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH net 09/13] net: stmmac: Remove default maxmtu DT-platform setting
Quoted 37 lines · Piotr Raczynski
Quoted 35 lines · Serge Semin
Initializing maxmtu platform parameter in the
stmmac_probe_config_dt()method by default makes being pointless the DW MAC-specific maximum MTU selection algorithm implemented in thestmmac_dvr_probe()method. At least for xGMAC we'll always have a frame MTU limited with 9000 while it supports units up to 16KB. Let's remove the default initialization of the maxmtu platform setting then. We don't replace it with setting the maxmtu with some greater value because a default maximum MTU is calculated later in thestmmac_dvr_probe()anyway. That would have been a pointless limitation too. Instead from now the main STMMAC driver code will consider the out of bounds maxmtu value as invalid and will silently replace it with a maximum MTU value specific to the corresponding DW MAC.Note this alteration will only affect the xGMAC IP-cores due to the way the MTU autodetecion algorithm is implemented. So from now the driver will permit DW xGMACs to handle frames up to 16KB length (
XGMAC_JUMBO_LEN). As before DW GMAC IP-cores of v4.0 and higher and IP-cores with enhanced descriptor support will be able to work with frames up to 8KB (JUMBO_LEN). The rest of the NICs will support frames ofSKB_MAX_HEAD(NET_SKB_PAD + NET_IP_ALIGN)size.Fixes 7d9e6c5afab6 ("net: stmmac: Integrate XGMAC into main driver flow")Signed-off-by Serge Semin <[email protected]>--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 ---- drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 5 ----- 2 files changed, 9 deletions(-)drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +0
-0@@ -7252,10 +7252,6 @@ int stmmac_dvr_probe(struct device *device,if ((priv->plat->maxmtu < ndev->max_mtu) && (priv->plat->maxmtu >= ndev->min_mtu)) ndev->max_mtu = priv->plat->maxmtu;
Quoted 8 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c int stmmac_dvr_probe(struct device *device, · line 7258
Quoted 4 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +0
-4-else if (priv->plat->maxmtu < ndev->min_mtu) -dev_warn (priv->device, -"%s: warning: maxmtu having invalid value (%d)\n" , - __func__, priv->plat->maxmtu);Looks fine but by removing
plat->maxmtu=JUMBO_LEN; you eliminate the case ofdev_warnhere or you removedev_warnsince the driver will be able to fix the mtu value?
That warning is kind of odd if not to say contradicting. Why having max_mtu being less than the HW-specific min-value is more dangerous than having it being greater than the max-value for which there is no warning? The driver gets to the HW-specific min and max MTU values in anyway. Why to warn in one case and leaving unnoticed another?..
Anyway getting back to this patch change I remove the warning since plat_stmmaceth_data.maxmtu is now will be initialized with zero most of the time (if glue-drivers leave it uninitialized or there is no "max-frame-size" DT-property specified) which will falsely trigger that warning.
-Serge(y)
Quoted 19 lines
Quoted 19 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +0
-0if (flow_ctrl) priv->flow_ctrl =FLOW_AUTO ;/* RX/TX pause on */ drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +0
-5@@ -468,11 +468,6 @@ stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac) plat->en_tx_lpi_clockgating =of_property_read_bool (np,"snps,en-tx-lpi-clockgating" ); -/* Set the maxmtu to a default of JUMBO_LEN in case the -* parameter is not present in the device tree. -*/ - plat->maxmtu =JUMBO_LEN ; -/* Set default value for multicast hash bins */ plat->multicast_filter_bins =HASH_TABLE_SIZE ;
Quoted 4 lines
Quoted 4 lines
Signature · 1 line
2.39.2
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 10/13 net: stmmac: Make buf_sz module parameter useful
In reply to Serge SeminSince the first day of the driver been added to the kernel the Rx DMA-buffer size module parameter hasn't been utilized for something more-or-less useful. The STMMAC main code used to initialize the actual Rx DMA-buffer size (priv->dma_buf_sz) with it by default, but then overwrote it anyway in accordance with Network device MTU or with default DMA_BUFFER_SIZE/DEFAULT_BUFSIZE macro. Moreover in the both older and modern versions of the STMMAC driver the buf_sz module parameter was overwritten on each Net-dev open procedure with a value calculated in accordance with MTU and allowed maximum buffer size. Needless to say that even though it doesn't affect the driver functionality much, setting the generic parameter with a value specific to a private device is wrong, seeing each DW MAC may have different maximum buffer size on the same platform.
In order to finally make the buf_sz (Rx DMA buffer size) parameter really useful let's stop setting it up with a value specific to a particular controller and use it to calculate the Rx DMA-buffer size instead of MTU if one is greater than the later. Thus we'll be able to tune the buffer size up when it's necessary.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +5 -6
@@ -100,10 +100,10 @@ static int tc = TC_DEFAULT;module_param (tc, int,0644 );MODULE_PARM_DESC (tc,"DMA threshold control value" ); -#define DEFAULT_BUFSIZE 1536 -static int buf_sz =DEFAULT_BUFSIZE ; -module_param (buf_sz, int,0644 ); -MODULE_PARM_DESC (buf_sz,"DMA buffer size" ); +#define DEFAULT_BUFSIZE 1536U +static unsigned int buf_sz =DEFAULT_BUFSIZE ; +module_param (buf_sz, uint,0644 ); +MODULE_PARM_DESC (buf_sz,"Rx DMA buffer size" );#define STMMAC_RX_COPYBREAK 256
@@ -3730,7 +3730,7 @@ stmmac_setup_dma_desc(struct stmmac_priv *priv, unsigned int mtu) bfsize =0 ;if (bfsize < BUF_SIZE_16KiB) - bfsize =stmmac_set_bfsize (mtu,0 ); + bfsize =stmmac_set_bfsize (max (buf_sz, mtu),0 ); dma_conf->dma_buf_sz = bfsize;/* Chose the tx/rx size from the already defined one in the
@@ -3817,7 +3817,6 @@ static int __stmmac_open(struct net_device *dev, priv->rx_copybreak =STMMAC_RX_COPYBREAK ; - buf_sz = dma_conf->dma_buf_sz;memcpy (&priv->dma_conf, dma_conf,sizeof (*dma_conf));stmmac_reset_queues_param (priv);
Signature · 1 line
2.39.2
PATCH 11/13 net: stmmac: gmac4: Use dwmac410_disable_dma_irq for DW MAC v4.10 DMA
In reply to Serge SeminFrom the very beginning of the DW GMAC v4.10 IP support the driver has used an invalid DMA IRQ disable method to switch the DMA IRQs off. Since commit 021bd5e36970 ("net: stmmac: Let TX and RX interrupts be independently enabled/disabled") a valid method has been added to the dwmac4_lib.c module, but the commit author forgot to initialize the corresponding field of the DW MAC DMA operations descriptor with it. That mistake hasn't caused any problem so far just because the RIE/TIE fields match in both 4.x and 4.10 IPs. Anyway fix the inconsistency in order to at least have a coherent driver code.
--- drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c +1 -1
@@ -557,7 +557,7 @@ const struct stmmac_dma_ops dwmac410_dma_ops = { .dma_rx_mode = dwmac4_dma_rx_chan_op_mode, .dma_tx_mode = dwmac4_dma_tx_chan_op_mode, .enable_dma_irq = dwmac410_enable_dma_irq, - .disable_dma_irq = dwmac4_disable_dma_irq, + .disable_dma_irq = dwmac410_disable_dma_irq, .start_tx = dwmac4_dma_start_tx, .stop_tx = dwmac4_dma_stop_tx, .start_rx = dwmac4_dma_start_rx,
Signature · 1 line
2.39.2
PATCH 12/13 net: stmmac: Stop overriding the PTP clock info static instance
In reply to Serge SeminIt had been defined as constant before commit 9a8a02c9d46d ("net: stmmac:
Add Flexible PPS support"). But then it was converted to be just static, which fields may get to be modified on each stmmac_ptp_register() invocation. Since that method is called from the driver probe method, a concurrent DW *MAC NIC initialization causes the race condition for the updated stmmac_ptp_clock_ops fields. That also may lead to setting an inappropriate max_adj value, which was specific for one device, was written to the stmmac_ptp_clock_ops, but then copied to the private ptp_clock_info instance unmodified.
So to speak let's leave the stmmac_ptp_clock_ops content untouched and just copy it to the device-specific instance of the ptp_clock_info structure, which fields could be then accordingly modified. After that we can get the const qualifier back to the stmmac_ptp_clock_ops instance definition.
While at it remove pointless zero-initialization of the stmmac_ptp_clock_ops fields. It's redundant since the structure is static.
--- .../net/ethernet/stmicro/stmmac/stmmac_ptp.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c +7 -12
@@ -254,15 +254,10 @@ static int stmmac_getcrosststamp(struct ptp_clock_info *ptp, }/* structure describing a PTP hardware clock */ -static struct ptp_clock_info stmmac_ptp_clock_ops = { +static const struct ptp_clock_info stmmac_ptp_clock_ops = { .owner =THIS_MODULE , .name ="stmmac ptp" , .max_adj =62500000 , - .n_alarm =0 , - .n_ext_ts =0 ,/* will be overwritten in stmmac_ptp_register */ - .n_per_out =0 ,/* will be overwritten in stmmac_ptp_register */ - .n_pins =0 , - .pps =0 , .adjfine = stmmac_adjust_freq, .adjtime = stmmac_adjust_time, .gettime64 = stmmac_get_time,
@@ -287,21 +282,21 @@ void stmmac_ptp_register(struct stmmac_priv *priv) priv->pps[i].available = true; } -if (priv->plat->ptp_max_adj) - stmmac_ptp_clock_ops.max_adj = priv->plat->ptp_max_adj; -/* Calculate the clock domain crossing (CDC) error if necessary */ priv->plat->cdc_error_adj =0 ;if (priv->plat->has_gmac4 && priv->plat->clk_ptp_rate) priv->plat->cdc_error_adj = (2 *NSEC_PER_SEC ) / priv->plat->clk_ptp_rate; - stmmac_ptp_clock_ops.n_per_out = priv->dma_cap.pps_out_num; - stmmac_ptp_clock_ops.n_ext_ts = priv->dma_cap.aux_snapshot_n; -rwlock_init (&priv->ptp_lock);mutex_init (&priv->aux_ts_lock); priv->ptp_clock_ops = stmmac_ptp_clock_ops; +if (priv->plat->ptp_max_adj) + priv->ptp_clock_ops.max_adj = priv->plat->ptp_max_adj; + + priv->ptp_clock_ops.n_per_out = priv->dma_cap.pps_out_num; + priv->ptp_clock_ops.n_ext_ts = priv->dma_cap.aux_snapshot_n; + priv->ptp_clock =ptp_clock_register (&priv->ptp_clock_ops, priv->device);if (IS_ERR (priv->ptp_clock)) {
Signature · 1 line
2.39.2
PATCH 13/13 net: dwmac-loongson: Perceive zero IRQ as invalid
In reply to Serge SeminLinux kernel defines zero IRQ number as invalid in case if IRQ couldn't be mapped. Fix that for Loongson PCI MAC specific IRQs request procedure.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +3 -3
@@ -127,20 +127,20 @@ static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_id res.addr =pcim_iomap_table (pdev)[0 ]; res.irq =of_irq_get_byname (np,"macirq" ); -if (res.irq <0 ) { +if (res.irq <=0 ) {dev_err (&pdev->dev,"IRQ macirq not found\n" ); ret = -ENODEV ; goto err_disable_msi; } res.wol_irq =of_irq_get_byname (np,"eth_wake_irq" ); -if (res.wol_irq <0 ) { +if (res.wol_irq <=0 ) {dev_info (&pdev->dev,"IRQ eth_wake_irq not found, using macirq\n" ); res.wol_irq = res.irq; } res.lpi_irq =of_irq_get_byname (np,"eth_lpi" ); -if (res.lpi_irq <0 ) { +if (res.lpi_irq <=0 ) {dev_err (&pdev->dev,"IRQ eth_lpi not found\n" ); ret = -ENODEV ; goto err_disable_msi;
Signature · 1 line
2.39.2
Re: [PATCH net 13/13] net: dwmac-loongson: Perceive zero IRQ as invalid
Quoted 3 lines · Serge Semin
Linux kernel defines zero IRQ number as invalid in case if IRQ couldn't be mapped. Fix that for Loongson PCI MAC specific IRQs request procedure.
Looks a little odd but as I also checked and kernel does seem to treat zero as mapping failure instead of -WHATEVER.
Fix looks fine.
Quoted 38 lines
Fixes 30bba69d7db4 ("stmmac: pci: Add dwmac support for Loongson")Signed-off-by Serge Semin <[email protected]>--- drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +3
-3@@ -127,20 +127,20 @@ static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_id res.addr =pcim_iomap_table (pdev)[0 ]; res.irq =of_irq_get_byname (np,"macirq" ); -if (res.irq <0 ) { +if (res.irq <=0 ) {dev_err (&pdev->dev,"IRQ macirq not found\n" ); ret = -ENODEV ; goto err_disable_msi; } res.wol_irq =of_irq_get_byname (np,"eth_wake_irq" ); -if (res.wol_irq <0 ) { +if (res.wol_irq <=0 ) {dev_info (&pdev->dev,"IRQ eth_wake_irq not found, using macirq\n" ); res.wol_irq = res.irq; } res.lpi_irq =of_irq_get_byname (np,"eth_lpi" ); -if (res.lpi_irq <0 ) { +if (res.lpi_irq <=0 ) {dev_err (&pdev->dev,"IRQ eth_lpi not found\n" ); ret = -ENODEV ; goto err_disable_msi;Signature · 1 line
2.39.2
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH net 13/13] net: dwmac-loongson: Perceive zero IRQ as invalid
Quoted 8 lines · Piotr Raczynski
Quoted 3 lines · Serge Semin
Linux kernel defines zero IRQ number as invalid in case if IRQ couldn't be mapped. Fix that for Loongson PCI MAC specific IRQs request procedure.
Looks a little odd but as I also checked and kernel does seem to treat zero as mapping failure instead of -WHATEVER.
See what Linus originally told about that:
https://lore.kernel.org/lkml/[email protected]/
Quoted 4 lines
Fix looks fine.
Reviewed-by Piotr Raczynski <[email protected]>
Thanks.
-Serge(y)
Quoted 39 lines
Quoted 39 lines
Fixes 30bba69d7db4 ("stmmac: pci: Add dwmac support for Loongson")Signed-off-by Serge Semin <[email protected]>--- drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +3
-3@@ -127,20 +127,20 @@ static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_id res.addr =pcim_iomap_table (pdev)[0 ]; res.irq =of_irq_get_byname (np,"macirq" ); -if (res.irq <0 ) { +if (res.irq <=0 ) {dev_err (&pdev->dev,"IRQ macirq not found\n" ); ret = -ENODEV ; goto err_disable_msi; } res.wol_irq =of_irq_get_byname (np,"eth_wake_irq" ); -if (res.wol_irq <0 ) { +if (res.wol_irq <=0 ) {dev_info (&pdev->dev,"IRQ eth_wake_irq not found, using macirq\n" ); res.wol_irq = res.irq; } res.lpi_irq =of_irq_get_byname (np,"eth_lpi" ); -if (res.lpi_irq <0 ) { +if (res.lpi_irq <=0 ) {dev_err (&pdev->dev,"IRQ eth_lpi not found\n" ); ret = -ENODEV ; goto err_disable_msi;Signature · 1 line
2.39.2
Jakub Kicinski
maintainerQuoted 1 line · On Tue, 14 Mar 2023 01:42:24 +0300 Serge Semin wrote:
From: Serge Semin <[email protected]>
We don't feel comfortable accepting patches from or relating to hardware produced by your organization.
Please withhold networking contributions until further notice.