]> git.baikalelectronics.ru Git - kernel.git/commitdiff
rt2800: initial watchdog implementation
authorStanislaw Gruszka <sgruszka@redhat.com>
Sat, 15 Jun 2019 10:00:56 +0000 (12:00 +0200)
committerKalle Valo <kvalo@codeaurora.org>
Tue, 25 Jun 2019 05:10:09 +0000 (08:10 +0300)
Add watchdog for rt2800 devices. For now it only detect hung
and print error.

[Note: I verified that printing messages from process context is
fine on MT7620 (WT3020) platform that have problem when printk
is called from interrupt context].

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/ralink/rt2x00/rt2800lib.c
drivers/net/wireless/ralink/rt2x00/rt2800lib.h
drivers/net/wireless/ralink/rt2x00/rt2800pci.c
drivers/net/wireless/ralink/rt2x00/rt2800soc.c
drivers/net/wireless/ralink/rt2x00/rt2800usb.c
drivers/net/wireless/ralink/rt2x00/rt2x00queue.h

index 621cd4ce69e2fd20d7e56eee33349afb15ece77a..d420d759a877572d50b972e15fa535c99201362a 100644 (file)
@@ -1212,6 +1212,60 @@ void rt2800_txdone_nostatus(struct rt2x00_dev *rt2x00dev)
 }
 EXPORT_SYMBOL_GPL(rt2800_txdone_nostatus);
 
+static int rt2800_check_hung(struct data_queue *queue)
+{
+       unsigned int cur_idx = rt2800_drv_get_dma_done(queue);
+
+       if (queue->wd_idx != cur_idx)
+               queue->wd_count = 0;
+       else
+               queue->wd_count++;
+
+       return queue->wd_count > 16;
+}
+
+void rt2800_watchdog(struct rt2x00_dev *rt2x00dev)
+{
+       struct data_queue *queue;
+       bool hung_tx = false;
+       bool hung_rx = false;
+
+       if (test_bit(DEVICE_STATE_SCANNING, &rt2x00dev->flags))
+               return;
+
+       queue_for_each(rt2x00dev, queue) {
+               switch (queue->qid) {
+               case QID_AC_VO:
+               case QID_AC_VI:
+               case QID_AC_BE:
+               case QID_AC_BK:
+               case QID_MGMT:
+                       if (rt2x00queue_empty(queue))
+                               continue;
+                       hung_tx = rt2800_check_hung(queue);
+                       break;
+               case QID_RX:
+                       /* For station mode we should reactive at least
+                        * beacons. TODO: need to find good way detect
+                        * RX hung for AP mode.
+                        */
+                       if (rt2x00dev->intf_sta_count == 0)
+                               continue;
+                       hung_rx = rt2800_check_hung(queue);
+                       break;
+               default:
+                       break;
+               }
+       }
+
+       if (hung_tx)
+               rt2x00_warn(rt2x00dev, "Watchdog TX hung detected\n");
+
+       if (hung_rx)
+               rt2x00_warn(rt2x00dev, "Watchdog RX hung detected\n");
+}
+EXPORT_SYMBOL_GPL(rt2800_watchdog);
+
 static unsigned int rt2800_hw_beacon_base(struct rt2x00_dev *rt2x00dev,
                                          unsigned int index)
 {
@@ -10211,6 +10265,8 @@ int rt2800_probe_hw(struct rt2x00_dev *rt2x00dev)
                __set_bit(REQUIRE_TASKLET_CONTEXT, &rt2x00dev->cap_flags);
        }
 
+       rt2x00dev->link.watchdog_interval = msecs_to_jiffies(100);
+
        /*
         * Set the rssi offset.
         */
index dbb413ec8b08d5a5d19269e82b3408610eda8b5f..f35f4e20d5aa50c1013a9d8befdaf68ec79c8943 100644 (file)
@@ -197,6 +197,8 @@ void rt2800_txdone_nostatus(struct rt2x00_dev *rt2x00dev);
 bool rt2800_txstatus_timeout(struct rt2x00_dev *rt2x00dev);
 bool rt2800_txstatus_pending(struct rt2x00_dev *rt2x00dev);
 
+void rt2800_watchdog(struct rt2x00_dev *rt2x00dev);
+
 void rt2800_write_beacon(struct queue_entry *entry, struct txentry_desc *txdesc);
 void rt2800_clear_beacon(struct queue_entry *entry);
 
index 71ef8f07b47b08d84327b6f8cfff6bd064d41570..df6345a92f72bebd6c5d3b61bb42b329be0004fa 100644 (file)
@@ -351,6 +351,7 @@ static const struct rt2x00lib_ops rt2800pci_rt2x00_ops = {
        .link_tuner             = rt2800_link_tuner,
        .gain_calibration       = rt2800_gain_calibration,
        .vco_calibration        = rt2800_vco_calibration,
+       .watchdog               = rt2800_watchdog,
        .start_queue            = rt2800mmio_start_queue,
        .kick_queue             = rt2800mmio_kick_queue,
        .stop_queue             = rt2800mmio_stop_queue,
index 34e9291d949cb95ac19ddbf89f78de551a11f696..1054ade65af2c2f24e022df4178507ea5a8a30db 100644 (file)
@@ -196,6 +196,7 @@ static const struct rt2x00lib_ops rt2800soc_rt2x00_ops = {
        .link_tuner             = rt2800_link_tuner,
        .gain_calibration       = rt2800_gain_calibration,
        .vco_calibration        = rt2800_vco_calibration,
+       .watchdog               = rt2800_watchdog,
        .start_queue            = rt2800mmio_start_queue,
        .kick_queue             = rt2800mmio_kick_queue,
        .stop_queue             = rt2800mmio_stop_queue,
index 9f23b18c50bbcb4c5ef806c7f2708c431bb8304e..da813dfa9a91454d9c86eaad272b04e230206313 100644 (file)
@@ -687,6 +687,7 @@ static const struct rt2x00lib_ops rt2800usb_rt2x00_ops = {
        .link_tuner             = rt2800_link_tuner,
        .gain_calibration       = rt2800_gain_calibration,
        .vco_calibration        = rt2800_vco_calibration,
+       .watchdog               = rt2800_watchdog,
        .start_queue            = rt2800usb_start_queue,
        .kick_queue             = rt2x00usb_kick_queue,
        .stop_queue             = rt2800usb_stop_queue,
index 099e747f70e7e701997f9701f862051a31fd4b44..23739dd0bc9b1757f036525471e653f33b1c6e23 100644 (file)
@@ -435,6 +435,9 @@ enum data_queue_flags {
  * @length: Number of frames in queue.
  * @index: Index pointers to entry positions in the queue,
  *     use &enum queue_index to get a specific index field.
+ * @wd_count: watchdog counter number of times entry does change
+ *      in the queue
+ * @wd_idx: index of queue entry saved by watchdog
  * @txop: maximum burst time.
  * @aifs: The aifs value for outgoing frames (field ignored in RX queue).
  * @cw_min: The cw min value for outgoing frames (field ignored in RX queue).
@@ -462,6 +465,9 @@ struct data_queue {
        unsigned short length;
        unsigned short index[Q_INDEX_MAX];
 
+       unsigned short wd_count;
+       unsigned int wd_idx;
+
        unsigned short txop;
        unsigned short aifs;
        unsigned short cw_min;