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

Commit 3cf51859 authored by Skylar Chang's avatar Skylar Chang
Browse files

msm: ipa: add wakelock to IPA RM IT



Hold a wakelock as long as IPA RM inactivity timer is set.
This will ensure that wakelock is held during TX operation to IPA.

Change-Id: I66271395d0a67b9598032598391a809071d19080
CRs-Fixed: 2133719
Acked-by: default avatarAdy Abraham <adya@qti.qualcomm.com>
Signed-off-by: default avatarSkylar Chang <chiaweic@codeaurora.org>
parent 9e3b6496
Loading
Loading
Loading
Loading
+18 −2
Original line number Original line Diff line number Diff line
/* Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
/* Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
 *
 *
 * This program is free software; you can redistribute it and/or modify
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * it under the terms of the GNU General Public License version 2 and
@@ -20,6 +20,8 @@
#include <linux/ipa.h>
#include <linux/ipa.h>
#include "ipa_rm_i.h"
#include "ipa_rm_i.h"


#define MAX_WS_NAME 20

/**
/**
 * struct ipa_rm_it_private - IPA RM Inactivity Timer private
 * struct ipa_rm_it_private - IPA RM Inactivity Timer private
 *	data
 *	data
@@ -45,6 +47,8 @@ struct ipa_rm_it_private {
	bool reschedule_work;
	bool reschedule_work;
	bool work_in_progress;
	bool work_in_progress;
	unsigned long jiffies;
	unsigned long jiffies;
	struct wakeup_source w_lock;
	char w_lock_name[MAX_WS_NAME];
};
};


static struct ipa_rm_it_private ipa_rm_it_handles[IPA_RM_RESOURCE_MAX];
static struct ipa_rm_it_private ipa_rm_it_handles[IPA_RM_RESOURCE_MAX];
@@ -87,6 +91,7 @@ static void ipa_rm_inactivity_timer_func(struct work_struct *work)
	} else {
	} else {
		IPA_RM_DBG_LOW("%s: calling release_resource on resource %d!\n",
		IPA_RM_DBG_LOW("%s: calling release_resource on resource %d!\n",
			__func__, me->resource_name);
			__func__, me->resource_name);
		__pm_relax(&ipa_rm_it_handles[me->resource_name].w_lock);
		ipa_rm_release_resource(me->resource_name);
		ipa_rm_release_resource(me->resource_name);
		ipa_rm_it_handles[me->resource_name].work_in_progress = false;
		ipa_rm_it_handles[me->resource_name].work_in_progress = false;
	}
	}
@@ -110,6 +115,9 @@ static void ipa_rm_inactivity_timer_func(struct work_struct *work)
int ipa_rm_inactivity_timer_init(enum ipa_rm_resource_name resource_name,
int ipa_rm_inactivity_timer_init(enum ipa_rm_resource_name resource_name,
				 unsigned long msecs)
				 unsigned long msecs)
{
{
	struct wakeup_source *pwlock;
	char *name;

	IPA_RM_DBG_LOW("%s: resource %d\n", __func__, resource_name);
	IPA_RM_DBG_LOW("%s: resource %d\n", __func__, resource_name);


	if (resource_name < 0 ||
	if (resource_name < 0 ||
@@ -130,7 +138,10 @@ int ipa_rm_inactivity_timer_init(enum ipa_rm_resource_name resource_name,
	ipa_rm_it_handles[resource_name].resource_requested = false;
	ipa_rm_it_handles[resource_name].resource_requested = false;
	ipa_rm_it_handles[resource_name].reschedule_work = false;
	ipa_rm_it_handles[resource_name].reschedule_work = false;
	ipa_rm_it_handles[resource_name].work_in_progress = false;
	ipa_rm_it_handles[resource_name].work_in_progress = false;

	pwlock = &(ipa_rm_it_handles[resource_name].w_lock);
	name = ipa_rm_it_handles[resource_name].w_lock_name;
	snprintf(name, MAX_WS_NAME, "IPA_RM%d\n", resource_name);
	wakeup_source_init(pwlock, name);
	INIT_DELAYED_WORK(&ipa_rm_it_handles[resource_name].work,
	INIT_DELAYED_WORK(&ipa_rm_it_handles[resource_name].work,
			  ipa_rm_inactivity_timer_func);
			  ipa_rm_inactivity_timer_func);
	ipa_rm_it_handles[resource_name].initied = 1;
	ipa_rm_it_handles[resource_name].initied = 1;
@@ -151,6 +162,8 @@ EXPORT_SYMBOL(ipa_rm_inactivity_timer_init);
*/
*/
int ipa_rm_inactivity_timer_destroy(enum ipa_rm_resource_name resource_name)
int ipa_rm_inactivity_timer_destroy(enum ipa_rm_resource_name resource_name)
{
{
	struct wakeup_source *pwlock;

	IPA_RM_DBG_LOW("%s: resource %d\n", __func__, resource_name);
	IPA_RM_DBG_LOW("%s: resource %d\n", __func__, resource_name);


	if (resource_name < 0 ||
	if (resource_name < 0 ||
@@ -166,6 +179,8 @@ int ipa_rm_inactivity_timer_destroy(enum ipa_rm_resource_name resource_name)
	}
	}


	cancel_delayed_work_sync(&ipa_rm_it_handles[resource_name].work);
	cancel_delayed_work_sync(&ipa_rm_it_handles[resource_name].work);
	pwlock = &(ipa_rm_it_handles[resource_name].w_lock);
	wakeup_source_trash(pwlock);


	memset(&ipa_rm_it_handles[resource_name], 0,
	memset(&ipa_rm_it_handles[resource_name], 0,
	       sizeof(struct ipa_rm_it_private));
	       sizeof(struct ipa_rm_it_private));
@@ -261,6 +276,7 @@ int ipa_rm_inactivity_timer_release_resource(
	}
	}
	ipa_rm_it_handles[resource_name].work_in_progress = true;
	ipa_rm_it_handles[resource_name].work_in_progress = true;
	ipa_rm_it_handles[resource_name].reschedule_work = false;
	ipa_rm_it_handles[resource_name].reschedule_work = false;
	__pm_stay_awake(&ipa_rm_it_handles[resource_name].w_lock);
	IPA_RM_DBG_LOW("%s: setting delayed work\n", __func__);
	IPA_RM_DBG_LOW("%s: setting delayed work\n", __func__);
	queue_delayed_work(system_unbound_wq,
	queue_delayed_work(system_unbound_wq,
			      &ipa_rm_it_handles[resource_name].work,
			      &ipa_rm_it_handles[resource_name].work,