rt2x00: Add watchdog functions for HW queue
authorIvo van Doorn <IvDoorn@gmail.com>
Sat, 6 Nov 2010 14:49:01 +0000 (15:49 +0100)
committerJohn W. Linville <linville@tuxdriver.com>
Mon, 15 Nov 2010 18:26:36 +0000 (13:26 -0500)
Add watchdog functions for managing the Queues inside the hardware.
Normally the driver doesn't have much to do with these queues
directly, but the Ralink drivers did implement watchdog functions
for these. These watchdog functions are not triggered that often,
compared to the other watchdog functions, but I have at least
seen them trigger once or twice during a long stresstest run.

v2: Add extra documentation for register fields

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/rt2x00/rt2800.h
drivers/net/wireless/rt2x00/rt2800usb.c

index c2cc126502d6cacc69ad2fd920c4bc4948c71a6d..002224c9bb621f4b23234ab5d07047fee36b638e 100644 (file)
 #define BCN_OFFSET1_BCN7               FIELD32(0xff000000)
 
 /*
- * PBF registers
- * Most are for debug. Driver doesn't touch PBF register.
+ * TXRXQ_PCNT: PBF register
+ * PCNT_TX0Q: Page count for TX hardware queue 0
+ * PCNT_TX1Q: Page count for TX hardware queue 1
+ * PCNT_TX2Q: Page count for TX hardware queue 2
+ * PCNT_RX0Q: Page count for RX hardware queue
  */
 #define TXRXQ_PCNT                     0x0438
+#define TXRXQ_PCNT_TX0Q                        FIELD32(0x000000ff)
+#define TXRXQ_PCNT_TX1Q                        FIELD32(0x0000ff00)
+#define TXRXQ_PCNT_TX2Q                        FIELD32(0x00ff0000)
+#define TXRXQ_PCNT_RX0Q                        FIELD32(0xff000000)
+
+/*
+ * PBF register
+ * Debug. Driver doesn't touch PBF register.
+ */
 #define PBF_DBG                                0x043c
 
 /*
index f93337128504ac1c03e84602b9ddf9e37f610dd0..389ecba8e89144fb9d5bda183832ff49c4e7d2f3 100644 (file)
@@ -242,6 +242,49 @@ static int rt2800usb_set_device_state(struct rt2x00_dev *rt2x00dev,
        return retval;
 }
 
+/*
+ * Watchdog handlers
+ */
+static void rt2800usb_watchdog(struct rt2x00_dev *rt2x00dev)
+{
+       unsigned int i;
+       u32 reg;
+
+       rt2800_register_read(rt2x00dev, TXRXQ_PCNT, &reg);
+       if (rt2x00_get_field32(reg, TXRXQ_PCNT_TX0Q)) {
+               WARNING(rt2x00dev, "TX HW queue 0 timed out,"
+                       " invoke forced kick");
+
+               rt2800_register_write(rt2x00dev, PBF_CFG, 0xf40012);
+
+               for (i = 0; i < 10; i++) {
+                       udelay(10);
+                       if (!rt2x00_get_field32(reg, TXRXQ_PCNT_TX0Q))
+                               break;
+               }
+
+               rt2800_register_write(rt2x00dev, PBF_CFG, 0xf40006);
+       }
+
+       rt2800_register_read(rt2x00dev, TXRXQ_PCNT, &reg);
+       if (rt2x00_get_field32(reg, TXRXQ_PCNT_TX1Q)) {
+               WARNING(rt2x00dev, "TX HW queue 1 timed out,"
+                       " invoke forced kick");
+
+               rt2800_register_write(rt2x00dev, PBF_CFG, 0xf4000a);
+
+               for (i = 0; i < 10; i++) {
+                       udelay(10);
+                       if (!rt2x00_get_field32(reg, TXRXQ_PCNT_TX1Q))
+                               break;
+               }
+
+               rt2800_register_write(rt2x00dev, PBF_CFG, 0xf40006);
+       }
+
+       rt2x00usb_watchdog(rt2x00dev);
+}
+
 /*
  * TX descriptor initialization
  */
@@ -534,7 +577,7 @@ static const struct rt2x00lib_ops rt2800usb_rt2x00_ops = {
        .link_stats             = rt2800_link_stats,
        .reset_tuner            = rt2800_reset_tuner,
        .link_tuner             = rt2800_link_tuner,
-       .watchdog               = rt2x00usb_watchdog,
+       .watchdog               = rt2800usb_watchdog,
        .write_tx_desc          = rt2800usb_write_tx_desc,
        .write_tx_data          = rt2800_write_tx_data,
        .write_beacon           = rt2800_write_beacon,