From 3fdaaf61ade1d293f4a67fb21d0a3e380dbfb280 Mon Sep 17 00:00:00 2001 From: Dustin Brown Date: Mon, 18 Mar 2019 14:00:16 -0700 Subject: [PATCH] qcacld-3.0: Remove cds_ssr_protect/unprotect cds_ssr_protect/unprotect is obsolete. Remove them, replacing any remaining call sites with qdf_op_protect/unprotect. Change-Id: Ib8e1fc1e16785dfe3c5f8273e4ad8d5d6ecdb6e6 CRs-Fixed: 2418454 --- .../policy_mgr/src/wlan_policy_mgr_action.c | 16 +- components/ipa/core/src/wlan_ipa_core.c | 65 +++--- components/ipa/core/src/wlan_ipa_stats.c | 14 +- core/cds/inc/cds_sched.h | 11 - core/cds/src/cds_api.c | 3 +- core/cds/src/cds_sched.c | 203 +----------------- core/hdd/src/wlan_hdd_driver_ops.c | 6 - core/hdd/src/wlan_hdd_main.c | 38 ++-- 8 files changed, 72 insertions(+), 284 deletions(-) diff --git a/components/cmn_services/policy_mgr/src/wlan_policy_mgr_action.c b/components/cmn_services/policy_mgr/src/wlan_policy_mgr_action.c index 05a3ee146e79..74a5a63a68a7 100644 --- a/components/cmn_services/policy_mgr/src/wlan_policy_mgr_action.c +++ b/components/cmn_services/policy_mgr/src/wlan_policy_mgr_action.c @@ -1340,12 +1340,7 @@ static void __policy_mgr_check_sta_ap_concurrent_ch_intf(void *data) uint8_t operating_channel[MAX_NUMBER_OF_CONC_CONNECTIONS]; uint8_t vdev_id[MAX_NUMBER_OF_CONC_CONNECTIONS]; - if (qdf_is_module_state_transitioning()) { - policy_mgr_err("Module transition in progress"); - goto end; - } - - work_info = (struct sta_ap_intf_check_work_ctx *) data; + work_info = data; if (!work_info) { policy_mgr_err("Invalid work_info"); goto end; @@ -1426,9 +1421,14 @@ end: void policy_mgr_check_sta_ap_concurrent_ch_intf(void *data) { - qdf_ssr_protect(__func__); + struct qdf_op_sync *op_sync; + + if (qdf_op_protect(&op_sync)) + return; + __policy_mgr_check_sta_ap_concurrent_ch_intf(data); - qdf_ssr_unprotect(__func__); + + qdf_op_unprotect(op_sync); } static bool policy_mgr_valid_sta_channel_check(struct wlan_objmgr_psoc *psoc, diff --git a/components/ipa/core/src/wlan_ipa_core.c b/components/ipa/core/src/wlan_ipa_core.c index 2d037afb99ee..c0277c815215 100644 --- a/components/ipa/core/src/wlan_ipa_core.c +++ b/components/ipa/core/src/wlan_ipa_core.c @@ -778,16 +778,6 @@ static void __wlan_ipa_w2i_cb(void *priv, qdf_ipa_dp_evt_type_t evt, return; } - if (qdf_is_module_state_transitioning()) { - ipa_err_rl("Module transition in progress"); - if (evt == IPA_RECEIVE) { - skb = (qdf_nbuf_t)data; - ipa_ctx->ipa_rx_internal_drop_count++; - dev_kfree_skb_any(skb); - } - return; - } - switch (evt) { case IPA_RECEIVE: skb = (qdf_nbuf_t) data; @@ -867,9 +857,23 @@ static void __wlan_ipa_w2i_cb(void *priv, qdf_ipa_dp_evt_type_t evt, static void wlan_ipa_w2i_cb(void *priv, qdf_ipa_dp_evt_type_t evt, unsigned long data) { - qdf_ssr_protect(__func__); + struct qdf_op_sync *op_sync; + + if (qdf_op_protect(&op_sync)) { + if (evt == IPA_RECEIVE) { + struct wlan_ipa_priv *ipa_ctx = priv; + qdf_nbuf_t skb = (qdf_nbuf_t)data; + + ipa_ctx->ipa_rx_internal_drop_count++; + dev_kfree_skb_any(skb); + } + + return; + } + __wlan_ipa_w2i_cb(priv, evt, data); - qdf_ssr_unprotect(__func__); + + qdf_op_unprotect(op_sync); } /** @@ -894,13 +898,6 @@ static void __wlan_ipa_i2w_cb(void *priv, qdf_ipa_dp_evt_type_t evt, ipa_tx_desc = (qdf_ipa_rx_data_t *)data; ipa_ctx = iface_context->ipa_ctx; - if (qdf_is_module_state_transitioning()) { - ipa_err_rl("Module transition in progress"); - ipa_free_skb(ipa_tx_desc); - iface_context->stats.num_tx_drop++; - return; - } - if (evt != IPA_RECEIVE) { ipa_err_rl("Event is not IPA_RECEIVE"); ipa_free_skb(ipa_tx_desc); @@ -961,9 +958,21 @@ static void __wlan_ipa_i2w_cb(void *priv, qdf_ipa_dp_evt_type_t evt, static void wlan_ipa_i2w_cb(void *priv, qdf_ipa_dp_evt_type_t evt, unsigned long data) { - qdf_ssr_protect(__func__); + struct qdf_op_sync *op_sync; + + if (qdf_op_protect(&op_sync)) { + qdf_ipa_rx_data_t *ipa_tx_desc = (qdf_ipa_rx_data_t *)data; + struct wlan_ipa_iface_context *iface_context = priv; + + ipa_free_skb(ipa_tx_desc); + iface_context->stats.num_tx_drop++; + + return; + } + __wlan_ipa_i2w_cb(priv, evt, data); - qdf_ssr_unprotect(__func__); + + qdf_op_unprotect(op_sync); } QDF_STATUS wlan_ipa_suspend(struct wlan_ipa_priv *ipa_ctx) @@ -2854,11 +2863,6 @@ static void __wlan_ipa_uc_fw_op_event_handler(void *data) (struct uc_op_work_struct *)data; struct wlan_ipa_priv *ipa_ctx = gp_ipa; - if (qdf_is_module_state_transitioning()) { - ipa_err("Module transition in progress"); - return; - } - msg = uc_op_work->msg; uc_op_work->msg = NULL; ipa_debug("posted msg %d", msg->op_code); @@ -2875,9 +2879,14 @@ static void __wlan_ipa_uc_fw_op_event_handler(void *data) */ static void wlan_ipa_uc_fw_op_event_handler(void *data) { - qdf_ssr_protect(__func__); + struct qdf_op_sync *op_sync; + + if (qdf_op_protect(&op_sync)) + return; + __wlan_ipa_uc_fw_op_event_handler(data); - qdf_ssr_unprotect(__func__); + + qdf_op_unprotect(op_sync); } /** diff --git a/components/ipa/core/src/wlan_ipa_stats.c b/components/ipa/core/src/wlan_ipa_stats.c index 9f5ec7154f51..7557c33c9d4a 100644 --- a/components/ipa/core/src/wlan_ipa_stats.c +++ b/components/ipa/core/src/wlan_ipa_stats.c @@ -866,11 +866,6 @@ static void __wlan_ipa_wdi_meter_notifier_cb(qdf_ipa_wdi_meter_evt_type_t evt, ipa_debug("event=%d", evt); - if (qdf_is_module_state_transitioning()) { - ipa_err_rl("Module transition in progress"); - return; - } - iface_ctx = wlan_ipa_get_iface(ipa_ctx, QDF_STA_MODE); if (!iface_ctx) { ipa_err_rl("IPA uC share stats failed - no iface"); @@ -957,9 +952,14 @@ static void __wlan_ipa_wdi_meter_notifier_cb(qdf_ipa_wdi_meter_evt_type_t evt, void wlan_ipa_wdi_meter_notifier_cb(qdf_ipa_wdi_meter_evt_type_t evt, void *data) { - qdf_ssr_protect(__func__); + struct qdf_op_sync *op_sync; + + if (qdf_op_protect(&op_sync)) + return; + __wlan_ipa_wdi_meter_notifier_cb(evt, data); - qdf_ssr_unprotect(__func__); + + qdf_op_unprotect(op_sync); } #endif /* FEATURE_METERING */ diff --git a/core/cds/inc/cds_sched.h b/core/cds/inc/cds_sched.h index 2c288805abdb..b6dd46f59039 100644 --- a/core/cds/inc/cds_sched.h +++ b/core/cds/inc/cds_sched.h @@ -460,19 +460,8 @@ p_cds_sched_context get_cds_sched_ctxt(void); void qdf_timer_module_init(void); void qdf_timer_module_deinit(void); void cds_ssr_protect_init(void); -void cds_ssr_protect(const char *caller_func); -void cds_ssr_unprotect(const char *caller_func); -bool cds_wait_for_external_threads_completion(const char *caller_func); -void cds_print_external_threads(void); int cds_get_gfp_flags(void); -/** - * cds_return_external_threads_count() - return active external thread calls - * - * Return: total number of active extrenal threads in driver - */ -int cds_return_external_threads_count(void); - /** * cds_shutdown_notifier_register() - Register for shutdown notification * @cb : Call back to be called diff --git a/core/cds/src/cds_api.c b/core/cds/src/cds_api.c index e8cd911d7eab..7e4977d88c6d 100644 --- a/core/cds/src/cds_api.c +++ b/core/cds/src/cds_api.c @@ -194,7 +194,6 @@ QDF_STATUS cds_init(void) qdf_register_self_recovery_callback(__cds_trigger_recovery); qdf_register_fw_down_callback(cds_is_fw_down); - qdf_register_ssr_protect_callbacks(cds_ssr_protect, cds_ssr_unprotect); qdf_register_recovering_state_query_callback(cds_is_driver_recovering); return QDF_STATUS_SUCCESS; @@ -216,8 +215,8 @@ void cds_deinit(void) QDF_BUG(gp_cds_context); if (!gp_cds_context) return; + qdf_register_recovering_state_query_callback(NULL); - qdf_register_ssr_protect_callbacks(NULL, NULL); qdf_register_fw_down_callback(NULL); qdf_register_self_recovery_callback(NULL); diff --git a/core/cds/src/cds_sched.c b/core/cds/src/cds_sched.c index 576abdc2b51d..d3448b173b61 100644 --- a/core/cds/src/cds_sched.c +++ b/core/cds/src/cds_sched.c @@ -39,31 +39,7 @@ #include #endif -/* Milli seconds to delay SSR thread when an Entry point is Active */ -#define SSR_WAIT_SLEEP_TIME 200 - -/* MAX iteration count to wait for Entry point to exit before - * we proceed with SSR in WD Thread - */ -#define MAX_SSR_WAIT_ITERATIONS 100 -#define MAX_SSR_PROTECT_LOG (16) - -static atomic_t ssr_protect_entry_count; - -/** - * struct ssr_protect - sub system restart(ssr) protection tracking table - * @func: Function which needs ssr protection - * @free: Flag to tell whether entry is free in table or not - * @pid: Process id which needs ssr protection - */ -struct ssr_protect { - const char *func; - bool free; - uint32_t pid; -}; - static spinlock_t ssr_protect_lock; -static struct ssr_protect ssr_protect_log[MAX_SSR_PROTECT_LOG]; struct shutdown_notifier { struct list_head list; @@ -78,7 +54,6 @@ enum notifier_state { NOTIFIER_STATE_NOTIFYING, } notifier_state; - static p_cds_sched_context gp_cds_sched_context; #ifdef QCA_CONFIG_SMP static int cds_ol_rx_thread(void *arg); @@ -374,9 +349,14 @@ static void __cds_cpu_hotplug_notify(uint32_t cpu, bool cpu_up) */ static void cds_cpu_hotplug_notify(uint32_t cpu, bool cpu_up) { - cds_ssr_protect(__func__); + struct qdf_op_sync *op_sync; + + if (qdf_op_protect(&op_sync)) + return; + __cds_cpu_hotplug_notify(cpu, cpu_up); - cds_ssr_unprotect(__func__); + + qdf_op_unprotect(op_sync); } static void cds_cpu_online_cb(void *context, uint32_t cpu) @@ -852,131 +832,10 @@ p_cds_sched_context get_cds_sched_ctxt(void) */ void cds_ssr_protect_init(void) { - int i = 0; - spin_lock_init(&ssr_protect_lock); - - while (i < MAX_SSR_PROTECT_LOG) { - ssr_protect_log[i].func = NULL; - ssr_protect_log[i].free = true; - ssr_protect_log[i].pid = 0; - i++; - } - INIT_LIST_HEAD(&shutdown_notifier_head); } -/** - * cds_print_external_threads() - print external threads stuck in driver - * - * Return: - * void - */ -void cds_print_external_threads(void) -{ - int i = 0; - unsigned long irq_flags; - - spin_lock_irqsave(&ssr_protect_lock, irq_flags); - - while (i < MAX_SSR_PROTECT_LOG) { - if (!ssr_protect_log[i].free) { - cds_err("PID %d is executing %s", - ssr_protect_log[i].pid, - ssr_protect_log[i].func); - } - i++; - } - - spin_unlock_irqrestore(&ssr_protect_lock, irq_flags); -} - -/** - * cds_ssr_protect() - start ssr protection - * @caller_func: name of calling function. - * - * This function is called to keep track of active driver entry points - * - * Return: none - */ -void cds_ssr_protect(const char *caller_func) -{ - int count; - int i = 0; - bool status = false; - unsigned long irq_flags; - - count = atomic_inc_return(&ssr_protect_entry_count); - - spin_lock_irqsave(&ssr_protect_lock, irq_flags); - - while (i < MAX_SSR_PROTECT_LOG) { - if (ssr_protect_log[i].free) { - ssr_protect_log[i].func = caller_func; - ssr_protect_log[i].free = false; - ssr_protect_log[i].pid = current->pid; - status = true; - break; - } - i++; - } - - spin_unlock_irqrestore(&ssr_protect_lock, irq_flags); - - /* - * Dump the protect log at intervals if count is consistently growing. - * Long running functions should tend to dominate the protect log, so - * hopefully, dumping at multiples of log size will prevent spamming the - * logs while telling us which calls are taking a long time to finish. - */ - if (count >= MAX_SSR_PROTECT_LOG && count % MAX_SSR_PROTECT_LOG == 0) { - cds_err("Protect Log overflow; Dumping contents:"); - cds_print_external_threads(); - } - - if (!status) - cds_err("%s can not be protected; PID:%d, entry_count:%d", - caller_func, current->pid, count); -} - -/** - * cds_ssr_unprotect() - stop ssr protection - * @caller_func: name of calling function. - * - * Return: none - */ -void cds_ssr_unprotect(const char *caller_func) -{ - int count; - int i = 0; - bool status = false; - unsigned long irq_flags; - - count = atomic_dec_return(&ssr_protect_entry_count); - - spin_lock_irqsave(&ssr_protect_lock, irq_flags); - - while (i < MAX_SSR_PROTECT_LOG) { - if (!ssr_protect_log[i].free) { - if ((ssr_protect_log[i].pid == current->pid) && - !strcmp(ssr_protect_log[i].func, caller_func)) { - ssr_protect_log[i].func = NULL; - ssr_protect_log[i].free = true; - ssr_protect_log[i].pid = 0; - status = true; - break; - } - } - i++; - } - - spin_unlock_irqrestore(&ssr_protect_lock, irq_flags); - - if (!status) - cds_err("%s was not protected; PID:%d, entry_count:%d", - caller_func, current->pid, count); -} - /** * cds_shutdown_notifier_register() - Register for shutdown notification * @cb : Call back to be called @@ -1084,54 +943,6 @@ void cds_shutdown_notifier_call(void) spin_unlock_irqrestore(&ssr_protect_lock, irq_flags); } -/** - * cds_wait_for_external_threads_completion() - wait for external threads - * completion before proceeding further - * @caller_func: name of calling function. - * - * Return: true if there is no active entry points in driver - * false if there is at least one active entry in driver - */ -bool cds_wait_for_external_threads_completion(const char *caller_func) -{ - int count = MAX_SSR_WAIT_ITERATIONS; - int r; - - while (count) { - - r = atomic_read(&ssr_protect_entry_count); - - if (!r) - break; - - if (--count) { - cds_err("Waiting for %d active entry points to exit", - r); - msleep(SSR_WAIT_SLEEP_TIME); - if (count & 0x1) { - cds_err("in middle of waiting for active entry points:"); - cds_print_external_threads(); - } - } - } - - /* at least one external thread is executing */ - if (!count) { - cds_err("Timed-out waiting for active entry points:"); - cds_print_external_threads(); - return false; - } - - cds_info("Allowing SSR/Driver unload for %s", caller_func); - - return true; -} - -int cds_return_external_threads_count(void) -{ - return atomic_read(&ssr_protect_entry_count); -} - /** * cds_get_gfp_flags(): get GFP flags * diff --git a/core/hdd/src/wlan_hdd_driver_ops.c b/core/hdd/src/wlan_hdd_driver_ops.c index 6fc9f1433121..677fcb565376 100644 --- a/core/hdd/src/wlan_hdd_driver_ops.c +++ b/core/hdd/src/wlan_hdd_driver_ops.c @@ -571,9 +571,6 @@ static void __hdd_soc_remove(struct device *dev) cds_set_driver_loaded(false); cds_set_unload_in_progress(true); - if (!cds_wait_for_external_threads_completion(__func__)) - hdd_warn("External threads are still active attempting driver unload anyway"); - if (!hdd_wait_for_debugfs_threads_completion()) hdd_warn("Debugfs threads are still active attempting driver unload anyway"); @@ -730,9 +727,6 @@ static void __hdd_soc_recovery_shutdown(void) hdd_psoc_shutdown_notify(hdd_ctx); - if (!cds_wait_for_external_threads_completion(__func__)) - hdd_err("Host is not ready for SSR, attempting anyway"); - if (!hdd_wait_for_debugfs_threads_completion()) hdd_err("Debufs threads are still pending, attempting SSR anyway"); diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c index cc6972371576..d76bec1eb7c6 100644 --- a/core/hdd/src/wlan_hdd_main.c +++ b/core/hdd/src/wlan_hdd_main.c @@ -8002,11 +8002,15 @@ stop_work: static void hdd_bus_bw_work_handler(void *context) { - struct wiphy *wiphy = context; + struct hdd_context *hdd_ctx = context; + struct qdf_op_sync *op_sync; - cds_ssr_protect(__func__); - __hdd_bus_bw_work_handler(wiphy_priv(wiphy)); - cds_ssr_unprotect(__func__); + if (qdf_op_protect(&op_sync)) + return; + + __hdd_bus_bw_work_handler(hdd_ctx); + + qdf_op_unprotect(op_sync); } int hdd_bus_bandwidth_init(struct hdd_context *hdd_ctx) @@ -8018,7 +8022,7 @@ int hdd_bus_bandwidth_init(struct hdd_context *hdd_ctx) spin_lock_init(&hdd_ctx->bus_bw_lock); status = qdf_periodic_work_create(&hdd_ctx->bus_bw_work, hdd_bus_bw_work_handler, - hdd_ctx->wiphy); + hdd_ctx); hdd_exit(); @@ -11275,7 +11279,6 @@ int hdd_wlan_stop_modules(struct hdd_context *hdd_ctx, bool ftm_mode) QDF_STATUS qdf_status; bool is_recovery_stop = cds_is_driver_recovering(); int ret = 0; - int active_threads; int debugfs_threads; struct target_psoc_info *tgt_hdl; @@ -11293,17 +11296,11 @@ int hdd_wlan_stop_modules(struct hdd_context *hdd_ctx, bool ftm_mode) hdd_ctx->stop_modules_in_progress = true; cds_set_module_stop_in_progress(true); - active_threads = cds_return_external_threads_count(); debugfs_threads = hdd_return_debugfs_threads_count(); - if (active_threads > 0 || debugfs_threads > 0 || - hdd_ctx->is_wiphy_suspended) { - hdd_warn("External threads %d, Debugfs threads %d, wiphy suspend %d", - active_threads, debugfs_threads, - hdd_ctx->is_wiphy_suspended); - - if (active_threads) - cds_print_external_threads(); + if (debugfs_threads > 0 || hdd_ctx->is_wiphy_suspended) { + hdd_warn("Debugfs threads %d, wiphy suspend %d", + debugfs_threads, hdd_ctx->is_wiphy_suspended); if (IS_IDLE_STOP && !ftm_mode) { mutex_unlock(&hdd_ctx->iface_change_lock); @@ -12880,7 +12877,6 @@ int hdd_init(void) } qdf_op_callbacks_register(__hdd_op_protect_cb, __hdd_op_unprotect_cb); - qdf_register_module_state_query_callback(hdd_state_query_cb); wlan_init_bug_report_lock(); @@ -13603,12 +13599,6 @@ static int hdd_driver_mode_change(enum QDF_GLOBAL_MODE mode) if (errno) goto trans_stop; - if (!cds_wait_for_external_threads_completion(__func__)) { - hdd_warn("External threads still active, cannot change mode"); - errno = -EAGAIN; - goto trans_stop; - } - errno = __hdd_driver_mode_change(hdd_ctx, mode); trans_stop: @@ -13803,10 +13793,6 @@ static void hdd_driver_unload(void) cds_set_driver_loaded(false); cds_set_unload_in_progress(true); - if (!cds_wait_for_external_threads_completion(__func__)) - hdd_warn("External threads are still active attempting " - "driver unload anyway"); - hdd_driver_mode_change_unregister(); pld_deinit(); wlan_hdd_state_ctrl_param_destroy();