osi: core: use appropriate sleep function

issue: on some setups link partner is not connected
and hence the sw retries for the link with a delay of
100msec for every retry. In case of HVRTOS udelay is a
busy loop and it starves other tasks on the CPU.

Fix: Use udelay for small wait checks, and usleep
for larger delays.

Bug 5278971

Change-Id: If2c29475dbd552a8da549668460385f9402e612b
Signed-off-by: Narayan Reddy <narayanr@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/kernel/nvethernetrm/+/3371471
Reviewed-by: svc-mobile-misra <svc-mobile-misra@nvidia.com>
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: Srinivas Ramachandran <srinivasra@nvidia.com>
Reviewed-by: Bhadram Varka <vbhadram@nvidia.com>
This commit is contained in:
Narayan Reddy
2025-05-27 11:16:18 +00:00
committed by mobile promotions
parent c46dc5ac44
commit 53c6e3ffc4
2 changed files with 8 additions and 13 deletions

View File

@@ -389,7 +389,7 @@ nve32_t xlgpcs_start(struct osi_core_priv_data *osi_core)
* so that if check get satisfies before 1msec will come * so that if check get satisfies before 1msec will come
* out of loop and it can save some boot time * out of loop and it can save some boot time
*/ */
osi_core->osd_ops.udelay(10U); osi_core->osd_ops.usleep(10U);
} }
} }
} }
@@ -421,7 +421,7 @@ nve32_t xlgpcs_start(struct osi_core_priv_data *osi_core)
* so that if check get satisfies before 1msec will come * so that if check get satisfies before 1msec will come
* out of loop and it can save some boot time * out of loop and it can save some boot time
*/ */
osi_core->osd_ops.udelay(10U); osi_core->osd_ops.usleep(10U);
} }
} }
fail: fail:
@@ -449,7 +449,6 @@ static nve32_t xpcs_uphy_lane_bring_up(struct osi_core_priv_data *osi_core,
nveu32_t val = 0; nveu32_t val = 0;
nveu32_t count; nveu32_t count;
nve32_t ret = 0; nve32_t ret = 0;
nveu32_t once = 0;
nveu64_t retry_delay = OSI_DELAY_1US; nveu64_t retry_delay = OSI_DELAY_1US;
const nveu32_t uphy_status_reg[OSI_MAX_MAC_IP_TYPES] = { const nveu32_t uphy_status_reg[OSI_MAX_MAC_IP_TYPES] = {
EQOS_XPCS_WRAP_UPHY_STATUS, EQOS_XPCS_WRAP_UPHY_STATUS,
@@ -510,15 +509,11 @@ static nve32_t xpcs_uphy_lane_bring_up(struct osi_core_priv_data *osi_core,
goto done; goto done;
} }
count++; count++;
/* Max wait time is 1usec. /* Apply delay based on retry_delay value */
* Most of the time loop got exited in first iteration. if (retry_delay == OSI_DELAY_1US) {
* but added an extra count of 4 for safer side
*/
if (once == 0U) {
osi_core->osd_ops.udelay(retry_delay); osi_core->osd_ops.udelay(retry_delay);
once = 1U;
} else { } else {
osi_core->osd_ops.udelay(retry_delay); osi_core->osd_ops.usleep(retry_delay);
} }
} }
} }
@@ -1261,7 +1256,7 @@ nve32_t xlgpcs_eee(struct osi_core_priv_data *osi_core, nveu32_t en_dis)
if ((val & XLGPCS_VR_PCS_DIG_STSLTXRX_STATE) == 0U) { if ((val & XLGPCS_VR_PCS_DIG_STSLTXRX_STATE) == 0U) {
cond = 0; cond = 0;
} else { } else {
osi_core->osd_ops.udelay(100U); osi_core->osd_ops.usleep(100U);
} }
} }
} else { } else {

View File

@@ -158,7 +158,7 @@ nve32_t eqos_xpcs_init(struct osi_core_priv_data *osi_core)
if ((ctrl & XPCS_SR_MII_CTRL_RST) == 0U) { if ((ctrl & XPCS_SR_MII_CTRL_RST) == 0U) {
cond = 0; cond = 0;
} else { } else {
osi_core->osd_ops.udelay(100U); osi_core->osd_ops.usleep(100U);
} }
} }
@@ -217,7 +217,7 @@ nve32_t eqos_xpcs_init(struct osi_core_priv_data *osi_core)
XPCS_SR_MII_STS_0_LINK_STS) { XPCS_SR_MII_STS_0_LINK_STS) {
cond = 0; cond = 0;
} else { } else {
osi_core->osd_ops.udelay(100U); osi_core->osd_ops.usleep(100U);
} }
} }