qcacmn: Fix long ping delay after enable RTPM

Issue1: Driver RTPM state is ON/NONE, Kernel state is RESUMING.
cdp_runtime_resume is already complete,
hif_pm_runtime_get return -E_INPROGRESS,
dp_tx_hw_enqueue will set the flush event,
but cdp_runtime_resume is already done,
this flush event will be handled only on next pkt tx.

Issue2: Driver RTPM state: Resuming
hif_pm_runtime_get returns -EBUSY,
dp_tx_hw_enqueue is interrupted by any IRQ,
cdp_runtime_resume is completed,
dp_tx_hw_enqueue will set the flush event,
This flush event will be handled only on next pkt tx.

Fix:
Introduce a link_state_up atomic variable in hif to track the link state
change by pld_cb.
Set atomic variable link_state_up=1 in pmo_core_psoc_bus_runtime_resume
just after pld_cb. pld_cb brings the PCIe bus out of suspend state.
Set atomic variable link_state_up=0 in pmo_core_psoc_bus_runtime_suspend
just before pld_cb. pld_cb puts the PCIe bus into suspend state.

Introduce dp_runtime_get and dp_runtime_put.
dp_runtime_get get refcount with increment of an atomic variable.
dp_runtime_put return refcount with decrement of  this atomic variable.

If hif_pm_runtime_get returns -EBUSY or -EINPROGRESS,
take the dp runtime refcount using dp_runtime_get,
check if the link state is up, write TX ring HP,
return the dp runtime refcount using dp_runtime_put.

cdp_runtime_suspend should reject the suspend, if dp_runtime_get is non
zero.
cdp_runtime_resume should wait until dp_runtime_get becomes zero or time
out, then flush pending tx for runtime suspend.

Change-Id: I5b97d50cba710082f117f3845f7830712b86cda7
CRs-Fixed: 2844888
此提交包含在:
Jianmin Zhu
2021-01-09 13:01:37 +08:00
提交者 snandini
父節點 1e157ef978
當前提交 6ef2047d56
共有 8 個檔案被更改,包括 214 行新增12 行删除

查看文件

@@ -1022,8 +1022,19 @@ static inline char *rtpm_string_from_dbgid(wlan_rtpm_dbgid id)
return (char *)strings[id];
}
/**
* enum hif_pm_link_state - hif link state
* HIF_PM_LINK_STATE_DOWN: hif link state is down
* HIF_PM_LINK_STATE_UP: hif link state is up
*/
enum hif_pm_link_state {
HIF_PM_LINK_STATE_DOWN,
HIF_PM_LINK_STATE_UP
};
#ifdef FEATURE_RUNTIME_PM
struct hif_pm_runtime_lock;
void hif_fastpath_resume(struct hif_opaque_softc *hif_ctx);
int hif_pm_runtime_get_sync(struct hif_opaque_softc *hif_ctx,
wlan_rtpm_dbgid rtpm_dbgid);
@@ -1058,6 +1069,22 @@ void hif_pm_runtime_mark_dp_rx_busy(struct hif_opaque_softc *hif_ctx);
int hif_pm_runtime_is_dp_rx_busy(struct hif_opaque_softc *hif_ctx);
qdf_time_t hif_pm_runtime_get_dp_rx_busy_mark(struct hif_opaque_softc *hif_ctx);
int hif_pm_runtime_sync_resume(struct hif_opaque_softc *hif_ctx);
/**
* hif_pm_set_link_state() - set link state during RTPM
* @hif_sc: HIF Context
*
* Return: None
*/
void hif_pm_set_link_state(struct hif_opaque_softc *hif_handle, uint8_t val);
/**
* hif_is_link_state_up() - Is link state up
* @hif_sc: HIF Context
*
* Return: 1 link is up, 0 link is down
*/
uint8_t hif_pm_get_link_state(struct hif_opaque_softc *hif_handle);
#else
struct hif_pm_runtime_lock {
const char *name;
@@ -1132,6 +1159,10 @@ hif_pm_runtime_get_dp_rx_busy_mark(struct hif_opaque_softc *hif_ctx)
{ return 0; }
static inline int hif_pm_runtime_sync_resume(struct hif_opaque_softc *hif_ctx)
{ return 0; }
static inline
void hif_pm_set_link_state(struct hif_opaque_softc *hif_handle, uint8_t val)
{}
#endif
void hif_enable_power_management(struct hif_opaque_softc *hif_ctx,