Merge branch 'drm-intel-next' of git://git.kernel.org/pub/scm/linux/kernel/git/anholt...
[sfrench/cifs-2.6.git] / drivers / net / wireless / iwlwifi / iwl-3945.c
index 9e6f9ec1a2b8f1d6bdf0410063c2c7fb6b4c0dfc..527525cc0919e523dc1f813b54d68935224e0880 100644 (file)
@@ -293,7 +293,7 @@ static void iwl3945_tx_queue_reclaim(struct iwl_priv *priv,
        if (iwl_queue_space(q) > q->low_mark && (txq_id >= 0) &&
                        (txq_id != IWL_CMD_QUEUE_NUM) &&
                        priv->mac80211_registered)
-               ieee80211_wake_queue(priv->hw, txq_id);
+               iwl_wake_queue(priv, txq_id);
 }
 
 /**
@@ -741,16 +741,12 @@ int iwl3945_hw_txq_attach_buf_to_tfd(struct iwl_priv *priv,
 void iwl3945_hw_txq_free_tfd(struct iwl_priv *priv, struct iwl_tx_queue *txq)
 {
        struct iwl3945_tfd *tfd_tmp = (struct iwl3945_tfd *)txq->tfds;
-       struct iwl3945_tfd *tfd = &tfd_tmp[txq->q.read_ptr];
+       int index = txq->q.read_ptr;
+       struct iwl3945_tfd *tfd = &tfd_tmp[index];
        struct pci_dev *dev = priv->pci_dev;
        int i;
        int counter;
 
-       /* classify bd */
-       if (txq->q.id == IWL_CMD_QUEUE_NUM)
-               /* nothing to cleanup after for host commands */
-               return;
-
        /* sanity check */
        counter = TFD_CTL_COUNT_GET(le32_to_cpu(tfd->control_flags));
        if (counter > NUM_TFD_CHUNKS) {
@@ -759,6 +755,13 @@ void iwl3945_hw_txq_free_tfd(struct iwl_priv *priv, struct iwl_tx_queue *txq)
                return;
        }
 
+       /* Unmap tx_cmd */
+       if (counter)
+               pci_unmap_single(dev,
+                               pci_unmap_addr(&txq->cmd[index]->meta, mapping),
+                               pci_unmap_len(&txq->cmd[index]->meta, len),
+                               PCI_DMA_TODEVICE);
+
        /* unmap chunks if any */
 
        for (i = 1; i < counter; i++) {
@@ -1038,7 +1041,7 @@ static int iwl3945_txq_ctx_reset(struct iwl_priv *priv)
                goto error;
 
        /* Tx queue(s) */
-       for (txq_id = 0; txq_id < TFD_QUEUE_MAX; txq_id++) {
+       for (txq_id = 0; txq_id <= priv->hw_params.max_txq_num; txq_id++) {
                slots_num = (txq_id == IWL_CMD_QUEUE_NUM) ?
                                TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS;
                rc = iwl_tx_queue_init(priv, &priv->txq[txq_id], slots_num,
@@ -1176,7 +1179,7 @@ int iwl3945_hw_nic_init(struct iwl_priv *priv)
        IWL_DEBUG_INFO(priv, "HW Revision ID = 0x%X\n", rev_id);
 
        rc = priv->cfg->ops->lib->apm_ops.set_pwr_src(priv, IWL_PWR_SRC_VMAIN);
-       if(rc)
+       if (rc)
                return rc;
 
        priv->cfg->ops->lib->apm_ops.config(priv);
@@ -1189,7 +1192,7 @@ int iwl3945_hw_nic_init(struct iwl_priv *priv)
                        return -ENOMEM;
                }
        } else
-               iwl_rx_queue_reset(priv, rxq);
+               iwl3945_rx_queue_reset(priv, rxq);
 
        iwl3945_rx_replenish(priv);
 
@@ -1231,8 +1234,12 @@ void iwl3945_hw_txq_ctx_free(struct iwl_priv *priv)
        int txq_id;
 
        /* Tx queues */
-       for (txq_id = 0; txq_id < TFD_QUEUE_MAX; txq_id++)
-               iwl_tx_queue_free(priv, txq_id);
+       for (txq_id = 0; txq_id <= priv->hw_params.max_txq_num; txq_id++)
+               if (txq_id == IWL_CMD_QUEUE_NUM)
+                       iwl_cmd_queue_free(priv);
+               else
+                       iwl_tx_queue_free(priv, txq_id);
+
 }
 
 void iwl3945_hw_txq_ctx_stop(struct iwl_priv *priv)
@@ -1251,7 +1258,7 @@ void iwl3945_hw_txq_ctx_stop(struct iwl_priv *priv)
        iwl_write_prph(priv, ALM_SCD_MODE_REG, 0);
 
        /* reset TFD queues */
-       for (txq_id = 0; txq_id < TFD_QUEUE_MAX; txq_id++) {
+       for (txq_id = 0; txq_id <= priv->hw_params.max_txq_num; txq_id++) {
                iwl_write_direct32(priv, FH39_TCSR_CONFIG(txq_id), 0x0);
                iwl_poll_direct_bit(priv, FH39_TSSR_TX_STATUS,
                                FH39_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(txq_id),
@@ -2480,6 +2487,9 @@ int iwl3945_hw_set_hw_params(struct iwl_priv *priv)
                return -ENOMEM;
        }
 
+       /* Assign number of Usable TX queues */
+       priv->hw_params.max_txq_num = TFD_QUEUE_MAX;
+
        priv->hw_params.tfd_size = sizeof(struct iwl3945_tfd);
        priv->hw_params.rx_buf_size = IWL_RX_BUF_SIZE_3K;
        priv->hw_params.max_pkt_size = 2342;