aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArik Nemtsov <arik@wizery.com>2013-12-01 05:30:38 -0500
committerEmmanuel Grumbach <emmanuel.grumbach@intel.com>2013-12-17 12:39:47 -0500
commiteb7ff77edd391f215deee3ee5d957c857121cd72 (patch)
treeef442824ec1dd5e5212f4f39a12399e9c9b75b79
parenta4082843674000ffc5db76c2d0e66455ca5af490 (diff)
iwlwifi: trans: use a unified transport status
The same bits are employed in all transport layers. Put the status field in the common transport layer. This allows us to employ them in common transport code. Signed-off-by: Arik Nemtsov <arik@wizery.com> Reviewed-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-trans.h20
-rw-r--r--drivers/net/wireless/iwlwifi/pcie/internal.h29
-rw-r--r--drivers/net/wireless/iwlwifi/pcie/rx.c27
-rw-r--r--drivers/net/wireless/iwlwifi/pcie/trans.c40
-rw-r--r--drivers/net/wireless/iwlwifi/pcie/tx.c30
5 files changed, 65 insertions, 81 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h
index 43ea1249d1bb..64196037ce9b 100644
--- a/drivers/net/wireless/iwlwifi/iwl-trans.h
+++ b/drivers/net/wireless/iwlwifi/iwl-trans.h
@@ -317,6 +317,24 @@ enum iwl_d3_status {
317}; 317};
318 318
319/** 319/**
320 * enum iwl_trans_status: transport status flags
321 * @STATUS_SYNC_HCMD_ACTIVE: a SYNC command is being processed
322 * @STATUS_DEVICE_ENABLED: APM is enabled
323 * @STATUS_TPOWER_PMI: the device might be asleep (need to wake it up)
324 * @STATUS_INT_ENABLED: interrupts are enabled
325 * @STATUS_RFKILL: the HW RFkill switch is in KILL position
326 * @STATUS_FW_ERROR: the fw is in error state
327 */
328enum iwl_trans_status {
329 STATUS_SYNC_HCMD_ACTIVE,
330 STATUS_DEVICE_ENABLED,
331 STATUS_TPOWER_PMI,
332 STATUS_INT_ENABLED,
333 STATUS_RFKILL,
334 STATUS_FW_ERROR,
335};
336
337/**
320 * struct iwl_trans_config - transport configuration 338 * struct iwl_trans_config - transport configuration
321 * 339 *
322 * @op_mode: pointer to the upper layer. 340 * @op_mode: pointer to the upper layer.
@@ -479,6 +497,7 @@ enum iwl_trans_state {
479 * @ops - pointer to iwl_trans_ops 497 * @ops - pointer to iwl_trans_ops
480 * @op_mode - pointer to the op_mode 498 * @op_mode - pointer to the op_mode
481 * @cfg - pointer to the configuration 499 * @cfg - pointer to the configuration
500 * @status: a bit-mask of transport status flags
482 * @dev - pointer to struct device * that represents the device 501 * @dev - pointer to struct device * that represents the device
483 * @hw_id: a u32 with the ID of the device / subdevice. 502 * @hw_id: a u32 with the ID of the device / subdevice.
484 * Set during transport allocation. 503 * Set during transport allocation.
@@ -499,6 +518,7 @@ struct iwl_trans {
499 struct iwl_op_mode *op_mode; 518 struct iwl_op_mode *op_mode;
500 const struct iwl_cfg *cfg; 519 const struct iwl_cfg *cfg;
501 enum iwl_trans_state state; 520 enum iwl_trans_state state;
521 unsigned long status;
502 522
503 struct device *dev; 523 struct device *dev;
504 u32 hw_rev; 524 u32 hw_rev;
diff --git a/drivers/net/wireless/iwlwifi/pcie/internal.h b/drivers/net/wireless/iwlwifi/pcie/internal.h
index 051268c037b1..8a2de33df48b 100644
--- a/drivers/net/wireless/iwlwifi/pcie/internal.h
+++ b/drivers/net/wireless/iwlwifi/pcie/internal.h
@@ -256,7 +256,6 @@ iwl_pcie_get_scratchbuf_dma(struct iwl_txq *txq, int idx)
256 * @hw_base: pci hardware address support 256 * @hw_base: pci hardware address support
257 * @ucode_write_complete: indicates that the ucode has been copied. 257 * @ucode_write_complete: indicates that the ucode has been copied.
258 * @ucode_write_waitq: wait queue for uCode load 258 * @ucode_write_waitq: wait queue for uCode load
259 * @status - transport specific status flags
260 * @cmd_queue - command queue number 259 * @cmd_queue - command queue number
261 * @rx_buf_size_8k: 8 kB RX buffer size 260 * @rx_buf_size_8k: 8 kB RX buffer size
262 * @bc_table_dword: true if the BC table expects DWORD (as opposed to bytes) 261 * @bc_table_dword: true if the BC table expects DWORD (as opposed to bytes)
@@ -296,7 +295,6 @@ struct iwl_trans_pcie {
296 wait_queue_head_t ucode_write_waitq; 295 wait_queue_head_t ucode_write_waitq;
297 wait_queue_head_t wait_command_queue; 296 wait_queue_head_t wait_command_queue;
298 297
299 unsigned long status;
300 u8 cmd_queue; 298 u8 cmd_queue;
301 u8 cmd_fifo; 299 u8 cmd_fifo;
302 u8 n_no_reclaim_cmds; 300 u8 n_no_reclaim_cmds;
@@ -315,24 +313,6 @@ struct iwl_trans_pcie {
315 spinlock_t reg_lock; 313 spinlock_t reg_lock;
316}; 314};
317 315
318/**
319 * enum iwl_pcie_status: status of the PCIe transport
320 * @STATUS_HCMD_ACTIVE: a SYNC command is being processed
321 * @STATUS_DEVICE_ENABLED: APM is enabled
322 * @STATUS_TPOWER_PMI: the device might be asleep (need to wake it up)
323 * @STATUS_INT_ENABLED: interrupts are enabled
324 * @STATUS_RFKILL: the HW RFkill switch is in KILL position
325 * @STATUS_FW_ERROR: the fw is in error state
326 */
327enum iwl_pcie_status {
328 STATUS_HCMD_ACTIVE,
329 STATUS_DEVICE_ENABLED,
330 STATUS_TPOWER_PMI,
331 STATUS_INT_ENABLED,
332 STATUS_RFKILL,
333 STATUS_FW_ERROR,
334};
335
336#define IWL_TRANS_GET_PCIE_TRANS(_iwl_trans) \ 316#define IWL_TRANS_GET_PCIE_TRANS(_iwl_trans) \
337 ((struct iwl_trans_pcie *) ((_iwl_trans)->trans_specific)) 317 ((struct iwl_trans_pcie *) ((_iwl_trans)->trans_specific))
338 318
@@ -399,8 +379,7 @@ void iwl_pcie_dump_csr(struct iwl_trans *trans);
399******************************************************/ 379******************************************************/
400static inline void iwl_disable_interrupts(struct iwl_trans *trans) 380static inline void iwl_disable_interrupts(struct iwl_trans *trans)
401{ 381{
402 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 382 clear_bit(STATUS_INT_ENABLED, &trans->status);
403 clear_bit(STATUS_INT_ENABLED, &trans_pcie->status);
404 383
405 /* disable interrupts from uCode/NIC to host */ 384 /* disable interrupts from uCode/NIC to host */
406 iwl_write32(trans, CSR_INT_MASK, 0x00000000); 385 iwl_write32(trans, CSR_INT_MASK, 0x00000000);
@@ -417,7 +396,7 @@ static inline void iwl_enable_interrupts(struct iwl_trans *trans)
417 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 396 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
418 397
419 IWL_DEBUG_ISR(trans, "Enabling interrupts\n"); 398 IWL_DEBUG_ISR(trans, "Enabling interrupts\n");
420 set_bit(STATUS_INT_ENABLED, &trans_pcie->status); 399 set_bit(STATUS_INT_ENABLED, &trans->status);
421 iwl_write32(trans, CSR_INT_MASK, trans_pcie->inta_mask); 400 iwl_write32(trans, CSR_INT_MASK, trans_pcie->inta_mask);
422} 401}
423 402
@@ -479,9 +458,7 @@ static inline bool iwl_is_rfkill_set(struct iwl_trans *trans)
479 458
480static inline void iwl_nic_error(struct iwl_trans *trans) 459static inline void iwl_nic_error(struct iwl_trans *trans)
481{ 460{
482 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 461 set_bit(STATUS_FW_ERROR, &trans->status);
483
484 set_bit(STATUS_FW_ERROR, &trans_pcie->status);
485 iwl_op_mode_nic_error(trans->op_mode); 462 iwl_op_mode_nic_error(trans->op_mode);
486} 463}
487 464
diff --git a/drivers/net/wireless/iwlwifi/pcie/rx.c b/drivers/net/wireless/iwlwifi/pcie/rx.c
index 1d6bf7b98e2d..bbbb3ca400d7 100644
--- a/drivers/net/wireless/iwlwifi/pcie/rx.c
+++ b/drivers/net/wireless/iwlwifi/pcie/rx.c
@@ -162,11 +162,8 @@ static void iwl_pcie_rxq_inc_wr_ptr(struct iwl_trans *trans,
162 rxq->write_actual = (rxq->write & ~0x7); 162 rxq->write_actual = (rxq->write & ~0x7);
163 iwl_write32(trans, FH_RSCSR_CHNL0_WPTR, rxq->write_actual); 163 iwl_write32(trans, FH_RSCSR_CHNL0_WPTR, rxq->write_actual);
164 } else { 164 } else {
165 struct iwl_trans_pcie *trans_pcie =
166 IWL_TRANS_GET_PCIE_TRANS(trans);
167
168 /* If power-saving is in use, make sure device is awake */ 165 /* If power-saving is in use, make sure device is awake */
169 if (test_bit(STATUS_TPOWER_PMI, &trans_pcie->status)) { 166 if (test_bit(STATUS_TPOWER_PMI, &trans->status)) {
170 reg = iwl_read32(trans, CSR_UCODE_DRV_GP1); 167 reg = iwl_read32(trans, CSR_UCODE_DRV_GP1);
171 168
172 if (reg & CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP) { 169 if (reg & CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP) {
@@ -222,7 +219,7 @@ static void iwl_pcie_rxq_restock(struct iwl_trans *trans)
222 * stopped, we cannot access the HW (in particular not prph). 219 * stopped, we cannot access the HW (in particular not prph).
223 * So don't try to restock if the APM has been already stopped. 220 * So don't try to restock if the APM has been already stopped.
224 */ 221 */
225 if (!test_bit(STATUS_DEVICE_ENABLED, &trans_pcie->status)) 222 if (!test_bit(STATUS_DEVICE_ENABLED, &trans->status))
226 return; 223 return;
227 224
228 spin_lock_irqsave(&rxq->lock, flags); 225 spin_lock_irqsave(&rxq->lock, flags);
@@ -791,7 +788,7 @@ static void iwl_pcie_irq_handle_error(struct iwl_trans *trans)
791 APMS_CLK_VAL_MRB_FUNC_MODE) || 788 APMS_CLK_VAL_MRB_FUNC_MODE) ||
792 (iwl_read_prph(trans, APMG_PS_CTRL_REG) & 789 (iwl_read_prph(trans, APMG_PS_CTRL_REG) &
793 APMG_PS_CTRL_VAL_RESET_REQ))) { 790 APMG_PS_CTRL_VAL_RESET_REQ))) {
794 clear_bit(STATUS_HCMD_ACTIVE, &trans_pcie->status); 791 clear_bit(STATUS_SYNC_HCMD_ACTIVE, &trans->status);
795 iwl_op_mode_wimax_active(trans->op_mode); 792 iwl_op_mode_wimax_active(trans->op_mode);
796 wake_up(&trans_pcie->wait_command_queue); 793 wake_up(&trans_pcie->wait_command_queue);
797 return; 794 return;
@@ -801,8 +798,8 @@ static void iwl_pcie_irq_handle_error(struct iwl_trans *trans)
801 iwl_dump_fh(trans, NULL); 798 iwl_dump_fh(trans, NULL);
802 799
803 /* set the ERROR bit before we wake up the caller */ 800 /* set the ERROR bit before we wake up the caller */
804 set_bit(STATUS_FW_ERROR, &trans_pcie->status); 801 set_bit(STATUS_FW_ERROR, &trans->status);
805 clear_bit(STATUS_HCMD_ACTIVE, &trans_pcie->status); 802 clear_bit(STATUS_SYNC_HCMD_ACTIVE, &trans->status);
806 wake_up(&trans_pcie->wait_command_queue); 803 wake_up(&trans_pcie->wait_command_queue);
807 804
808 local_bh_disable(); 805 local_bh_disable();
@@ -894,14 +891,14 @@ irqreturn_t iwl_pcie_irq_handler(int irq, void *dev_id)
894 891
895 iwl_op_mode_hw_rf_kill(trans->op_mode, hw_rfkill); 892 iwl_op_mode_hw_rf_kill(trans->op_mode, hw_rfkill);
896 if (hw_rfkill) { 893 if (hw_rfkill) {
897 set_bit(STATUS_RFKILL, &trans_pcie->status); 894 set_bit(STATUS_RFKILL, &trans->status);
898 if (test_and_clear_bit(STATUS_HCMD_ACTIVE, 895 if (test_and_clear_bit(STATUS_SYNC_HCMD_ACTIVE,
899 &trans_pcie->status)) 896 &trans->status))
900 IWL_DEBUG_RF_KILL(trans, 897 IWL_DEBUG_RF_KILL(trans,
901 "Rfkill while SYNC HCMD in flight\n"); 898 "Rfkill while SYNC HCMD in flight\n");
902 wake_up(&trans_pcie->wait_command_queue); 899 wake_up(&trans_pcie->wait_command_queue);
903 } else { 900 } else {
904 clear_bit(STATUS_RFKILL, &trans_pcie->status); 901 clear_bit(STATUS_RFKILL, &trans->status);
905 } 902 }
906 903
907 handled |= CSR_INT_BIT_RF_KILL; 904 handled |= CSR_INT_BIT_RF_KILL;
@@ -1005,7 +1002,7 @@ irqreturn_t iwl_pcie_irq_handler(int irq, void *dev_id)
1005 1002
1006 /* Re-enable all interrupts */ 1003 /* Re-enable all interrupts */
1007 /* only Re-enable if disabled by irq */ 1004 /* only Re-enable if disabled by irq */
1008 if (test_bit(STATUS_INT_ENABLED, &trans_pcie->status)) 1005 if (test_bit(STATUS_INT_ENABLED, &trans->status))
1009 iwl_enable_interrupts(trans); 1006 iwl_enable_interrupts(trans);
1010 /* Re-enable RF_KILL if it occurred */ 1007 /* Re-enable RF_KILL if it occurred */
1011 else if (handled & CSR_INT_BIT_RF_KILL) 1008 else if (handled & CSR_INT_BIT_RF_KILL)
@@ -1160,7 +1157,7 @@ static irqreturn_t iwl_pcie_isr(int irq, void *data)
1160 * the handler can be scheduled because of a previous 1157 * the handler can be scheduled because of a previous
1161 * interrupt. 1158 * interrupt.
1162 */ 1159 */
1163 if (test_bit(STATUS_INT_ENABLED, &trans_pcie->status) && 1160 if (test_bit(STATUS_INT_ENABLED, &trans->status) &&
1164 !trans_pcie->inta) 1161 !trans_pcie->inta)
1165 iwl_enable_interrupts(trans); 1162 iwl_enable_interrupts(trans);
1166 return IRQ_NONE; 1163 return IRQ_NONE;
@@ -1290,7 +1287,7 @@ irqreturn_t iwl_pcie_isr_ict(int irq, void *data)
1290 /* re-enable interrupts here since we don't have anything to service. 1287 /* re-enable interrupts here since we don't have anything to service.
1291 * only Re-enable if disabled by irq. 1288 * only Re-enable if disabled by irq.
1292 */ 1289 */
1293 if (test_bit(STATUS_INT_ENABLED, &trans_pcie->status) && 1290 if (test_bit(STATUS_INT_ENABLED, &trans->status) &&
1294 !trans_pcie->inta) 1291 !trans_pcie->inta)
1295 iwl_enable_interrupts(trans); 1292 iwl_enable_interrupts(trans);
1296 1293
diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
index 43eed4d8a52a..28c62a57ae59 100644
--- a/drivers/net/wireless/iwlwifi/pcie/trans.c
+++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
@@ -150,7 +150,6 @@ static void iwl_pcie_apm_config(struct iwl_trans *trans)
150 */ 150 */
151static int iwl_pcie_apm_init(struct iwl_trans *trans) 151static int iwl_pcie_apm_init(struct iwl_trans *trans)
152{ 152{
153 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
154 int ret = 0; 153 int ret = 0;
155 IWL_DEBUG_INFO(trans, "Init card's basic functions\n"); 154 IWL_DEBUG_INFO(trans, "Init card's basic functions\n");
156 155
@@ -223,7 +222,7 @@ static int iwl_pcie_apm_init(struct iwl_trans *trans)
223 /* Clear the interrupt in APMG if the NIC is in RFKILL */ 222 /* Clear the interrupt in APMG if the NIC is in RFKILL */
224 iwl_write_prph(trans, APMG_RTC_INT_STT_REG, APMG_RTC_INT_STT_RFKILL); 223 iwl_write_prph(trans, APMG_RTC_INT_STT_REG, APMG_RTC_INT_STT_RFKILL);
225 224
226 set_bit(STATUS_DEVICE_ENABLED, &trans_pcie->status); 225 set_bit(STATUS_DEVICE_ENABLED, &trans->status);
227 226
228out: 227out:
229 return ret; 228 return ret;
@@ -249,10 +248,9 @@ static int iwl_pcie_apm_stop_master(struct iwl_trans *trans)
249 248
250static void iwl_pcie_apm_stop(struct iwl_trans *trans) 249static void iwl_pcie_apm_stop(struct iwl_trans *trans)
251{ 250{
252 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
253 IWL_DEBUG_INFO(trans, "Stop card, put in low power state\n"); 251 IWL_DEBUG_INFO(trans, "Stop card, put in low power state\n");
254 252
255 clear_bit(STATUS_DEVICE_ENABLED, &trans_pcie->status); 253 clear_bit(STATUS_DEVICE_ENABLED, &trans->status);
256 254
257 /* Stop device's DMA activity */ 255 /* Stop device's DMA activity */
258 iwl_pcie_apm_stop_master(trans); 256 iwl_pcie_apm_stop_master(trans);
@@ -582,7 +580,6 @@ static int iwl_pcie_load_given_ucode(struct iwl_trans *trans,
582static int iwl_trans_pcie_start_fw(struct iwl_trans *trans, 580static int iwl_trans_pcie_start_fw(struct iwl_trans *trans,
583 const struct fw_img *fw, bool run_in_rfkill) 581 const struct fw_img *fw, bool run_in_rfkill)
584{ 582{
585 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
586 int ret; 583 int ret;
587 bool hw_rfkill; 584 bool hw_rfkill;
588 585
@@ -592,16 +589,16 @@ static int iwl_trans_pcie_start_fw(struct iwl_trans *trans,
592 return -EIO; 589 return -EIO;
593 } 590 }
594 591
595 clear_bit(STATUS_FW_ERROR, &trans_pcie->status); 592 clear_bit(STATUS_FW_ERROR, &trans->status);
596 593
597 iwl_enable_rfkill_int(trans); 594 iwl_enable_rfkill_int(trans);
598 595
599 /* If platform's RF_KILL switch is NOT set to KILL */ 596 /* If platform's RF_KILL switch is NOT set to KILL */
600 hw_rfkill = iwl_is_rfkill_set(trans); 597 hw_rfkill = iwl_is_rfkill_set(trans);
601 if (hw_rfkill) 598 if (hw_rfkill)
602 set_bit(STATUS_RFKILL, &trans_pcie->status); 599 set_bit(STATUS_RFKILL, &trans->status);
603 else 600 else
604 clear_bit(STATUS_RFKILL, &trans_pcie->status); 601 clear_bit(STATUS_RFKILL, &trans->status);
605 iwl_op_mode_hw_rf_kill(trans->op_mode, hw_rfkill); 602 iwl_op_mode_hw_rf_kill(trans->op_mode, hw_rfkill);
606 if (hw_rfkill && !run_in_rfkill) 603 if (hw_rfkill && !run_in_rfkill)
607 return -ERFKILL; 604 return -ERFKILL;
@@ -658,7 +655,7 @@ static void iwl_trans_pcie_stop_device(struct iwl_trans *trans)
658 * restart. So don't process again if the device is 655 * restart. So don't process again if the device is
659 * already dead. 656 * already dead.
660 */ 657 */
661 if (test_bit(STATUS_DEVICE_ENABLED, &trans_pcie->status)) { 658 if (test_bit(STATUS_DEVICE_ENABLED, &trans->status)) {
662 iwl_pcie_tx_stop(trans); 659 iwl_pcie_tx_stop(trans);
663 iwl_pcie_rx_stop(trans); 660 iwl_pcie_rx_stop(trans);
664 661
@@ -686,11 +683,11 @@ static void iwl_trans_pcie_stop_device(struct iwl_trans *trans)
686 iwl_write32(trans, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); 683 iwl_write32(trans, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET);
687 684
688 /* clear all status bits */ 685 /* clear all status bits */
689 clear_bit(STATUS_HCMD_ACTIVE, &trans_pcie->status); 686 clear_bit(STATUS_SYNC_HCMD_ACTIVE, &trans->status);
690 clear_bit(STATUS_INT_ENABLED, &trans_pcie->status); 687 clear_bit(STATUS_INT_ENABLED, &trans->status);
691 clear_bit(STATUS_DEVICE_ENABLED, &trans_pcie->status); 688 clear_bit(STATUS_DEVICE_ENABLED, &trans->status);
692 clear_bit(STATUS_TPOWER_PMI, &trans_pcie->status); 689 clear_bit(STATUS_TPOWER_PMI, &trans->status);
693 clear_bit(STATUS_RFKILL, &trans_pcie->status); 690 clear_bit(STATUS_RFKILL, &trans->status);
694 691
695 /* 692 /*
696 * Even if we stop the HW, we still want the RF kill 693 * Even if we stop the HW, we still want the RF kill
@@ -706,9 +703,9 @@ static void iwl_trans_pcie_stop_device(struct iwl_trans *trans)
706 */ 703 */
707 hw_rfkill = iwl_is_rfkill_set(trans); 704 hw_rfkill = iwl_is_rfkill_set(trans);
708 if (hw_rfkill) 705 if (hw_rfkill)
709 set_bit(STATUS_RFKILL, &trans_pcie->status); 706 set_bit(STATUS_RFKILL, &trans->status);
710 else 707 else
711 clear_bit(STATUS_RFKILL, &trans_pcie->status); 708 clear_bit(STATUS_RFKILL, &trans->status);
712 iwl_op_mode_hw_rf_kill(trans->op_mode, hw_rfkill); 709 iwl_op_mode_hw_rf_kill(trans->op_mode, hw_rfkill);
713} 710}
714 711
@@ -794,7 +791,6 @@ static int iwl_trans_pcie_d3_resume(struct iwl_trans *trans,
794 791
795static int iwl_trans_pcie_start_hw(struct iwl_trans *trans) 792static int iwl_trans_pcie_start_hw(struct iwl_trans *trans)
796{ 793{
797 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
798 bool hw_rfkill; 794 bool hw_rfkill;
799 int err; 795 int err;
800 796
@@ -816,9 +812,9 @@ static int iwl_trans_pcie_start_hw(struct iwl_trans *trans)
816 812
817 hw_rfkill = iwl_is_rfkill_set(trans); 813 hw_rfkill = iwl_is_rfkill_set(trans);
818 if (hw_rfkill) 814 if (hw_rfkill)
819 set_bit(STATUS_RFKILL, &trans_pcie->status); 815 set_bit(STATUS_RFKILL, &trans->status);
820 else 816 else
821 clear_bit(STATUS_RFKILL, &trans_pcie->status); 817 clear_bit(STATUS_RFKILL, &trans->status);
822 iwl_op_mode_hw_rf_kill(trans->op_mode, hw_rfkill); 818 iwl_op_mode_hw_rf_kill(trans->op_mode, hw_rfkill);
823 819
824 return 0; 820 return 0;
@@ -924,12 +920,10 @@ void iwl_trans_pcie_free(struct iwl_trans *trans)
924 920
925static void iwl_trans_pcie_set_pmi(struct iwl_trans *trans, bool state) 921static void iwl_trans_pcie_set_pmi(struct iwl_trans *trans, bool state)
926{ 922{
927 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
928
929 if (state) 923 if (state)
930 set_bit(STATUS_TPOWER_PMI, &trans_pcie->status); 924 set_bit(STATUS_TPOWER_PMI, &trans->status);
931 else 925 else
932 clear_bit(STATUS_TPOWER_PMI, &trans_pcie->status); 926 clear_bit(STATUS_TPOWER_PMI, &trans->status);
933} 927}
934 928
935static bool iwl_trans_pcie_grab_nic_access(struct iwl_trans *trans, bool silent, 929static bool iwl_trans_pcie_grab_nic_access(struct iwl_trans *trans, bool silent,
diff --git a/drivers/net/wireless/iwlwifi/pcie/tx.c b/drivers/net/wireless/iwlwifi/pcie/tx.c
index a4ef5cc11100..a36884e993db 100644
--- a/drivers/net/wireless/iwlwifi/pcie/tx.c
+++ b/drivers/net/wireless/iwlwifi/pcie/tx.c
@@ -300,10 +300,8 @@ void iwl_pcie_txq_inc_wr_ptr(struct iwl_trans *trans, struct iwl_txq *txq)
300 iwl_write32(trans, HBUS_TARG_WRPTR, 300 iwl_write32(trans, HBUS_TARG_WRPTR,
301 txq->q.write_ptr | (txq_id << 8)); 301 txq->q.write_ptr | (txq_id << 8));
302 } else { 302 } else {
303 struct iwl_trans_pcie *trans_pcie =
304 IWL_TRANS_GET_PCIE_TRANS(trans);
305 /* if we're trying to save power */ 303 /* if we're trying to save power */
306 if (test_bit(STATUS_TPOWER_PMI, &trans_pcie->status)) { 304 if (test_bit(STATUS_TPOWER_PMI, &trans->status)) {
307 /* wake up nic if it's powered down ... 305 /* wake up nic if it's powered down ...
308 * uCode will wake up, and interrupt us again, so next 306 * uCode will wake up, and interrupt us again, so next
309 * time we'll skip this part. */ 307 * time we'll skip this part. */
@@ -1449,12 +1447,12 @@ void iwl_pcie_hcmd_complete(struct iwl_trans *trans,
1449 iwl_pcie_cmdq_reclaim(trans, txq_id, index); 1447 iwl_pcie_cmdq_reclaim(trans, txq_id, index);
1450 1448
1451 if (!(meta->flags & CMD_ASYNC)) { 1449 if (!(meta->flags & CMD_ASYNC)) {
1452 if (!test_bit(STATUS_HCMD_ACTIVE, &trans_pcie->status)) { 1450 if (!test_bit(STATUS_SYNC_HCMD_ACTIVE, &trans->status)) {
1453 IWL_WARN(trans, 1451 IWL_WARN(trans,
1454 "HCMD_ACTIVE already clear for command %s\n", 1452 "HCMD_ACTIVE already clear for command %s\n",
1455 get_cmd_string(trans_pcie, cmd->hdr.cmd)); 1453 get_cmd_string(trans_pcie, cmd->hdr.cmd));
1456 } 1454 }
1457 clear_bit(STATUS_HCMD_ACTIVE, &trans_pcie->status); 1455 clear_bit(STATUS_SYNC_HCMD_ACTIVE, &trans->status);
1458 IWL_DEBUG_INFO(trans, "Clearing HCMD_ACTIVE for command %s\n", 1456 IWL_DEBUG_INFO(trans, "Clearing HCMD_ACTIVE for command %s\n",
1459 get_cmd_string(trans_pcie, cmd->hdr.cmd)); 1457 get_cmd_string(trans_pcie, cmd->hdr.cmd));
1460 wake_up(&trans_pcie->wait_command_queue); 1458 wake_up(&trans_pcie->wait_command_queue);
@@ -1499,8 +1497,8 @@ static int iwl_pcie_send_hcmd_sync(struct iwl_trans *trans,
1499 IWL_DEBUG_INFO(trans, "Attempting to send sync command %s\n", 1497 IWL_DEBUG_INFO(trans, "Attempting to send sync command %s\n",
1500 get_cmd_string(trans_pcie, cmd->id)); 1498 get_cmd_string(trans_pcie, cmd->id));
1501 1499
1502 if (WARN(test_and_set_bit(STATUS_HCMD_ACTIVE, 1500 if (WARN(test_and_set_bit(STATUS_SYNC_HCMD_ACTIVE,
1503 &trans_pcie->status), 1501 &trans->status),
1504 "Command %s: a command is already active!\n", 1502 "Command %s: a command is already active!\n",
1505 get_cmd_string(trans_pcie, cmd->id))) 1503 get_cmd_string(trans_pcie, cmd->id)))
1506 return -EIO; 1504 return -EIO;
@@ -1511,7 +1509,7 @@ static int iwl_pcie_send_hcmd_sync(struct iwl_trans *trans,
1511 cmd_idx = iwl_pcie_enqueue_hcmd(trans, cmd); 1509 cmd_idx = iwl_pcie_enqueue_hcmd(trans, cmd);
1512 if (cmd_idx < 0) { 1510 if (cmd_idx < 0) {
1513 ret = cmd_idx; 1511 ret = cmd_idx;
1514 clear_bit(STATUS_HCMD_ACTIVE, &trans_pcie->status); 1512 clear_bit(STATUS_SYNC_HCMD_ACTIVE, &trans->status);
1515 IWL_ERR(trans, 1513 IWL_ERR(trans,
1516 "Error sending %s: enqueue_hcmd failed: %d\n", 1514 "Error sending %s: enqueue_hcmd failed: %d\n",
1517 get_cmd_string(trans_pcie, cmd->id), ret); 1515 get_cmd_string(trans_pcie, cmd->id), ret);
@@ -1523,8 +1521,8 @@ static int iwl_pcie_send_hcmd_sync(struct iwl_trans *trans,
1523 1521
1524 timeout -= COMMAND_POKE_TIMEOUT; 1522 timeout -= COMMAND_POKE_TIMEOUT;
1525 ret = wait_event_timeout(trans_pcie->wait_command_queue, 1523 ret = wait_event_timeout(trans_pcie->wait_command_queue,
1526 !test_bit(STATUS_HCMD_ACTIVE, 1524 !test_bit(STATUS_SYNC_HCMD_ACTIVE,
1527 &trans_pcie->status), 1525 &trans->status),
1528 COMMAND_POKE_TIMEOUT); 1526 COMMAND_POKE_TIMEOUT);
1529 if (ret) 1527 if (ret)
1530 break; 1528 break;
@@ -1552,7 +1550,7 @@ static int iwl_pcie_send_hcmd_sync(struct iwl_trans *trans,
1552 IWL_ERR(trans, "Current CMD queue read_ptr %d write_ptr %d\n", 1550 IWL_ERR(trans, "Current CMD queue read_ptr %d write_ptr %d\n",
1553 q->read_ptr, q->write_ptr); 1551 q->read_ptr, q->write_ptr);
1554 1552
1555 clear_bit(STATUS_HCMD_ACTIVE, &trans_pcie->status); 1553 clear_bit(STATUS_SYNC_HCMD_ACTIVE, &trans->status);
1556 IWL_DEBUG_INFO(trans, "Clearing HCMD_ACTIVE for command %s\n", 1554 IWL_DEBUG_INFO(trans, "Clearing HCMD_ACTIVE for command %s\n",
1557 get_cmd_string(trans_pcie, cmd->id)); 1555 get_cmd_string(trans_pcie, cmd->id));
1558 ret = -ETIMEDOUT; 1556 ret = -ETIMEDOUT;
@@ -1562,7 +1560,7 @@ static int iwl_pcie_send_hcmd_sync(struct iwl_trans *trans,
1562 goto cancel; 1560 goto cancel;
1563 } 1561 }
1564 1562
1565 if (test_bit(STATUS_FW_ERROR, &trans_pcie->status)) { 1563 if (test_bit(STATUS_FW_ERROR, &trans->status)) {
1566 IWL_ERR(trans, "FW error in SYNC CMD %s\n", 1564 IWL_ERR(trans, "FW error in SYNC CMD %s\n",
1567 get_cmd_string(trans_pcie, cmd->id)); 1565 get_cmd_string(trans_pcie, cmd->id));
1568 dump_stack(); 1566 dump_stack();
@@ -1571,7 +1569,7 @@ static int iwl_pcie_send_hcmd_sync(struct iwl_trans *trans,
1571 } 1569 }
1572 1570
1573 if (!(cmd->flags & CMD_SEND_IN_RFKILL) && 1571 if (!(cmd->flags & CMD_SEND_IN_RFKILL) &&
1574 test_bit(STATUS_RFKILL, &trans_pcie->status)) { 1572 test_bit(STATUS_RFKILL, &trans->status)) {
1575 IWL_DEBUG_RF_KILL(trans, "RFKILL in SYNC CMD... no rsp\n"); 1573 IWL_DEBUG_RF_KILL(trans, "RFKILL in SYNC CMD... no rsp\n");
1576 ret = -ERFKILL; 1574 ret = -ERFKILL;
1577 goto cancel; 1575 goto cancel;
@@ -1608,13 +1606,11 @@ cancel:
1608 1606
1609int iwl_trans_pcie_send_hcmd(struct iwl_trans *trans, struct iwl_host_cmd *cmd) 1607int iwl_trans_pcie_send_hcmd(struct iwl_trans *trans, struct iwl_host_cmd *cmd)
1610{ 1608{
1611 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 1609 if (test_bit(STATUS_FW_ERROR, &trans->status))
1612
1613 if (test_bit(STATUS_FW_ERROR, &trans_pcie->status))
1614 return -EIO; 1610 return -EIO;
1615 1611
1616 if (!(cmd->flags & CMD_SEND_IN_RFKILL) && 1612 if (!(cmd->flags & CMD_SEND_IN_RFKILL) &&
1617 test_bit(STATUS_RFKILL, &trans_pcie->status)) { 1613 test_bit(STATUS_RFKILL, &trans->status)) {
1618 IWL_DEBUG_RF_KILL(trans, "Dropping CMD 0x%x: RF KILL\n", 1614 IWL_DEBUG_RF_KILL(trans, "Dropping CMD 0x%x: RF KILL\n",
1619 cmd->id); 1615 cmd->id);
1620 return -ERFKILL; 1616 return -ERFKILL;