iwlwifi: split POWER_PMI status bit
authorDon Fry <donald.h.fry@intel.com>
Thu, 15 Mar 2012 20:27:06 +0000 (13:27 -0700)
committerJohn W. Linville <linville@tuxdriver.com>
Mon, 9 Apr 2012 20:37:49 +0000 (16:37 -0400)
Move the POWER_PMI to the op_mode where it is changed.  The trans needs
to check it frequently, so shadow the status in the trans and update it
in trans when it infrequently changes.

Signed-off-by: Don Fry <donald.h.fry@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/iwlwifi/iwl-agn-lib.c
drivers/net/wireless/iwlwifi/iwl-agn.h
drivers/net/wireless/iwlwifi/iwl-debugfs.c
drivers/net/wireless/iwlwifi/iwl-power.c
drivers/net/wireless/iwlwifi/iwl-scan.c
drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c
drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c
drivers/net/wireless/iwlwifi/iwl-trans-pcie.c
drivers/net/wireless/iwlwifi/iwl-trans.h

index 180df01d0916a786e1418a76468a01137cab9fa6..4da4ab23cce7f01f55e9ae06ab768892d9944c1a 100644 (file)
@@ -856,7 +856,7 @@ static u8 iwl_count_chain_bitmap(u32 chain_bitmap)
 void iwlagn_set_rxon_chain(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
 {
        bool is_single = is_single_rx_stream(priv);
-       bool is_cam = !test_bit(STATUS_POWER_PMI, &priv->shrd->status);
+       bool is_cam = !test_bit(STATUS_POWER_PMI, &priv->status);
        u8 idle_rx_cnt, active_rx_cnt, valid_rx_cnt;
        u32 active_chains;
        u16 rx_chain;
index cddd9ed7c94f6875eb654b293c1979e50a943758..51001622430b3238e865e773e0527e3019be7394 100644 (file)
@@ -392,6 +392,15 @@ static inline int iwl_is_ready_rf(struct iwl_priv *priv)
        return iwl_is_ready(priv);
 }
 
+static inline void iwl_dvm_set_pmi(struct iwl_priv *priv, bool state)
+{
+       if (state)
+               set_bit(STATUS_POWER_PMI, &priv->status);
+       else
+               clear_bit(STATUS_POWER_PMI, &priv->status);
+       iwl_trans_set_pmi(trans(priv), state);
+}
+
 #ifdef CONFIG_IWLWIFI_DEBUG
 #define IWL_DEBUG_QUIET_RFKILL(m, fmt, args...)        \
 do {                                                                   \
index 03fc27db72d1b1be398e5760fa37c98d2228dd20..417fc37f0bbbb83e1dca9ac0cddd22071cfdfbf7 100644 (file)
@@ -555,7 +555,7 @@ static ssize_t iwl_dbgfs_status_read(struct file *file,
        pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCAN_HW:\t\t %d\n",
                test_bit(STATUS_SCAN_HW, &priv->status));
        pos += scnprintf(buf + pos, bufsz - pos, "STATUS_POWER_PMI:\t %d\n",
-               test_bit(STATUS_POWER_PMI, &priv->shrd->status));
+               test_bit(STATUS_POWER_PMI, &priv->status));
        pos += scnprintf(buf + pos, bufsz - pos, "STATUS_FW_ERROR:\t %d\n",
                test_bit(STATUS_FW_ERROR, &priv->status));
        return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
index 958d9d09aee3f0e55137ac58b7095a535481591d..7bc7a82aba47b73e77d697b12948a73eef41a410 100644 (file)
@@ -403,12 +403,12 @@ int iwl_power_set_mode(struct iwl_priv *priv, struct iwl_powertable_cmd *cmd,
        }
 
        if (cmd->flags & IWL_POWER_DRIVER_ALLOW_SLEEP_MSK)
-               set_bit(STATUS_POWER_PMI, &priv->shrd->status);
+               iwl_dvm_set_pmi(priv, true);
 
        ret = iwl_set_power(priv, cmd);
        if (!ret) {
                if (!(cmd->flags & IWL_POWER_DRIVER_ALLOW_SLEEP_MSK))
-                       clear_bit(STATUS_POWER_PMI, &priv->shrd->status);
+                       iwl_dvm_set_pmi(priv, false);
 
                if (update_chains)
                        iwl_update_chain_flags(priv);
index 56becf25656a6b96f75d0e2e1f78891a8d1272a2..dcf5b12071b4012ef355791f135e156f883b7219 100644 (file)
@@ -850,7 +850,7 @@ static int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
         * In power save mode while associated use one chain,
         * otherwise use all chains
         */
-       if (test_bit(STATUS_POWER_PMI, &priv->shrd->status) &&
+       if (test_bit(STATUS_POWER_PMI, &priv->status) &&
            !(priv->hw->conf.flags & IEEE80211_CONF_IDLE)) {
                /* rx_ant has been set to all valid chains previously */
                active_chains = rx_ant &
index a070f51fba17addea1ad889e9c6348bfcea44721..ab0f3fc22b87197c87b6ee0066aa29c9a10d4f85 100644 (file)
@@ -146,8 +146,11 @@ void iwl_rx_queue_update_write_ptr(struct iwl_trans *trans,
                q->write_actual = (q->write & ~0x7);
                iwl_write32(trans, FH_RSCSR_CHNL0_WPTR, q->write_actual);
        } else {
+               struct iwl_trans_pcie *trans_pcie =
+                       IWL_TRANS_GET_PCIE_TRANS(trans);
+
                /* If power-saving is in use, make sure device is awake */
-               if (test_bit(STATUS_POWER_PMI, &trans->shrd->status)) {
+               if (test_bit(STATUS_POWER_PMI, &trans_pcie->status)) {
                        reg = iwl_read32(trans, CSR_UCODE_DRV_GP1);
 
                        if (reg & CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP) {
index 61b0fba5abc72e03a85dfb6b9ab04ad64fa2629a..4684e2310cd89ac9c4f920e854dce0e78cf5b4b3 100644 (file)
@@ -104,8 +104,10 @@ void iwl_txq_update_write_ptr(struct iwl_trans *trans, struct iwl_tx_queue *txq)
                iwl_write32(trans, HBUS_TARG_WRPTR,
                            txq->q.write_ptr | (txq_id << 8));
        } else {
+               struct iwl_trans_pcie *trans_pcie =
+                       IWL_TRANS_GET_PCIE_TRANS(trans);
                /* if we're trying to save power */
-               if (test_bit(STATUS_POWER_PMI, &trans->shrd->status)) {
+               if (test_bit(STATUS_POWER_PMI, &trans_pcie->status)) {
                        /* wake up nic if it's powered down ...
                         * uCode will wake up, and interrupt us again, so next
                         * time we'll skip this part. */
index b0b7107c85a429e19771e3890c58b5895a46d879..52e218b2bd375a9f09acb4bd957036757ec44447 100644 (file)
@@ -1518,6 +1518,16 @@ static void iwl_trans_pcie_free(struct iwl_trans *trans)
        kfree(trans);
 }
 
+static void iwl_trans_pcie_set_pmi(struct iwl_trans *trans, bool state)
+{
+       struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
+
+       if (state)
+               set_bit(STATUS_POWER_PMI, &trans_pcie->status);
+       else
+               clear_bit(STATUS_POWER_PMI, &trans_pcie->status);
+}
+
 #ifdef CONFIG_PM_SLEEP
 static int iwl_trans_pcie_suspend(struct iwl_trans *trans)
 {
@@ -2038,6 +2048,7 @@ const struct iwl_trans_ops trans_ops_pcie = {
        .write32 = iwl_trans_pcie_write32,
        .read32 = iwl_trans_pcie_read32,
        .configure = iwl_trans_pcie_configure,
+       .set_pmi = iwl_trans_pcie_set_pmi,
 };
 
 struct iwl_trans *iwl_trans_pcie_alloc(struct iwl_shared *shrd,
index 27853087a803ecf14af7daf81bfebcdf335f034e..66c54c1b404ed696e56ea0977b6eea78be1797cc 100644 (file)
@@ -364,6 +364,7 @@ struct iwl_trans_config {
  * @configure: configure parameters required by the transport layer from
  *     the op_mode. May be called several times before start_fw, can't be
  *     called after that.
+ * @set_pmi: set the power pmi state
  */
 struct iwl_trans_ops {
 
@@ -400,6 +401,7 @@ struct iwl_trans_ops {
        u32 (*read32)(struct iwl_trans *trans, u32 ofs);
        void (*configure)(struct iwl_trans *trans,
                          const struct iwl_trans_config *trans_cfg);
+       void (*set_pmi)(struct iwl_trans *trans, bool state);
 };
 
 /**
@@ -611,6 +613,11 @@ static inline u32 iwl_trans_read32(struct iwl_trans *trans, u32 ofs)
        return trans->ops->read32(trans, ofs);
 }
 
+static inline void iwl_trans_set_pmi(struct iwl_trans *trans, bool state)
+{
+       trans->ops->set_pmi(trans, state);
+}
+
 /*****************************************************
 * Transport layers implementations + their allocation function
 ******************************************************/