From ad97f0cf4df229a2e8be9375b748d1256f803a53 Mon Sep 17 00:00:00 2001 From: Samantha Tran Date: Fri, 30 Aug 2019 17:05:56 -0700 Subject: [PATCH] disp: msm: sde: revert to previous smmu state upon failure to switch This change saves the previous state before moving into the transitional smmu state, during secure-display/secure-camera usecases. Upon failure to complete the transition, set smmu state to the previous state. Previously, smmu state was staying in transitional state. Change-Id: I1a78ddcf6ac1c7ea66c8c2095cd1a6d6160647a1 Signed-off-by: Samantha Tran --- msm/sde/sde_crtc.c | 2 ++ msm/sde/sde_kms.c | 22 +++++++++++++++++----- msm/sde/sde_kms.h | 2 ++ 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/msm/sde/sde_crtc.c b/msm/sde/sde_crtc.c index f0917f1507..4f816e8e35 100644 --- a/msm/sde/sde_crtc.c +++ b/msm/sde/sde_crtc.c @@ -1781,6 +1781,8 @@ int sde_crtc_get_secure_transition_ops(struct drm_crtc *crtc, return -EINVAL; smmu_state = &sde_kms->smmu_state; + smmu_state->prev_state = smmu_state->state; + sde_crtc = to_sde_crtc(crtc); secure_level = sde_crtc_get_secure_level(crtc, crtc->state); catalog = sde_kms->catalog; diff --git a/msm/sde/sde_kms.c b/msm/sde/sde_kms.c index e34f7be6f8..7b71897bb8 100644 --- a/msm/sde/sde_kms.c +++ b/msm/sde/sde_kms.c @@ -528,12 +528,24 @@ static int _sde_kms_secure_ctrl(struct sde_kms *sde_kms, struct drm_crtc *crtc, end: smmu_state->sui_misr_state = NONE; smmu_state->transition_type = NONE; - smmu_state->transition_error = ret ? true : false; + smmu_state->transition_error = false; - SDE_DEBUG("crtc %d: old_state %d, new_state %d, sec_lvl %d, ret %d\n", - DRMID(crtc), old_smmu_state, smmu_state->state, - smmu_state->secure_level, ret); - SDE_EVT32(DRMID(crtc), smmu_state->state, smmu_state->transition_type, + /* + * If switch failed, toggling secure_level is enough since + * there are only two secure levels - secure/non-secure + */ + if (ret) { + smmu_state->transition_error = true; + smmu_state->state = smmu_state->prev_state; + smmu_state->secure_level = !smmu_state->secure_level; + } + + SDE_DEBUG( + "crtc %d: old_state %d, req_state %d, new_state %d, sec_lvl %d, ret %d\n", + DRMID(crtc), smmu_state->prev_state, old_smmu_state, + smmu_state->state, smmu_state->secure_level, ret); + SDE_EVT32(DRMID(crtc), smmu_state->prev_state, + smmu_state->state, smmu_state->transition_type, smmu_state->transition_error, smmu_state->secure_level, smmu_state->sui_misr_state, ret, SDE_EVTLOG_FUNC_EXIT); diff --git a/msm/sde/sde_kms.h b/msm/sde/sde_kms.h index a330b13d4d..1634ab31b8 100644 --- a/msm/sde/sde_kms.h +++ b/msm/sde/sde_kms.h @@ -187,12 +187,14 @@ enum frame_trigger_mode_type { /** * struct sde_kms_smmu_state_data: stores the smmu state and transition type * @state: current state of smmu context banks + * @prev_state: previous state of smmu context banks * @secure_level: secure level cached from crtc * @transition_type: transition request type * @transition_error: whether there is error while transitioning the state */ struct sde_kms_smmu_state_data { uint32_t state; + uint32_t prev_state; uint32_t secure_level; uint32_t transition_type; uint32_t transition_error;