aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/intel/ixgbe
diff options
context:
space:
mode:
authorMark Rustad <mark.d.rustad@intel.com>2014-07-22 02:50:47 -0400
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>2014-07-25 22:01:28 -0400
commitacb1ce223b3e6a340e46fe7b21a9dd4797618ace (patch)
tree3a26f8196b445237f484262d446f36e39a11cba4 /drivers/net/ethernet/intel/ixgbe
parente4856696b4afbf53a84e0475149369b78b47f713 (diff)
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 <mark.d.rustad@intel.com> Tested-by: Phil Schmitt <phillip.j.schmitt@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Diffstat (limited to 'drivers/net/ethernet/intel/ixgbe')
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c34
1 files changed, 16 insertions, 18 deletions
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c
index efdb517b8fc2..1e26794febd6 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c
@@ -659,46 +659,44 @@ static void ixgbe_release_swfw_sync_X540(struct ixgbe_hw *hw, u16 mask)
659} 659}
660 660
661/** 661/**
662 * ixgbe_get_nvm_semaphore - Get hardware semaphore 662 * ixgbe_get_swfw_sync_semaphore - Get hardware semaphore
663 * @hw: pointer to hardware structure 663 * @hw: pointer to hardware structure
664 * 664 *
665 * Sets the hardware semaphores so SW/FW can gain control of shared resources 665 * Sets the hardware semaphores so SW/FW can gain control of shared resources
666 **/ 666 */
667static s32 ixgbe_get_swfw_sync_semaphore(struct ixgbe_hw *hw) 667static s32 ixgbe_get_swfw_sync_semaphore(struct ixgbe_hw *hw)
668{ 668{
669 s32 status = IXGBE_ERR_EEPROM;
670 u32 timeout = 2000; 669 u32 timeout = 2000;
671 u32 i; 670 u32 i;
672 u32 swsm; 671 u32 swsm;
673 672
674 /* Get SMBI software semaphore between device drivers first */ 673 /* Get SMBI software semaphore between device drivers first */
675 for (i = 0; i < timeout; i++) { 674 for (i = 0; i < timeout; i++) {
676 /* 675 /* If the SMBI bit is 0 when we read it, then the bit will be
677 * If the SMBI bit is 0 when we read it, then the bit will be
678 * set and we have the semaphore 676 * set and we have the semaphore
679 */ 677 */
680 swsm = IXGBE_READ_REG(hw, IXGBE_SWSM); 678 swsm = IXGBE_READ_REG(hw, IXGBE_SWSM);
681 if (!(swsm & IXGBE_SWSM_SMBI)) { 679 if (!(swsm & IXGBE_SWSM_SMBI))
682 status = 0;
683 break; 680 break;
684 }
685 usleep_range(50, 100); 681 usleep_range(50, 100);
686 } 682 }
687 683
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
688 /* Now get the semaphore between SW/FW through the REGSMP bit */ 690 /* Now get the semaphore between SW/FW through the REGSMP bit */
689 if (status) { 691 for (i = 0; i < timeout; i++) {
690 for (i = 0; i < timeout; i++) { 692 swsm = IXGBE_READ_REG(hw, IXGBE_SWFW_SYNC);
691 swsm = IXGBE_READ_REG(hw, IXGBE_SWFW_SYNC); 693 if (!(swsm & IXGBE_SWFW_REGSMP))
692 if (!(swsm & IXGBE_SWFW_REGSMP)) 694 return 0;
693 break;
694 695
695 usleep_range(50, 100); 696 usleep_range(50, 100);
696 }
697 } else {
698 hw_dbg(hw, "Software semaphore SMBI between device drivers not granted.\n");
699 } 697 }
700 698
701 return status; 699 return IXGBE_ERR_EEPROM;
702} 700}
703 701
704/** 702/**