Commit 416dde0f authored by Johannes Berg's avatar Johannes Berg Committed by Luca Coelho

iwlwifi: pcie: normally grab NIC access for inflight-hcmd

We currently have a special, separate, code path to acquire NIC
access for the in-flight host-command workaround on 7000 series
hardware. However, the normal code path here has grown a number
of additional workarounds/semantics over time, such as reprobing
the device if things fail.

Rather than try to replicate any of this logic, call the normal
grab_nic_access logic for the workaround.

This changes the spinlock to _bh, but that's OK since it's just
redundant, we already have soft-IRQs disabled when we get here,
and so didn't (have to) do it again. Since it's only for commands
there's however no point in making the code more complex just to
not use _bh here.
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
Signed-off-by: default avatarLuca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20210330162204.d196fc6ffb23.Idc1ce3ce9fed9178beee7e5409bc669f79b06a0d@changeidSigned-off-by: default avatarLuca Coelho <luciano.coelho@intel.com>
parent 72bc934c
...@@ -629,7 +629,6 @@ static int iwl_pcie_set_cmd_in_flight(struct iwl_trans *trans, ...@@ -629,7 +629,6 @@ static int iwl_pcie_set_cmd_in_flight(struct iwl_trans *trans,
const struct iwl_host_cmd *cmd) const struct iwl_host_cmd *cmd)
{ {
struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
int ret = 0;
/* Make sure the NIC is still alive in the bus */ /* Make sure the NIC is still alive in the bus */
if (test_bit(STATUS_TRANS_DEAD, &trans->status)) if (test_bit(STATUS_TRANS_DEAD, &trans->status))
...@@ -638,34 +637,24 @@ static int iwl_pcie_set_cmd_in_flight(struct iwl_trans *trans, ...@@ -638,34 +637,24 @@ static int iwl_pcie_set_cmd_in_flight(struct iwl_trans *trans,
if (!trans->trans_cfg->base_params->apmg_wake_up_wa) if (!trans->trans_cfg->base_params->apmg_wake_up_wa)
return 0; return 0;
spin_lock(&trans_pcie->reg_lock);
/* /*
* wake up the NIC to make sure that the firmware will see the host * wake up the NIC to make sure that the firmware will see the host
* command - we will let the NIC sleep once all the host commands * command - we will let the NIC sleep once all the host commands
* returned. This needs to be done only on NICs that have * returned. This needs to be done only on NICs that have
* apmg_wake_up_wa set (see above.) * apmg_wake_up_wa set (see above.)
*/ */
if (!trans_pcie->cmd_hold_nic_awake) { if (!iwl_trans_grab_nic_access(trans))
__iwl_trans_pcie_set_bit(trans, CSR_GP_CNTRL, return -EIO;
CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ);
ret = iwl_poll_bit(trans, CSR_GP_CNTRL,
CSR_GP_CNTRL_REG_VAL_MAC_ACCESS_EN,
(CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY |
CSR_GP_CNTRL_REG_FLAG_GOING_TO_SLEEP),
15000);
if (ret < 0) {
__iwl_trans_pcie_clear_bit(trans, CSR_GP_CNTRL,
CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ);
IWL_ERR(trans, "Failed to wake NIC for hcmd\n");
ret = -EIO;
} else {
trans_pcie->cmd_hold_nic_awake = true;
}
}
spin_unlock(&trans_pcie->reg_lock);
return ret; /*
* In iwl_trans_grab_nic_access(), we've acquired the reg_lock.
* There, we also returned immediately if cmd_hold_nic_awake is
* already true, so it's OK to unconditionally set it to true.
*/
trans_pcie->cmd_hold_nic_awake = true;
spin_unlock_bh(&trans_pcie->reg_lock);
return 0;
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment