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

Commit 1c252c83 authored by Jordan Crouse's avatar Jordan Crouse Committed by Tarun Karra
Browse files

adreno_tz: Initialize a static workqueue at init time



Workqueues are rather generic and flexible entities. We don't need
to create one every time the governor is started and stopped.

Change-Id: Ic0dedbad286f4cd36679a7282914d4746e6f6d05
Signed-off-by: default avatarJordan Crouse <jcrouse@codeaurora.org>
parent 5cc9c0b5
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -64,6 +64,9 @@ static int devfreq_gpubw_get_target(struct devfreq *df,
	int norm_ab;
	unsigned long ab_mbytes = 0;

	if (priv == NULL)
		return 0;

	stats.private_data = &b;

	result = df->profile->get_dev_status(df->dev.parent, &stats);
+20 −19
Original line number Diff line number Diff line
@@ -55,12 +55,15 @@ static DEFINE_SPINLOCK(tz_lock);

#define TAG "msm_adreno_tz: "

struct msm_adreno_extended_profile *partner_gpu_profile;
static struct msm_adreno_extended_profile *partner_gpu_profile;

static void do_partner_start_event(struct work_struct *work);
static void do_partner_stop_event(struct work_struct *work);
static void do_partner_suspend_event(struct work_struct *work);
static void do_partner_resume_event(struct work_struct *work);

static struct workqueue_struct *workqueue;

/* Trap into the TrustZone, and call funcs there. */
static int __secure_tz_reset_entry2(unsigned int *scm_data, u32 size_scm_data,
					bool is_64)
@@ -298,8 +301,6 @@ static int tz_start(struct devfreq *devfreq)
		return -EINVAL;
	}

	gpu_profile->partner_wq = create_freezable_workqueue
					("governor_msm_adreno_tz_wq");
	INIT_WORK(&gpu_profile->partner_start_event_ws,
					do_partner_start_event);
	INIT_WORK(&gpu_profile->partner_stop_event_ws,
@@ -322,15 +323,10 @@ static int tz_start(struct devfreq *devfreq)
static int tz_stop(struct devfreq *devfreq)
{
	struct devfreq_msm_adreno_tz_data *priv = devfreq->data;
	struct msm_adreno_extended_profile *gpu_profile = container_of(
					(devfreq->profile),
					struct msm_adreno_extended_profile,
					profile);

	kgsl_devfreq_del_notifier(devfreq->dev.parent, &priv->nb);

	flush_workqueue(gpu_profile->partner_wq);
	destroy_workqueue(gpu_profile->partner_wq);
	flush_workqueue(workqueue);

	/* leaving the governor and cleaning the pointer to private data */
	devfreq->data = NULL;
@@ -364,6 +360,11 @@ static int tz_handler(struct devfreq *devfreq, unsigned int event, void *data)
		break;

	case DEVFREQ_GOV_STOP:
		/* Queue the stop work before the TZ is stopped */
		if (partner_gpu_profile && partner_gpu_profile->bus_devfreq)
			queue_work(workqueue,
				&gpu_profile->partner_stop_event_ws);

		result = tz_stop(devfreq);
		break;

@@ -382,19 +383,15 @@ static int tz_handler(struct devfreq *devfreq, unsigned int event, void *data)
	if (partner_gpu_profile && partner_gpu_profile->bus_devfreq)
		switch (event) {
		case DEVFREQ_GOV_START:
			queue_work(gpu_profile->partner_wq,
			queue_work(workqueue,
					&gpu_profile->partner_start_event_ws);
			break;
		case DEVFREQ_GOV_STOP:
			queue_work(gpu_profile->partner_wq,
					&gpu_profile->partner_stop_event_ws);
			break;
		case DEVFREQ_GOV_SUSPEND:
			queue_work(gpu_profile->partner_wq,
			queue_work(workqueue,
					&gpu_profile->partner_suspend_event_ws);
			break;
		case DEVFREQ_GOV_RESUME:
			queue_work(gpu_profile->partner_wq,
			queue_work(workqueue,
					&gpu_profile->partner_resume_event_ws);
			break;
		}
@@ -439,18 +436,22 @@ static struct devfreq_governor msm_adreno_tz = {

static int __init msm_adreno_tz_init(void)
{
	workqueue = create_freezable_workqueue("governor_msm_adreno_tz_wq");
	if (workqueue == NULL)
		return -ENOMEM;

	return devfreq_add_governor(&msm_adreno_tz);
}
subsys_initcall(msm_adreno_tz_init);

static void __exit msm_adreno_tz_exit(void)
{
	int ret;
	ret = devfreq_remove_governor(&msm_adreno_tz);
	int ret = devfreq_remove_governor(&msm_adreno_tz);
	if (ret)
		pr_err(TAG "failed to remove governor %d\n", ret);

	return;
	if (workqueue != NULL)
		destroy_workqueue(workqueue);
}

module_exit(msm_adreno_tz_exit);