]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - drivers/net/ethernet/intel/i40evf/i40e_adminq.c
Merge remote-tracking branch 'sound-current/for-linus'
[karo-tx-linux.git] / drivers / net / ethernet / intel / i40evf / i40e_adminq.c
index a23ebfd5cd254014cd0632979aa441a2a6f6eadf..fd123ca60761e84721a02ab991ed677925338126 100644 (file)
@@ -469,8 +469,12 @@ static i40e_status i40e_shutdown_asq(struct i40e_hw *hw)
 {
        i40e_status ret_code = 0;
 
-       if (hw->aq.asq.count == 0)
-               return I40E_ERR_NOT_READY;
+       mutex_lock(&hw->aq.asq_mutex);
+
+       if (hw->aq.asq.count == 0) {
+               ret_code = I40E_ERR_NOT_READY;
+               goto shutdown_asq_out;
+       }
 
        /* Stop firmware AdminQ processing */
        wr32(hw, hw->aq.asq.head, 0);
@@ -479,16 +483,13 @@ static i40e_status i40e_shutdown_asq(struct i40e_hw *hw)
        wr32(hw, hw->aq.asq.bal, 0);
        wr32(hw, hw->aq.asq.bah, 0);
 
-       /* make sure lock is available */
-       mutex_lock(&hw->aq.asq_mutex);
-
        hw->aq.asq.count = 0; /* to indicate uninitialized queue */
 
        /* free ring buffers */
        i40e_free_asq_bufs(hw);
 
+shutdown_asq_out:
        mutex_unlock(&hw->aq.asq_mutex);
-
        return ret_code;
 }
 
@@ -502,8 +503,12 @@ static i40e_status i40e_shutdown_arq(struct i40e_hw *hw)
 {
        i40e_status ret_code = 0;
 
-       if (hw->aq.arq.count == 0)
-               return I40E_ERR_NOT_READY;
+       mutex_lock(&hw->aq.arq_mutex);
+
+       if (hw->aq.arq.count == 0) {
+               ret_code = I40E_ERR_NOT_READY;
+               goto shutdown_arq_out;
+       }
 
        /* Stop firmware AdminQ processing */
        wr32(hw, hw->aq.arq.head, 0);
@@ -512,16 +517,13 @@ static i40e_status i40e_shutdown_arq(struct i40e_hw *hw)
        wr32(hw, hw->aq.arq.bal, 0);
        wr32(hw, hw->aq.arq.bah, 0);
 
-       /* make sure lock is available */
-       mutex_lock(&hw->aq.arq_mutex);
-
        hw->aq.arq.count = 0; /* to indicate uninitialized queue */
 
        /* free ring buffers */
        i40e_free_arq_bufs(hw);
 
+shutdown_arq_out:
        mutex_unlock(&hw->aq.arq_mutex);
-
        return ret_code;
 }
 
@@ -596,6 +598,9 @@ i40e_status i40evf_shutdown_adminq(struct i40e_hw *hw)
 
        /* destroy the locks */
 
+       if (hw->nvm_buff.va)
+               i40e_free_virt_mem(hw, &hw->nvm_buff);
+
        return ret_code;
 }
 
@@ -617,8 +622,7 @@ static u16 i40e_clean_asq(struct i40e_hw *hw)
        details = I40E_ADMINQ_DETAILS(*asq, ntc);
        while (rd32(hw, hw->aq.asq.head) != ntc) {
                i40e_debug(hw, I40E_DEBUG_AQ_MESSAGE,
-                          "%s: ntc %d head %d.\n", __func__, ntc,
-                          rd32(hw, hw->aq.asq.head));
+                          "ntc %d head %d.\n", ntc, rd32(hw, hw->aq.asq.head));
 
                if (details->callback) {
                        I40E_ADMINQ_CALLBACK cb_func =
@@ -682,19 +686,23 @@ i40e_status i40evf_asq_send_command(struct i40e_hw *hw,
        u16  retval = 0;
        u32  val = 0;
 
-       val = rd32(hw, hw->aq.asq.head);
-       if (val >= hw->aq.num_asq_entries) {
+       mutex_lock(&hw->aq.asq_mutex);
+
+       if (hw->aq.asq.count == 0) {
                i40e_debug(hw, I40E_DEBUG_AQ_MESSAGE,
-                          "AQTX: head overrun at %d\n", val);
+                          "AQTX: Admin queue not initialized.\n");
                status = I40E_ERR_QUEUE_EMPTY;
-               goto asq_send_command_exit;
+               goto asq_send_command_error;
        }
 
-       if (hw->aq.asq.count == 0) {
+       hw->aq.asq_last_status = I40E_AQ_RC_OK;
+
+       val = rd32(hw, hw->aq.asq.head);
+       if (val >= hw->aq.num_asq_entries) {
                i40e_debug(hw, I40E_DEBUG_AQ_MESSAGE,
-                          "AQTX: Admin queue not initialized.\n");
+                          "AQTX: head overrun at %d\n", val);
                status = I40E_ERR_QUEUE_EMPTY;
-               goto asq_send_command_exit;
+               goto asq_send_command_error;
        }
 
        details = I40E_ADMINQ_DETAILS(hw->aq.asq, hw->aq.asq.next_to_use);
@@ -719,8 +727,6 @@ i40e_status i40evf_asq_send_command(struct i40e_hw *hw,
        desc->flags &= ~cpu_to_le16(details->flags_dis);
        desc->flags |= cpu_to_le16(details->flags_ena);
 
-       mutex_lock(&hw->aq.asq_mutex);
-
        if (buff_size > hw->aq.asq_buf_size) {
                i40e_debug(hw,
                           I40E_DEBUG_AQ_MESSAGE,
@@ -830,6 +836,10 @@ i40e_status i40evf_asq_send_command(struct i40e_hw *hw,
        i40evf_debug_aq(hw, I40E_DEBUG_AQ_COMMAND, (void *)desc, buff,
                        buff_size);
 
+       /* save writeback aq if requested */
+       if (details->wb_desc)
+               *details->wb_desc = *desc_on_ring;
+
        /* update the error if time out occurred */
        if ((!cmd_completed) &&
            (!details->async && !details->postpone)) {
@@ -841,7 +851,6 @@ i40e_status i40evf_asq_send_command(struct i40e_hw *hw,
 
 asq_send_command_error:
        mutex_unlock(&hw->aq.asq_mutex);
-asq_send_command_exit:
        return status;
 }