netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] stmmac: fixed dma lib build when turn-on the debug option
@ 2011-04-11  9:16 Giuseppe CAVALLARO
  2011-04-11  9:16 ` [PATCH 2/3] stmmac: fix open funct when exit on error Giuseppe CAVALLARO
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Giuseppe CAVALLARO @ 2011-04-11  9:16 UTC (permalink / raw)
  To: netdev; +Cc: Giuseppe Cavallaro

This patch fixes a compilation error when build the
dwmac_lib with the DEBUG option enabled.

Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
---
 drivers/net/stmmac/dwmac_lib.c |   28 ++++++++++++++--------------
 1 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/net/stmmac/dwmac_lib.c b/drivers/net/stmmac/dwmac_lib.c
index d65fab1..e250935 100644
--- a/drivers/net/stmmac/dwmac_lib.c
+++ b/drivers/net/stmmac/dwmac_lib.c
@@ -26,9 +26,9 @@
 
 #undef DWMAC_DMA_DEBUG
 #ifdef DWMAC_DMA_DEBUG
-#define DBG(fmt, args...)  printk(fmt, ## args)
+#define DWMAC_LIB_DBG(fmt, args...)  printk(fmt, ## args)
 #else
-#define DBG(fmt, args...)  do { } while (0)
+#define DWMAC_LIB_DBG(fmt, args...)  do { } while (0)
 #endif
 
 /* CSR1 enables the transmit DMA to check for new descriptor */
@@ -152,7 +152,7 @@ int dwmac_dma_interrupt(void __iomem *ioaddr,
 	/* read the status register (CSR5) */
 	u32 intr_status = readl(ioaddr + DMA_STATUS);
 
-	DBG(INFO, "%s: [CSR5: 0x%08x]\n", __func__, intr_status);
+	DWMAC_LIB_DBG(KERN_INFO "%s: [CSR5: 0x%08x]\n", __func__, intr_status);
 #ifdef DWMAC_DMA_DEBUG
 	/* It displays the DMA process states (CSR5 register) */
 	show_tx_process_state(intr_status);
@@ -160,43 +160,43 @@ int dwmac_dma_interrupt(void __iomem *ioaddr,
 #endif
 	/* ABNORMAL interrupts */
 	if (unlikely(intr_status & DMA_STATUS_AIS)) {
-		DBG(INFO, "CSR5[15] DMA ABNORMAL IRQ: ");
+		DWMAC_LIB_DBG(KERN_INFO "CSR5[15] DMA ABNORMAL IRQ: ");
 		if (unlikely(intr_status & DMA_STATUS_UNF)) {
-			DBG(INFO, "transmit underflow\n");
+			DWMAC_LIB_DBG(KERN_INFO "transmit underflow\n");
 			ret = tx_hard_error_bump_tc;
 			x->tx_undeflow_irq++;
 		}
 		if (unlikely(intr_status & DMA_STATUS_TJT)) {
-			DBG(INFO, "transmit jabber\n");
+			DWMAC_LIB_DBG(KERN_INFO "transmit jabber\n");
 			x->tx_jabber_irq++;
 		}
 		if (unlikely(intr_status & DMA_STATUS_OVF)) {
-			DBG(INFO, "recv overflow\n");
+			DWMAC_LIB_DBG(KERN_INFO "recv overflow\n");
 			x->rx_overflow_irq++;
 		}
 		if (unlikely(intr_status & DMA_STATUS_RU)) {
-			DBG(INFO, "receive buffer unavailable\n");
+			DWMAC_LIB_DBG(KERN_INFO "receive buffer unavailable\n");
 			x->rx_buf_unav_irq++;
 		}
 		if (unlikely(intr_status & DMA_STATUS_RPS)) {
-			DBG(INFO, "receive process stopped\n");
+			DWMAC_LIB_DBG(KERN_INFO "receive process stopped\n");
 			x->rx_process_stopped_irq++;
 		}
 		if (unlikely(intr_status & DMA_STATUS_RWT)) {
-			DBG(INFO, "receive watchdog\n");
+			DWMAC_LIB_DBG(KERN_INFO "receive watchdog\n");
 			x->rx_watchdog_irq++;
 		}
 		if (unlikely(intr_status & DMA_STATUS_ETI)) {
-			DBG(INFO, "transmit early interrupt\n");
+			DWMAC_LIB_DBG(KERN_INFO "transmit early interrupt\n");
 			x->tx_early_irq++;
 		}
 		if (unlikely(intr_status & DMA_STATUS_TPS)) {
-			DBG(INFO, "transmit process stopped\n");
+			DWMAC_LIB_DBG(KERN_INFO "transmit process stopped\n");
 			x->tx_process_stopped_irq++;
 			ret = tx_hard_error;
 		}
 		if (unlikely(intr_status & DMA_STATUS_FBI)) {
-			DBG(INFO, "fatal bus error\n");
+			DWMAC_LIB_DBG(KERN_INFO "fatal bus error\n");
 			x->fatal_bus_error_irq++;
 			ret = tx_hard_error;
 		}
@@ -215,7 +215,7 @@ int dwmac_dma_interrupt(void __iomem *ioaddr,
 	/* Clear the interrupt by writing a logic 1 to the CSR5[15-0] */
 	writel((intr_status & 0x1ffff), ioaddr + DMA_STATUS);
 
-	DBG(INFO, "\n\n");
+	DWMAC_LIB_DBG(KERN_INFO "\n\n");
 	return ret;
 }
 
-- 
1.7.4.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3] stmmac: fix open funct when exit on error
  2011-04-11  9:16 [PATCH 1/3] stmmac: fixed dma lib build when turn-on the debug option Giuseppe CAVALLARO
@ 2011-04-11  9:16 ` Giuseppe CAVALLARO
  2011-04-11 19:56   ` David Miller
  2011-04-11  9:16 ` [PATCH 3/3] stmmac: fix Transmit Underflow error Giuseppe CAVALLARO
  2011-04-11 19:56 ` [PATCH 1/3] stmmac: fixed dma lib build when turn-on the debug option David Miller
  2 siblings, 1 reply; 6+ messages in thread
From: Giuseppe CAVALLARO @ 2011-04-11  9:16 UTC (permalink / raw)
  To: netdev; +Cc: Giuseppe Cavallaro, Shiraz Hashim

This patch reviews the open function and fixes some
errors when exit with an error state.
It also moves the request_irq after core is initialized
when interrupts are properly masked.

Signed-off-by: Shiraz Hashim <shiraz.hashim@st.com>
Hacked-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
---
 drivers/net/stmmac/stmmac_main.c |   48 ++++++++++++++++++++++---------------
 1 files changed, 28 insertions(+), 20 deletions(-)

diff --git a/drivers/net/stmmac/stmmac_main.c b/drivers/net/stmmac/stmmac_main.c
index 62fa51e..442a7ca 100644
--- a/drivers/net/stmmac/stmmac_main.c
+++ b/drivers/net/stmmac/stmmac_main.c
@@ -780,21 +780,6 @@ static int stmmac_open(struct net_device *dev)
 
 	stmmac_verify_args();
 
-	ret = stmmac_init_phy(dev);
-	if (unlikely(ret)) {
-		pr_err("%s: Cannot attach to PHY (error: %d)\n", __func__, ret);
-		return ret;
-	}
-
-	/* Request the IRQ lines */
-	ret = request_irq(dev->irq, stmmac_interrupt,
-			  IRQF_SHARED, dev->name, dev);
-	if (unlikely(ret < 0)) {
-		pr_err("%s: ERROR: allocating the IRQ %d (error: %d)\n",
-		       __func__, dev->irq, ret);
-		return ret;
-	}
-
 #ifdef CONFIG_STMMAC_TIMER
 	priv->tm = kzalloc(sizeof(struct stmmac_timer *), GFP_KERNEL);
 	if (unlikely(priv->tm == NULL)) {
@@ -813,6 +798,11 @@ static int stmmac_open(struct net_device *dev)
 	} else
 		priv->tm->enable = 1;
 #endif
+	ret = stmmac_init_phy(dev);
+	if (unlikely(ret)) {
+		pr_err("%s: Cannot attach to PHY (error: %d)\n", __func__, ret);
+		goto open_error;
+	}
 
 	/* Create and initialize the TX/RX descriptors chains. */
 	priv->dma_tx_size = STMMAC_ALIGN(dma_txsize);
@@ -821,12 +811,11 @@ static int stmmac_open(struct net_device *dev)
 	init_dma_desc_rings(dev);
 
 	/* DMA initialization and SW reset */
-	if (unlikely(priv->hw->dma->init(priv->ioaddr, priv->plat->pbl,
-					 priv->dma_tx_phy,
-					 priv->dma_rx_phy) < 0)) {
-
+	ret = priv->hw->dma->init(priv->ioaddr, priv->plat->pbl,
+				  priv->dma_tx_phy, priv->dma_rx_phy);
+	if (ret < 0) {
 		pr_err("%s: DMA initialization failed\n", __func__);
-		return -1;
+		goto open_error;
 	}
 
 	/* Copy the MAC addr into the HW  */
@@ -848,6 +837,15 @@ static int stmmac_open(struct net_device *dev)
 	writel(0xffffffff, priv->ioaddr + MMC_HIGH_INTR_MASK);
 	writel(0xffffffff, priv->ioaddr + MMC_LOW_INTR_MASK);
 
+	/* Request the IRQ lines */
+	ret = request_irq(dev->irq, stmmac_interrupt,
+			 IRQF_SHARED, dev->name, dev);
+	if (unlikely(ret < 0)) {
+		pr_err("%s: ERROR: allocating the IRQ %d (error: %d)\n",
+		       __func__, dev->irq, ret);
+		goto open_error;
+	}
+
 	/* Enable the MAC Rx/Tx */
 	stmmac_enable_mac(priv->ioaddr);
 
@@ -878,7 +876,17 @@ static int stmmac_open(struct net_device *dev)
 	napi_enable(&priv->napi);
 	skb_queue_head_init(&priv->rx_recycle);
 	netif_start_queue(dev);
+
 	return 0;
+
+open_error:
+#ifdef CONFIG_STMMAC_TIMER
+	kfree(priv->tm);
+#endif
+	if (priv->phydev)
+		phy_disconnect(priv->phydev);
+
+	return ret;
 }
 
 /**
-- 
1.7.4.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/3] stmmac: fix Transmit Underflow error
  2011-04-11  9:16 [PATCH 1/3] stmmac: fixed dma lib build when turn-on the debug option Giuseppe CAVALLARO
  2011-04-11  9:16 ` [PATCH 2/3] stmmac: fix open funct when exit on error Giuseppe CAVALLARO
@ 2011-04-11  9:16 ` Giuseppe CAVALLARO
  2011-04-11 19:56   ` David Miller
  2011-04-11 19:56 ` [PATCH 1/3] stmmac: fixed dma lib build when turn-on the debug option David Miller
  2 siblings, 1 reply; 6+ messages in thread
From: Giuseppe CAVALLARO @ 2011-04-11  9:16 UTC (permalink / raw)
  To: netdev; +Cc: Giuseppe Cavallaro

On some old MAC chips without COE sometime the
Transmit Underflow error is issued.

The driver aborted all the transmission process
and initialized it from scratch.
This breaks the network activity as raised by Nachiketa
on a SPEAr board.

The patch is to fix this rare underflow event.
The driver will only clear the interrupt and the Tx
DMA will go out the Suspend state as soon as the
descriptor is fetched again.
The driver will continue to bump-up the DMA FIFO threshold
that, indeed, helped somebody to prevent this kind of error
in the past as well.

Reported-by: Nachiketa Prachanda <nprachanda@ncomputing.com>
Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
---
 drivers/net/stmmac/stmmac_main.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/drivers/net/stmmac/stmmac_main.c b/drivers/net/stmmac/stmmac_main.c
index 442a7ca..ba9daec 100644
--- a/drivers/net/stmmac/stmmac_main.c
+++ b/drivers/net/stmmac/stmmac_main.c
@@ -749,7 +749,6 @@ static void stmmac_dma_interrupt(struct stmmac_priv *priv)
 			priv->hw->dma->dma_mode(priv->ioaddr, tc, SF_DMA_MODE);
 			priv->xstats.threshold = tc;
 		}
-		stmmac_tx_err(priv);
 	} else if (unlikely(status == tx_hard_error))
 		stmmac_tx_err(priv);
 }
-- 
1.7.4.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/3] stmmac: fixed dma lib build when turn-on the debug option
  2011-04-11  9:16 [PATCH 1/3] stmmac: fixed dma lib build when turn-on the debug option Giuseppe CAVALLARO
  2011-04-11  9:16 ` [PATCH 2/3] stmmac: fix open funct when exit on error Giuseppe CAVALLARO
  2011-04-11  9:16 ` [PATCH 3/3] stmmac: fix Transmit Underflow error Giuseppe CAVALLARO
@ 2011-04-11 19:56 ` David Miller
  2 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2011-04-11 19:56 UTC (permalink / raw)
  To: peppe.cavallaro; +Cc: netdev

From: Giuseppe CAVALLARO <peppe.cavallaro@st.com>
Date: Mon, 11 Apr 2011 11:16:44 +0200

> This patch fixes a compilation error when build the
> dwmac_lib with the DEBUG option enabled.
> 
> Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>

Applied.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/3] stmmac: fix open funct when exit on error
  2011-04-11  9:16 ` [PATCH 2/3] stmmac: fix open funct when exit on error Giuseppe CAVALLARO
@ 2011-04-11 19:56   ` David Miller
  0 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2011-04-11 19:56 UTC (permalink / raw)
  To: peppe.cavallaro; +Cc: netdev, shiraz.hashim

From: Giuseppe CAVALLARO <peppe.cavallaro@st.com>
Date: Mon, 11 Apr 2011 11:16:45 +0200

> This patch reviews the open function and fixes some
> errors when exit with an error state.
> It also moves the request_irq after core is initialized
> when interrupts are properly masked.
> 
> Signed-off-by: Shiraz Hashim <shiraz.hashim@st.com>
> Hacked-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>

Applied.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 3/3] stmmac: fix Transmit Underflow error
  2011-04-11  9:16 ` [PATCH 3/3] stmmac: fix Transmit Underflow error Giuseppe CAVALLARO
@ 2011-04-11 19:56   ` David Miller
  0 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2011-04-11 19:56 UTC (permalink / raw)
  To: peppe.cavallaro; +Cc: netdev

From: Giuseppe CAVALLARO <peppe.cavallaro@st.com>
Date: Mon, 11 Apr 2011 11:16:46 +0200

> On some old MAC chips without COE sometime the
> Transmit Underflow error is issued.
> 
> The driver aborted all the transmission process
> and initialized it from scratch.
> This breaks the network activity as raised by Nachiketa
> on a SPEAr board.
> 
> The patch is to fix this rare underflow event.
> The driver will only clear the interrupt and the Tx
> DMA will go out the Suspend state as soon as the
> descriptor is fetched again.
> The driver will continue to bump-up the DMA FIFO threshold
> that, indeed, helped somebody to prevent this kind of error
> in the past as well.
> 
> Reported-by: Nachiketa Prachanda <nprachanda@ncomputing.com>
> Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>

Applied.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-04-11 19:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-11  9:16 [PATCH 1/3] stmmac: fixed dma lib build when turn-on the debug option Giuseppe CAVALLARO
2011-04-11  9:16 ` [PATCH 2/3] stmmac: fix open funct when exit on error Giuseppe CAVALLARO
2011-04-11 19:56   ` David Miller
2011-04-11  9:16 ` [PATCH 3/3] stmmac: fix Transmit Underflow error Giuseppe CAVALLARO
2011-04-11 19:56   ` David Miller
2011-04-11 19:56 ` [PATCH 1/3] stmmac: fixed dma lib build when turn-on the debug option David Miller

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).