Skip to content

Commit

Permalink
i40e: clean event descriptor before use
Browse files Browse the repository at this point in the history
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.

Also update copyright year in file headers.

Change-ID: I68bbc41965e93f4adf07cbe98b9dfd63d41509a4
Signed-off-by: Shannon Nelson <shannon.nelson@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
  • Loading branch information
Shannon Nelson authored and Jeff Kirsher committed Feb 18, 2016
1 parent 9b9344f commit 73b03f9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
20 changes: 11 additions & 9 deletions drivers/net/ethernet/intel/i40e/i40e_adminq.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*******************************************************************************
*
* Intel Ethernet Controller XL710 Family Linux Driver
* Copyright(c) 2013 - 2014 Intel Corporation.
* Copyright(c) 2013 - 2016 Intel Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
Expand Down Expand Up @@ -953,6 +953,9 @@ i40e_status i40e_clean_arq_element(struct i40e_hw *hw,
u16 flags;
u16 ntu;

/* pre-clean the event info */
memset(&e->desc, 0, sizeof(e->desc));

/* take the lock before we start messing with the ring */
mutex_lock(&hw->aq.arq_mutex);

Expand Down Expand Up @@ -1020,14 +1023,6 @@ i40e_status 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:
mutex_unlock(&hw->aq.arq_mutex);

if (i40e_is_nvm_update_op(&e->desc)) {
if (hw->aq.nvm_release_on_done) {
i40e_release_nvm(hw);
Expand All @@ -1048,6 +1043,13 @@ i40e_status i40e_clean_arq_element(struct i40e_hw *hw,
}
}

clean_arq_element_out:
/* Set pending if needed, unlock and return */
if (pending)
*pending = (ntc > ntu ? hw->aq.arq.count : 0) + (ntu - ntc);
clean_arq_element_err:
mutex_unlock(&hw->aq.arq_mutex);

return ret_code;
}

Expand Down
5 changes: 4 additions & 1 deletion drivers/net/ethernet/intel/i40evf/i40e_adminq.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*******************************************************************************
*
* Intel Ethernet Controller XL710 Family Linux Virtual Function Driver
* Copyright(c) 2013 - 2014 Intel Corporation.
* Copyright(c) 2013 - 2016 Intel Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
Expand Down Expand Up @@ -887,6 +887,9 @@ i40e_status i40evf_clean_arq_element(struct i40e_hw *hw,
u16 flags;
u16 ntu;

/* pre-clean the event info */
memset(&e->desc, 0, sizeof(e->desc));

/* take the lock before we start messing with the ring */
mutex_lock(&hw->aq.arq_mutex);

Expand Down

0 comments on commit 73b03f9

Please sign in to comment.