Skip to content

Commit

Permalink
e1000e: fix acquisition of SW/FW/HW semaphore for ICHx parts
Browse files Browse the repository at this point in the history
For ICHx parts, write the EXTCNF_CTRL.SWFLAG bit once when trying to
acquire the SW/FW/HW semaphore instead of multiple times to prevent the
hardware from having problems (especially for systems with manageability
enabled), and extend the timeout for the hardware to set the SWFLAG bit.

Signed-off-by: Bruce Allan <[email protected]>
Signed-off-by: Jeff Kirsher <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
bwallan authored and davem330 committed Aug 10, 2009
1 parent 6e455b8 commit 373a88d
Showing 1 changed file with 31 additions and 13 deletions.
44 changes: 31 additions & 13 deletions drivers/net/e1000e/ich8lan.c
Original file line number Diff line number Diff line change
Expand Up @@ -594,37 +594,55 @@ static DEFINE_MUTEX(nvm_mutex);
**/
static s32 e1000_acquire_swflag_ich8lan(struct e1000_hw *hw)
{
u32 extcnf_ctrl;
u32 timeout = PHY_CFG_TIMEOUT;
u32 extcnf_ctrl, timeout = PHY_CFG_TIMEOUT;
s32 ret_val = 0;

might_sleep();

mutex_lock(&nvm_mutex);

while (timeout) {
extcnf_ctrl = er32(EXTCNF_CTRL);
if (!(extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG))
break;

if (!(extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG)) {
extcnf_ctrl |= E1000_EXTCNF_CTRL_SWFLAG;
ew32(EXTCNF_CTRL, extcnf_ctrl);
mdelay(1);
timeout--;
}

if (!timeout) {
hw_dbg(hw, "SW/FW/HW has locked the resource for too long.\n");
ret_val = -E1000_ERR_CONFIG;
goto out;
}

timeout = PHY_CFG_TIMEOUT * 2;

extcnf_ctrl |= E1000_EXTCNF_CTRL_SWFLAG;
ew32(EXTCNF_CTRL, extcnf_ctrl);

while (timeout) {
extcnf_ctrl = er32(EXTCNF_CTRL);
if (extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG)
break;

extcnf_ctrl = er32(EXTCNF_CTRL);
if (extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG)
break;
}
mdelay(1);
timeout--;
}

if (!timeout) {
hw_dbg(hw, "FW or HW has locked the resource for too long.\n");
hw_dbg(hw, "Failed to acquire the semaphore.\n");
extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG;
ew32(EXTCNF_CTRL, extcnf_ctrl);
mutex_unlock(&nvm_mutex);
return -E1000_ERR_CONFIG;
ret_val = -E1000_ERR_CONFIG;
goto out;
}

return 0;
out:
if (ret_val)
mutex_unlock(&nvm_mutex);

return ret_val;
}

/**
Expand Down

0 comments on commit 373a88d

Please sign in to comment.