Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fb8a287f authored by Siddharth Bhal's avatar Siddharth Bhal Committed by Gerrit - the friendly Code Review server
Browse files

wcnss: avoid removing pm_qos request when already removed



Race condition is observed when removing pm_qos request to
avoid power collapse of BIMC.

Using Mutex lock to ensure proper synchronization in removing
pm_qos request and not remove request when already removed.

CRs-Fixed: 766358
Change-Id: I8976fec9d6f145e213a827894bb58aee23155971
Signed-off-by: default avatarSiddharth Bhal <sbhal@codeaurora.org>
parent 89e32cb5
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -432,6 +432,7 @@ static struct {
	struct pm_qos_request wcnss_pm_qos_request;
	int pc_disabled;
	struct delayed_work wcnss_pm_qos_del_req;
	struct mutex pm_qos_mutex;
} *penv = NULL;

static ssize_t wcnss_wlan_macaddr_store(struct device *dev,
@@ -1219,22 +1220,26 @@ void wcnss_pm_qos_update_request(int val)

void wcnss_disable_pc_remove_req(void)
{
	mutex_lock(&penv->pm_qos_mutex);
	if (penv->pc_disabled) {
		penv->pc_disabled = 0;
		wcnss_pm_qos_update_request(WCNSS_ENABLE_PC_LATENCY);
		wcnss_pm_qos_remove_request();
		wcnss_allow_suspend();
		penv->pc_disabled = 0;
	}
	mutex_unlock(&penv->pm_qos_mutex);
}

void wcnss_disable_pc_add_req(void)
{
	mutex_lock(&penv->pm_qos_mutex);
	if (!penv->pc_disabled) {
		wcnss_pm_qos_add_request();
		wcnss_prevent_suspend();
		wcnss_pm_qos_update_request(WCNSS_DISABLE_PC_LATENCY);
		penv->pc_disabled = 1;
	}
	mutex_unlock(&penv->pm_qos_mutex);
}

static void wcnss_smd_notify_event(void *data, unsigned int event)
@@ -3205,6 +3210,7 @@ wcnss_wlan_probe(struct platform_device *pdev)
	mutex_init(&penv->dev_lock);
	mutex_init(&penv->ctrl_lock);
	mutex_init(&penv->vbat_monitor_mutex);
	mutex_init(&penv->pm_qos_mutex);
	init_waitqueue_head(&penv->read_wait);

	/* Since we were built into the kernel we'll be called as part