From ddd0ab4e614841631bbee4397971eba48c5fce0c Mon Sep 17 00:00:00 2001 From: Narayan Reddy Date: Mon, 12 Dec 2022 13:23:51 +0000 Subject: [PATCH] osi: xpcs: add delays as per HW team suggestion Issue: Random delays were added in xpcs_start and xpcs_init which can lead to increase in the boot time Fix: Instead of adding random delays and retries add the exact delays suggested by HW team Bug 3806700 Change-Id: If6f781d86c7de4019883e4b02dc89b2d04ecc768 Signed-off-by: Narayan Reddy Reviewed-on: https://git-master.nvidia.com/r/c/kernel/nvethernetrm/+/2826256 Reviewed-by: svcacv Reviewed-by: Bhadram Varka Reviewed-by: Zuyu Liao Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-misra Reviewed-by: svc-mobile-cert Reviewed-by: Srinivas Ramachandran Tested-by: Zuyu Liao GVS: Gerrit_Virtual_Submit --- osi/core/xpcs.c | 35 ++++++++++++++++++++++++++++------- osi/core/xpcs.h | 9 --------- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/osi/core/xpcs.c b/osi/core/xpcs.c index e749dc5..b61cacb 100644 --- a/osi/core/xpcs.c +++ b/osi/core/xpcs.c @@ -216,7 +216,12 @@ nve32_t xpcs_start(struct osi_core_priv_data *osi_core) XPCS_SR_XS_PCS_STS1_RLU) { cond = COND_MET; } else { - osi_core->osd_ops.udelay(1000U); + /* Maximum wait delay as per HW team is 1msec. + * So add a loop for 1000 iterations with 1usec delay, + * so that if check get satisfies before 1msec will come + * out of loop and it can save some boot time + */ + osi_core->osd_ops.udelay(1U); } } fail: @@ -239,7 +244,7 @@ static nve32_t xpcs_uphy_lane_bring_up(struct osi_core_priv_data *osi_core, nveu32_t lane_init_en) { void *xpcs_base = osi_core->xpcs_base; - nveu32_t retry = XPCS_RETRY_COUNT; + nveu32_t retry = 5U; nve32_t cond = COND_NOT_MET; nveu32_t val = 0; nveu32_t count; @@ -269,7 +274,11 @@ static nve32_t xpcs_uphy_lane_bring_up(struct osi_core_priv_data *osi_core, /* exit loop */ cond = COND_MET; } else { - osi_core->osd_ops.udelay(5U); + /* Max wait time is 1usec. + * Most of the time loop got exited in first iteration. + * but added an extra count of 4 for safer side + */ + osi_core->osd_ops.udelay(1U); } } } @@ -291,7 +300,7 @@ fail: static nve32_t xpcs_check_pcs_lock_status(struct osi_core_priv_data *osi_core) { void *xpcs_base = osi_core->xpcs_base; - nveu32_t retry = XPCS_RETRY_COUNT; + nveu32_t retry = RETRY_COUNT; nve32_t cond = COND_NOT_MET; nveu32_t val = 0; nveu32_t count; @@ -312,7 +321,12 @@ static nve32_t xpcs_check_pcs_lock_status(struct osi_core_priv_data *osi_core) /* exit loop */ cond = COND_MET; } else { - osi_core->osd_ops.udelay(5U); + /* Maximum wait delay as per HW team is 1msec. + * So add a loop for 1000 iterations with 1usec delay, + * so that if check get satisfies before 1msec will come + * out of loop and it can save some boot time + */ + osi_core->osd_ops.udelay(1U); } } @@ -336,7 +350,7 @@ fail: static nve32_t xpcs_lane_bring_up(struct osi_core_priv_data *osi_core) { struct core_local *l_core = (struct core_local *)(void *)osi_core; - nveu32_t retry = 1000; + nveu32_t retry = 7U; nveu32_t count; nveu32_t val = 0; nve32_t cond; @@ -412,7 +426,14 @@ static nve32_t xpcs_lane_bring_up(struct osi_core_priv_data *osi_core) if ((val & XPCS_WRAP_UPHY_RX_CONTROL_0_0_RX_CAL_EN) == 0U) { cond = COND_MET; } else { - osi_core->osd_ops.udelay(1000U); + /* Maximum wait delay as per HW team is 100 usec. + * But most of the time as per experiments it takes + * around 14usec to satisy the condition, so add a + * minimum delay of 14usec and loop it for 7times. + * With this 14usec delay condition gets satifies + * in first iteration itself. + */ + osi_core->osd_ops.udelay(14U); } } diff --git a/osi/core/xpcs.h b/osi/core/xpcs.h index 345fc27..be788e3 100644 --- a/osi/core/xpcs.h +++ b/osi/core/xpcs.h @@ -26,15 +26,6 @@ #include "../osi/common/common.h" #include -/** - * @addtogroup XPCS helper macros - * - * @brief XPCS helper macros. - * @{ - */ -#define XPCS_RETRY_COUNT (RETRY_COUNT * (2U)) -/** @} */ - /** * @addtogroup XPCS Register offsets *