~ubuntu-branches/ubuntu/quantal/linux-linaro-mx51/quantal

« back to all changes in this revision

Viewing changes to drivers/net/wireless/iwlegacy/iwl-tx.c

  • Committer: Package Import Robot
  • Author(s): John Rigby, John Rigby
  • Date: 2011-09-26 10:44:23 UTC
  • Revision ID: package-import@ubuntu.com-20110926104423-3o58a3c1bj7x00rs
Tags: 3.0.0-1007.9
[ John Rigby ]

Enable crypto modules and remove crypto-modules from
exclude-module files
LP: #826021

Show diffs side-by-side

added added

removed removed

Lines of Context:
146
146
{
147
147
        struct iwl_tx_queue *txq = &priv->txq[priv->cmd_queue];
148
148
        struct iwl_queue *q = &txq->q;
149
 
        bool huge = false;
150
149
        int i;
151
150
 
152
151
        if (q->n_bd == 0)
153
152
                return;
154
153
 
155
154
        while (q->read_ptr != q->write_ptr) {
156
 
                /* we have no way to tell if it is a huge cmd ATM */
157
155
                i = iwl_legacy_get_cmd_index(q, q->read_ptr, 0);
158
156
 
159
 
                if (txq->meta[i].flags & CMD_SIZE_HUGE)
160
 
                        huge = true;
161
 
                else
 
157
                if (txq->meta[i].flags & CMD_MAPPED) {
162
158
                        pci_unmap_single(priv->pci_dev,
163
159
                                         dma_unmap_addr(&txq->meta[i], mapping),
164
160
                                         dma_unmap_len(&txq->meta[i], len),
165
161
                                         PCI_DMA_BIDIRECTIONAL);
 
162
                        txq->meta[i].flags = 0;
 
163
                }
166
164
 
167
165
                q->read_ptr = iwl_legacy_queue_inc_wrap(q->read_ptr, q->n_bd);
168
166
        }
169
167
 
170
 
        if (huge) {
171
 
                i = q->n_window;
 
168
        i = q->n_window;
 
169
        if (txq->meta[i].flags & CMD_MAPPED) {
172
170
                pci_unmap_single(priv->pci_dev,
173
171
                                 dma_unmap_addr(&txq->meta[i], mapping),
174
172
                                 dma_unmap_len(&txq->meta[i], len),
175
173
                                 PCI_DMA_BIDIRECTIONAL);
 
174
                txq->meta[i].flags = 0;
176
175
        }
177
176
}
178
177
EXPORT_SYMBOL(iwl_legacy_cmd_queue_unmap);
467
466
                return -EIO;
468
467
        }
469
468
 
 
469
        spin_lock_irqsave(&priv->hcmd_lock, flags);
 
470
 
470
471
        if (iwl_legacy_queue_space(q) < ((cmd->flags & CMD_ASYNC) ? 2 : 1)) {
471
 
                IWL_ERR(priv, "No space in command queue\n");
472
 
                IWL_ERR(priv, "Restarting adapter due to queue full\n");
 
472
                spin_unlock_irqrestore(&priv->hcmd_lock, flags);
 
473
 
 
474
                IWL_ERR(priv, "Restarting adapter due to command queue full\n");
473
475
                queue_work(priv->workqueue, &priv->restart);
474
476
                return -ENOSPC;
475
477
        }
476
478
 
477
 
        spin_lock_irqsave(&priv->hcmd_lock, flags);
478
 
 
479
 
        /* If this is a huge cmd, mark the huge flag also on the meta.flags
480
 
         * of the _original_ cmd. This is used for DMA mapping clean up.
481
 
         */
482
 
        if (cmd->flags & CMD_SIZE_HUGE) {
483
 
                idx = iwl_legacy_get_cmd_index(q, q->write_ptr, 0);
484
 
                txq->meta[idx].flags = CMD_SIZE_HUGE;
485
 
        }
486
 
 
487
479
        idx = iwl_legacy_get_cmd_index(q, q->write_ptr, cmd->flags & CMD_SIZE_HUGE);
488
480
        out_cmd = txq->cmd[idx];
489
481
        out_meta = &txq->meta[idx];
490
482
 
 
483
        if (WARN_ON(out_meta->flags & CMD_MAPPED)) {
 
484
                spin_unlock_irqrestore(&priv->hcmd_lock, flags);
 
485
                return -ENOSPC;
 
486
        }
 
487
 
491
488
        memset(out_meta, 0, sizeof(*out_meta)); /* re-initialize to NULL */
492
 
        out_meta->flags = cmd->flags;
 
489
        out_meta->flags = cmd->flags | CMD_MAPPED;
493
490
        if (cmd->flags & CMD_WANT_SKB)
494
491
                out_meta->source = cmd;
495
492
        if (cmd->flags & CMD_ASYNC)
610
607
        struct iwl_device_cmd *cmd;
611
608
        struct iwl_cmd_meta *meta;
612
609
        struct iwl_tx_queue *txq = &priv->txq[priv->cmd_queue];
 
610
        unsigned long flags;
613
611
 
614
612
        /* If a Tx command is being handled and it isn't in the actual
615
613
         * command queue then there a command routing bug has been introduced
623
621
                return;
624
622
        }
625
623
 
626
 
        /* If this is a huge cmd, clear the huge flag on the meta.flags
627
 
         * of the _original_ cmd. So that iwl_legacy_cmd_queue_free won't unmap
628
 
         * the DMA buffer for the scan (huge) command.
629
 
         */
630
 
        if (huge) {
631
 
                cmd_index = iwl_legacy_get_cmd_index(&txq->q, index, 0);
632
 
                txq->meta[cmd_index].flags = 0;
633
 
        }
634
624
        cmd_index = iwl_legacy_get_cmd_index(&txq->q, index, huge);
635
625
        cmd = txq->cmd[cmd_index];
636
626
        meta = &txq->meta[cmd_index];
647
637
        } else if (meta->callback)
648
638
                meta->callback(priv, cmd, pkt);
649
639
 
 
640
        spin_lock_irqsave(&priv->hcmd_lock, flags);
 
641
 
650
642
        iwl_legacy_hcmd_queue_reclaim(priv, txq_id, index, cmd_index);
651
643
 
652
644
        if (!(meta->flags & CMD_ASYNC)) {
655
647
                               iwl_legacy_get_cmd_string(cmd->hdr.cmd));
656
648
                wake_up_interruptible(&priv->wait_command_queue);
657
649
        }
 
650
 
 
651
        /* Mark as unmapped */
658
652
        meta->flags = 0;
 
653
 
 
654
        spin_unlock_irqrestore(&priv->hcmd_lock, flags);
659
655
}
660
656
EXPORT_SYMBOL(iwl_legacy_tx_cmd_complete);