lkml.org 
[lkml]   [2021]   [Feb]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 12/16] net: stmmac: Introduce NIC software reset function
Date
Since we are about to move the IRQs handler setup into the device probe
method, the DW MAC reset procedure needs to be redefined to be performed
with care. We must make sure the IRQs handler isn't executed while the
reset is proceeded and the IRQs are fully masked after that. The later is
required for some early versions of DW GMAC (in our case it's DW GMAC
v3.73a).

Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
---
.../net/ethernet/stmicro/stmmac/stmmac_main.c | 32 +++++++++++++++++--
1 file changed, 30 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index b37f49f3dc03..c4c41b554c6a 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -1827,6 +1827,34 @@ static void free_dma_desc_resources(struct stmmac_priv *priv)
free_dma_tx_desc_resources(priv);
}

+/**
+ * stmmac_sw_reset - reset the MAC/DMA/etc state
+ * @priv: driver private structure
+ * Description: Cleanup/reset the DW *MAC registers to their initial state.
+ */
+static int stmmac_sw_reset(struct stmmac_priv *priv)
+{
+ int ret;
+
+ /* Disable the IRQ signal while the reset is in progress so not to
+ * interfere with what the main ISR is doing.
+ */
+ disable_irq(priv->dev->irq);
+
+ ret = stmmac_reset(priv, priv->ioaddr);
+
+ /* Make sure all IRQs are disabled by default. Some DW MAC IP-cores
+ * like early versions of DW GMAC have MAC and MMC interrupts enabled
+ * after reset.
+ */
+ if (!ret)
+ stmmac_disable_irq(priv);
+
+ enable_irq(priv->dev->irq);
+
+ return ret;
+}
+
/**
* stmmac_mac_enable_rx_queues - Enable MAC rx queues
* @priv: driver private structure
@@ -2340,9 +2368,9 @@ static int stmmac_init_dma_engine(struct stmmac_priv *priv)
if (priv->extend_desc && (priv->mode == STMMAC_RING_MODE))
atds = 1;

- ret = stmmac_reset(priv, priv->ioaddr);
+ ret = stmmac_sw_reset(priv);
if (ret) {
- dev_err(priv->device, "Failed to reset the dma\n");
+ dev_err(priv->device, "Failed to reset the core\n");
return ret;
}

--
2.29.2
\
 
 \ /
  Last update: 2021-02-08 15:38    [W:0.203 / U:1.564 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site