From 9f5cc5aae8befa0e66ed238356bda89077007fa0 Mon Sep 17 00:00:00 2001 From: Vevek Venkatesan Date: Mon, 19 Jul 2021 18:29:13 +0530 Subject: [PATCH] qcacmn: refer system time for pld_is_pci_ep_awake timeout Currently timeout for checking pld_is_pci_ep_awake in hif_prevent_link_low_power_states might be higher than the defined timeout depends on how long qdf_sleep takes to get scheduled again, so avoid this uncertain timeout adding reference to the system time. Change-Id: I67a28d46c996ccc56680cf8e20c09a70729a33c5 CRs-Fixed: 2994746 --- hif/src/ipcie/if_ipci.c | 13 +++++++------ hif/src/ipcie/if_ipci.h | 8 ++++---- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/hif/src/ipcie/if_ipci.c b/hif/src/ipcie/if_ipci.c index d2740df1a7..fb0f9904b1 100644 --- a/hif/src/ipcie/if_ipci.c +++ b/hif/src/ipcie/if_ipci.c @@ -897,15 +897,16 @@ int hif_prevent_link_low_power_states(struct hif_opaque_softc *hif) { struct hif_softc *scn = HIF_GET_SOFTC(hif); struct hif_ipci_softc *ipci_scn = HIF_GET_IPCI_SOFTC(scn); - uint32_t timeout = 0; + uint32_t start_time = 0, curr_time = 0; if (pld_is_pci_ep_awake(scn->qdf_dev->dev) == -ENOTSUPP) return 0; + start_time = curr_time = qdf_system_ticks_to_msecs(qdf_system_ticks()); while (pld_is_pci_ep_awake(scn->qdf_dev->dev) && - timeout <= EP_WAKE_RESET_DELAY_TIMEOUT_US) { + curr_time <= start_time + EP_WAKE_RESET_DELAY_TIMEOUT_MS) { qdf_sleep_us(EP_WAKE_RESET_DELAY_US); - timeout += EP_WAKE_RESET_DELAY_US; + curr_time = qdf_system_ticks_to_msecs(qdf_system_ticks()); } if (pld_is_pci_ep_awake(scn->qdf_dev->dev)) { @@ -921,11 +922,11 @@ int hif_prevent_link_low_power_states(struct hif_opaque_softc *hif) } ipci_scn->prevent_l1 = true; - timeout = 0; + start_time = curr_time = qdf_system_ticks_to_msecs(qdf_system_ticks()); while (!pld_is_pci_ep_awake(scn->qdf_dev->dev) && - timeout <= EP_WAKE_DELAY_TIMEOUT_US) { + curr_time <= start_time + EP_WAKE_DELAY_TIMEOUT_MS) { qdf_sleep_us(EP_WAKE_DELAY_US); - timeout += EP_WAKE_DELAY_US; + curr_time = qdf_system_ticks_to_msecs(qdf_system_ticks()); } if (pld_is_pci_ep_awake(scn->qdf_dev->dev) <= 0) { diff --git a/hif/src/ipcie/if_ipci.h b/hif/src/ipcie/if_ipci.h index 3ec328f536..2a68c47ed4 100644 --- a/hif/src/ipcie/if_ipci.h +++ b/hif/src/ipcie/if_ipci.h @@ -66,11 +66,11 @@ struct hif_ipci_stats { #ifdef FEATURE_HAL_DELAYED_REG_WRITE #ifdef HAL_CONFIG_SLUB_DEBUG_ON -#define EP_WAKE_RESET_DELAY_TIMEOUT_US 3000 -#define EP_WAKE_DELAY_TIMEOUT_US 7000 +#define EP_WAKE_RESET_DELAY_TIMEOUT_MS 3 +#define EP_WAKE_DELAY_TIMEOUT_MS 7 #else -#define EP_WAKE_RESET_DELAY_TIMEOUT_US 10000 -#define EP_WAKE_DELAY_TIMEOUT_US 10000 +#define EP_WAKE_RESET_DELAY_TIMEOUT_MS 10 +#define EP_WAKE_DELAY_TIMEOUT_MS 10 #endif #define EP_WAKE_RESET_DELAY_US 50 #define EP_WAKE_DELAY_US 200