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

Commit fc667d11 authored by Dhaval Patel's avatar Dhaval Patel Committed by Gerrit - the friendly Code Review server
Browse files

msm: mdss: handle secure display state for MDP



Secure display state is MDP hardware state instead of
individual interface state. All interfaces should push
only secure content data when MDP hardware is in secure state.
All non-secure content should be rejected to avoid XPU
violation. DSI hardware should also avoid DCS command
communication in this state to avoid non-secure VBIF access.

CRs-fixed: 686451
Change-Id: I3beb6c24361e3c42e18107d2a2ebebafc5da1b52
Signed-off-by: default avatarDhaval Patel <pdhaval@codeaurora.org>
parent 2049a6cf
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -135,6 +135,7 @@ struct mdss_data_type {
	bool has_panic_ctrl;
	u32 wfd_mode;
	u32 has_no_lut_read;
	atomic_t sd_client_count;
	u8 has_wb_ad;
	u8 has_non_scalar_rgb;
	bool has_src_split;
@@ -271,4 +272,12 @@ static inline int mdss_get_iommu_domain(u32 type)

	return mdss_res->iommu_map[type].domain_idx;
}

static inline int mdss_get_sd_client_cnt(void)
{
	if (!mdss_res)
		return 0;
	else
		return atomic_read(&mdss_res->sd_client_count);
}
#endif /* MDSS_H */
+3 −0
Original line number Diff line number Diff line
@@ -1320,6 +1320,9 @@ int mdss_dsi_cmdlist_commit(struct mdss_dsi_ctrl_pdata *ctrl, int from_mdp)
	int ret = -EINVAL;
	int rc = 0;

	if (mdss_get_sd_client_cnt())
		return -EPERM;

	if (from_mdp)	/* from mdp kickoff */
		mutex_lock(&ctrl->cmd_mutex);

+24 −0
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@
#include <linux/msm_iommu_domains.h>
#include <linux/msm-bus.h>
#include <linux/msm-bus-board.h>
#include <soc/qcom/scm.h>

#include "mdss.h"
#include "mdss_fb.h"
@@ -79,6 +80,8 @@ struct msm_mdp_interface mdp5 = {
#define IB_QUOTA 800000000
#define AB_QUOTA 800000000

#define MEM_PROTECT_SD_CTRL 0xF

static DEFINE_SPINLOCK(mdp_lock);
static DEFINE_MUTEX(mdp_clk_lock);
static DEFINE_MUTEX(bus_bw_lock);
@@ -1490,6 +1493,7 @@ static int mdss_mdp_probe(struct platform_device *pdev)
	platform_set_drvdata(pdev, mdata);
	mdss_res = mdata;
	mutex_init(&mdata->reg_lock);
	atomic_set(&mdata->sd_client_count, 0);

	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mdp_phys");
	if (!res) {
@@ -2953,6 +2957,26 @@ int mdss_mdp_footswitch_ctrl_idle_pc(int on, struct device *dev)
	return 0;
}

int mdss_mdp_secure_display_ctrl(unsigned int enable)
{
	struct sd_ctrl_req {
		unsigned int enable;
	} __attribute__ ((__packed__)) request;
	unsigned int resp = -1;
	int ret = 0;

	request.enable = enable;

	ret = scm_call(SCM_SVC_MP, MEM_PROTECT_SD_CTRL,
		&request, sizeof(request), &resp, sizeof(resp));
	pr_debug("scm_call MEM_PROTECT_SD_CTRL(%u): ret=%d, resp=%x",
				enable, ret, resp);
	if (ret)
		return ret;

	return resp;
}

static inline int mdss_mdp_suspend_sub(struct mdss_data_type *mdata)
{
	mdata->suspend_fs_ena = mdata->fs_ena;
+10 −0
Original line number Diff line number Diff line
@@ -576,6 +576,15 @@ static inline struct clk *mdss_mdp_get_clk(u32 clk_idx)
	return NULL;
}

static inline void mdss_update_sd_client(struct mdss_data_type *mdata,
							bool status)
{
	if (status)
		atomic_inc(&mdata->sd_client_count);
	else
		atomic_add_unless(&mdss_res->sd_client_count, -1, 0);
}

irqreturn_t mdss_mdp_isr(int irq, void *ptr);
int mdss_iommu_attach(struct mdss_data_type *mdata);
int mdss_iommu_dettach(struct mdss_data_type *mdata);
@@ -597,6 +606,7 @@ unsigned long mdss_mdp_get_clk_rate(u32 clk_idx);
int mdss_mdp_vsync_clk_enable(int enable);
void mdss_mdp_clk_ctrl(int enable);
struct mdss_data_type *mdss_mdp_get_mdata(void);
int mdss_mdp_secure_display_ctrl(unsigned int enable);

int mdss_mdp_overlay_init(struct msm_fb_data_type *mfd);
int mdss_mdp_overlay_req_check(struct msm_fb_data_type *mfd,
+12 −30
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@
#include <linux/memblock.h>
#include <linux/sort.h>
#include <linux/sw_sync.h>
#include <soc/qcom/scm.h>

#include <linux/msm_iommu_domains.h>
#include <soc/qcom/event_timer.h>
@@ -44,14 +43,8 @@
#define IS_RIGHT_MIXER_OV(flags, dst_x, left_lm_w)	\
	((flags & MDSS_MDP_RIGHT_MIXER) || (dst_x >= left_lm_w))

#define MEM_PROTECT_SD_CTRL 0xF

#define OVERLAY_MAX 10

struct sd_ctrl_req {
	unsigned int enable;
} __attribute__ ((__packed__));

static atomic_t ov_active_panels = ATOMIC_INIT(0);
static int mdss_mdp_overlay_free_fb_pipe(struct msm_fb_data_type *mfd);
static int mdss_mdp_overlay_fb_parse_dt(struct msm_fb_data_type *mfd);
@@ -118,25 +111,6 @@ static inline bool __is_more_decimation_doable(struct mdss_mdp_pipe *pipe)
		return true;
}

static int mdss_mdp_overlay_sd_ctrl(struct msm_fb_data_type *mfd,
					unsigned int enable)
{
	struct sd_ctrl_req request;
	unsigned int resp = -1;
	int ret = 0;

	request.enable = enable;

	ret = scm_call(SCM_SVC_MP, MEM_PROTECT_SD_CTRL,
		&request, sizeof(request), &resp, sizeof(resp));
	pr_debug("scm_call MEM_PROTECT_SD_CTRL(%u): ret=%d, resp=%x",
				enable, ret, resp);
	if (ret)
		return ret;

	return resp;
}

static struct mdss_mdp_pipe *__overlay_find_pipe(
		struct msm_fb_data_type *mfd, u32 ndx)
{
@@ -1257,7 +1231,7 @@ static int __overlay_queue_pipes(struct msm_fb_data_type *mfd)
		 * When secure display is enabled, if there is a non secure
		 * display pipe, skip that
		 */
		if ((mdp5_data->sd_enabled) &&
		if (mdss_get_sd_client_cnt() &&
			!(pipe->flags & MDP_SECURE_DISPLAY_OVERLAY_SESSION)) {
			pr_warn("Non secure pipe during secure display: %u: %08X, skip\n",
					pipe->num, pipe->flags);
@@ -1370,9 +1344,14 @@ int mdss_mdp_overlay_kickoff(struct msm_fb_data_type *mfd,
	 * secure display session
	 */
	if (!sd_in_pipe && mdp5_data->sd_enabled) {
		if (0 == mdss_mdp_overlay_sd_ctrl(mfd, 0))
		/* disable the secure display on last client */
		if (mdss_get_sd_client_cnt() == 1)
			ret = mdss_mdp_secure_display_ctrl(0);
		if (!ret) {
			mdss_update_sd_client(mdp5_data->mdata, false);
			mdp5_data->sd_enabled = 0;
		}
	}

	if (!ctl->shared_lock)
		mdss_mdp_ctl_notify(ctl, MDP_NOTIFY_FRAME_BEGIN);
@@ -1434,9 +1413,12 @@ int mdss_mdp_overlay_kickoff(struct msm_fb_data_type *mfd,

	if (ret == 0) {
		if (!mdp5_data->sd_enabled && sd_in_pipe) {
			ret = mdss_mdp_overlay_sd_ctrl(mfd, 1);
			if (ret == 0)
			if (!mdss_get_sd_client_cnt())
				ret = mdss_mdp_secure_display_ctrl(1);
			if (!ret) {
				mdp5_data->sd_enabled = 1;
				mdss_update_sd_client(mdp5_data->mdata, true);
			}
		}
	}