diff --git a/hif/src/pcie/if_pci.c b/hif/src/pcie/if_pci.c index 8f9cb957d7..14df72a9a5 100644 --- a/hif/src/pcie/if_pci.c +++ b/hif/src/pcie/if_pci.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2018 The Linux Foundation. All rights reserved. + * Copyright (c) 2013-2019 The Linux Foundation. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -1104,7 +1104,7 @@ static void hif_runtime_exit(struct device *dev) pm_runtime_set_active(dev); } -static void hif_pm_runtime_lock_timeout_fn(unsigned long data); +static void hif_pm_runtime_lock_timeout_fn(void *data); /** * hif_pm_runtime_start(): start the runtime pm @@ -1128,8 +1128,9 @@ static void hif_pm_runtime_start(struct hif_pci_softc *sc) return; } - setup_timer(&sc->runtime_timer, hif_pm_runtime_lock_timeout_fn, - (unsigned long)sc); + qdf_timer_init(NULL, &sc->runtime_timer, + hif_pm_runtime_lock_timeout_fn, + sc, QDF_TIMER_TYPE_WAKE_APPS); HIF_INFO("%s: Enabling RUNTIME PM, Delay: %d ms", __func__, ol_sc->hif_config.runtime_pm_delay); @@ -1163,7 +1164,7 @@ static void hif_pm_runtime_stop(struct hif_pci_softc *sc) qdf_atomic_set(&sc->pm_state, HIF_PM_RUNTIME_STATE_NONE); hif_runtime_pm_debugfs_remove(sc); - del_timer_sync(&sc->runtime_timer); + qdf_timer_free(&sc->runtime_timer); /* doesn't wait for penting trafic unlike cld-2.0 */ } @@ -4063,9 +4064,9 @@ static int __hif_pm_runtime_allow_suspend(struct hif_pci_softc *hif_sc, * * dummy implementation until lock acquisition is implemented. */ -static void hif_pm_runtime_lock_timeout_fn(unsigned long data) +static void hif_pm_runtime_lock_timeout_fn(void *data) { - struct hif_pci_softc *hif_sc = (struct hif_pci_softc *)data; + struct hif_pci_softc *hif_sc = data; unsigned long timer_expires; struct hif_pm_runtime_lock *context, *temp; @@ -4152,7 +4153,7 @@ int hif_pm_runtime_allow_suspend(struct hif_opaque_softc *ol_sc, */ if (hif_sc->prevent_suspend_cnt == 0 && hif_sc->runtime_timer_expires > 0) { - del_timer(&hif_sc->runtime_timer); + qdf_timer_free(&hif_sc->runtime_timer); hif_sc->runtime_timer_expires = 0; } @@ -4230,7 +4231,7 @@ int hif_pm_runtime_prevent_suspend_timeout(struct hif_opaque_softc *ol_sc, * timeout */ if (time_after(expires, hif_sc->runtime_timer_expires)) { - mod_timer(&hif_sc->runtime_timer, expires); + qdf_timer_mod(&hif_sc->runtime_timer, delay); hif_sc->runtime_timer_expires = expires; } diff --git a/hif/src/pcie/if_pci.h b/hif/src/pcie/if_pci.h index cb64f870d0..31650255ae 100644 --- a/hif/src/pcie/if_pci.h +++ b/hif/src/pcie/if_pci.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2018 The Linux Foundation. All rights reserved. + * Copyright (c) 2013-2019 The Linux Foundation. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -128,7 +128,7 @@ struct hif_pci_softc { struct hif_pci_pm_stats pm_stats; struct work_struct pm_work; spinlock_t runtime_lock; - struct timer_list runtime_timer; + qdf_timer_t runtime_timer; struct list_head prevent_suspend_list; unsigned long runtime_timer_expires; qdf_runtime_lock_t prevent_linkdown_lock; diff --git a/qdf/inc/qdf_mc_timer.h b/qdf/inc/qdf_mc_timer.h index 8f85569f15..19ef611815 100644 --- a/qdf/inc/qdf_mc_timer.h +++ b/qdf/inc/qdf_mc_timer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2018 The Linux Foundation. All rights reserved. + * Copyright (c) 2014-2019 The Linux Foundation. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -293,7 +293,8 @@ void qdf_timer_module_deinit(void); * Return: None */ void qdf_get_time_of_the_day_in_hr_min_sec_usec(char *tbuf, int len); -void qdf_register_mc_timer_callback(void (*callback) (unsigned long data)); + +void qdf_register_mc_timer_callback(void (*callback) (qdf_mc_timer_t *data)); /** * qdf_timer_set_multiplier() - set the global QDF timer scalar value diff --git a/qdf/linux/src/qdf_mc_timer.c b/qdf/linux/src/qdf_mc_timer.c index 238e238812..7a3d297bea 100644 --- a/qdf/linux/src/qdf_mc_timer.c +++ b/qdf/linux/src/qdf_mc_timer.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2018 The Linux Foundation. All rights reserved. + * Copyright (c) 2014-2019 The Linux Foundation. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -60,11 +60,12 @@ qdf_export_symbol(qdf_timer_get_multiplier); static unsigned int persistent_timer_count; static qdf_mutex_t persistent_timer_count_lock; -static void (*scheduler_timer_callback) (unsigned long data); -void qdf_register_mc_timer_callback(void (*callback) (unsigned long data)) +static void (*scheduler_timer_callback)(qdf_mc_timer_t *); +void qdf_register_mc_timer_callback(void (*callback) (qdf_mc_timer_t *)) { scheduler_timer_callback = callback; } + qdf_export_symbol(qdf_register_mc_timer_callback); /* Function declarations and documenation */ @@ -273,6 +274,51 @@ void qdf_mc_timer_manager_exit(void) qdf_export_symbol(qdf_mc_timer_manager_exit); #endif +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) +static void __os_mc_timer_shim(struct timer_list *os_timer) +{ + qdf_mc_timer_platform_t *platform_info_ptr = + qdf_container_of(os_timer, + qdf_mc_timer_platform_t, + timer); + qdf_mc_timer_t *timer = qdf_container_of(platform_info_ptr, + qdf_mc_timer_t, + platform_info); + + scheduler_timer_callback(timer); +} + +static void qdf_mc_timer_setup(qdf_mc_timer_t *timer, + QDF_TIMER_TYPE timer_type) +{ + uint32_t flags = 0; + + if (QDF_TIMER_TYPE_SW == timer_type) + flags |= TIMER_DEFERRABLE; + + timer_setup(&timer->platform_info.timer, + __os_mc_timer_shim, flags); +} +#else +static void __os_mc_timer_shim(unsigned long data) +{ + qdf_mc_timer_t *timer = (qdf_mc_timer_t *)data; + + scheduler_timer_callback(timer); +} + +static void qdf_mc_timer_setup(qdf_mc_timer_t *timer, + QDF_TIMER_TYPE timer_type) +{ + if (QDF_TIMER_TYPE_SW == timer_type) + init_timer_deferrable(&timer->platform_info.timer); + else + init_timer(&timer->platform_info.timer); + + timer->platform_info.timer.function = __os_mc_timer_shim; + timer->platform_info.timer.data = (unsigned long)timer; +} +#endif /** * qdf_mc_timer_init() - initialize a QDF timer * @timer: Pointer to timer object @@ -351,12 +397,7 @@ QDF_STATUS qdf_mc_timer_init_debug(qdf_mc_timer_t *timer, * with arguments passed or with default values */ qdf_spinlock_create(&timer->platform_info.spinlock); - if (QDF_TIMER_TYPE_SW == timer_type) - init_timer_deferrable(&(timer->platform_info.timer)); - else - init_timer(&(timer->platform_info.timer)); - timer->platform_info.timer.function = scheduler_timer_callback; - timer->platform_info.timer.data = (unsigned long)timer; + qdf_mc_timer_setup(timer, timer_type); timer->callback = callback; timer->user_data = user_data; timer->type = timer_type; @@ -384,12 +425,7 @@ QDF_STATUS qdf_mc_timer_init(qdf_mc_timer_t *timer, QDF_TIMER_TYPE timer_type, * with arguments passed or with default values */ qdf_spinlock_create(&timer->platform_info.spinlock); - if (QDF_TIMER_TYPE_SW == timer_type) - init_timer_deferrable(&(timer->platform_info.timer)); - else - init_timer(&(timer->platform_info.timer)); - timer->platform_info.timer.function = scheduler_timer_callback; - timer->platform_info.timer.data = (unsigned long)timer; + qdf_mc_timer_setup(timer, timer_type); timer->callback = callback; timer->user_data = user_data; timer->type = timer_type; diff --git a/scheduler/inc/scheduler_api.h b/scheduler/inc/scheduler_api.h index fa8ec9571b..fa13775753 100644 --- a/scheduler/inc/scheduler_api.h +++ b/scheduler/inc/scheduler_api.h @@ -323,11 +323,11 @@ QDF_STATUS scheduler_deregister_wma_legacy_handler(void); /** * scheduler_mc_timer_callback() - timer callback, gets called at time out - * @data: unsigned long, holds the timer object. + * @timer: holds the mc timer object. * * Return: None */ -void scheduler_mc_timer_callback(unsigned long data); +void scheduler_mc_timer_callback(qdf_mc_timer_t *timer); /** * scheduler_get_queue_size() - Get the current size of the scheduler queue diff --git a/scheduler/src/scheduler_api.c b/scheduler/src/scheduler_api.c index d0dd85a99e..02e25ab2e5 100644 --- a/scheduler/src/scheduler_api.c +++ b/scheduler/src/scheduler_api.c @@ -569,9 +569,8 @@ static QDF_STATUS scheduler_msg_flush_noop(struct scheduler_msg *msg) return QDF_STATUS_SUCCESS; } -void scheduler_mc_timer_callback(unsigned long data) +void scheduler_mc_timer_callback(qdf_mc_timer_t *timer) { - qdf_mc_timer_t *timer = (qdf_mc_timer_t *)data; struct scheduler_msg msg = {0}; QDF_STATUS status;