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

Commit dcf79600 authored by Ken Zhang's avatar Ken Zhang
Browse files

msm: display: reduce display commit prepare waiting time



Unblock overlay_set, prepare and buffer sync ioctls when
commit thread finishes hardware programming.
Use wait_for_kickoff instead of pan_idle for these ioctls.

CRs-fixed: 620740
Change-Id: Iefb6cbc390d2130926fdcb93688b4d92bfb26937
Signed-off-by: default avatarKen Zhang <kenz@codeaurora.org>
parent 62e43848
Loading
Loading
Loading
Loading
+51 −11
Original line number Diff line number Diff line
@@ -1454,6 +1454,7 @@ static int mdss_fb_register(struct msm_fb_data_type *mfd)
	atomic_set(&mfd->mdp_sync_pt_data.commit_cnt, 0);
	atomic_set(&mfd->commits_pending, 0);
	atomic_set(&mfd->ioctl_ref_cnt, 0);
	atomic_set(&mfd->kickoff_pending, 0);

	init_timer(&mfd->no_update.timer);
	mfd->no_update.timer.function = mdss_fb_no_update_notify_timer_cb;
@@ -1467,6 +1468,7 @@ static int mdss_fb_register(struct msm_fb_data_type *mfd)
	init_waitqueue_head(&mfd->commit_wait_q);
	init_waitqueue_head(&mfd->idle_wait_q);
	init_waitqueue_head(&mfd->ioctl_q);
	init_waitqueue_head(&mfd->kickoff_wait_q);

	ret = fb_alloc_cmap(&fbi->cmap, 256, 0);
	if (ret)
@@ -1879,6 +1881,25 @@ static int mdss_fb_pan_idle(struct msm_fb_data_type *mfd)
	return 0;
}

static int mdss_fb_wait_for_kickoff(struct msm_fb_data_type *mfd)
{
	int ret = 0;

	ret = wait_event_timeout(mfd->kickoff_wait_q,
			(!atomic_read(&mfd->kickoff_pending) ||
			 mfd->shutdown_pending),
			msecs_to_jiffies(WAIT_DISP_OP_TIMEOUT / 2));
	if (!ret) {
		pr_err("wait for kickoff timeout %d pending=%d\n",
				ret, atomic_read(&mfd->kickoff_pending));

	} else if (mfd->shutdown_pending) {
		pr_debug("Shutdown signalled\n");
		return -EPERM;
	}

	return 0;
}

static int mdss_fb_pan_display_ex(struct fb_info *info,
		struct mdp_display_commit *disp_commit)
@@ -1917,6 +1938,7 @@ static int mdss_fb_pan_display_ex(struct fb_info *info,

	atomic_inc(&mfd->mdp_sync_pt_data.commit_cnt);
	atomic_inc(&mfd->commits_pending);
	atomic_inc(&mfd->kickoff_pending);
	wake_up_all(&mfd->commit_wait_q);
	mutex_unlock(&mfd->mdp_sync_pt_data.sync_mutex);
	if (wait_for_finish)
@@ -2009,6 +2031,8 @@ static int __mdss_fb_perform_commit(struct msm_fb_data_type *mfd)
		if (ret)
			pr_err("pan display failed %x on fb%d\n", ret,
					mfd->index);
		atomic_set(&mfd->kickoff_pending, 0);
		wake_up_all(&mfd->kickoff_wait_q);
	}
	if (!ret)
		mdss_fb_update_backlight(mfd);
@@ -2050,6 +2074,7 @@ static int __mdss_fb_display_thread(void *data)
	}

	atomic_set(&mfd->commits_pending, 0);
	atomic_set(&mfd->kickoff_pending, 0);
	wake_up_all(&mfd->idle_wait_q);

	return ret;
@@ -2521,6 +2546,29 @@ static int mdss_fb_display_commit(struct fb_info *info,
	return ret;
}

static int __ioctl_wait_idle(struct msm_fb_data_type *mfd, u32 cmd)
{
	int ret = 0;

	if (mfd->wait_for_kickoff &&
		((cmd == MSMFB_OVERLAY_PREPARE) ||
		(cmd == MSMFB_BUFFER_SYNC) ||
		(cmd == MSMFB_OVERLAY_SET))) {
		ret = mdss_fb_wait_for_kickoff(mfd);
	} else if ((cmd != MSMFB_VSYNC_CTRL) &&
		(cmd != MSMFB_OVERLAY_VSYNC_CTRL) &&
		(cmd != MSMFB_ASYNC_BLIT) &&
		(cmd != MSMFB_BLIT) &&
		(cmd != MSMFB_NOTIFY_UPDATE) &&
		(cmd != MSMFB_OVERLAY_PREPARE)) {
		ret = mdss_fb_pan_idle(mfd);
	}

	if (ret)
		pr_debug("Shutdown pending. Aborting operation %x\n", cmd);
	return ret;
}

/*
 * mdss_fb_do_ioctl() - MDSS Framebuffer ioctl function
 * @info:	pointer to framebuffer info
@@ -2555,17 +2603,9 @@ int mdss_fb_do_ioctl(struct fb_info *info, unsigned int cmd,

	mdss_fb_power_setting_idle(mfd);

	if ((cmd != MSMFB_VSYNC_CTRL) && (cmd != MSMFB_OVERLAY_VSYNC_CTRL) &&
			(cmd != MSMFB_ASYNC_BLIT) && (cmd != MSMFB_BLIT) &&
			(cmd != MSMFB_NOTIFY_UPDATE) &&
			(cmd != MSMFB_OVERLAY_PREPARE)) {
		ret = mdss_fb_pan_idle(mfd);
		if (ret) {
			pr_debug("Shutdown pending. Aborting operation %x\n",
				cmd);
	ret = __ioctl_wait_idle(mfd, cmd);
	if (ret)
		goto exit;
		}
	}

	switch (cmd) {
	case MSMFB_CURSOR:
+4 −0
Original line number Diff line number Diff line
@@ -216,8 +216,10 @@ struct msm_fb_data_type {
	/* for non-blocking */
	struct task_struct *disp_thread;
	atomic_t commits_pending;
	atomic_t kickoff_pending;
	wait_queue_head_t commit_wait_q;
	wait_queue_head_t idle_wait_q;
	wait_queue_head_t kickoff_wait_q;
	bool shutdown_pending;

	struct task_struct *splash_thread;
@@ -236,6 +238,8 @@ struct msm_fb_data_type {
	struct ion_handle *fb_ion_handle;

	bool mdss_fb_split_stored;

	u32 wait_for_kickoff;
};

static inline void mdss_fb_update_notify_update(struct msm_fb_data_type *mfd)
+2 −0
Original line number Diff line number Diff line
@@ -446,8 +446,10 @@ static int mdss_mdp_video_wait4comp(struct mdss_mdp_ctl *ctl, void *arg)
	if (ctx->polling_en) {
		rc = mdss_mdp_video_pollwait(ctl);
	} else {
		mutex_unlock(&ctl->lock);
		rc = wait_for_completion_timeout(&ctx->vsync_comp,
				usecs_to_jiffies(VSYNC_TIMEOUT_US));
		mutex_lock(&ctl->lock);
		if (rc == 0) {
			pr_warn("vsync wait timeout %d, fallback to poll mode\n",
					ctl->num);
+6 −0
Original line number Diff line number Diff line
@@ -1350,12 +1350,17 @@ int mdss_mdp_overlay_kickoff(struct msm_fb_data_type *mfd,
	else
		ret = mdss_mdp_display_commit(mdp5_data->ctl, NULL);

	atomic_set(&mfd->kickoff_pending, 0);
	wake_up_all(&mfd->kickoff_wait_q);

	if (IS_ERR_VALUE(ret))
		goto commit_fail;

	mutex_unlock(&mdp5_data->ov_lock);
	mdss_mdp_overlay_update_pm(mdp5_data);

	ret = mdss_mdp_display_wait4comp(mdp5_data->ctl);
	mutex_lock(&mdp5_data->ov_lock);

	if (ret == 0) {
		if (!mdp5_data->sd_enabled && sd_in_pipe) {
@@ -3582,6 +3587,7 @@ int mdss_mdp_overlay_init(struct msm_fb_data_type *mfd)
		goto init_fail;
	}
	mfd->mdp.private1 = mdp5_data;
	mfd->wait_for_kickoff = true;

	rc = mdss_mdp_overlay_fb_parse_dt(mfd);
	if (rc)