Skip to content

Commit

Permalink
iwlwifi: pcie: try to get ownership several times
Browse files Browse the repository at this point in the history
commit 501fd98 upstream.

Some races with the hardware can happen when we take
ownership of the device. Don't give up after the first try.

Reviewed-by: Johannes Berg <[email protected]>
Signed-off-by: Emmanuel Grumbach <[email protected]>
Signed-off-by: Jiri Slaby <[email protected]>
  • Loading branch information
egrumbach authored and Jiri Slaby committed Jul 17, 2014
1 parent 2cee628 commit 78a97b5
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions drivers/net/wireless/iwlwifi/pcie/trans.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ static int iwl_pcie_prepare_card_hw(struct iwl_trans *trans)
{
int ret;
int t = 0;
int iter;

IWL_DEBUG_INFO(trans, "iwl_trans_prepare_card_hw enter\n");

Expand All @@ -353,18 +354,23 @@ static int iwl_pcie_prepare_card_hw(struct iwl_trans *trans)
if (ret >= 0)
return 0;

/* If HW is not ready, prepare the conditions to check again */
iwl_set_bit(trans, CSR_HW_IF_CONFIG_REG,
CSR_HW_IF_CONFIG_REG_PREPARE);
for (iter = 0; iter < 10; iter++) {
/* If HW is not ready, prepare the conditions to check again */
iwl_set_bit(trans, CSR_HW_IF_CONFIG_REG,
CSR_HW_IF_CONFIG_REG_PREPARE);

do {
ret = iwl_pcie_set_hw_ready(trans);
if (ret >= 0)
return 0;

do {
ret = iwl_pcie_set_hw_ready(trans);
if (ret >= 0)
return 0;
usleep_range(200, 1000);
t += 200;
} while (t < 150000);
msleep(25);
}

usleep_range(200, 1000);
t += 200;
} while (t < 150000);
IWL_DEBUG_INFO(trans, "got NIC after %d iterations\n", iter);

return ret;
}
Expand Down

0 comments on commit 78a97b5

Please sign in to comment.