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

Commit 686bd556 authored by Krishna Manikandan's avatar Krishna Manikandan
Browse files

disp: msm: sde: wait for cwb done before transitioning to secure



There are some scenarios where the secure commit
can come when the previous cwb commit is going on.
Add support to wait for cwb commit to be completed
before making the transition to secure.

Change-Id: I95d10ecb5b682e60c059588db926f765a0c7c381
Signed-off-by: default avatarKrishna Manikandan <mkrishn@codeaurora.org>
parent dbae03d9
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -1769,9 +1769,11 @@ int sde_crtc_get_secure_transition_ops(struct drm_crtc *crtc,
	struct sde_kms *sde_kms;
	struct sde_mdss_cfg *catalog;
	struct sde_kms_smmu_state_data *smmu_state;
	struct drm_device *dev;
	uint32_t translation_mode = 0, secure_level;
	int ops  = 0;
	bool post_commit = false;
	bool clone_mode = false;

	if (!crtc || !crtc->state) {
		SDE_ERROR("invalid crtc\n");
@@ -1789,6 +1791,17 @@ int sde_crtc_get_secure_transition_ops(struct drm_crtc *crtc,
	sde_crtc = to_sde_crtc(crtc);
	secure_level = sde_crtc_get_secure_level(crtc, crtc->state);
	catalog = sde_kms->catalog;
	dev = sde_kms->dev;

	/*
	 * Loop through encoder list to find out if clone mode is
	 * enabled on any of the encoders. If clone mode is enabled,
	 * wait for the cwb commit to be completed, before making
	 * the secure transition.
	 */
	list_for_each_entry(encoder, &crtc->dev->mode_config.encoder_list, head)
		if (sde_encoder_in_clone_mode(encoder))
			clone_mode = true;

	/*
	 * SMMU operations need to be delayed in case of video mode panels
@@ -1830,6 +1843,8 @@ int sde_crtc_get_secure_transition_ops(struct drm_crtc *crtc,
	case SDE_DRM_FB_SEC_DIR_TRANS:
		_sde_drm_fb_sec_dir_trans(smmu_state, secure_level,
				catalog, old_valid_fb, &ops);
		if (clone_mode && (ops & SDE_KMS_OPS_SECURE_STATE_CHANGE))
			ops |= SDE_KMS_OPS_WAIT_FOR_TX_DONE;
		break;

	case SDE_DRM_FB_SEC:
+28 −0
Original line number Diff line number Diff line
@@ -1285,6 +1285,33 @@ static int sde_encoder_phys_wb_wait_for_commit_done(
	return _sde_encoder_phys_wb_wait_for_commit_done(phys_enc, false);
}

static int sde_encoder_phys_wb_wait_for_cwb_done(
		struct sde_encoder_phys *phys_enc)
{
	struct sde_encoder_phys_wb *wb_enc = to_sde_encoder_phys_wb(phys_enc);
	struct sde_encoder_wait_info wait_info = {0};
	int rc = 0;

	if (!phys_enc->in_clone_mode)
		return 0;

	SDE_EVT32(atomic_read(&phys_enc->pending_retire_fence_cnt));

	wait_info.wq = &phys_enc->pending_kickoff_wq;
	wait_info.atomic_cnt = &phys_enc->pending_retire_fence_cnt;
	wait_info.timeout_ms = max_t(u32, wb_enc->wbdone_timeout,
				KICKOFF_TIMEOUT_MS);

	rc = sde_encoder_helper_wait_for_irq(phys_enc, INTR_IDX_WB_DONE,
		&wait_info);

	if (rc == -ETIMEDOUT)
		SDE_EVT32(DRMID(phys_enc->parent), WBID(wb_enc),
			wb_enc->frame_count, SDE_EVTLOG_ERROR);

	return rc;
}

/**
 * sde_encoder_phys_wb_prepare_for_kickoff - pre-kickoff processing
 * @phys_enc:	Pointer to physical encoder
@@ -1718,6 +1745,7 @@ static void sde_encoder_phys_wb_init_ops(struct sde_encoder_phys_ops *ops)
	ops->trigger_start = sde_encoder_helper_trigger_start;
	ops->hw_reset = sde_encoder_helper_hw_reset;
	ops->irq_control = sde_encoder_phys_wb_irq_ctrl;
	ops->wait_for_tx_complete = sde_encoder_phys_wb_wait_for_cwb_done;
}

/**