qcacmn: Restructure HIF Runtime PM module

Currently, different modules had different ways of allowing
and preventing runtime suspend. Multiple debug mechanisms
were introduced and workarounds are present as well bloating
the runtime PM module.
This change is done to clean up and restructure HIF runtime
PM module. Modules using Runtime PM module need to register
with an ID present in hif_rtpm_client_id.
hif_rtpm_get() will increment the device usage_count and
prevent device from suspending. Based on argument type, if
system is suspended, subsequent resume action will be done.
hif_rtpm_put() will decrement the usage_count of device and
if it is NULL, based on type of put call, idle sequence will
start. Register HIF module and update respective get and put
calls done from HIF module.

Change-Id: I23747f0f7208e689c1c9eb55789aa81945f596ec
CRs-Fixed: 3169272
This commit is contained in:
Ananya Gupta
2022-03-01 13:06:11 +05:30
committed by Madan Koyyalamudi
parent 65161e36f3
commit 4021d4b379
17 changed files with 1484 additions and 2089 deletions

View File

@@ -450,6 +450,38 @@ void *hif_get_dev_ba_ce(struct hif_opaque_softc *hif_handle)
qdf_export_symbol(hif_get_dev_ba_ce);
#ifdef FEATURE_RUNTIME_PM
void hif_runtime_prevent_linkdown(struct hif_softc *scn, bool is_get)
{
if (is_get)
qdf_runtime_pm_prevent_suspend(&scn->prevent_linkdown_lock);
else
qdf_runtime_pm_allow_suspend(&scn->prevent_linkdown_lock);
}
static inline
void hif_rtpm_lock_init(struct hif_softc *scn)
{
qdf_runtime_lock_init(&scn->prevent_linkdown_lock);
}
static inline
void hif_rtpm_lock_deinit(struct hif_softc *scn)
{
qdf_runtime_lock_deinit(&scn->prevent_linkdown_lock);
}
#else
static inline
void hif_rtpm_lock_init(struct hif_softc *scn)
{
}
static inline
void hif_rtpm_lock_deinit(struct hif_softc *scn)
{
}
#endif
#ifdef WLAN_CE_INTERRUPT_THRESHOLD_CONFIG
/**
* hif_get_cfg_from_psoc() - Retrieve ini cfg from psoc
@@ -935,7 +967,6 @@ struct hif_opaque_softc *hif_open(qdf_device_t qdf_ctx,
sizeof(struct hif_driver_state_callbacks));
scn->bus_type = bus_type;
hif_pm_set_link_state(GET_HIF_OPAQUE_HDL(scn), HIF_PM_LINK_STATE_DOWN);
hif_allow_ep_vote_access(GET_HIF_OPAQUE_HDL(scn));
hif_get_cfg_from_psoc(scn, psoc);
@@ -949,6 +980,8 @@ struct hif_opaque_softc *hif_open(qdf_device_t qdf_ctx,
goto out;
}
hif_rtpm_lock_init(scn);
hif_cpuhp_register(scn);
hif_latency_detect_timer_init(scn);
@@ -1006,6 +1039,7 @@ void hif_close(struct hif_opaque_softc *hif_ctx)
hif_uninit_rri_on_ddr(scn);
hif_cleanup_static_buf_to_target(scn);
hif_cpuhp_unregister(scn);
hif_rtpm_lock_deinit(scn);
hif_bus_close(scn);
@@ -1253,7 +1287,6 @@ QDF_STATUS hif_enable(struct hif_opaque_softc *hif_ctx, struct device *dev,
return status;
}
hif_pm_set_link_state(GET_HIF_OPAQUE_HDL(scn), HIF_PM_LINK_STATE_UP);
status = hif_hal_attach(scn);
if (status != QDF_STATUS_SUCCESS) {
hif_err("hal attach failed");
@@ -1311,7 +1344,6 @@ void hif_disable(struct hif_opaque_softc *hif_ctx, enum hif_disable_type type)
hif_hal_detach(scn);
hif_pm_set_link_state(hif_ctx, HIF_PM_LINK_STATE_DOWN);
hif_disable_bus(scn);
hif_wlan_disable(scn);
@@ -2098,12 +2130,11 @@ hif_pm_wake_irq_type hif_pm_get_wake_irq_type(struct hif_opaque_softc *hif_ctx)
irqreturn_t hif_wake_interrupt_handler(int irq, void *context)
{
struct hif_softc *scn = context;
struct hif_opaque_softc *hif_ctx = GET_HIF_OPAQUE_HDL(scn);
hif_info("wake interrupt received on irq %d", irq);
hif_pm_runtime_set_monitor_wake_intr(hif_ctx, 0);
hif_pm_runtime_request_resume(hif_ctx, RTPM_ID_WAKE_INTR_HANDLER);
hif_rtpm_set_monitor_wake_intr(0);
hif_rtpm_request_resume();
if (scn->initial_wakeup_cb)
scn->initial_wakeup_cb(scn->initial_wakeup_priv);