drm/msm/sde: add plane property to expose secure-ui support
Add a property in plane to indicate the user-mode if
the SSPP supports secure-ui layers. This is set, based
on the target specific capability controlled by the
secure-ui-misr feature. Target specific allowed xin-mask
can be specified in the catalog. Add validation code
in crtc to allow only secure-ui allowed sspp to be staged
during secure-ui commit.
Change-Id: I0ff00b0e039c7c393c2197e95287a3027742e047
Signed-off-by: Veera Sundaram Sankaran <veeras@codeaurora.org>
diff --git a/drivers/gpu/drm/msm/sde/sde_crtc.c b/drivers/gpu/drm/msm/sde/sde_crtc.c
index 3a23fd9..b549307 100644
--- a/drivers/gpu/drm/msm/sde/sde_crtc.c
+++ b/drivers/gpu/drm/msm/sde/sde_crtc.c
@@ -4375,6 +4375,7 @@
struct drm_crtc_state *state, struct plane_state pstates[],
int cnt)
{
+ struct drm_plane *plane;
struct drm_encoder *encoder;
struct sde_crtc_state *cstate;
struct sde_crtc *sde_crtc;
@@ -4420,8 +4421,25 @@
return -EINVAL;
}
- /* only one blending stage is allowed in sec_crtc */
+ /*
+ * - only one blending stage is allowed in sec_crtc
+ * - validate if pipe is allowed for sec-ui updates
+ */
for (i = 1; i < cnt; i++) {
+ if (!pstates[i].drm_pstate
+ || !pstates[i].drm_pstate->plane) {
+ SDE_ERROR("crtc%d: invalid pstate at i:%d\n",
+ crtc->base.id, i);
+ return -EINVAL;
+ }
+ plane = pstates[i].drm_pstate->plane;
+
+ if (!sde_plane_is_sec_ui_allowed(plane)) {
+ SDE_ERROR("crtc%d: sec-ui not allowed in p%d\n",
+ crtc->base.id, plane->base.id);
+ return -EINVAL;
+ }
+
if (pstates[i].stage != pstates[i-1].stage) {
SDE_ERROR(
"crtc%d: invalid blend stages %d:%d, %d:%d\n",
diff --git a/drivers/gpu/drm/msm/sde/sde_hw_catalog.c b/drivers/gpu/drm/msm/sde/sde_hw_catalog.c
index ea39dcd..e908b47 100644
--- a/drivers/gpu/drm/msm/sde/sde_hw_catalog.c
+++ b/drivers/gpu/drm/msm/sde/sde_hw_catalog.c
@@ -3276,6 +3276,18 @@
max_vert_deci = max(max_vert_deci,
sde_cfg->sspp[i].sblk->maxvdeciexp);
}
+
+ /*
+ * set sec-ui allowed SSPP feature flag based on allowed
+ * xin-mask if sec-ui-misr feature is enabled;
+ * otherwise allow for all SSPP
+ */
+ if (!sde_cfg->sui_misr_supported
+ || (sde_cfg->sui_misr_supported
+ && (sde_cfg->sui_allow_xin_mask
+ & BIT(sde_cfg->sspp[i].xin_id))))
+ set_bit(SDE_SSPP_SEC_UI_ALLOWED,
+ &sde_cfg->sspp[i].features);
}
/* this should be updated based on HW rev in future */
diff --git a/drivers/gpu/drm/msm/sde/sde_hw_catalog.h b/drivers/gpu/drm/msm/sde/sde_hw_catalog.h
index 0cb14d1..be44acc 100644
--- a/drivers/gpu/drm/msm/sde/sde_hw_catalog.h
+++ b/drivers/gpu/drm/msm/sde/sde_hw_catalog.h
@@ -120,6 +120,7 @@
* @SDE_SSPP_TS_PREFILL Supports prefill with traffic shaper
* @SDE_SSPP_TS_PREFILL_REC1 Supports prefill with traffic shaper multirec
* @SDE_SSPP_CDP Supports client driven prefetch
+ * @SDE_SSPP_SEC_UI_ALLOWED Allows secure-ui layers
* @SDE_SSPP_MAX maximum value
*/
enum {
@@ -143,6 +144,7 @@
SDE_SSPP_TS_PREFILL,
SDE_SSPP_TS_PREFILL_REC1,
SDE_SSPP_CDP,
+ SDE_SSPP_SEC_UI_ALLOWED,
SDE_SSPP_MAX
};
@@ -933,6 +935,8 @@
* @vbif_qos_nlvl number of vbif QoS priority level
* @ts_prefill_rev prefill traffic shaper feature revision
* @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
*/
struct sde_mdss_cfg {
u32 hwversion;
@@ -964,6 +968,7 @@
u32 ts_prefill_rev;
bool sui_misr_supported;
+ u32 sui_allow_xin_mask;
bool has_hdr;
u32 mdss_count;
diff --git a/drivers/gpu/drm/msm/sde/sde_plane.c b/drivers/gpu/drm/msm/sde/sde_plane.c
index 4c281666..aa2cacc 100644
--- a/drivers/gpu/drm/msm/sde/sde_plane.c
+++ b/drivers/gpu/drm/msm/sde/sde_plane.c
@@ -204,6 +204,18 @@
state->crtc->state->enable;
}
+bool sde_plane_is_sec_ui_allowed(struct drm_plane *plane)
+{
+ struct sde_plane *psde;
+
+ if (!plane)
+ return false;
+
+ psde = to_sde_plane(plane);
+
+ return (psde->features & BIT(SDE_SSPP_SEC_UI_ALLOWED));
+}
+
/**
* _sde_plane_calc_fill_level - calculate fill level of the given source format
* @plane: Pointer to drm plane
@@ -4370,6 +4382,8 @@
psde->pipe_sblk->maxvdeciexp);
sde_kms_info_add_keyint(info, "max_per_pipe_bw",
psde->pipe_sblk->max_per_pipe_bw * 1000LL);
+ if (psde->features & BIT(SDE_SSPP_SEC_UI_ALLOWED))
+ sde_kms_info_add_keyint(info, "sec_ui_allowed", 1);
msm_property_set_blob(&psde->property_info, &psde->blob_info,
info->data, SDE_KMS_INFO_DATALEN(info),
PLANE_PROP_INFO);
diff --git a/drivers/gpu/drm/msm/sde/sde_plane.h b/drivers/gpu/drm/msm/sde/sde_plane.h
index ad58097..19b7548 100644
--- a/drivers/gpu/drm/msm/sde/sde_plane.h
+++ b/drivers/gpu/drm/msm/sde/sde_plane.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
* Copyright (C) 2013 Red Hat
* Author: Rob Clark <robdclark@gmail.com>
*
@@ -334,4 +334,11 @@
int sde_plane_helper_reset_custom_properties(struct drm_plane *plane,
struct drm_plane_state *plane_state);
+/**
+ * sde_plane_is_sec_ui_allowed - indicates if the sspp allows secure-ui layers
+ * @plane: Pointer to DRM plane object
+ * Returns: true if allowed; false otherwise
+ */
+bool sde_plane_is_sec_ui_allowed(struct drm_plane *plane);
+
#endif /* _SDE_PLANE_H_ */