i40e/base: fix uncertain event descriptor issue
authorHelin Zhang <helin.zhang@intel.com>
Tue, 8 Mar 2016 08:14:16 +0000 (16:14 +0800)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Wed, 16 Mar 2016 16:24:47 +0000 (17:24 +0100)
In one obscure corner case, it was possible to clear the NVM update
wait flag when no update_done message was actually received. This
patch cleans the event descriptor before use, and moves the opcode
check to where it won't get done if there was no event to clean.

Fixes: 8db9e2a1b232 ("i40e: base driver")

Signed-off-by: Helin Zhang <helin.zhang@intel.com>
Acked-by: Jingjing Wu <jingjing.wu@intel.com>
Acked-by: Remy Horton <remy.horton@intel.com>
drivers/net/i40e/base/i40e_adminq.c

index ee563e4..222add4 100644 (file)
@@ -1032,6 +1032,9 @@ enum i40e_status_code i40e_clean_arq_element(struct i40e_hw *hw,
        u16 flags;
        u16 ntu;
 
+       /* pre-clean the event info */
+       i40e_memset(&e->desc, 0, sizeof(e->desc), I40E_NONDMA_MEM);
+
        /* take the lock before we start messing with the ring */
        i40e_acquire_spinlock(&hw->aq.arq_spinlock);
 
@@ -1116,13 +1119,6 @@ enum i40e_status_code i40e_clean_arq_element(struct i40e_hw *hw,
        hw->aq.arq.next_to_clean = ntc;
        hw->aq.arq.next_to_use = ntu;
 
-clean_arq_element_out:
-       /* Set pending if needed, unlock and return */
-       if (pending != NULL)
-               *pending = (ntc > ntu ? hw->aq.arq.count : 0) + (ntu - ntc);
-clean_arq_element_err:
-       i40e_release_spinlock(&hw->aq.arq_spinlock);
-
 #ifdef PF_DRIVER
        if (i40e_is_nvm_update_op(&e->desc)) {
                if (hw->aq.nvm_release_on_done) {
@@ -1145,6 +1141,13 @@ clean_arq_element_err:
        }
 
 #endif
+clean_arq_element_out:
+       /* Set pending if needed, unlock and return */
+       if (pending != NULL)
+               *pending = (ntc > ntu ? hw->aq.arq.count : 0) + (ntu - ntc);
+clean_arq_element_err:
+       i40e_release_spinlock(&hw->aq.arq_spinlock);
+
        return ret_code;
 }