Merge "msm: mdss: Disable secure session after Flush for video mode panels"

This commit is contained in:
Linux Build Service Account 2017-03-13 11:50:05 -07:00 committed by Gerrit - the friendly Code Review server
commit 8d7423e396
2 changed files with 79 additions and 24 deletions

View file

@ -164,6 +164,14 @@ enum mdss_mdp_mixer_mux {
MDSS_MDP_MIXER_MUX_RIGHT,
};
enum mdss_secure_transition {
SECURE_TRANSITION_NONE,
SD_NON_SECURE_TO_SECURE,
SD_SECURE_TO_NON_SECURE,
SC_NON_SECURE_TO_SECURE,
SC_SECURE_TO_NON_SECURE,
};
static inline enum mdss_mdp_sspp_index get_pipe_num_from_ndx(u32 ndx)
{
u32 id;
@ -953,6 +961,8 @@ struct mdss_overlay_private {
struct kthread_worker worker;
struct kthread_work vsync_work;
struct task_struct *thread;
u8 secure_transition_state;
};
struct mdss_mdp_set_ot_params {

View file

@ -2322,14 +2322,12 @@ set_roi:
}
/*
* Enables/disable secure (display or camera) sessions
* Check if there is any change in secure state and store it.
*/
static int __overlay_secure_ctrl(struct msm_fb_data_type *mfd)
static void __overlay_set_secure_transition_state(struct msm_fb_data_type *mfd)
{
struct mdss_overlay_private *mdp5_data = mfd_to_mdp5_data(mfd);
struct mdss_mdp_ctl *ctl = mfd_to_ctl(mfd);
struct mdss_mdp_pipe *pipe;
int ret = 0;
int sd_in_pipe = 0;
int sc_in_pipe = 0;
u64 pipes_flags = 0;
@ -2350,25 +2348,53 @@ static int __overlay_secure_ctrl(struct msm_fb_data_type *mfd)
MDSS_XLOG(sd_in_pipe, sc_in_pipe, pipes_flags,
mdp5_data->sc_enabled, mdp5_data->sd_enabled);
pr_debug("sd:%d sd_in_pipe:%d sc:%d sc_in_pipe:%d flags:0x%llx\n",
mdp5_data->sd_enabled, sd_in_pipe,
mdp5_data->sc_enabled, sc_in_pipe, pipes_flags);
mdp5_data->sd_enabled, sd_in_pipe,
mdp5_data->sc_enabled, sc_in_pipe, pipes_flags);
/* Reset the secure transition state */
mdp5_data->secure_transition_state = SECURE_TRANSITION_NONE;
/*
* Return early in only two conditions:
* 1. All the features are already disabled and state remains
* disabled for the pipes.
* 2. One of the features is already enabled and state remains
* enabled for the pipes.
*/
* Secure transition would be NONE in two conditions:
* 1. All the features are already disabled and state remains
* disabled for the pipes.
* 2. One of the features is already enabled and state remains
* enabled for the pipes.
*/
if (!sd_in_pipe && !mdp5_data->sd_enabled &&
!sc_in_pipe && !mdp5_data->sc_enabled)
return ret;
return;
else if ((sd_in_pipe && mdp5_data->sd_enabled) ||
(sc_in_pipe && mdp5_data->sc_enabled))
return;
/* Secure Display */
if (!mdp5_data->sd_enabled && sd_in_pipe)
mdp5_data->secure_transition_state |= SD_NON_SECURE_TO_SECURE;
else if (mdp5_data->sd_enabled && !sd_in_pipe)
mdp5_data->secure_transition_state |= SD_SECURE_TO_NON_SECURE;
/* Secure Camera */
if (!mdp5_data->sc_enabled && sc_in_pipe)
mdp5_data->secure_transition_state |= SC_NON_SECURE_TO_SECURE;
else if (mdp5_data->sc_enabled && !sc_in_pipe)
mdp5_data->secure_transition_state |= SC_SECURE_TO_NON_SECURE;
}
/*
* Enable/disable secure (display or camera) sessions
*/
static int __overlay_secure_ctrl(struct msm_fb_data_type *mfd)
{
struct mdss_overlay_private *mdp5_data = mfd_to_mdp5_data(mfd);
struct mdss_mdp_ctl *ctl = mfd_to_ctl(mfd);
int ret = 0;
if (mdp5_data->secure_transition_state == SECURE_TRANSITION_NONE)
return ret;
/* Secure Display */
if (!mdp5_data->sd_enabled && sd_in_pipe) {
if (mdp5_data->secure_transition_state == SD_NON_SECURE_TO_SECURE) {
if (!mdss_get_sd_client_cnt()) {
MDSS_XLOG(0x11);
/*wait for ping pong done */
@ -2390,7 +2416,8 @@ static int __overlay_secure_ctrl(struct msm_fb_data_type *mfd)
}
mdp5_data->sd_enabled = 1;
mdss_update_sd_client(mdp5_data->mdata, true);
} else if (mdp5_data->sd_enabled && !sd_in_pipe) {
} else if (mdp5_data->secure_transition_state ==
SD_SECURE_TO_NON_SECURE) {
/* disable the secure display on last client */
if (mdss_get_sd_client_cnt() == 1) {
MDSS_XLOG(0x22);
@ -2408,11 +2435,9 @@ static int __overlay_secure_ctrl(struct msm_fb_data_type *mfd)
}
/* Secure Camera */
if (!mdp5_data->sc_enabled && sc_in_pipe) {
if (mdp5_data->secure_transition_state == SC_NON_SECURE_TO_SECURE) {
if (!mdss_get_sc_client_cnt()) {
MDSS_XLOG(0x33);
if (ctl->ops.wait_pingpong)
mdss_mdp_display_wait4pingpong(ctl, true);
ret = mdss_mdp_secure_session_ctrl(1,
MDP_SECURE_CAMERA_OVERLAY_SESSION);
if (ret) {
@ -2422,7 +2447,8 @@ static int __overlay_secure_ctrl(struct msm_fb_data_type *mfd)
}
mdp5_data->sc_enabled = 1;
mdss_update_sc_client(mdp5_data->mdata, true);
} else if (mdp5_data->sc_enabled && !sc_in_pipe) {
} else if (mdp5_data->secure_transition_state ==
SC_SECURE_TO_NON_SECURE) {
/* disable the secure camera on last client */
if (mdss_get_sc_client_cnt() == 1) {
MDSS_XLOG(0x44);
@ -2501,15 +2527,23 @@ int mdss_mdp_overlay_kickoff(struct msm_fb_data_type *mfd,
list_move(&pipe->list, &mdp5_data->pipes_destroy);
}
__overlay_set_secure_transition_state(mfd);
/*
* go to secure state if required, this should be done
* after moving the buffers from the previous commit to
* destroy list
* destroy list.
* For video mode panels, secure display/camera should be disabled
* after flushing the new buffer. Skip secure disable here for those
* cases.
*/
ret = __overlay_secure_ctrl(mfd);
if (IS_ERR_VALUE(ret)) {
pr_err("secure operation failed %d\n", ret);
goto commit_fail;
if (!((mfd->panel_info->type == MIPI_VIDEO_PANEL) &&
((mdp5_data->secure_transition_state == SD_SECURE_TO_NON_SECURE) ||
(mdp5_data->secure_transition_state == SC_SECURE_TO_NON_SECURE)))) {
ret = __overlay_secure_ctrl(mfd);
if (IS_ERR_VALUE(ret)) {
pr_err("secure operation failed %d\n", ret);
goto commit_fail;
}
}
/* call this function before any registers programming */
@ -2581,6 +2615,17 @@ int mdss_mdp_overlay_kickoff(struct msm_fb_data_type *mfd,
mutex_lock(&mdp5_data->ov_lock);
/* Disable secure display/camera for video mode panels */
if ((mfd->panel_info->type == MIPI_VIDEO_PANEL) &&
((mdp5_data->secure_transition_state == SD_SECURE_TO_NON_SECURE) ||
(mdp5_data->secure_transition_state == SC_SECURE_TO_NON_SECURE))) {
ret = __overlay_secure_ctrl(mfd);
if (IS_ERR_VALUE(ret)) {
pr_err("secure operation failed %d\n", ret);
goto commit_fail;
}
}
mdss_fb_update_notify_update(mfd);
commit_fail:
ATRACE_BEGIN("overlay_cleanup");