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

Commit 40950548 authored by Kuogee Hsieh's avatar Kuogee Hsieh Committed by Gerrit - the friendly Code Review server
Browse files

msm: mdss: add iommu mutex for dsi dcs command send



DSI use iommu buffer to store dcs commands to be sent
to panel. Iommu mutex is need to ensure iommu will not
be dettached during send.

CRs-Fixed: 796660
Change-Id: I9904dc001a3923d545b2d01aac5c0cdc9e0cdeb6
Signed-off-by: default avatarKuogee Hsieh <khsieh@codeaurora.org>
parent 6dd43dee
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -320,6 +320,8 @@ struct mdss_util_intf {
	int (*get_iommu_domain)(u32 type);
	int (*iommu_attached)(void);
	int (*iommu_ctrl)(int enable);
	void (*iommu_lock)(void);
	void (*iommu_unlock)(void);
	void (*bus_bandwidth_ctrl)(int enable);
	int (*bus_scale_set_quota)(int client, u64 ab_quota, u64 ib_quota);
	struct mdss_panel_cfg* (*panel_intf_type)(int intf_val);
+6 −1
Original line number Diff line number Diff line
@@ -1714,12 +1714,14 @@ static int mdss_dsi_cmd_dma_tx(struct mdss_dsi_ctrl_pdata *ctrl,
	ctrl->dma_size = ALIGN(tp->len, SZ_4K);


	ctrl->mdss_util->iommu_lock();
	if (ctrl->mdss_util->iommu_attached()) {
		int ret = msm_iommu_map_contig_buffer(tp->dmap,
				ctrl->mdss_util->get_iommu_domain(domain), 0,
				ctrl->dma_size, SZ_4K, 0, &(ctrl->dma_addr));
		if (IS_ERR_VALUE(ret)) {
			pr_err("unable to map dma memory to iommu(%d)\n", ret);
			ctrl->mdss_util->iommu_unlock();
			return -ENOMEM;
		}
		ctrl->dmap_iommu_map = true;
@@ -1808,6 +1810,7 @@ static int mdss_dsi_cmd_dma_tx(struct mdss_dsi_ctrl_pdata *ctrl,
	ctrl->dma_addr = 0;
	ctrl->dma_size = 0;
end:
	ctrl->mdss_util->iommu_unlock();
	return ret;
}

@@ -2059,6 +2062,7 @@ int mdss_dsi_cmdlist_commit(struct mdss_dsi_ctrl_pdata *ctrl, int from_mdp)
	struct dcs_cmd_req *req;
	struct mdss_panel_info *pinfo;
	struct mdss_rect *roi = NULL;
	bool use_iommu = false;
	int ret = -EINVAL;
	int rc = 0;
	u32 ctrl_rev;
@@ -2135,6 +2139,7 @@ int mdss_dsi_cmdlist_commit(struct mdss_dsi_ctrl_pdata *ctrl, int from_mdp)
				mutex_unlock(&ctrl->cmd_mutex);
				return rc;
			}
			use_iommu = true;
		}
	}

@@ -2152,7 +2157,7 @@ int mdss_dsi_cmdlist_commit(struct mdss_dsi_ctrl_pdata *ctrl, int from_mdp)
		mdss_dsi_set_tx_power_mode(1, &ctrl->panel_data);

	if (!(req->flags & CMD_REQ_DMA_TPG)) {
		if (ctrl->mdss_util->iommu_ctrl)
		if (use_iommu)
			ctrl->mdss_util->iommu_ctrl(0);

		if (ctrl->mdss_util->bus_scale_set_quota)
+21 −4
Original line number Diff line number Diff line
@@ -93,6 +93,7 @@ static DEFINE_SPINLOCK(mdp_lock);
static DEFINE_MUTEX(mdp_clk_lock);
static DEFINE_MUTEX(bus_bw_lock);
static DEFINE_MUTEX(mdp_iommu_lock);
static DEFINE_MUTEX(mdp_iommu_ref_cnt_lock);
static DEFINE_MUTEX(mdp_fs_idle_pc_lock);

static struct mdss_panel_intf pan_types[] = {
@@ -662,12 +663,22 @@ static inline int is_mdss_iommu_attached(void)
	return mdss_res->iommu_attached;
}

void mdss_iommu_lock(void)
{
	mutex_lock(&mdp_iommu_lock);
}

void mdss_iommu_unlock(void)
{
	mutex_unlock(&mdp_iommu_lock);
}

int mdss_iommu_ctrl(int enable)
{
	struct mdss_data_type *mdata = mdss_mdp_get_mdata();
	int rc = 0;

	mutex_lock(&mdp_iommu_lock);
	mutex_lock(&mdp_iommu_ref_cnt_lock);
	pr_debug("%pS: enable %d mdata->iommu_ref_cnt %d\n",
		__builtin_return_address(0), enable, mdata->iommu_ref_cnt);

@@ -688,7 +699,7 @@ int mdss_iommu_ctrl(int enable)
			pr_err("unbalanced iommu ref\n");
		}
	}
	mutex_unlock(&mdp_iommu_lock);
	mutex_unlock(&mdp_iommu_ref_cnt_lock);

	if (IS_ERR_VALUE(rc))
		return rc;
@@ -977,6 +988,7 @@ static int mdss_iommu_attach(struct mdss_data_type *mdata)

	MDSS_XLOG(mdata->iommu_attached);

	mutex_lock(&mdp_iommu_lock);
	if (mdata->iommu_attached) {
		pr_debug("mdp iommu already attached\n");
		goto end;
@@ -1005,6 +1017,7 @@ static int mdss_iommu_attach(struct mdss_data_type *mdata)

	mdata->iommu_attached = true;
end:
	mutex_unlock(&mdp_iommu_lock);
	return rc;
}

@@ -1016,9 +1029,10 @@ static int mdss_iommu_dettach(struct mdss_data_type *mdata)

	MDSS_XLOG(mdata->iommu_attached);

	mutex_lock(&mdp_iommu_lock);
	if (!mdata->iommu_attached) {
		pr_debug("mdp iommu already dettached\n");
		return 0;
		goto end;
	}

	for (i = 0; i < MDSS_IOMMU_MAX_DOMAIN; i++) {
@@ -1034,7 +1048,8 @@ static int mdss_iommu_dettach(struct mdss_data_type *mdata)
	}

	mdata->iommu_attached = false;

end:
	mutex_unlock(&mdp_iommu_lock);
	return 0;
}

@@ -1514,6 +1529,8 @@ static int mdss_mdp_probe(struct platform_device *pdev)

	mdss_res->mdss_util->get_iommu_domain = mdss_get_iommu_domain;
	mdss_res->mdss_util->iommu_attached = is_mdss_iommu_attached;
	mdss_res->mdss_util->iommu_lock = mdss_iommu_lock;
	mdss_res->mdss_util->iommu_unlock = mdss_iommu_unlock;
	mdss_res->mdss_util->iommu_ctrl = mdss_iommu_ctrl;
	mdss_res->mdss_util->bus_scale_set_quota = mdss_bus_scale_set_quota;
	mdss_res->mdss_util->bus_bandwidth_ctrl = mdss_bus_bandwidth_ctrl;