From 2ec3781464a0364c91324a035ce657d73727111a Mon Sep 17 00:00:00 2001 From: Vivek Date: Wed, 15 May 2019 15:22:46 +0530 Subject: [PATCH] qcacmn: Define qdf timer multiplier as a macro The current QDF timer multiplier factor is of type uint32 which takes whole number, so we cannot have multiplier factors like 0.5 or 1.5 To provide such timer multiplier, we define timer multiplier, as a macro, provided though build options and support values like 0.5 or 1.5 through 1/2 and 3/2 respectively and this is used to configure the timeout value. Change-Id: I3f5441e33cca71f4a399cbbf9c6f61e2f21ee828 CRs-Fixed: 2450710 --- qdf/inc/qdf_timer.h | 8 ++++++++ qdf/linux/src/i_qdf_timer.h | 8 ++++---- qdf/linux/src/qdf_event.c | 8 ++++---- qdf/linux/src/qdf_mc_timer.c | 6 ++---- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/qdf/inc/qdf_timer.h b/qdf/inc/qdf_timer.h index f7ac35e41365..0f82b1c2167f 100644 --- a/qdf/inc/qdf_timer.h +++ b/qdf/inc/qdf_timer.h @@ -51,6 +51,14 @@ qdf_timer_init(qdf_handle_t hdl, qdf_timer_t *timer, qdf_timer_func_t func, return __qdf_timer_init(timer, func, arg, type); } +#ifdef QDF_TIMER_MULTIPLIER_FRAC +#define qdf_msecs_to_jiffies(msec) \ + (QDF_TIMER_MULTIPLIER_FRAC * __qdf_msecs_to_jiffies(msec)) +#else +#define qdf_msecs_to_jiffies(msec) \ + (qdf_timer_get_multiplier() * __qdf_msecs_to_jiffies(msec)) +#endif + /** * qdf_timer_start() - start a timer * @timer: timer to start diff --git a/qdf/linux/src/i_qdf_timer.h b/qdf/linux/src/i_qdf_timer.h index 521e03ddb4a7..2cbb6cbf7c7f 100644 --- a/qdf/linux/src/i_qdf_timer.h +++ b/qdf/linux/src/i_qdf_timer.h @@ -36,8 +36,6 @@ typedef void (*qdf_timer_func_t)(void *); -#define qdf_msecs_to_jiffies(msec) \ - (qdf_timer_get_multiplier() * msecs_to_jiffies(msec)) struct __qdf_timer_t { struct timer_list os_timer; @@ -45,6 +43,8 @@ struct __qdf_timer_t { void *context; }; +#define __qdf_msecs_to_jiffies(msec) msecs_to_jiffies(msec) + #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) static inline void __os_timer_shim(struct timer_list *os_timer) { @@ -121,13 +121,13 @@ static inline void __qdf_timer_start(struct __qdf_timer_t *timer, uint32_t msec) { struct timer_list *os_timer = &timer->os_timer; - os_timer->expires = jiffies + qdf_msecs_to_jiffies(msec); + os_timer->expires = jiffies + __qdf_msecs_to_jiffies(msec); add_timer(os_timer); } static inline void __qdf_timer_mod(struct __qdf_timer_t *timer, uint32_t msec) { - mod_timer(&timer->os_timer, jiffies + qdf_msecs_to_jiffies(msec)); + mod_timer(&timer->os_timer, jiffies + __qdf_msecs_to_jiffies(msec)); } static inline bool __qdf_timer_stop(struct __qdf_timer_t *timer) diff --git a/qdf/linux/src/qdf_event.c b/qdf/linux/src/qdf_event.c index ba7223a1323e..929eff8972dd 100644 --- a/qdf/linux/src/qdf_event.c +++ b/qdf/linux/src/qdf_event.c @@ -28,6 +28,7 @@ /* Include Files */ #include "qdf_event.h" #include "qdf_mc_timer.h" +#include "qdf_timer.h" #include struct qdf_evt_node { @@ -211,10 +212,9 @@ QDF_STATUS qdf_wait_single_event(qdf_event_t *event, uint32_t timeout) if (timeout) { long ret; - /* update the timeout if it's on an emulation platform */ - timeout *= qdf_timer_get_multiplier(); - ret = wait_for_completion_timeout(&event->complete, - msecs_to_jiffies(timeout)); + ret = wait_for_completion_timeout( + &event->complete, + qdf_msecs_to_jiffies(timeout)); if (ret <= 0) return QDF_STATUS_E_TIMEOUT; diff --git a/qdf/linux/src/qdf_mc_timer.c b/qdf/linux/src/qdf_mc_timer.c index d0baa3adbeae..c9ec3d7418f0 100644 --- a/qdf/linux/src/qdf_mc_timer.c +++ b/qdf/linux/src/qdf_mc_timer.c @@ -29,6 +29,7 @@ #include "qdf_list.h" #include "qdf_mem.h" #include +#include "qdf_timer.h" /* Preprocessor definitions and constants */ #define LINUX_TIMER_COOKIE 0x12341234 @@ -662,9 +663,6 @@ QDF_STATUS qdf_mc_timer_start(qdf_mc_timer_t *timer, uint32_t expiration_time) return QDF_STATUS_E_INVAL; } - /* update expiration time based on if emulation platform */ - expiration_time *= qdf_timer_get_multiplier(); - /* make sure the remainer of the logic isn't interrupted */ qdf_spin_lock_irqsave(&timer->platform_info.spinlock); @@ -679,7 +677,7 @@ QDF_STATUS qdf_mc_timer_start(qdf_mc_timer_t *timer, uint32_t expiration_time) /* start the timer */ mod_timer(&(timer->platform_info.timer), - jiffies + msecs_to_jiffies(expiration_time)); + jiffies + qdf_msecs_to_jiffies(expiration_time)); timer->state = QDF_TIMER_STATE_RUNNING;