rt2x00: Cleanup RX index counting
authorIvo van Doorn <ivdoorn@gmail.com>
Mon, 13 Dec 2010 11:36:00 +0000 (12:36 +0100)
committerJohn W. Linville <linville@tuxdriver.com>
Mon, 13 Dec 2010 20:23:36 +0000 (15:23 -0500)
Add the rt2x00_dmastart function to rt2x00lib which
marks the queue_entry as "owned by device", and increased
the Q_INDEX number.

This cleanups up the index handling by rt2x00lib which
at until so far used hackish approaches to keep the
RX queue index numbering sane.

The rt2x00pci.c changes are from Helmut Schaa

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/rt2x00/rt2x00.h
drivers/net/wireless/rt2x00/rt2x00dev.c
drivers/net/wireless/rt2x00/rt2x00pci.c
drivers/net/wireless/rt2x00/rt2x00queue.c
drivers/net/wireless/rt2x00/rt2x00usb.c

index 1d7b481ec357d989873343d19bcda6a58b8a568c..28ea59ab2b0617e058134baee704a6e3f68d63cf 100644 (file)
@@ -1171,6 +1171,7 @@ static inline void rt2x00debug_dump_frame(struct rt2x00_dev *rt2x00dev,
  */
 void rt2x00lib_beacondone(struct rt2x00_dev *rt2x00dev);
 void rt2x00lib_pretbtt(struct rt2x00_dev *rt2x00dev);
+void rt2x00lib_dmastart(struct queue_entry *entry);
 void rt2x00lib_dmadone(struct queue_entry *entry);
 void rt2x00lib_txdone(struct queue_entry *entry,
                      struct txdone_entry_desc *txdesc);
index 9ef5a2468216fb8d9808ab2277c0649845824c18..3d4c61fcf06f447ed3d75307ee8cfdc3d0504f23 100644 (file)
@@ -226,6 +226,13 @@ void rt2x00lib_pretbtt(struct rt2x00_dev *rt2x00dev)
 }
 EXPORT_SYMBOL_GPL(rt2x00lib_pretbtt);
 
+void rt2x00lib_dmastart(struct queue_entry *entry)
+{
+       set_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags);
+       rt2x00queue_index_inc(entry->queue, Q_INDEX);
+}
+EXPORT_SYMBOL_GPL(rt2x00lib_dmastart);
+
 void rt2x00lib_dmadone(struct queue_entry *entry)
 {
        clear_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags);
@@ -555,10 +562,8 @@ submit_entry:
        entry->flags = 0;
        rt2x00queue_index_inc(entry->queue, Q_INDEX_DONE);
        if (test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags) &&
-           test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags)) {
+           test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags))
                rt2x00dev->ops->lib->clear_entry(entry);
-               rt2x00queue_index_inc(entry->queue, Q_INDEX);
-       }
 }
 EXPORT_SYMBOL_GPL(rt2x00lib_rxdone);
 
index 868ca19b13ea3e59b57a475ccdbc63a919693862..28e6ff1a6694d8b428b53a6bc5b07a6c3167b2cd 100644 (file)
@@ -81,6 +81,13 @@ void rt2x00pci_rxdone(struct rt2x00_dev *rt2x00dev)
                skbdesc->desc = entry_priv->desc;
                skbdesc->desc_len = entry->queue->desc_size;
 
+               /*
+                * DMA is already done, notify rt2x00lib that
+                * it finished successfully.
+                */
+               rt2x00lib_dmastart(entry);
+               rt2x00lib_dmadone(entry);
+
                /*
                 * Send the frame to rt2x00lib for further processing.
                 */
index 313a8faa5fa43708d2f5606b0364c8b92d3c0090..52cc92d426f3a30b1c9014b7dee7489e8e8941dd 100644 (file)
@@ -968,11 +968,8 @@ void rt2x00queue_init_queues(struct rt2x00_dev *rt2x00dev)
        queue_for_each(rt2x00dev, queue) {
                rt2x00queue_reset(queue);
 
-               for (i = 0; i < queue->limit; i++) {
+               for (i = 0; i < queue->limit; i++)
                        rt2x00dev->ops->lib->clear_entry(&queue->entries[i]);
-                       if (queue->qid == QID_RX)
-                               rt2x00queue_index_inc(queue, Q_INDEX);
-               }
        }
 }
 
index cd80eec5ff51e0fc20079d170d650a17c354f2e9..cd29ebc8a37b70fc71edc0a407c4c0e8707a6a04 100644 (file)
@@ -330,6 +330,8 @@ static void rt2x00usb_kick_rx_entry(struct queue_entry *entry)
        if (test_and_set_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags))
                return;
 
+       rt2x00lib_dmastart(entry);
+
        usb_fill_bulk_urb(entry_priv->urb, usb_dev,
                          usb_rcvbulkpipe(usb_dev, entry->queue->usb_endpoint),
                          entry->skb->data, entry->skb->len,