Skip to content

Commit acb1ce2

Browse files
mdrustadJeff Kirsher
authored andcommitted
ixgbe: Correct X540 semaphore error
In the function ixgbe_get_swfw_sync_semaphore, an incorrect check was treating success as failure and vice-versa. This led to manipulating the IXGBE_SWFW_SYNC register without holding the software semaphore first, which is an error. In addition, if getting the REGSMP bit in the IXGBE_SW_FW_SYNC register timed out, no error code would be returned, making the caller think that it had successfully acquired the lock. Fix both of those issues and clean up the function a bit, such as make the name in the comment match the function. Signed-off-by: Mark Rustad <[email protected]> Tested-by: Phil Schmitt <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent e485669 commit acb1ce2

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -659,46 +659,44 @@ static void ixgbe_release_swfw_sync_X540(struct ixgbe_hw *hw, u16 mask)
659659
}
660660

661661
/**
662-
* ixgbe_get_nvm_semaphore - Get hardware semaphore
662+
* ixgbe_get_swfw_sync_semaphore - Get hardware semaphore
663663
* @hw: pointer to hardware structure
664664
*
665665
* Sets the hardware semaphores so SW/FW can gain control of shared resources
666-
**/
666+
*/
667667
static s32 ixgbe_get_swfw_sync_semaphore(struct ixgbe_hw *hw)
668668
{
669-
s32 status = IXGBE_ERR_EEPROM;
670669
u32 timeout = 2000;
671670
u32 i;
672671
u32 swsm;
673672

674673
/* Get SMBI software semaphore between device drivers first */
675674
for (i = 0; i < timeout; i++) {
676-
/*
677-
* If the SMBI bit is 0 when we read it, then the bit will be
675+
/* If the SMBI bit is 0 when we read it, then the bit will be
678676
* set and we have the semaphore
679677
*/
680678
swsm = IXGBE_READ_REG(hw, IXGBE_SWSM);
681-
if (!(swsm & IXGBE_SWSM_SMBI)) {
682-
status = 0;
679+
if (!(swsm & IXGBE_SWSM_SMBI))
683680
break;
684-
}
685681
usleep_range(50, 100);
686682
}
687683

684+
if (i == timeout) {
685+
hw_dbg(hw,
686+
"Software semaphore SMBI between device drivers not granted.\n");
687+
return IXGBE_ERR_EEPROM;
688+
}
689+
688690
/* Now get the semaphore between SW/FW through the REGSMP bit */
689-
if (status) {
690-
for (i = 0; i < timeout; i++) {
691-
swsm = IXGBE_READ_REG(hw, IXGBE_SWFW_SYNC);
692-
if (!(swsm & IXGBE_SWFW_REGSMP))
693-
break;
691+
for (i = 0; i < timeout; i++) {
692+
swsm = IXGBE_READ_REG(hw, IXGBE_SWFW_SYNC);
693+
if (!(swsm & IXGBE_SWFW_REGSMP))
694+
return 0;
694695

695-
usleep_range(50, 100);
696-
}
697-
} else {
698-
hw_dbg(hw, "Software semaphore SMBI between device drivers not granted.\n");
696+
usleep_range(50, 100);
699697
}
700698

701-
return status;
699+
return IXGBE_ERR_EEPROM;
702700
}
703701

704702
/**

0 commit comments

Comments
 (0)