diff --git a/hif/inc/hif.h b/hif/inc/hif.h index e525da7998..98b24c0c81 100644 --- a/hif/inc/hif.h +++ b/hif/inc/hif.h @@ -698,7 +698,7 @@ void hif_fastpath_resume(struct hif_opaque_softc *hif_ctx); int hif_pm_runtime_get(struct hif_opaque_softc *hif_ctx); void hif_pm_runtime_get_noresume(struct hif_opaque_softc *hif_ctx); int hif_pm_runtime_put(struct hif_opaque_softc *hif_ctx); -struct hif_pm_runtime_lock *hif_runtime_lock_init(const char *name); +int hif_runtime_lock_init(qdf_runtime_lock_t *lock, const char *name); void hif_runtime_lock_deinit(struct hif_opaque_softc *hif_ctx, struct hif_pm_runtime_lock *lock); int hif_pm_runtime_prevent_suspend(struct hif_opaque_softc *ol_sc, @@ -719,9 +719,9 @@ static inline int hif_pm_runtime_get(struct hif_opaque_softc *hif_ctx) { return 0; } static inline int hif_pm_runtime_put(struct hif_opaque_softc *hif_ctx) { return 0; } -static inline struct hif_pm_runtime_lock *hif_runtime_lock_init( - const char *name) -{ return NULL; } +static inline int hif_runtime_lock_init(qdf_runtime_lock_t *lock, + const char *name) +{ return 0; } static inline void hif_runtime_lock_deinit(struct hif_opaque_softc *hif_ctx, struct hif_pm_runtime_lock *lock) {} diff --git a/hif/src/pcie/if_pci.c b/hif/src/pcie/if_pci.c index 5ae2bf6bd3..a7e85e3e6e 100644 --- a/hif/src/pcie/if_pci.c +++ b/hif/src/pcie/if_pci.c @@ -1233,8 +1233,7 @@ static void hif_pm_runtime_open(struct hif_pci_softc *sc) spin_lock_init(&sc->runtime_lock); qdf_atomic_init(&sc->pm_state); - sc->prevent_linkdown_lock = - hif_runtime_lock_init("linkdown suspend disabled"); + qdf_runtime_lock_init(&sc->prevent_linkdown_lock); qdf_atomic_set(&sc->pm_state, HIF_PM_RUNTIME_STATE_NONE); INIT_LIST_HEAD(&sc->prevent_suspend_list); } @@ -1311,12 +1310,11 @@ static void hif_pm_runtime_close(struct hif_pci_softc *sc) { struct hif_softc *scn = HIF_GET_SOFTC(sc); - hif_runtime_lock_deinit(GET_HIF_OPAQUE_HDL(sc), - sc->prevent_linkdown_lock); + qdf_runtime_lock_deinit(&sc->prevent_linkdown_lock); if (qdf_atomic_read(&sc->pm_state) == HIF_PM_RUNTIME_STATE_NONE) return; - else - hif_pm_runtime_stop(sc); + + hif_pm_runtime_stop(sc); hif_is_recovery_in_progress(scn) ? hif_pm_runtime_sanitize_on_ssr_exit(sc) : @@ -2724,14 +2722,11 @@ void hif_pci_disable_bus(struct hif_softc *scn) static void hif_runtime_prevent_linkdown(struct hif_softc *scn, bool flag) { struct hif_pci_softc *sc = HIF_GET_PCI_SOFTC(scn); - struct hif_opaque_softc *hif_hdl = GET_HIF_OPAQUE_HDL(scn); if (flag) - hif_pm_runtime_prevent_suspend(hif_hdl, - sc->prevent_linkdown_lock); + qdf_runtime_pm_prevent_suspend(&sc->prevent_linkdown_lock); else - hif_pm_runtime_allow_suspend(hif_hdl, - sc->prevent_linkdown_lock); + qdf_runtime_pm_allow_suspend(&sc->prevent_linkdown_lock); } #else static void hif_runtime_prevent_linkdown(struct hif_softc *scn, bool flag) @@ -4449,21 +4444,23 @@ int hif_pm_runtime_prevent_suspend_timeout(struct hif_opaque_softc *ol_sc, * This API initalizes the Runtime PM context of the caller and * return the pointer. * - * Return: void * + * Return: None */ -struct hif_pm_runtime_lock *hif_runtime_lock_init(const char *name) +int hif_runtime_lock_init(qdf_runtime_lock_t *lock, const char *name) { struct hif_pm_runtime_lock *context; context = qdf_mem_malloc(sizeof(*context)); if (!context) { HIF_ERROR("%s: No memory for Runtime PM wakelock context\n", - __func__); - return NULL; + __func__); + return -ENOMEM; } context->name = name ? name : "Default"; - return context; + lock->lock = context; + + return 0; } /** diff --git a/hif/src/pcie/if_pci.h b/hif/src/pcie/if_pci.h index 7016fe39c5..98bfbd7261 100644 --- a/hif/src/pcie/if_pci.h +++ b/hif/src/pcie/if_pci.h @@ -136,7 +136,7 @@ struct hif_pci_softc { struct timer_list runtime_timer; struct list_head prevent_suspend_list; unsigned long runtime_timer_expires; - struct hif_pm_runtime_lock *prevent_linkdown_lock; + qdf_runtime_lock_t prevent_linkdown_lock; #ifdef WLAN_OPEN_SOURCE struct dentry *pm_dentry; #endif diff --git a/os_if/linux/scan/src/wlan_cfg80211_scan.c b/os_if/linux/scan/src/wlan_cfg80211_scan.c index 981f6ee321..1d1e20cb37 100644 --- a/os_if/linux/scan/src/wlan_cfg80211_scan.c +++ b/os_if/linux/scan/src/wlan_cfg80211_scan.c @@ -964,7 +964,7 @@ allow_suspend: osif_priv = wlan_pdev_get_ospriv(pdev); if (qdf_list_empty(&osif_priv->osif_scan->scan_req_q)) qdf_runtime_pm_allow_suspend( - osif_priv->osif_scan->runtime_pm_lock); + &osif_priv->osif_scan->runtime_pm_lock); } @@ -978,8 +978,7 @@ void wlan_scan_runtime_pm_deinit(struct wlan_objmgr_pdev *pdev) wlan_pdev_obj_unlock(pdev); scan_priv = osif_priv->osif_scan; - qdf_runtime_lock_deinit(scan_priv->runtime_pm_lock); - scan_priv->runtime_pm_lock = NULL; + qdf_runtime_lock_deinit(&scan_priv->runtime_pm_lock); } QDF_STATUS wlan_cfg80211_scan_priv_init(struct wlan_objmgr_pdev *pdev) @@ -1005,7 +1004,7 @@ QDF_STATUS wlan_cfg80211_scan_priv_init(struct wlan_objmgr_pdev *pdev) qdf_list_create(&scan_priv->scan_req_q, WLAN_MAX_SCAN_COUNT); qdf_mutex_create(&scan_priv->scan_req_q_lock); scan_priv->req_id = req_id; - scan_priv->runtime_pm_lock = qdf_runtime_lock_init("scan"); + qdf_runtime_lock_init(&scan_priv->runtime_pm_lock); return QDF_STATUS_SUCCESS; } @@ -1292,7 +1291,7 @@ int wlan_cfg80211_scan(struct wlan_objmgr_pdev *pdev, wlan_scan_request_enqueue(pdev, request, source, req->scan_req.scan_id); qdf_runtime_pm_prevent_suspend( - osif_priv->osif_scan->runtime_pm_lock); + &osif_priv->osif_scan->runtime_pm_lock); status = ucfg_scan_start(req); if (QDF_STATUS_SUCCESS != status) { @@ -1306,7 +1305,7 @@ int wlan_cfg80211_scan(struct wlan_objmgr_pdev *pdev, wlan_scan_request_dequeue(pdev, scan_id, &request, &source); if (qdf_list_empty(&osif_priv->osif_scan->scan_req_q)) qdf_runtime_pm_allow_suspend( - osif_priv->osif_scan->runtime_pm_lock); + &osif_priv->osif_scan->runtime_pm_lock); } end: diff --git a/qdf/inc/qdf_lock.h b/qdf/inc/qdf_lock.h index d8f2bba25b..d3c560408d 100644 --- a/qdf/inc/qdf_lock.h +++ b/qdf/inc/qdf_lock.h @@ -489,15 +489,16 @@ QDF_STATUS qdf_wake_lock_release(qdf_wake_lock_t *lock, uint32_t reason); QDF_STATUS qdf_wake_lock_destroy(qdf_wake_lock_t *lock); -struct hif_pm_runtime_lock; -typedef struct hif_pm_runtime_lock *qdf_runtime_lock_t; - QDF_STATUS qdf_runtime_pm_get(void); QDF_STATUS qdf_runtime_pm_put(void); -QDF_STATUS qdf_runtime_pm_prevent_suspend(qdf_runtime_lock_t lock); -QDF_STATUS qdf_runtime_pm_allow_suspend(qdf_runtime_lock_t lock); -qdf_runtime_lock_t qdf_runtime_lock_init(const char *name); -void qdf_runtime_lock_deinit(qdf_runtime_lock_t lock); +QDF_STATUS qdf_runtime_pm_prevent_suspend(qdf_runtime_lock_t *lock); +QDF_STATUS qdf_runtime_pm_allow_suspend(qdf_runtime_lock_t *lock); + +QDF_STATUS __qdf_runtime_lock_init(qdf_runtime_lock_t *lock, const char *name); + +#define qdf_runtime_lock_init(lock) __qdf_runtime_lock_init(lock, #lock) + +void qdf_runtime_lock_deinit(qdf_runtime_lock_t *lock); QDF_STATUS qdf_spinlock_acquire(qdf_spinlock_t *lock); diff --git a/qdf/linux/src/i_qdf_lock.h b/qdf/linux/src/i_qdf_lock.h index eea7867f37..ebd054f269 100644 --- a/qdf/linux/src/i_qdf_lock.h +++ b/qdf/linux/src/i_qdf_lock.h @@ -95,6 +95,11 @@ typedef struct semaphore __qdf_semaphore_t; typedef struct wakeup_source qdf_wake_lock_t; +struct hif_pm_runtime_lock; +typedef struct qdf_runtime_lock { + struct hif_pm_runtime_lock *lock; +} qdf_runtime_lock_t; + #define LINUX_LOCK_COOKIE 0x12345678 /* Function declarations and documenation */ diff --git a/qdf/linux/src/qdf_lock.c b/qdf/linux/src/qdf_lock.c index 791db34f0c..088bbf80c6 100644 --- a/qdf/linux/src/qdf_lock.c +++ b/qdf/linux/src/qdf_lock.c @@ -467,7 +467,7 @@ EXPORT_SYMBOL(qdf_runtime_pm_put); * * return: QDF_STATUS_SUCCESS or failure code. */ -QDF_STATUS qdf_runtime_pm_prevent_suspend(qdf_runtime_lock_t lock) +QDF_STATUS qdf_runtime_pm_prevent_suspend(qdf_runtime_lock_t *lock) { void *ol_sc; int ret; @@ -481,7 +481,7 @@ QDF_STATUS qdf_runtime_pm_prevent_suspend(qdf_runtime_lock_t lock) return QDF_STATUS_E_INVAL; } - ret = hif_pm_runtime_prevent_suspend(ol_sc, lock); + ret = hif_pm_runtime_prevent_suspend(ol_sc, lock->lock); if (ret) return QDF_STATUS_E_FAILURE; @@ -490,14 +490,14 @@ QDF_STATUS qdf_runtime_pm_prevent_suspend(qdf_runtime_lock_t lock) EXPORT_SYMBOL(qdf_runtime_pm_prevent_suspend); /** - * qdf_runtime_pm_prevent_suspend() - prevent a runtime bus suspend + * qdf_runtime_pm_allow_suspend() - prevent a runtime bus suspend * @lock: an opaque context for tracking * * The lock can only be acquired once per lock context and is tracked. * * return: QDF_STATUS_SUCCESS or failure code. */ -QDF_STATUS qdf_runtime_pm_allow_suspend(qdf_runtime_lock_t lock) +QDF_STATUS qdf_runtime_pm_allow_suspend(qdf_runtime_lock_t *lock) { void *ol_sc; int ret; @@ -510,7 +510,7 @@ QDF_STATUS qdf_runtime_pm_allow_suspend(qdf_runtime_lock_t lock) return QDF_STATUS_E_INVAL; } - ret = hif_pm_runtime_allow_suspend(ol_sc, lock); + ret = hif_pm_runtime_allow_suspend(ol_sc, lock->lock); if (ret) return QDF_STATUS_E_FAILURE; @@ -528,11 +528,16 @@ EXPORT_SYMBOL(qdf_runtime_pm_allow_suspend); * * Return: runtime_pm_lock_t */ -qdf_runtime_lock_t qdf_runtime_lock_init(const char *name) +QDF_STATUS __qdf_runtime_lock_init(qdf_runtime_lock_t *lock, const char *name) { - return hif_runtime_lock_init(name); + int ret = hif_runtime_lock_init(lock, name); + + if (ret) + return QDF_STATUS_E_NOMEM; + + return QDF_STATUS_SUCCESS; } -EXPORT_SYMBOL(qdf_runtime_lock_init); +EXPORT_SYMBOL(__qdf_runtime_lock_init); /** * qdf_runtime_lock_deinit() - deinitialize runtime pm lock @@ -542,10 +547,10 @@ EXPORT_SYMBOL(qdf_runtime_lock_init); * * Return: void */ -void qdf_runtime_lock_deinit(qdf_runtime_lock_t lock) +void qdf_runtime_lock_deinit(qdf_runtime_lock_t *lock) { void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); - hif_runtime_lock_deinit(hif_ctx, lock); + hif_runtime_lock_deinit(hif_ctx, lock->lock); } EXPORT_SYMBOL(qdf_runtime_lock_deinit); @@ -563,25 +568,25 @@ QDF_STATUS qdf_runtime_pm_put(void) } EXPORT_SYMBOL(qdf_runtime_pm_put); -QDF_STATUS qdf_runtime_pm_prevent_suspend(qdf_runtime_lock_t lock) +QDF_STATUS qdf_runtime_pm_prevent_suspend(qdf_runtime_lock_t *lock) { return QDF_STATUS_SUCCESS; } EXPORT_SYMBOL(qdf_runtime_pm_prevent_suspend); -QDF_STATUS qdf_runtime_pm_allow_suspend(qdf_runtime_lock_t lock) +QDF_STATUS qdf_runtime_pm_allow_suspend(qdf_runtime_lock_t *lock) { return QDF_STATUS_SUCCESS; } EXPORT_SYMBOL(qdf_runtime_pm_allow_suspend); -qdf_runtime_lock_t qdf_runtime_lock_init(const char *name) +QDF_STATUS __qdf_runtime_lock_init(qdf_runtime_lock_t *lock, const char *name) { - return NULL; + return QDF_STATUS_SUCCESS; } -EXPORT_SYMBOL(qdf_runtime_lock_init); +EXPORT_SYMBOL(__qdf_runtime_lock_init); -void qdf_runtime_lock_deinit(qdf_runtime_lock_t lock) +void qdf_runtime_lock_deinit(qdf_runtime_lock_t *lock) { } EXPORT_SYMBOL(qdf_runtime_lock_deinit); diff --git a/umac/p2p/core/src/wlan_p2p_main.c b/umac/p2p/core/src/wlan_p2p_main.c index bce6afc5fe..3d68b43cec 100644 --- a/umac/p2p/core/src/wlan_p2p_main.c +++ b/umac/p2p/core/src/wlan_p2p_main.c @@ -663,8 +663,8 @@ QDF_STATUS p2p_psoc_object_open(struct wlan_objmgr_psoc *soc) p2p_err("failed to create cancel roc done event"); goto fail_event; } - p2p_soc_obj->roc_runtime_lock = qdf_runtime_lock_init( - P2P_MODULE_NAME); + + qdf_runtime_lock_init(&p2p_soc_obj->roc_runtime_lock); p2p_debug("p2p psoc object open successful"); @@ -694,7 +694,7 @@ QDF_STATUS p2p_psoc_object_close(struct wlan_objmgr_psoc *soc) return QDF_STATUS_E_FAILURE; } - qdf_runtime_lock_deinit(p2p_soc_obj->roc_runtime_lock); + qdf_runtime_lock_deinit(&p2p_soc_obj->roc_runtime_lock); qdf_event_destroy(&p2p_soc_obj->cancel_roc_done); qdf_list_destroy(&p2p_soc_obj->tx_q_ack); qdf_list_destroy(&p2p_soc_obj->tx_q_roc); diff --git a/umac/p2p/core/src/wlan_p2p_roc.c b/umac/p2p/core/src/wlan_p2p_roc.c index e83914d1c3..6456b723ad 100644 --- a/umac/p2p/core/src/wlan_p2p_roc.c +++ b/umac/p2p/core/src/wlan_p2p_roc.c @@ -345,7 +345,7 @@ static QDF_STATUS p2p_execute_roc_req(struct p2p_roc_context *roc_ctx) roc_ctx->roc_type, roc_ctx->roc_state); /* prevent runtime suspend */ - qdf_runtime_pm_prevent_suspend(p2p_soc_obj->roc_runtime_lock); + qdf_runtime_pm_prevent_suspend(&p2p_soc_obj->roc_runtime_lock); status = qdf_mc_timer_init(&roc_ctx->roc_timer, QDF_TIMER_TYPE_SW, p2p_roc_timeout, @@ -375,7 +375,7 @@ fail: if (status != QDF_STATUS_SUCCESS) { p2p_destroy_roc_ctx(roc_ctx, true, true); qdf_runtime_pm_allow_suspend( - p2p_soc_obj->roc_runtime_lock); + &p2p_soc_obj->roc_runtime_lock); return status; } @@ -501,7 +501,7 @@ static QDF_STATUS p2p_process_scan_complete_evt( roc_ctx->roc_type, roc_ctx->roc_state); /* allow runtime suspend */ - qdf_runtime_pm_allow_suspend(p2p_soc_obj->roc_runtime_lock); + qdf_runtime_pm_allow_suspend(&p2p_soc_obj->roc_runtime_lock); if (QDF_TIMER_STATE_RUNNING == qdf_mc_timer_get_current_state(&roc_ctx->roc_timer)) {