From 3ff9b8e96aed47e5896751568fb4f187c4e9294c Mon Sep 17 00:00:00 2001 From: Naseer Ahmed Date: Tue, 25 Jun 2013 16:54:01 -0400 Subject: [PATCH] msm: mdp: Update sync pt. behaviour Add a retire fence and clean up the existing release fence implementation Signed-off-by: Naseer Ahmed Change-Id: Iecf7e95d0786ac43aa6a12d70442936600c0249a --- drivers/video/msm/msm_fb.c | 72 ++++++++++++++++++++++---------------- drivers/video/msm/msm_fb.h | 6 ---- include/linux/msm_mdp.h | 8 +---- 3 files changed, 43 insertions(+), 43 deletions(-) diff --git a/drivers/video/msm/msm_fb.c b/drivers/video/msm/msm_fb.c index efe047c00dd..b6094b45081 100644 --- a/drivers/video/msm/msm_fb.c +++ b/drivers/video/msm/msm_fb.c @@ -1864,8 +1864,6 @@ int msm_fb_signal_timeline(struct msm_fb_data_type *mfd) sw_sync_timeline_inc(mfd->timeline, 1); mfd->timeline_value++; } - mfd->last_rel_fence = mfd->cur_rel_fence; - mfd->cur_rel_fence = 0; if (atomic_read(&mfd->commit_cnt) > 0) atomic_dec(&mfd->commit_cnt); mutex_unlock(&mfd->sync_mutex); @@ -1876,15 +1874,13 @@ void msm_fb_release_timeline(struct msm_fb_data_type *mfd) { u32 commit_cnt; mutex_lock(&mfd->sync_mutex); - commit_cnt = atomic_read(&mfd->commit_cnt) + 2; + commit_cnt = atomic_read(&mfd->commit_cnt) + 3; if (commit_cnt < 0) commit_cnt = 0; if (mfd->timeline) { sw_sync_timeline_inc(mfd->timeline, 2 + commit_cnt); mfd->timeline_value += 2 + commit_cnt; } - mfd->last_rel_fence = 0; - mfd->cur_rel_fence = 0; atomic_set(&mfd->commit_cnt, 0); mutex_unlock(&mfd->sync_mutex); } @@ -3724,6 +3720,12 @@ static int msmfb_handle_buf_sync_ioctl(struct msm_fb_data_type *mfd, u32 threshold; int acq_fen_fd[MDP_MAX_FENCE_FD]; struct sync_fence *fence; + struct sync_pt *release_sync_pt; + struct sync_pt *retire_sync_pt; + struct sync_fence *release_fence; + struct sync_fence *retire_fence; + int release_fen_fd; + int retire_fen_fd; if ((buf_sync->acq_fen_fd_cnt > MDP_MAX_FENCE_FD) || (mfd->timeline == NULL)) @@ -3761,46 +3763,56 @@ static int msmfb_handle_buf_sync_ioctl(struct msm_fb_data_type *mfd, threshold = 1; else threshold = 2; - mfd->cur_rel_sync_pt = sw_sync_pt_create(mfd->timeline, - mfd->timeline_value + threshold + - atomic_read(&mfd->commit_cnt)); - if (mfd->cur_rel_sync_pt == NULL) { - pr_err("%s: cannot create sync point", __func__); - ret = -ENOMEM; + + release_fen_fd = get_unused_fd_flags(0); + if (release_fen_fd < 0) { + pr_err("%s: get_unused_fd_flags failed", __func__); + ret = -EIO; goto buf_sync_err_1; } - /* create fence */ - mfd->cur_rel_fence = sync_fence_create("mdp-fence", - mfd->cur_rel_sync_pt); - if (mfd->cur_rel_fence == NULL) { - sync_pt_free(mfd->cur_rel_sync_pt); - mfd->cur_rel_sync_pt = NULL; - pr_err("%s: cannot create fence", __func__); - ret = -ENOMEM; - goto buf_sync_err_1; - } - /* create fd */ - mfd->cur_rel_fen_fd = get_unused_fd_flags(0); - if (mfd->cur_rel_fen_fd < 0) { + + retire_fen_fd = get_unused_fd_flags(0); + if (retire_fen_fd < 0) { pr_err("%s: get_unused_fd_flags failed", __func__); ret = -EIO; goto buf_sync_err_2; } - sync_fence_install(mfd->cur_rel_fence, mfd->cur_rel_fen_fd); + + release_sync_pt = sw_sync_pt_create(mfd->timeline, + mfd->timeline_value + threshold + + atomic_read(&mfd->commit_cnt)); + release_fence = sync_fence_create("mdp-fence", + release_sync_pt); + sync_fence_install(release_fence, release_fen_fd); + retire_sync_pt = sw_sync_pt_create(mfd->timeline, + mfd->timeline_value + threshold + + atomic_read(&mfd->commit_cnt) + 1); + retire_fence = sync_fence_create("mdp-retire-fence", + retire_sync_pt); + sync_fence_install(retire_fence, retire_fen_fd); + ret = copy_to_user(buf_sync->rel_fen_fd, - &mfd->cur_rel_fen_fd, sizeof(int)); + &release_fen_fd, sizeof(int)); if (ret) { pr_err("%s:copy_to_user failed", __func__); goto buf_sync_err_3; } + + ret = copy_to_user(buf_sync->retire_fen_fd, + &retire_fen_fd, sizeof(int)); + if (ret) { + pr_err("%s:copy_to_user failed", __func__); + goto buf_sync_err_3; + } + mutex_unlock(&mfd->sync_mutex); return ret; buf_sync_err_3: - put_unused_fd(mfd->cur_rel_fen_fd); + sync_fence_put(release_fence); + sync_fence_put(retire_fence); + put_unused_fd(retire_fen_fd); buf_sync_err_2: - sync_fence_put(mfd->cur_rel_fence); - mfd->cur_rel_fence = NULL; - mfd->cur_rel_fen_fd = 0; + put_unused_fd(release_fen_fd); buf_sync_err_1: for (i = 0; i < mfd->acq_fen_cnt; i++) sync_fence_put(mfd->acq_fen[i]); diff --git a/drivers/video/msm/msm_fb.h b/drivers/video/msm/msm_fb.h index 698e64d9090..231cd38c175 100644 --- a/drivers/video/msm/msm_fb.h +++ b/drivers/video/msm/msm_fb.h @@ -199,14 +199,8 @@ struct msm_fb_data_type { void *cpu_pm_hdl; u32 acq_fen_cnt; struct sync_fence *acq_fen[MDP_MAX_FENCE_FD]; - int cur_rel_fen_fd; - struct sync_pt *cur_rel_sync_pt; - struct sync_fence *cur_rel_fence; - struct sync_fence *last_rel_fence; struct sw_sync_timeline *timeline; int timeline_value; - u32 last_acq_fen_cnt; - struct sync_fence *last_acq_fen[MDP_MAX_FENCE_FD]; struct mutex sync_mutex; struct mutex queue_mutex; struct completion commit_comp; diff --git a/include/linux/msm_mdp.h b/include/linux/msm_mdp.h index 394394b618d..641f4239f00 100644 --- a/include/linux/msm_mdp.h +++ b/include/linux/msm_mdp.h @@ -573,13 +573,7 @@ struct mdp_buf_sync { uint32_t acq_fen_fd_cnt; int *acq_fen_fd; int *rel_fen_fd; -}; - -struct mdp_buf_fence { - uint32_t flags; - uint32_t acq_fen_fd_cnt; - int acq_fen_fd[MDP_MAX_FENCE_FD]; - int rel_fen_fd[MDP_MAX_FENCE_FD]; + int *retire_fen_fd; }; #define MDP_DISPLAY_COMMIT_OVERLAY 0x00000001