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

Commit 6d62aa31 authored by Pawan Kumar's avatar Pawan Kumar
Browse files

msm: mdss: add iommu attach in bus bandwidth control request



Add mdss_iommu_attach in mdss_bus_bandwidth_ctrl to
attach iommu on bus bandwidth enable request.
mdss_iommu_attach/mdss_iommu_dettach can happen in
separate thread, which may lead to a race condition
where attach/detach may happen at same time. Add lock
to properly synchronize the iommu attach/detach to
fix race condition.

Change-Id: I45c8ef1fa1fa1c2da9c6c3702bd007856e469b9d
Signed-off-by: default avatarPawan Kumar <pavaku@codeaurora.org>
parent af83c6c7
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -196,6 +196,8 @@ struct mdss_data_type {
	bool mixer_switched;
	struct mdss_panel_cfg pan_cfg;
	struct mdss_prefill_data prefill_data;

	int handoff_pending;
};
extern struct mdss_data_type *mdss_res;

+11 −0
Original line number Diff line number Diff line
@@ -82,6 +82,7 @@ struct msm_mdp_interface mdp5 = {
static DEFINE_SPINLOCK(mdp_lock);
static DEFINE_MUTEX(mdp_clk_lock);
static DEFINE_MUTEX(bus_bw_lock);
static DEFINE_MUTEX(mdp_iommu_lock);

static struct mdss_panel_intf pan_types[] = {
	{"dsi", MDSS_PANEL_INTF_DSI},
@@ -694,6 +695,8 @@ void mdss_bus_bandwidth_ctrl(int enable)
			pm_runtime_get_sync(&mdata->pdev->dev);
			msm_bus_scale_client_update_request(
				mdata->bus_hdl, mdata->curr_bw_uc_idx);
			if (!mdata->handoff_pending)
				mdss_iommu_attach(mdata);
		}
	}

@@ -824,8 +827,10 @@ int mdss_iommu_attach(struct mdss_data_type *mdata)
	struct mdss_iommu_map_type *iomap;
	int i;

	mutex_lock(&mdp_iommu_lock);
	if (mdata->iommu_attached) {
		pr_debug("mdp iommu already attached\n");
		mutex_unlock(&mdp_iommu_lock);
		return 0;
	}

@@ -842,6 +847,7 @@ int mdss_iommu_attach(struct mdss_data_type *mdata)
	}

	mdata->iommu_attached = true;
	mutex_unlock(&mdp_iommu_lock);

	return 0;
}
@@ -852,8 +858,10 @@ int mdss_iommu_dettach(struct mdss_data_type *mdata)
	struct mdss_iommu_map_type *iomap;
	int i;

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

@@ -870,6 +878,7 @@ int mdss_iommu_dettach(struct mdss_data_type *mdata)
	}

	mdata->iommu_attached = false;
	mutex_unlock(&mdp_iommu_lock);

	return 0;
}
@@ -1089,6 +1098,7 @@ void mdss_mdp_footswitch_ctrl_splash(int on)
	if (mdata != NULL) {
		if (on) {
			pr_debug("Enable MDP FS for splash.\n");
			mdata->handoff_pending = true;
			ret = regulator_enable(mdata->fs);
			if (ret)
				pr_err("Footswitch failed to enable\n");
@@ -1096,6 +1106,7 @@ void mdss_mdp_footswitch_ctrl_splash(int on)
		} else {
			pr_debug("Disable MDP FS for splash.\n");
			regulator_disable(mdata->fs);
			mdata->handoff_pending = false;
		}
	} else {
		pr_warn("mdss mdata not initialized\n");
+1 −1
Original line number Diff line number Diff line
@@ -2616,8 +2616,8 @@ int mdss_panel_register_done(struct mdss_panel_data *pdata)
	 * increasing ref_cnt to help balance clocks once done.
	 */
	if (pdata->panel_info.cont_splash_enabled) {
		mdss_mdp_clk_ctrl(MDP_BLOCK_POWER_ON, false);
		mdss_mdp_footswitch_ctrl_splash(1);
		mdss_mdp_clk_ctrl(MDP_BLOCK_POWER_ON, false);
	}
	return 0;
}