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

Commit 4ca8b294 authored by Tim Murray's avatar Tim Murray Committed by Nirmal Abraham
Browse files

msm: mdss: move to a kthread for vsync_retire_work_handler



vsync_retire_work_handler is in the critical display path and should
never be delayed because of other non-FIFO work.

bug 30115868

(cherry picked from commit 91fd2c322af5c111309e343e7d58f6e5e1841823)

Change-Id: Ic97744a81198ff303f9c87e1cf7c2468b4356a25
Signed-off-by: default avatarNaseer Ahmed <naseer@codeaurora.org>
Signed-off-by: default avatarNirmal Abraham <nabrah@codeaurora.org>
parent fb61632d
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
#include <linux/notifier.h>
#include <linux/irqreturn.h>
#include <linux/kref.h>
#include <linux/kthread.h>

#include "mdss.h"
#include "mdss_mdp_hwio.h"
@@ -1005,7 +1006,6 @@ struct mdss_overlay_private {

	struct sw_sync_timeline *vsync_timeline;
	struct mdss_mdp_vsync_handler vsync_retire_handler;
	struct work_struct retire_work;
	int retire_cnt;
	bool kickoff_released;
	u32 cursor_ndx[2];
@@ -1019,6 +1019,9 @@ struct mdss_overlay_private {
	/* video frame info used by deterministic frame rate control */
	struct mdss_mdp_frc_fsm *frc_fsm;
	u8 sd_transition_state;
	struct kthread_worker worker;
	struct kthread_work vsync_work;
	struct task_struct *thread;
};

struct mdss_mdp_set_ot_params {
+20 −5
Original line number Diff line number Diff line
@@ -6108,7 +6108,7 @@ static int mdss_mdp_overlay_off(struct msm_fb_data_type *mfd)
		 * retire_signal api checks for retire_cnt with sync_mutex lock.
		 */

		flush_work(&mdp5_data->retire_work);
		flush_kthread_work(&mdp5_data->vsync_work);
	}

ctl_stop:
@@ -6313,13 +6313,13 @@ static void __vsync_retire_handle_vsync(struct mdss_mdp_ctl *ctl, ktime_t t)
	}

	mdp5_data = mfd_to_mdp5_data(mfd);
	schedule_work(&mdp5_data->retire_work);
	queue_kthread_work(&mdp5_data->worker, &mdp5_data->vsync_work);
}

static void __vsync_retire_work_handler(struct work_struct *work)
static void __vsync_retire_work_handler(struct kthread_work *work)
{
	struct mdss_overlay_private *mdp5_data =
		container_of(work, typeof(*mdp5_data), retire_work);
		container_of(work, typeof(*mdp5_data), vsync_work);

	if (!mdp5_data->ctl || !mdp5_data->ctl->mfd)
		return;
@@ -6410,6 +6410,7 @@ static int __vsync_retire_setup(struct msm_fb_data_type *mfd)
{
	struct mdss_overlay_private *mdp5_data = mfd_to_mdp5_data(mfd);
	char name[24];
	struct sched_param param = { .sched_priority = 5 };

	snprintf(name, sizeof(name), "mdss_fb%d_retire", mfd->index);
	mdp5_data->vsync_timeline = sw_sync_timeline_create(name);
@@ -6417,12 +6418,26 @@ static int __vsync_retire_setup(struct msm_fb_data_type *mfd)
		pr_err("cannot vsync create time line");
		return -ENOMEM;
	}

	init_kthread_worker(&mdp5_data->worker);
	init_kthread_work(&mdp5_data->vsync_work, __vsync_retire_work_handler);

	mdp5_data->thread = kthread_run(kthread_worker_fn,
					&mdp5_data->worker, "vsync_retire_work");

	if (IS_ERR(mdp5_data->thread)) {
		pr_err("unable to start vsync thread\n");
		mdp5_data->thread = NULL;
		return -ENOMEM;
	}

	sched_setscheduler(mdp5_data->thread, SCHED_FIFO, &param);

	mfd->mdp_sync_pt_data.get_retire_fence = __vsync_retire_get_fence;

	mdp5_data->vsync_retire_handler.vsync_handler =
		__vsync_retire_handle_vsync;
	mdp5_data->vsync_retire_handler.cmd_post_flush = false;
	INIT_WORK(&mdp5_data->retire_work, __vsync_retire_work_handler);

	return 0;
}