diff options
author | Emil Tantilov <emil.s.tantilov@intel.com> | 2011-02-08 04:42:41 -0500 |
---|---|---|
committer | Jeff Kirsher <jeffrey.t.kirsher@intel.com> | 2011-03-03 05:53:28 -0500 |
commit | dbf893ee85369debaa05b3c222a40c8ac5273a06 (patch) | |
tree | 979e7ad0e9c17d9a1cc8e7a414f386f78a0b05ed /drivers/net/ixgbe | |
parent | 888be1a1e148a5a600050d455f73370f51f26d59 (diff) |
ixgbe: cleanup logic related to HW semaphores
This change cleans up much of the logic related to the hardware semaphores
on the adapters. There were a number of issues with timings that needed to
be addressed.
Signed-off-by: Emil Tantilov <emil.s.tantilov@intel.com>
Tested-by: Stephen Ko <stephen.s.ko@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Diffstat (limited to 'drivers/net/ixgbe')
-rw-r--r-- | drivers/net/ixgbe/ixgbe_common.c | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/drivers/net/ixgbe/ixgbe_common.c b/drivers/net/ixgbe/ixgbe_common.c index ebbda7d15254..345c32eab4a5 100644 --- a/drivers/net/ixgbe/ixgbe_common.c +++ b/drivers/net/ixgbe/ixgbe_common.c | |||
@@ -603,7 +603,6 @@ s32 ixgbe_write_eeprom_generic(struct ixgbe_hw *hw, u16 offset, u16 data) | |||
603 | ixgbe_shift_out_eeprom_bits(hw, data, 16); | 603 | ixgbe_shift_out_eeprom_bits(hw, data, 16); |
604 | ixgbe_standby_eeprom(hw); | 604 | ixgbe_standby_eeprom(hw); |
605 | 605 | ||
606 | msleep(hw->eeprom.semaphore_delay); | ||
607 | /* Done with writing - release the EEPROM */ | 606 | /* Done with writing - release the EEPROM */ |
608 | ixgbe_release_eeprom(hw); | 607 | ixgbe_release_eeprom(hw); |
609 | } | 608 | } |
@@ -747,7 +746,7 @@ s32 ixgbe_poll_eerd_eewr_done(struct ixgbe_hw *hw, u32 ee_reg) | |||
747 | static s32 ixgbe_acquire_eeprom(struct ixgbe_hw *hw) | 746 | static s32 ixgbe_acquire_eeprom(struct ixgbe_hw *hw) |
748 | { | 747 | { |
749 | s32 status = 0; | 748 | s32 status = 0; |
750 | u32 eec = 0; | 749 | u32 eec; |
751 | u32 i; | 750 | u32 i; |
752 | 751 | ||
753 | if (ixgbe_acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM) != 0) | 752 | if (ixgbe_acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM) != 0) |
@@ -776,15 +775,15 @@ static s32 ixgbe_acquire_eeprom(struct ixgbe_hw *hw) | |||
776 | ixgbe_release_swfw_sync(hw, IXGBE_GSSR_EEP_SM); | 775 | ixgbe_release_swfw_sync(hw, IXGBE_GSSR_EEP_SM); |
777 | status = IXGBE_ERR_EEPROM; | 776 | status = IXGBE_ERR_EEPROM; |
778 | } | 777 | } |
779 | } | ||
780 | 778 | ||
781 | /* Setup EEPROM for Read/Write */ | 779 | /* Setup EEPROM for Read/Write */ |
782 | if (status == 0) { | 780 | if (status == 0) { |
783 | /* Clear CS and SK */ | 781 | /* Clear CS and SK */ |
784 | eec &= ~(IXGBE_EEC_CS | IXGBE_EEC_SK); | 782 | eec &= ~(IXGBE_EEC_CS | IXGBE_EEC_SK); |
785 | IXGBE_WRITE_REG(hw, IXGBE_EEC, eec); | 783 | IXGBE_WRITE_REG(hw, IXGBE_EEC, eec); |
786 | IXGBE_WRITE_FLUSH(hw); | 784 | IXGBE_WRITE_FLUSH(hw); |
787 | udelay(1); | 785 | udelay(1); |
786 | } | ||
788 | } | 787 | } |
789 | return status; | 788 | return status; |
790 | } | 789 | } |
@@ -798,13 +797,10 @@ static s32 ixgbe_acquire_eeprom(struct ixgbe_hw *hw) | |||
798 | static s32 ixgbe_get_eeprom_semaphore(struct ixgbe_hw *hw) | 797 | static s32 ixgbe_get_eeprom_semaphore(struct ixgbe_hw *hw) |
799 | { | 798 | { |
800 | s32 status = IXGBE_ERR_EEPROM; | 799 | s32 status = IXGBE_ERR_EEPROM; |
801 | u32 timeout; | 800 | u32 timeout = 2000; |
802 | u32 i; | 801 | u32 i; |
803 | u32 swsm; | 802 | u32 swsm; |
804 | 803 | ||
805 | /* Set timeout value based on size of EEPROM */ | ||
806 | timeout = hw->eeprom.word_size + 1; | ||
807 | |||
808 | /* Get SMBI software semaphore between device drivers first */ | 804 | /* Get SMBI software semaphore between device drivers first */ |
809 | for (i = 0; i < timeout; i++) { | 805 | for (i = 0; i < timeout; i++) { |
810 | /* | 806 | /* |
@@ -816,7 +812,7 @@ static s32 ixgbe_get_eeprom_semaphore(struct ixgbe_hw *hw) | |||
816 | status = 0; | 812 | status = 0; |
817 | break; | 813 | break; |
818 | } | 814 | } |
819 | msleep(1); | 815 | udelay(50); |
820 | } | 816 | } |
821 | 817 | ||
822 | /* Now get the semaphore between SW/FW through the SWESMBI bit */ | 818 | /* Now get the semaphore between SW/FW through the SWESMBI bit */ |
@@ -844,11 +840,14 @@ static s32 ixgbe_get_eeprom_semaphore(struct ixgbe_hw *hw) | |||
844 | * was not granted because we don't have access to the EEPROM | 840 | * was not granted because we don't have access to the EEPROM |
845 | */ | 841 | */ |
846 | if (i >= timeout) { | 842 | if (i >= timeout) { |
847 | hw_dbg(hw, "Driver can't access the Eeprom - Semaphore " | 843 | hw_dbg(hw, "SWESMBI Software EEPROM semaphore " |
848 | "not granted.\n"); | 844 | "not granted.\n"); |
849 | ixgbe_release_eeprom_semaphore(hw); | 845 | ixgbe_release_eeprom_semaphore(hw); |
850 | status = IXGBE_ERR_EEPROM; | 846 | status = IXGBE_ERR_EEPROM; |
851 | } | 847 | } |
848 | } else { | ||
849 | hw_dbg(hw, "Software semaphore SMBI between device drivers " | ||
850 | "not granted.\n"); | ||
852 | } | 851 | } |
853 | 852 | ||
854 | return status; | 853 | return status; |
@@ -1081,10 +1080,13 @@ static void ixgbe_release_eeprom(struct ixgbe_hw *hw) | |||
1081 | IXGBE_WRITE_REG(hw, IXGBE_EEC, eec); | 1080 | IXGBE_WRITE_REG(hw, IXGBE_EEC, eec); |
1082 | 1081 | ||
1083 | ixgbe_release_swfw_sync(hw, IXGBE_GSSR_EEP_SM); | 1082 | ixgbe_release_swfw_sync(hw, IXGBE_GSSR_EEP_SM); |
1083 | |||
1084 | /* Delay before attempt to obtain semaphore again to allow FW access */ | ||
1085 | msleep(hw->eeprom.semaphore_delay); | ||
1084 | } | 1086 | } |
1085 | 1087 | ||
1086 | /** | 1088 | /** |
1087 | * ixgbe_calc_eeprom_checksum - Calculates and returns the checksum | 1089 | * ixgbe_calc_eeprom_checksum_generic - Calculates and returns the checksum |
1088 | * @hw: pointer to hardware structure | 1090 | * @hw: pointer to hardware structure |
1089 | **/ | 1091 | **/ |
1090 | u16 ixgbe_calc_eeprom_checksum_generic(struct ixgbe_hw *hw) | 1092 | u16 ixgbe_calc_eeprom_checksum_generic(struct ixgbe_hw *hw) |
@@ -2206,6 +2208,10 @@ s32 ixgbe_acquire_swfw_sync(struct ixgbe_hw *hw, u16 mask) | |||
2206 | s32 timeout = 200; | 2208 | s32 timeout = 200; |
2207 | 2209 | ||
2208 | while (timeout) { | 2210 | while (timeout) { |
2211 | /* | ||
2212 | * SW EEPROM semaphore bit is used for access to all | ||
2213 | * SW_FW_SYNC/GSSR bits (not just EEPROM) | ||
2214 | */ | ||
2209 | if (ixgbe_get_eeprom_semaphore(hw)) | 2215 | if (ixgbe_get_eeprom_semaphore(hw)) |
2210 | return IXGBE_ERR_SWFW_SYNC; | 2216 | return IXGBE_ERR_SWFW_SYNC; |
2211 | 2217 | ||
@@ -2223,7 +2229,7 @@ s32 ixgbe_acquire_swfw_sync(struct ixgbe_hw *hw, u16 mask) | |||
2223 | } | 2229 | } |
2224 | 2230 | ||
2225 | if (!timeout) { | 2231 | if (!timeout) { |
2226 | hw_dbg(hw, "Driver can't access resource, GSSR timeout.\n"); | 2232 | hw_dbg(hw, "Driver can't access resource, SW_FW_SYNC timeout.\n"); |
2227 | return IXGBE_ERR_SWFW_SYNC; | 2233 | return IXGBE_ERR_SWFW_SYNC; |
2228 | } | 2234 | } |
2229 | 2235 | ||