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

Commit 732d2f5f authored by Kuogee Hsieh's avatar Kuogee Hsieh Committed by Anusha Koduru
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>
Signed-off-by: default avatarPadmanabhan Komanduru <pkomandu@codeaurora.org>
parent 09deb55f
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -479,6 +479,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
@@ -1823,11 +1823,13 @@ static int mdss_dsi_cmd_dma_tx(struct mdss_dsi_ctrl_pdata *ctrl,
	len = ALIGN(tp->len, 4);
	ctrl->dma_size = ALIGN(tp->len, SZ_4K);

	ctrl->mdss_util->iommu_lock();
	if (ctrl->mdss_util->iommu_attached()) {
		ret = mdss_smmu_dsi_map_buffer(tp->dmap, domain, ctrl->dma_size,
			&(ctrl->dma_addr), tp->start, DMA_TO_DEVICE);
		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;
@@ -1932,6 +1934,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;
}

@@ -2276,6 +2279,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;
	bool hs_req = false;
@@ -2358,6 +2362,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;
		}
	}

@@ -2376,7 +2381,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);

		(void)mdss_dsi_bus_bandwidth_vote(ctrl->shared_data, false);
+3 −3
Original line number Diff line number Diff line
@@ -91,7 +91,7 @@ struct msm_mdp_interface mdp5 = {

static DEFINE_SPINLOCK(mdp_lock);
static DEFINE_MUTEX(mdp_clk_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[] = {
@@ -794,7 +794,7 @@ 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 ref_cnt:%d attach:%d hoff:%d\n",
		__builtin_return_address(0), enable, mdata->iommu_ref_cnt,
		mdata->iommu_attached, mdata->handoff_pending);
@@ -816,7 +816,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;
+14 −0
Original line number Diff line number Diff line
@@ -34,6 +34,18 @@
#include "mdss_mdp.h"
#include "mdss_smmu.h"

static DEFINE_MUTEX(mdp_iommu_lock);

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

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

static int mdss_smmu_util_parse_dt_clock(struct platform_device *pdev,
		struct dss_module_power *mp)
{
@@ -469,6 +481,8 @@ int mdss_smmu_init(struct mdss_data_type *mdata, struct device *dev)
{
	mdss_smmu_device_create(dev);
	mdss_smmu_ops_init(mdata);
	mdata->mdss_util->iommu_lock = mdss_iommu_lock;
	mdata->mdss_util->iommu_unlock = mdss_iommu_unlock;
	return 0;
}