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

Commit 0e84af49 authored by Jayant Shekhar's avatar Jayant Shekhar Committed by Gerrit - the friendly Code Review server
Browse files

msm: mdss: Change IOMMU map sequence during splash cleanup



Currently PA to VA mapping is not working with existing
sequence. Correct the sequence as below:

- set DOMAIN_ATTR_EARLY_MAP  attr to 1
- attach iommu
- perform mapping
- set DOMAIN_ATTR_EARLY_MAP to 0.

Change-Id: Id9c430efde05eb6a683a41f10cbf216102d4fa23
Signed-off-by: default avatarJayant Shekhar <jshekhar@codeaurora.org>
Signed-off-by: default avatarNirmal Abraham <nabrah@codeaurora.org>
parent a0d115fe
Loading
Loading
Loading
Loading
+31 −18
Original line number Diff line number Diff line
/* Copyright (c) 2013-2015, 2017-2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 2013-2015, 2017-2019, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -135,7 +135,7 @@ static int mdss_mdp_splash_iommu_attach(struct msm_fb_data_type *mfd)
{
	struct mdss_overlay_private *mdp5_data = mfd_to_mdp5_data(mfd);
	struct mdss_data_type *mdata = mdss_mdp_get_mdata();
	int rc, ret;
	int ret;

	/*
	 * iommu dynamic attach for following conditions.
@@ -148,30 +148,45 @@ static int mdss_mdp_splash_iommu_attach(struct msm_fb_data_type *mfd)
		!mdss_mdp_iommu_dyn_attach_supported(mdp5_data->mdata) ||
		!mdp5_data->splash_mem_addr ||
		!mdp5_data->splash_mem_size) {
		pr_debug("dynamic attach is not supported\n");
		pr_err("dynamic attach is not supported\n");
		return -EPERM;
	}

	rc = mdss_smmu_map(MDSS_IOMMU_DOMAIN_UNSECURE,
				mdp5_data->splash_mem_addr,
				mdp5_data->splash_mem_addr,
				mdp5_data->splash_mem_size,
				IOMMU_READ | IOMMU_NOEXEC);
	if (rc) {
		pr_debug("iommu memory mapping failed rc=%d\n", rc);
	} else {
	/*
	 * Putting handoff pending to false to ensure smmu attach happens
	 * with early flag attribute
	 */
	mdata->handoff_pending = false;

	ret = mdss_smmu_set_attribute(MDSS_IOMMU_DOMAIN_UNSECURE, EARLY_MAP, 1);
	if (ret) {
		pr_err("mdss set attribute failed for early map\n");
		goto end;
	}

	ret = mdss_iommu_ctrl(1);
	if (IS_ERR_VALUE((unsigned long) ret)) {
		pr_err("mdss iommu attach failed\n");
			mdss_smmu_unmap(MDSS_IOMMU_DOMAIN_UNSECURE,
		goto end;
	}

	ret = mdss_smmu_map(MDSS_IOMMU_DOMAIN_UNSECURE,
				mdp5_data->splash_mem_addr,
					mdp5_data->splash_mem_size);
				mdp5_data->splash_mem_addr,
				mdp5_data->splash_mem_size,
				IOMMU_READ | IOMMU_NOEXEC);
	if (ret) {
		pr_err("iommu memory mapping failed ret=%d\n", ret);
	} else {
		pr_err("iommu map passed for PA=VA\n");
		mfd->splash_info.iommu_dynamic_attached = true;
	}
	}

	return rc;
	ret = mdss_smmu_set_attribute(MDSS_IOMMU_DOMAIN_UNSECURE, EARLY_MAP, 0);
end:
	mdata->handoff_pending = true;

	return ret;
}

static void mdss_mdp_splash_unmap_splash_mem(struct msm_fb_data_type *mfd)
@@ -179,12 +194,10 @@ static void mdss_mdp_splash_unmap_splash_mem(struct msm_fb_data_type *mfd)
	struct mdss_overlay_private *mdp5_data = mfd_to_mdp5_data(mfd);

	if (mfd->splash_info.iommu_dynamic_attached) {

		mdss_smmu_unmap(MDSS_IOMMU_DOMAIN_UNSECURE,
				mdp5_data->splash_mem_addr,
				mdp5_data->splash_mem_size);
		mdss_iommu_ctrl(0);

		mfd->splash_info.iommu_dynamic_attached = false;
	}
}
+21 −0
Original line number Diff line number Diff line
@@ -290,6 +290,27 @@ static int mdss_smmu_enable_power(struct mdss_smmu_client *mdss_smmu,
	return rc;
}

int mdss_smmu_set_attribute(int domain, int flag, int val)
{
	int rc = 0, domain_attr = 0;
	struct mdss_smmu_client *mdss_smmu = mdss_smmu_get_cb(domain);

	if (!mdss_smmu) {
		pr_err("not able to get smmu context\n");
		return -EINVAL;
	}

	if (flag == EARLY_MAP)
		domain_attr = DOMAIN_ATTR_EARLY_MAP;
	else
		goto end;

	rc = iommu_domain_set_attr(mdss_smmu->mmu_mapping->domain,
			domain_attr, &val);
end:
	return rc;
}

/*
 * mdss_smmu_attach_v2()
 *
+5 −0
Original line number Diff line number Diff line
@@ -49,6 +49,11 @@ struct mdss_smmu_private {

void mdss_smmu_register(struct device *dev);
int mdss_smmu_init(struct mdss_data_type *mdata, struct device *dev);
int mdss_smmu_set_attribute(int domain, int flag, int val);

enum smmu_attributes {
	EARLY_MAP
};

static inline int mdss_smmu_dma_data_direction(int dir)
{