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 A8FC4454EF; Tue, 25 Jun 2024 13:23:06 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2D15242F7A; Tue, 25 Jun 2024 13:18:10 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) by mails.dpdk.org (Postfix) with ESMTP id 2647942D8C for ; Tue, 25 Jun 2024 13:16:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719314215; x=1750850215; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=IrhL8Nc4IKnglEBcV8gw56f138PgAJmhZLsGktTTkIE=; b=C2JbcofaTHv/wrXW1S4M/LnI3gJ3hCHdz3YmylHG0RFYFLmXl74Z6hMc s7jqmzwvrGErfuY0kx+m2tn1OmAwh1P3LXy5F3NghmAVp8bhLkIzer6HJ 17mRfQVq7wKvmOx7Qb2iCZ8iIgaYGacLji5x09z0IcOa0I+7sp2kAoST5 cEVAAkkk/3aJPGc3vcugAxyKDRcAUV0EU8iqyHUN6mO/SLnHncJyf+VIO mM4/2tpVirf5+DGKa7XmUoK9XE43/oeGoO4nKwBSmIdY6796yqsfz3i5g mPH790zzYB47Q4CLih067cbUUFrbpFizcBTuhKzSW3Hno/USZxuuxYsDS A==; X-CSE-ConnectionGUID: HuXKc/23Shec/bgbldoHMg== X-CSE-MsgGUID: ySu/TVVuTZO8d+aUnyN5yA== X-IronPort-AV: E=McAfee;i="6700,10204,11113"; a="16080276" X-IronPort-AV: E=Sophos;i="6.08,263,1712646000"; d="scan'208";a="16080276" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jun 2024 04:16:37 -0700 X-CSE-ConnectionGUID: 0hsAepTWQWyq85+15cWg0g== X-CSE-MsgGUID: NZOAtCjCQzqzn2mG/SbQbw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,263,1712646000"; d="scan'208";a="43719271" Received: from unknown (HELO silpixa00401119.ir.intel.com) ([10.55.129.167]) by orviesa009.jf.intel.com with ESMTP; 25 Jun 2024 04:16:37 -0700 From: Anatoly Burakov To: dev@dpdk.org Cc: Jaroslaw Ilgiewicz , bruce.richardson@intel.com, ian.stokes@intel.com Subject: [PATCH v3 060/129] net/ice/base: read OROM in a loop Date: Tue, 25 Jun 2024 12:13:05 +0100 Message-ID: <6cde2b233b65e006c21b9db5389b1db1b9c373de.1719313663.git.anatoly.burakov@intel.com> X-Mailer: git-send-email 2.43.0 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: Jaroslaw Ilgiewicz Previously NVM was once acquired and OROM was read to RAM in 4KB chunks. Changed this to a loop in which with each iteration NVM is acquired and only 4 bytes are read. Signed-off-by: Jaroslaw Ilgiewicz Signed-off-by: Ian Stokes --- drivers/net/ice/base/ice_nvm.c | 43 +++++++++++++++++----------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/drivers/net/ice/base/ice_nvm.c b/drivers/net/ice/base/ice_nvm.c index 55e624cb31..79b66fa70f 100644 --- a/drivers/net/ice/base/ice_nvm.c +++ b/drivers/net/ice/base/ice_nvm.c @@ -723,9 +723,10 @@ static int ice_get_orom_civd_data(struct ice_hw *hw, enum ice_bank_select bank, struct ice_orom_civd_info *civd) { - u8 *orom_data; + struct ice_orom_civd_info civd_data_section; int status; u32 offset; + u32 tmp; /* The CIVD section is located in the Option ROM aligned to 512 bytes. * The first 4 bytes must contain the ASCII characters "$CIV". @@ -736,38 +737,37 @@ ice_get_orom_civd_data(struct ice_hw *hw, enum ice_bank_select bank, * usually somewhere in the middle of the bank. We need to scan the * Option ROM bank to locate it. * - * It's significantly faster to read the entire Option ROM up front - * using the maximum page size, than to read each possible location - * with a separate firmware command. */ - orom_data = (u8 *)ice_calloc(hw, hw->flash.banks.orom_size, sizeof(u8)); - if (!orom_data) - return ICE_ERR_NO_MEMORY; - - status = ice_read_flash_module(hw, bank, ICE_SR_1ST_OROM_BANK_PTR, 0, - orom_data, hw->flash.banks.orom_size); - if (status) { - ice_debug(hw, ICE_DBG_NVM, "Unable to read Option ROM data\n"); - goto exit_error;; - } /* Scan the memory buffer to locate the CIVD data section */ for (offset = 0; (offset + 512) <= hw->flash.banks.orom_size; offset += 512) { - struct ice_orom_civd_info *tmp; u8 sum = 0, i; - tmp = (struct ice_orom_civd_info *)&orom_data[offset]; + status = ice_read_flash_module(hw, bank, ICE_SR_1ST_OROM_BANK_PTR, + offset, (u8 *)&tmp, sizeof(tmp)); + if (status) { + ice_debug(hw, ICE_DBG_NVM, "Unable to read Option ROM data\n"); + return status; + } /* Skip forward until we find a matching signature */ - if (memcmp("$CIV", tmp->signature, sizeof(tmp->signature)) != 0) + if (memcmp("$CIV", &tmp, sizeof(tmp)) != 0) continue; ice_debug(hw, ICE_DBG_NVM, "Found CIVD section at offset %u\n", offset); + status = ice_read_flash_module(hw, bank, ICE_SR_1ST_OROM_BANK_PTR, + offset, (u8 *)&civd_data_section, + sizeof(civd_data_section)); + if (status) { + ice_debug(hw, ICE_DBG_NVM, "Unable to read CIVD data\n"); + goto exit_error; + } + /* Verify that the simple checksum is zero */ - for (i = 0; i < sizeof(*tmp); i++) - sum += ((u8 *)tmp)[i]; + for (i = 0; i < sizeof(civd_data_section); i++) + sum += ((u8 *)&civd_data_section)[i]; if (sum) { ice_debug(hw, ICE_DBG_NVM, "Found CIVD data with invalid checksum of %u\n", @@ -776,8 +776,8 @@ ice_get_orom_civd_data(struct ice_hw *hw, enum ice_bank_select bank, goto exit_error; } - *civd = *tmp; - ice_free(hw, orom_data); + *civd = civd_data_section; + return 0; } @@ -785,7 +785,6 @@ ice_get_orom_civd_data(struct ice_hw *hw, enum ice_bank_select bank, ice_debug(hw, ICE_DBG_NVM, "Unable to locate CIVD data within the Option ROM\n"); exit_error: - ice_free(hw, orom_data); return status; } -- 2.43.0