[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210208140820.10410-13-Sergey.Semin@baikalelectronics.ru>
Date: Mon, 8 Feb 2021 17:08:16 +0300
From: Serge Semin <Sergey.Semin@...kalelectronics.ru>
To: Rob Herring <robh+dt@...nel.org>,
Giuseppe Cavallaro <peppe.cavallaro@...com>,
Alexandre Torgue <alexandre.torgue@...com>,
Jose Abreu <joabreu@...opsys.com>,
"David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
Maxime Coquelin <mcoquelin.stm32@...il.com>
CC: Serge Semin <Sergey.Semin@...kalelectronics.ru>,
Serge Semin <fancer.lancer@...il.com>,
Alexey Malahov <Alexey.Malahov@...kalelectronics.ru>,
Pavel Parkhomenko <Pavel.Parkhomenko@...kalelectronics.ru>,
Vyacheslav Mitrofanov
<Vyacheslav.Mitrofanov@...kalelectronics.ru>,
<netdev@...r.kernel.org>,
<linux-stm32@...md-mailman.stormreply.com>,
<linux-arm-kernel@...ts.infradead.org>,
<devicetree@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: [PATCH 12/16] net: stmmac: Introduce NIC software reset function
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@...kalelectronics.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
Powered by blists - more mailing lists