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

Commit 5616c9b9 authored by Veera Sundaram Sankaran's avatar Veera Sundaram Sankaran Committed by Gerrit - the friendly Code Review server
Browse files

drm/msm/sde: handle VBIF programming before/after secure-ui session



When secure-ui-misr feature is enabled, program the OT limits
and QOS for the xin-clients allowed during secure-ui session
and halt the other xin-clients while entering the session.
Unhalt the xin-clients while coming out of the session.
xin-clients to be halted/allowed are defined in the target
specific catalog.

Change-Id: I8b50eef7bfdf627c0f5288cb0fd64885e491eef0
Signed-off-by: default avatarVeera Sundaram Sankaran <veeras@codeaurora.org>
parent 27cdcfbd
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -937,6 +937,8 @@ struct sde_perf_cfg {
 * @sui_misr_supported  indicate if secure-ui-misr is supported
 * @sui_allow_xin_mask  mask of all the xin-clients allowed during secure-ui
 *                         when secure-ui-misr feature is supported
 * @sui_block_xin_mask  mask of all the xin-clients to be blocked during
 *                         secure-ui when secure-ui-misr feature is supported
 */
struct sde_mdss_cfg {
	u32 hwversion;
@@ -969,6 +971,7 @@ struct sde_mdss_cfg {

	bool sui_misr_supported;
	u32 sui_allow_xin_mask;
	u32 sui_block_xin_mask;

	bool has_hdr;
	u32 mdss_count;
+39 −0
Original line number Diff line number Diff line
@@ -412,6 +412,36 @@ static void sde_kms_wait_for_frame_transfer_complete(struct msm_kms *kms,
	}
}

static int _sde_kms_secure_ctrl_xin_clients(struct sde_kms *sde_kms,
			struct drm_crtc *crtc, bool enable)
{
	struct drm_device *dev;
	struct msm_drm_private *priv;
	struct sde_mdss_cfg *sde_cfg;
	struct drm_plane *plane;
	int i, ret;

	dev = sde_kms->dev;
	priv = dev->dev_private;
	sde_cfg = sde_kms->catalog;

	ret = sde_vbif_halt_xin_mask(sde_kms,
			sde_cfg->sui_block_xin_mask, enable);
	if (ret) {
		SDE_ERROR("failed to halt some xin-clients, ret:%d\n", ret);
		return ret;
	}

	if (enable) {
		for (i = 0; i < priv->num_planes; i++) {
			plane = priv->planes[i];
			sde_plane_secure_ctrl_xin_client(plane, crtc);
		}
	}

	return 0;
}

/**
 * _sde_kms_scm_call - makes secure channel call to switch the VMIDs
 * @vimd: switch the stage 2 translation to this VMID.
@@ -560,9 +590,18 @@ static int _sde_kms_sui_misr_ctrl(struct sde_kms *sde_kms,
			SDE_ERROR("failed to enable resource, ret:%d\n", ret);
			return ret;
		}

		sde_crtc_misr_setup(crtc, true, 1);

		ret = _sde_kms_secure_ctrl_xin_clients(sde_kms, crtc, true);
		if (ret) {
			sde_power_resource_enable(&priv->phandle,
					sde_kms->core_client, false);
			return ret;
		}

	} else {
		_sde_kms_secure_ctrl_xin_clients(sde_kms, crtc, false);
		sde_crtc_misr_setup(crtc, false, 0);
		sde_power_resource_enable(&priv->phandle,
					sde_kms->core_client, false);
+18 −0
Original line number Diff line number Diff line
@@ -2577,6 +2577,24 @@ void sde_plane_halt_requests(struct drm_plane *plane, bool enable)
				psde->xin_halt_forced_clk, enable);
}

void sde_plane_secure_ctrl_xin_client(struct drm_plane *plane,
				struct drm_crtc *crtc)
{
	struct sde_plane *psde;

	if (!plane || !crtc) {
		SDE_ERROR("invalid plane/crtc\n");
		return;
	}
	psde = to_sde_plane(plane);

	/* do all VBIF programming for the sec-ui allowed SSPP */
	if (psde->features & BIT(SDE_SSPP_SEC_UI_ALLOWED)) {
		_sde_plane_set_qos_remap(plane);
		_sde_plane_set_ot_limit(plane, crtc);
	}
}

int sde_plane_reset_rot(struct drm_plane *plane, struct drm_plane_state *state)
{
	struct sde_plane *psde;
+9 −0
Original line number Diff line number Diff line
@@ -341,4 +341,13 @@ int sde_plane_helper_reset_custom_properties(struct drm_plane *plane,
 */
bool sde_plane_is_sec_ui_allowed(struct drm_plane *plane);

/* sde_plane_secure_ctrl_xin_client - controls the VBIF programming of
 *	the xin-client before the secure-ui session. Programs the QOS
 *	and OT limits in VBIF for the sec-ui allowed xins
 * @plane: Pointer to DRM plane object
 * @crtc: Pointer to DRM CRTC state object
 */
void sde_plane_secure_ctrl_xin_client(struct drm_plane *plane,
		struct drm_crtc *crtc);

#endif /* _SDE_PLANE_H_ */
+48 −0
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@
#include "sde_hw_vbif.h"
#include "sde_trace.h"

#define MAX_XIN_CLIENT	16

/**
 * _sde_vbif_wait_for_xin_halt - wait for the xin to halt
 * @vbif:	Pointer to hardware vbif driver
@@ -478,6 +480,52 @@ void sde_vbif_init_memtypes(struct sde_kms *sde_kms)
	}
}

int sde_vbif_halt_xin_mask(struct sde_kms *sde_kms, u32 xin_id_mask,
				bool halt)
{
	struct sde_hw_vbif *vbif;
	int i = 0, status, rc;

	if (!sde_kms) {
		SDE_ERROR("invalid argument\n");
		return -EINVAL;
	}

	vbif = sde_kms->hw_vbif[VBIF_RT];

	if (!vbif->ops.get_halt_ctrl || !vbif->ops.set_halt_ctrl)
		return 0;

	SDE_EVT32(xin_id_mask, halt);

	for (i = 0; i < MAX_XIN_CLIENT; i++) {
		if (xin_id_mask & BIT(i)) {
			/* unhalt the xin-clients */
			if (!halt) {
				vbif->ops.set_halt_ctrl(vbif, i, false);
				continue;
			}

			status = vbif->ops.get_halt_ctrl(vbif, i);
			if (status)
				continue;

			/* halt xin-clients and wait for ack */
			vbif->ops.set_halt_ctrl(vbif, i, true);

			rc = _sde_vbif_wait_for_xin_halt(vbif, i);
			if (rc) {
				SDE_ERROR("xin_halt failed for xin:%d, rc:%d\n",
					i, rc);
				SDE_EVT32(xin_id_mask, i, rc, SDE_EVTLOG_ERROR);
				return rc;
			}
		}
	}

	return 0;
}

#ifdef CONFIG_DEBUG_FS
void sde_debugfs_vbif_destroy(struct sde_kms *sde_kms)
{
Loading