net/ice/base: add retries for reading NVM

Message ID 20240723061915.249540-1-zhichaox.zeng@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Bruce Richardson
Headers
Series net/ice/base: add retries for reading NVM |

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/github-robot: build success github build: passed
ci/intel-Functional success Functional PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-marvell-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS

Commit Message

Zhichao Zeng July 23, 2024, 6:19 a.m. UTC
Reading NVM fails in some scenarios, so synchronize with the share code
in the kernel driver to add retries for reading NVM.

Signed-off-by: Zhichao Zeng <zhichaox.zeng@intel.com>
---
 drivers/net/ice/base/ice_nvm.c | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)
  

Comments

Jiale, SongX July 23, 2024, 9:07 a.m. UTC | #1
> -----Original Message-----
> From: Zhichao Zeng <zhichaox.zeng@intel.com>
> Sent: Tuesday, July 23, 2024 2:19 PM
> To: dev@dpdk.org
> Cc: Zeng, ZhichaoX <zhichaox.zeng@intel.com>
> Subject: [PATCH] net/ice/base: add retries for reading NVM
> 
> Reading NVM fails in some scenarios, so synchronize with the share code in
> the kernel driver to add retries for reading NVM.
> 
> Signed-off-by: Zhichao Zeng <zhichaox.zeng@intel.com>
> ---
Tested-by: Jiale Song <songx.jiale@intel.com>
  
Bruce Richardson July 23, 2024, 10:52 a.m. UTC | #2
On Tue, Jul 23, 2024 at 09:07:32AM +0000, Jiale, SongX wrote:
> > -----Original Message-----
> > From: Zhichao Zeng <zhichaox.zeng@intel.com>
> > Sent: Tuesday, July 23, 2024 2:19 PM
> > To: dev@dpdk.org
> > Cc: Zeng, ZhichaoX <zhichaox.zeng@intel.com>
> > Subject: [PATCH] net/ice/base: add retries for reading NVM
> > 
> > Reading NVM fails in some scenarios, so synchronize with the share code in
> > the kernel driver to add retries for reading NVM.
> > 
> > Signed-off-by: Zhichao Zeng <zhichaox.zeng@intel.com>
> > ---
> Tested-by: Jiale Song <songx.jiale@intel.com>

Pushed to dpdk-next-net-intel, as a bug fix with fixes line:

Fixes: 2516684aed7a ("net/ice/base: extract logic of flat NVM read to function")

Thanks,
/Bruce
  

Patch

diff --git a/drivers/net/ice/base/ice_nvm.c b/drivers/net/ice/base/ice_nvm.c
index 528489929e..2bfc608a8e 100644
--- a/drivers/net/ice/base/ice_nvm.c
+++ b/drivers/net/ice/base/ice_nvm.c
@@ -71,6 +71,7 @@  ice_read_flat_nvm(struct ice_hw *hw, u32 offset, u32 *length, u8 *data,
 {
 	u32 inlen = *length;
 	u32 bytes_read = 0;
+	int retry_cnt = 0;
 	bool last_cmd;
 	int status;
 
@@ -106,11 +107,24 @@  ice_read_flat_nvm(struct ice_hw *hw, u32 offset, u32 *length, u8 *data,
 					 offset, (u16)read_size,
 					 data + bytes_read, last_cmd,
 					 read_shadow_ram, NULL);
-		if (status)
-			break;
-
-		bytes_read += read_size;
-		offset += read_size;
+		if (status) {
+			if (hw->adminq.sq_last_status != ICE_AQ_RC_EBUSY ||
+				retry_cnt > ICE_SQ_SEND_MAX_EXECUTE)
+				break;
+			ice_debug(hw, ICE_DBG_NVM,
+				  "NVM read EBUSY error, retry %d\n",
+				  retry_cnt + 1);
+			ice_release_nvm(hw);
+			msleep(ICE_SQ_SEND_DELAY_TIME_MS);
+			status = ice_acquire_nvm(hw, ICE_RES_READ);
+			if (status)
+				break;
+			retry_cnt++;
+		} else {
+			bytes_read += read_size;
+			offset += read_size;
+			retry_cnt = 0;
+		}
 	} while (!last_cmd);
 
 	*length = bytes_read;