From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <hzhan75@shecgisg004.sh.intel.com>
Received: from mga14.intel.com (mga14.intel.com [192.55.52.115])
 by dpdk.org (Postfix) with ESMTP id 824D1388F
 for <dev@dpdk.org>; Tue,  8 Mar 2016 09:15:04 +0100 (CET)
Received: from orsmga003.jf.intel.com ([10.7.209.27])
 by fmsmga103.fm.intel.com with ESMTP; 08 Mar 2016 00:15:03 -0800
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.22,556,1449561600"; d="scan'208";a="760065690"
Received: from shvmail01.sh.intel.com ([10.239.29.42])
 by orsmga003.jf.intel.com with ESMTP; 08 Mar 2016 00:15:02 -0800
Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com
 [10.239.29.89])
 by shvmail01.sh.intel.com with ESMTP id u288F0Ue008455;
 Tue, 8 Mar 2016 16:15:00 +0800
Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1])
 by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id
 u288EuR2026572; Tue, 8 Mar 2016 16:14:58 +0800
Received: (from hzhan75@localhost)
 by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id u288Euc1026568;
 Tue, 8 Mar 2016 16:14:56 +0800
From: Helin Zhang <helin.zhang@intel.com>
To: dev@dpdk.org
Date: Tue,  8 Mar 2016 16:14:16 +0800
Message-Id: <1457424877-26234-9-git-send-email-helin.zhang@intel.com>
X-Mailer: git-send-email 1.7.4.1
In-Reply-To: <1457424877-26234-1-git-send-email-helin.zhang@intel.com>
References: <1457278919-30800-1-git-send-email-helin.zhang@intel.com>
 <1457424877-26234-1-git-send-email-helin.zhang@intel.com>
Subject: [dpdk-dev] [PATCH v5 08/29] i40e/base: fix uncertain event
	descriptor issue
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: patches and discussions about DPDK <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Tue, 08 Mar 2016 08:15:05 -0000

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>
---
 drivers/net/i40e/base/i40e_adminq.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

v4:
 - Reworded the commit logs.

diff --git a/drivers/net/i40e/base/i40e_adminq.c b/drivers/net/i40e/base/i40e_adminq.c
index ee563e4..222add4 100644
--- a/drivers/net/i40e/base/i40e_adminq.c
+++ b/drivers/net/i40e/base/i40e_adminq.c
@@ -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;
 }
 
-- 
2.5.0