Skip to content

Commit

Permalink
mt6625l: Drop usage of wakelocks Android API, use wake sources instead.
Browse files Browse the repository at this point in the history
fix for kernel-crash included
  • Loading branch information
lexa2 authored and frank-w committed Oct 25, 2019
1 parent 3ffb45a commit 247c0a1
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 183 deletions.
Expand Up @@ -192,11 +192,7 @@ typedef struct _OSAL_LXOP_Q {
} OSAL_OP_Q, *P_OSAL_OP_Q;

typedef struct _OSAL_WAKE_LOCK_ {
#ifdef CONFIG_PM_WAKELOCKS
struct wakeup_source wake_lock;
#else
struct wake_lock wake_lock;
#endif
struct wakeup_source *wake_lock;
UINT8 name[MAX_WAKE_LOCK_NAME_LEN];
} OSAL_WAKE_LOCK, *P_OSAL_WAKE_LOCK;
#if 1
Expand Down
Expand Up @@ -57,11 +57,7 @@
#include <aee.h>
#endif
#include <linux/kfifo.h>
#ifdef CONFIG_PM_WAKELOCKS
#include <linux/pm_wakeup.h>
#else
#include <linux/wakelock.h>
#endif
#include <linux/log2.h>

#ifndef _TYPEDEFS_H /*fix redifine */
Expand Down
Expand Up @@ -985,11 +985,9 @@ INT32 osal_wake_lock_init(P_OSAL_WAKE_LOCK pLock)
if (!pLock)
return -1;

#ifdef CONFIG_PM_WAKELOCKS
wakeup_source_init(&pLock->wake_lock, pLock->name);
#else
wake_lock_init(&pLock->wake_lock, WAKE_LOCK_SUSPEND, pLock->name);
#endif
if((pLock->wake_lock = wakeup_source_create(pLock->name)))
wakeup_source_add(pLock->wake_lock);

return 0;
}

Expand All @@ -998,11 +996,8 @@ INT32 osal_wake_lock_deinit(P_OSAL_WAKE_LOCK pLock)
if (!pLock)
return -1;

#ifdef CONFIG_PM_WAKELOCKS
wakeup_source_trash(&pLock->wake_lock);
#else
wake_lock_destroy(&pLock->wake_lock);
#endif
wakeup_source_remove(pLock->wake_lock);
wakeup_source_destroy(pLock->wake_lock);
return 0;
}

Expand All @@ -1011,11 +1006,7 @@ INT32 osal_wake_lock(P_OSAL_WAKE_LOCK pLock)
if (!pLock)
return -1;

#ifdef CONFIG_PM_WAKELOCKS
__pm_stay_awake(&pLock->wake_lock);
#else
wake_lock(&pLock->wake_lock);
#endif
__pm_stay_awake(pLock->wake_lock);

return 0;
}
Expand All @@ -1025,11 +1016,7 @@ INT32 osal_wake_unlock(P_OSAL_WAKE_LOCK pLock)
if (!pLock)
return -1;

#ifdef CONFIG_PM_WAKELOCKS
__pm_relax(&pLock->wake_lock);
#else
wake_unlock(&pLock->wake_lock);
#endif
__pm_relax(pLock->wake_lock);

return 0;

Expand All @@ -1042,11 +1029,7 @@ INT32 osal_wake_lock_count(P_OSAL_WAKE_LOCK pLock)
if (!pLock)
return -1;

#ifdef CONFIG_PM_WAKELOCKS
count = pLock->wake_lock.active;
#else
count = wake_lock_active(&pLock->wake_lock);
#endif
count = pLock->wake_lock->active;
return count;
}

Expand Down
Expand Up @@ -121,11 +121,7 @@ BT_WIFI_V33_STATUS gBtWifiV33;
*/
#if CFG_WMT_WAKELOCK_SUPPORT
static struct mutex gOsSLock;
#ifdef CONFIG_PM_WAKELOCKS
static struct wakeup_source wmtWakeLock;
#else
static struct wake_lock wmtWakeLock;
#endif
static struct wakeup_source *wmtWakeLock;
#endif

irq_cb wmt_plat_bgf_irq_cb = NULL;
Expand Down Expand Up @@ -325,11 +321,8 @@ INT32 wmt_plat_init(UINT32 co_clock_type)
/* register to cmb_stub */
iret = mtk_wcn_cmb_stub_reg(&stub_cb);
#ifdef CFG_WMT_WAKELOCK_SUPPORT
#ifdef CONFIG_PM_WAKELOCKS
wakeup_source_init(&wmtWakeLock, "wmtFuncCtrl");
#else
wake_lock_init(&wmtWakeLock, WAKE_LOCK_SUSPEND, "wmtFuncCtrl");
#endif
if((wmtWakeLock = wakeup_source_create("wmtFuncCtrl")))
wakeup_source_add(wmtWakeLock);
mutex_init(&gOsSLock);
#endif

Expand All @@ -355,16 +348,9 @@ INT32 wmt_plat_deinit(VOID)
printk(KERN_ALERT "DEBUG: Passed %s %d now calling wmt wakelock deinit\n",__FUNCTION__,__LINE__);
/*3. wmt wakelock deinit */
#ifdef CFG_WMT_WAKELOCK_SUPPORT
#ifdef CONFIG_PM_WAKELOCKS
printk(KERN_ALERT "DEBUG: Passed %s %d now calling wakeup_source_trash\n",__FUNCTION__,__LINE__);
wakeup_source_trash(&wmtWakeLock);
#else
printk(KERN_ALERT "DEBUG: Passed %s %d now calling wake lock destroy %d\n",__FUNCTION__,__LINE__,(int)&wmtWakeLock);
//destroy calls wakeup_source_trash with &lock->ws
printk(KERN_ALERT "DEBUG: Passed %s %d now wmtWakeLock:%d\n",__FUNCTION__,__LINE__,(int)&wmtWakeLock);
printk(KERN_ALERT "DEBUG: Passed %s %d now wmtWakeLock->ws: %d\n",__FUNCTION__,__LINE__,(int)&(wmtWakeLock.ws));
wake_lock_destroy(&wmtWakeLock);
#endif
wakeup_source_remove(wmtWakeLock);
wakeup_source_destroy(wmtWakeLock);
printk(KERN_ALERT "DEBUG: Passed %s %d now calling mutex_destroy\n",__FUNCTION__,__LINE__);
mutex_destroy(&gOsSLock);
WMT_PLAT_DBG_FUNC("destroy wmtWakeLock\n");
Expand Down Expand Up @@ -834,30 +820,16 @@ INT32 wmt_plat_wake_lock_ctrl(ENUM_WL_OP opId)

mutex_unlock(&gOsSLock);
if (WL_OP_GET == opId && counter == 1) {
#ifdef CONFIG_PM_WAKELOCKS
__pm_stay_awake(&wmtWakeLock);
status = wmtWakeLock.active;
#else
wake_lock(&wmtWakeLock);
status = wake_lock_active(&wmtWakeLock);
#endif
__pm_stay_awake(wmtWakeLock);
status = wmtWakeLock->active;
WMT_PLAT_DBG_FUNC("WMT-PLAT: after wake_lock(%d), counter(%d)\n", status, counter);

} else if (WL_OP_PUT == opId && counter == 0) {
#ifdef CONFIG_PM_WAKELOCKS
__pm_relax(&wmtWakeLock);
status = wmtWakeLock.active;
#else
wake_unlock(&wmtWakeLock);
status = wake_lock_active(&wmtWakeLock);
#endif
__pm_relax(wmtWakeLock);
status = wmtWakeLock->active;
WMT_PLAT_DBG_FUNC("WMT-PLAT: after wake_unlock(%d), counter(%d)\n", status, counter);
} else {
#ifdef CONFIG_PM_WAKELOCKS
status = wmtWakeLock.active;
#else
status = wake_lock_active(&wmtWakeLock);
#endif
status = wmtWakeLock->active;
WMT_PLAT_WARN_FUNC("WMT-PLAT: wakelock status(%d), counter(%d)\n", status, counter);
}
return 0;
Expand Down
Expand Up @@ -778,7 +778,8 @@ typedef enum _ENUM_WMTHWVER_TYPE_T {
*/
VOID kalHifAhbKalWakeLockTimeout(IN P_GLUE_INFO_T prGlueInfo)
{
KAL_WAKE_LOCK_TIMEOUT(prGlueInfo->prAdapter, &(prGlueInfo->rAhbIsrWakeLock), (HZ / 10)); /* 100ms */
//KAL_WAKE_LOCK_TIMEOUT(prGlueInfo->prAdapter, &(prGlueInfo->rAhbIsrWakeLock), (HZ / 10)); /* 100ms */
printk(KERN_CRIT "kalHifAhbKalWakeLockTimeout: prGlueInfo->rAhbIsrWakeLock = %px\n", prGlueInfo->rAhbIsrWakeLock);
}

#if CFG_ENABLE_FW_DOWNLOAD
Expand Down
Expand Up @@ -643,11 +643,7 @@ typedef enum _ENUM_KAL_MEM_ALLOCATION_TYPE_E {
MEM_TYPE_NUM
} ENUM_KAL_MEM_ALLOCATION_TYPE;

#if CONFIG_ANDROID /* Defined in Android kernel source */
typedef struct wake_lock KAL_WAKE_LOCK_T, *P_KAL_WAKE_LOCK_T;
#else
typedef UINT_32 KAL_WAKE_LOCK_T, *P_KAL_WAKE_LOCK_T;
#endif
typedef struct wakeup_source *KAL_WAKE_LOCK_T, **P_KAL_WAKE_LOCK_T;

#if CFG_SUPPORT_AGPS_ASSIST
typedef enum _ENUM_MTK_AGPS_ATTR {
Expand Down Expand Up @@ -723,29 +719,22 @@ struct KAL_HALT_CTRL_T {
/*----------------------------------------------------------------------------*/
/* Macros of wake_lock operations for using in Driver Layer */
/*----------------------------------------------------------------------------*/
#if CONFIG_ANDROID /* Defined in Android kernel source */
#define KAL_WAKE_LOCK_INIT(_prAdapter, _prWakeLock, _pcName) \
wake_lock_init(_prWakeLock, WAKE_LOCK_SUSPEND, _pcName)
if( (*(_prWakeLock) = wakeup_source_create(_pcName)) ) \
wakeup_source_add(*(_prWakeLock))

#define KAL_WAKE_LOCK_DESTROY(_prAdapter, _prWakeLock) \
wake_lock_destroy(_prWakeLock)
{ wakeup_source_remove(*(_prWakeLock)); \
wakeup_source_destroy(*(_prWakeLock));}

#define KAL_WAKE_LOCK(_prAdapter, _prWakeLock) \
wake_lock(_prWakeLock)
__pm_stay_awake(*(_prWakeLock))

#define KAL_WAKE_LOCK_TIMEOUT(_prAdapter, _prWakeLock, _u4Timeout) \
wake_lock_timeout(_prWakeLock, _u4Timeout)
__pm_wakeup_event(*(_prWakeLock), jiffies_to_msecs(_u4Timeout))

#define KAL_WAKE_UNLOCK(_prAdapter, _prWakeLock) \
wake_unlock(_prWakeLock)

#else
#define KAL_WAKE_LOCK_INIT(_prAdapter, _prWakeLock, _pcName)
#define KAL_WAKE_LOCK_DESTROY(_prAdapter, _prWakeLock)
#define KAL_WAKE_LOCK(_prAdapter, _prWakeLock)
#define KAL_WAKE_LOCK_TIMEOUT(_prAdapter, _prWakeLock, _u4Timeout)
#define KAL_WAKE_UNLOCK(_prAdapter, _prWakeLock)
#endif
__pm_relax(*(_prWakeLock))

/*----------------------------------------------------------------------------*/
/*!
Expand Down
Expand Up @@ -517,11 +517,6 @@

#define DRV_NAME "["CHIP_NAME"]: "

#define CONFIG_ANDROID 1
/* Define if target platform is Android.
* It should already be defined in Android kernel source
*/

/* for CFG80211 IE buffering mechanism */
#define CFG_CFG80211_IE_BUF_LEN (512)

Expand All @@ -537,10 +532,6 @@
#include <linux/jiffies.h> /* jiffies */
#include <linux/delay.h> /* udelay and mdelay macro */

#if CONFIG_ANDROID
#include <linux/wakelock.h>
#endif

#include <linux/irq.h> /* IRQT_FALLING */

#include <linux/netdevice.h> /* struct net_device, struct net_device_stats */
Expand Down
15 changes: 0 additions & 15 deletions include/linux/pm_wakeup.h
Expand Up @@ -183,21 +183,6 @@ static inline void pm_wakeup_dev_event(struct device *dev, unsigned int msec,

#endif /* !CONFIG_PM_SLEEP */

static inline void wakeup_source_init(struct wakeup_source *ws,
const char *name)
{
ws=wakeup_source_create(name);
wakeup_source_add(ws);
}

static inline void wakeup_source_trash(struct wakeup_source *ws)
{
wakeup_source_remove(ws);
//wakeup_source_drop(ws);
if (ws)
__pm_relax(ws);
}

static inline void __pm_wakeup_event(struct wakeup_source *ws, unsigned int msec)
{
return pm_wakeup_ws_event(ws, msec, false);
Expand Down
67 changes: 0 additions & 67 deletions include/linux/wakelock.h

This file was deleted.

0 comments on commit 247c0a1

Please sign in to comment.