147
147
struct iwl_tx_queue *txq = &priv->txq[priv->cmd_queue];
148
148
struct iwl_queue *q = &txq->q;
152
151
if (q->n_bd == 0)
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);
159
if (txq->meta[i].flags & CMD_SIZE_HUGE)
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;
167
165
q->read_ptr = iwl_legacy_queue_inc_wrap(q->read_ptr, q->n_bd);
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;
178
177
EXPORT_SYMBOL(iwl_legacy_cmd_queue_unmap);
469
spin_lock_irqsave(&priv->hcmd_lock, flags);
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);
474
IWL_ERR(priv, "Restarting adapter due to command queue full\n");
473
475
queue_work(priv->workqueue, &priv->restart);
477
spin_lock_irqsave(&priv->hcmd_lock, flags);
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.
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;
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];
483
if (WARN_ON(out_meta->flags & CMD_MAPPED)) {
484
spin_unlock_irqrestore(&priv->hcmd_lock, flags);
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];
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
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.
631
cmd_index = iwl_legacy_get_cmd_index(&txq->q, index, 0);
632
txq->meta[cmd_index].flags = 0;
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);
640
spin_lock_irqsave(&priv->hcmd_lock, flags);
650
642
iwl_legacy_hcmd_queue_reclaim(priv, txq_id, index, cmd_index);
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);
651
/* Mark as unmapped */
654
spin_unlock_irqrestore(&priv->hcmd_lock, flags);
660
656
EXPORT_SYMBOL(iwl_legacy_tx_cmd_complete);