i40e: Handle admin Q timeout when releasing NVM
authorPaul M Stillwell Jr <paul.m.stillwell.jr@intel.com>
Tue, 20 Jun 2017 22:16:55 +0000 (15:16 -0700)
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>
Wed, 26 Jul 2017 10:25:19 +0000 (03:25 -0700)
There are some rare cases where the release resource call will return an
admin Q timeout. In these cases the code needs to try to release the
resource again until it succeeds or it times out.

Signed-off-by: Paul M Stillwell Jr <paul.m.stillwell.jr@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
drivers/net/ethernet/intel/i40e/i40e_nvm.c

index 800bd55d0159c083c3d2267c5eda0289b1d6435c..6fdecd70dcbcb1bb4a1a93a6db22288a46fc1d2f 100644 (file)
@@ -134,8 +134,25 @@ i40e_i40e_acquire_nvm_exit:
  **/
 void i40e_release_nvm(struct i40e_hw *hw)
 {
-       if (!hw->nvm.blank_nvm_mode)
-               i40e_aq_release_resource(hw, I40E_NVM_RESOURCE_ID, 0, NULL);
+       i40e_status ret_code = I40E_SUCCESS;
+       u32 total_delay = 0;
+
+       if (hw->nvm.blank_nvm_mode)
+               return;
+
+       ret_code = i40e_aq_release_resource(hw, I40E_NVM_RESOURCE_ID, 0, NULL);
+
+       /* there are some rare cases when trying to release the resource
+        * results in an admin Q timeout, so handle them correctly
+        */
+       while ((ret_code == I40E_ERR_ADMIN_QUEUE_TIMEOUT) &&
+              (total_delay < hw->aq.asq_cmd_timeout)) {
+               usleep_range(1000, 2000);
+               ret_code = i40e_aq_release_resource(hw,
+                                                   I40E_NVM_RESOURCE_ID,
+                                                   0, NULL);
+               total_delay++;
+       }
 }
 
 /**