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

Commit 5ee3f7ca authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "drm/msm: Use dma_addr_t to manage iova" into dev/msm-3.18-drm_kms

parents 333e5fe6 1d684daf
Loading
Loading
Loading
Loading
+5 −9
Original line number Diff line number Diff line
@@ -43,13 +43,13 @@ static void msm_iommu_detach(struct msm_mmu *mmu, const char **names, int cnt)
	iommu_detach_device(iommu->domain, mmu->dev);
}

static int msm_iommu_map(struct msm_mmu *mmu, uint32_t iova,
static int msm_iommu_map(struct msm_mmu *mmu, dma_addr_t iova,
		struct sg_table *sgt, unsigned len, int prot)
{
	struct msm_iommu *iommu = to_msm_iommu(mmu);
	struct iommu_domain *domain = iommu->domain;
	struct scatterlist *sg;
	unsigned int da = iova;
	dma_addr_t da = iova;
	unsigned int i, j;
	int ret;

@@ -57,11 +57,9 @@ static int msm_iommu_map(struct msm_mmu *mmu, uint32_t iova,
		return -EINVAL;

	for_each_sg(sgt->sgl, sg, sgt->nents, i) {
		u32 pa = sg_phys(sg) - sg->offset;
		dma_addr_t pa = sg_phys(sg) - sg->offset;
		size_t bytes = sg->length + sg->offset;

		VERB("map[%d]: %08x %08x(%zx)", i, iova, pa, bytes);

		ret = iommu_map(domain, da, pa, bytes, prot);
		if (ret)
			goto fail;
@@ -82,13 +80,13 @@ fail:
	return ret;
}

static int msm_iommu_unmap(struct msm_mmu *mmu, uint32_t iova,
static int msm_iommu_unmap(struct msm_mmu *mmu, dma_addr_t iova,
		struct sg_table *sgt, unsigned len)
{
	struct msm_iommu *iommu = to_msm_iommu(mmu);
	struct iommu_domain *domain = iommu->domain;
	struct scatterlist *sg;
	unsigned int da = iova;
	dma_addr_t da = iova;
	int i;

	for_each_sg(sgt->sgl, sg, sgt->nents, i) {
@@ -99,8 +97,6 @@ static int msm_iommu_unmap(struct msm_mmu *mmu, uint32_t iova,
		if (unmapped < bytes)
			return unmapped;

		VERB("unmap[%d]: %08x(%zx)", i, iova, bytes);

		BUG_ON(!PAGE_ALIGNED(bytes));

		da += bytes;
+2 −2
Original line number Diff line number Diff line
@@ -35,9 +35,9 @@ enum msm_mmu_domain_type {
struct msm_mmu_funcs {
	int (*attach)(struct msm_mmu *mmu, const char **names, int cnt);
	void (*detach)(struct msm_mmu *mmu, const char **names, int cnt);
	int (*map)(struct msm_mmu *mmu, uint32_t iova, struct sg_table *sgt,
	int (*map)(struct msm_mmu *mmu, dma_addr_t iova, struct sg_table *sgt,
			unsigned len, int prot);
	int (*unmap)(struct msm_mmu *mmu, uint32_t iova, struct sg_table *sgt,
	int (*unmap)(struct msm_mmu *mmu, dma_addr_t iova, struct sg_table *sgt,
			unsigned len);
	int (*map_sg)(struct msm_mmu *mmu, struct sg_table *sgt,
			enum dma_data_direction dir);
+7 −11
Original line number Diff line number Diff line
@@ -96,16 +96,17 @@ static void msm_smmu_detach(struct msm_mmu *mmu, const char **names, int cnt)
	DBG("detaching");
}

static int msm_smmu_map(struct msm_mmu *mmu, uint32_t iova,
static int msm_smmu_map(struct msm_mmu *mmu, dma_addr_t iova,
		struct sg_table *sgt, unsigned len, int prot)
{
	struct msm_smmu *smmu = to_msm_smmu(mmu);
	struct msm_smmu_client *client = msm_smmu_to_client(smmu);
	struct iommu_domain *domain;
	struct scatterlist *sg;
	unsigned int da = iova;
	dma_addr_t da = iova;
	unsigned int i, j;
	int ret;
	size_t bytes;

	if (!client)
		return -ENODEV;
@@ -115,11 +116,9 @@ static int msm_smmu_map(struct msm_mmu *mmu, uint32_t iova,
		return -EINVAL;

	for_each_sg(sgt->sgl, sg, sgt->nents, i) {
		u32 pa = sg_phys(sg) - sg->offset;
		dma_addr_t pa = sg_phys(sg) - sg->offset;
		size_t bytes = sg->length + sg->offset;

		VERB("map[%d]: %08x %08x(%zx)", i, iova, pa, bytes);

		ret = iommu_map(domain, da, pa, bytes, prot);
		if (ret)
			goto fail;
@@ -133,8 +132,7 @@ fail:
	da = iova;

	for_each_sg(sgt->sgl, sg, i, j) {
		size_t bytes = sg->length + sg->offset;

		bytes = sg->length + sg->offset;
		iommu_unmap(domain, da, bytes);
		da += bytes;
	}
@@ -164,14 +162,14 @@ static void msm_smmu_unmap_sg(struct msm_mmu *mmu, struct sg_table *sgt,
	dma_unmap_sg(client->dev, sgt->sgl, sgt->nents, dir);
}

static int msm_smmu_unmap(struct msm_mmu *mmu, uint32_t iova,
static int msm_smmu_unmap(struct msm_mmu *mmu, dma_addr_t iova,
		struct sg_table *sgt, unsigned len)
{
	struct msm_smmu *smmu = to_msm_smmu(mmu);
	struct msm_smmu_client *client = msm_smmu_to_client(smmu);
	struct iommu_domain *domain;
	struct scatterlist *sg;
	unsigned int da = iova;
	dma_addr_t da = iova;
	int i;

	if (!client)
@@ -189,8 +187,6 @@ static int msm_smmu_unmap(struct msm_mmu *mmu, uint32_t iova,
		if (unmapped < bytes)
			return unmapped;

		VERB("unmap[%d]: %08x(%zx)", i, iova, bytes);

		WARN_ON(!PAGE_ALIGNED(bytes));

		da += bytes;