Re: [PATCH 2/6] ucc_geth: Fix TX watchdog timeout handling

Previous thread: [PATCH 1/6] ucc_geth: Fix endless loop in stop_{tx,rx} routines by Anton Vorontsov on Thursday, December 18, 2008 - 11:23 am. (1 message)

Next thread: [PATCH 3/6] ucc_geth: Fix IRQ freeing code in ucc_geth_open() by Anton Vorontsov on Thursday, December 18, 2008 - 11:23 am. (1 message)
From: Anton Vorontsov
Date: Thursday, December 18, 2008 - 11:23 am

The timeout handling code is currently broken in several ways:

- It calls stop() (which frees all the memory and IRQ), and then
  calls startup() (which won't re-request IRQ, neither it will
  re-init the Fast UCC structure).
- It calls these routines from the softirq context, which is wrong,
  since stop() calls free_irq() (which might sleep) and startup()
  allocates things with GFP_KERNEL.
- It won't soft-reset the PHY. We need the PHY reset for at least
  MPC8360E-MDS boards with Marvell 88E1111 PHY, the PHY won't recover
  from timeouts w/o the reset.

So the patch fixes these problems by implementing the workqueue for the
timeout handling, and there we fully re-open the device via close() and
open() calls. The close/open paths do the right things, and I can see
that the driver actually survive the timeouts.

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
---
 drivers/net/ucc_geth.c |   37 +++++++++++++++++++++++++++++--------
 drivers/net/ucc_geth.h |    1 +
 2 files changed, 30 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ucc_geth.c b/drivers/net/ucc_geth.c
index 79e6d3d..98a7bd4 100644
--- a/drivers/net/ucc_geth.c
+++ b/drivers/net/ucc_geth.c
@@ -3355,13 +3355,17 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
 	return 0;
 }
 
-/* ucc_geth_timeout gets called when a packet has not been
- * transmitted after a set amount of time.
- * For now, assume that clearing out all the structures, and
- * starting over will fix the problem. */
-static void ucc_geth_timeout(struct net_device *dev)
+static int ucc_geth_close(struct net_device *dev);
+static int ucc_geth_open(struct net_device *dev);
+
+/* Reopen device. This will reset the MAC and PHY. */
+static void ucc_geth_timeout_work(struct work_struct *work)
 {
-	struct ucc_geth_private *ugeth = netdev_priv(dev);
+	struct ucc_geth_private *ugeth;
+	struct net_device *dev;
+
+	ugeth = container_of(work, struct ucc_geth_private, timeout_work);
+	dev = ugeth->dev;
 
 ...
From: Timur Tabi
Date: Saturday, December 20, 2008 - 8:19 pm

On Thu, Dec 18, 2008 at 12:23 PM, Anton Vorontsov

I would prefer that you reorder the functions to eliminate the need
for forward references.

-- 
Timur Tabi
Linux kernel developer at Freescale
--

From: Anton Vorontsov
Date: Saturday, December 20, 2008 - 8:37 pm

I'll post a cleanup patch (0/6 series is already in the netdev tree).

Thanks!

-- 
Anton Vorontsov
email: cbouatmailru@gmail.com
irc://irc.freenode.net/bd2
--

Previous thread: [PATCH 1/6] ucc_geth: Fix endless loop in stop_{tx,rx} routines by Anton Vorontsov on Thursday, December 18, 2008 - 11:23 am. (1 message)

Next thread: [PATCH 3/6] ucc_geth: Fix IRQ freeing code in ucc_geth_open() by Anton Vorontsov on Thursday, December 18, 2008 - 11:23 am. (1 message)