From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A86F9458CD; Mon, 2 Sep 2024 11:57:42 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5596C40DDC; Mon, 2 Sep 2024 11:55:45 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) by mails.dpdk.org (Postfix) with ESMTP id EA6C14066C for ; Mon, 2 Sep 2024 11:55:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1725270923; x=1756806923; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3KGbZfJ7DV9+8WI05gPGwRQi6yJIjL8jZ2BF6wmfuVU=; b=XK/umiBdlK+cPKZscSiPHE+bvEhJ8h0taMHaSgL5M2ShPA5vhF0s7xqt Cvp4SPBbMvvTNS/sMa27fi/zPpSxh5K2siNlr6A5HSWHQaicT6CVRIFMG pa0LSny6F4ArNf1Wz9XTmDSp6oaLS1v4JB0j6kehDhaZF/DnGkoZhe0D5 uy3gO3XXIB8q1cFpDkTzMy8J6srRWHmD8bRLOeJq76Jq2UZthR1L+8ezu KUpzRKv4b/LuoI3m/6qghDXc8sIa9xMYNI3+DVg6efWcqKgRM6B02rFqv io+jOPeMDDotXUp1mYM+kMlV3nmET9Kr5i8DcXGChzT5pGwiRHV7mTPJw A==; X-CSE-ConnectionGUID: /5wdDlclSSWKRVh2QlcPkQ== X-CSE-MsgGUID: NvLpzKZKRnOY2lzh+kxHHw== X-IronPort-AV: E=McAfee;i="6700,10204,11182"; a="26747250" X-IronPort-AV: E=Sophos;i="6.10,195,1719903600"; d="scan'208";a="26747250" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Sep 2024 02:55:22 -0700 X-CSE-ConnectionGUID: fe/xMQN6TP2QtyXSsqb/Pw== X-CSE-MsgGUID: lQ8uymFmT6GDbmBWzsKyrA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,195,1719903600"; d="scan'208";a="64597997" Received: from silpixa00401119.ir.intel.com ([10.55.129.167]) by fmviesa009.fm.intel.com with ESMTP; 02 Sep 2024 02:55:21 -0700 From: Anatoly Burakov To: dev@dpdk.org Cc: bruce.richardson@intel.com Subject: [PATCH v1 24/30] net/i40e/base: make semaphore timeout 32-bit Date: Mon, 2 Sep 2024 10:54:36 +0100 Message-ID: <2dceaa2fbd8eee934a7ff28ee2837fefe196422e.1725270827.git.anatoly.burakov@intel.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Aleksandr Loktionov Decrease hw_semaphore_timeout size down to 32bits, because FW I40E_GLVFGEN_TIMER register is 32bits only anyway, and having both variables as same 32-bit size simplifies code. Also, fix FW write semaphore expiration condition, taking into account that I40E_GLVFGEN_TIMER wraps, by checking the sign of substraction of two 32 bit vaues. Signed-off-by: Aleksandr Loktionov Signed-off-by: Anatoly Burakov --- drivers/net/i40e/base/i40e_nvm.c | 8 ++++---- drivers/net/i40e/base/i40e_type.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/net/i40e/base/i40e_nvm.c b/drivers/net/i40e/base/i40e_nvm.c index 05816a4b79..c0f40691f3 100644 --- a/drivers/net/i40e/base/i40e_nvm.c +++ b/drivers/net/i40e/base/i40e_nvm.c @@ -61,7 +61,7 @@ enum i40e_status_code i40e_acquire_nvm(struct i40e_hw *hw, enum i40e_aq_resource_access_type access) { enum i40e_status_code ret_code = I40E_SUCCESS; - u64 gtime, timeout; + u32 gtime, timeout; u64 time_left = 0; DEBUGFUNC("i40e_acquire_nvm"); @@ -85,7 +85,7 @@ enum i40e_status_code i40e_acquire_nvm(struct i40e_hw *hw, if (ret_code && time_left) { /* Poll until the current NVM owner timeouts */ timeout = I40E_MS_TO_GTIME(I40E_MAX_NVM_TIMEOUT) + gtime; - while ((gtime < timeout) && time_left) { + while ((s32)(gtime - timeout) < 0 && time_left) { i40e_msec_delay(10); gtime = rd32(hw, I40E_GLVFGEN_TIMER); ret_code = i40e_aq_request_resource(hw, @@ -1301,9 +1301,9 @@ STATIC enum i40e_status_code i40e_nvmupd_state_writing(struct i40e_hw *hw, u32 gtime; gtime = rd32(hw, I40E_GLVFGEN_TIMER); - if (gtime >= hw->nvm.hw_semaphore_timeout) { + if ((s32)(gtime - hw->nvm.hw_semaphore_timeout) >= 0) { i40e_debug(hw, I40E_DEBUG_ALL, - "NVMUPD: write semaphore expired (%d >= %" PRIu64 "), retrying\n", + "NVMUPD: write semaphore expired (%d >= %" PRIu32 "), retrying\n", gtime, hw->nvm.hw_semaphore_timeout); i40e_release_nvm(hw); status = i40e_acquire_nvm(hw, I40E_RESOURCE_WRITE); diff --git a/drivers/net/i40e/base/i40e_type.h b/drivers/net/i40e/base/i40e_type.h index 83cf701fb4..2d5afb99dd 100644 --- a/drivers/net/i40e/base/i40e_type.h +++ b/drivers/net/i40e/base/i40e_type.h @@ -443,7 +443,7 @@ enum i40e_aq_resource_access_type { }; struct i40e_nvm_info { - u64 hw_semaphore_timeout; /* usec global time (GTIME resolution) */ + u32 hw_semaphore_timeout; /* usec global time (GTIME resolution) */ u32 timeout; /* [ms] */ u16 sr_size; /* Shadow RAM size in words */ bool blank_nvm_mode; /* is NVM empty (no FW present)*/ -- 2.43.5