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

Commit 72ef8b3d authored by Amit Kushwaha's avatar Amit Kushwaha Committed by Archana Sriram
Browse files

msm: kgsl: Change default pagetable creation sequence



In the existing code, due to dynamic allocation of SMMU
context banks, gfx3d_secure is allotted CB 0 followed by
gfx3d_user with CB 1. This affects per process pagetable
functionality which uses GPU path which updates TTBR0 of
SMMU CB0 by default. This poses issue for targets which
do not have support for Dynamic GPU Aperture programming
in TZ. Move defaultpagetable creation for user context to
kgsl_iommu_init, prior to securepagetable initialization
so that gfx3d_user is allotted CB 0 and gfx3d_secure with
CB 1.

Change-Id: Idf203502281eb2738032425c0132d325fc412094
Signed-off-by: default avatarAmit Kushwaha <kushwaha@codeaurora.org>
Signed-off-by: default avatarArchana Sriram <apsrir@codeaurora.org>
parent 17d718ca
Loading
Loading
Loading
Loading
+27 −15
Original line number Diff line number Diff line
@@ -135,10 +135,12 @@ static int kgsl_iommu_map_globals(struct kgsl_pagetable *pagetable)
			int ret = kgsl_mmu_map(pagetable,
					global_pt_entries[i].memdesc);

			if (ret)
			if (ret) {
				kgsl_iommu_unmap_globals(pagetable);
				return ret;
			}
		}
	}

	return 0;
}
@@ -1011,6 +1013,8 @@ static void kgsl_iommu_destroy_pagetable(struct kgsl_pagetable *pt)
	} else {
		ctx = &iommu->ctx[KGSL_IOMMU_CONTEXT_USER];
		kgsl_iommu_unmap_globals(pt);
		if (pt->name == KGSL_MMU_GLOBAL_PT)
			mmu->globalpt_mapped = false;
	}

	if (iommu_pt->domain) {
@@ -1244,8 +1248,6 @@ static int _init_global_pt(struct kgsl_mmu *mmu, struct kgsl_pagetable *pt)
		goto done;
	}

	ret = kgsl_iommu_map_globals(pt);

done:
	if (ret)
		_free_pt(ctx, pt);
@@ -1529,6 +1531,18 @@ static int kgsl_iommu_init(struct kgsl_mmu *mmu)
	kgsl_setup_qdss_desc(device);
	kgsl_setup_qtimer_desc(device);

	mmu->defaultpagetable = kgsl_mmu_getpagetable(mmu,
				KGSL_MMU_GLOBAL_PT);
	/* if we don't have a default pagetable, nothing will work */
	if (IS_ERR(mmu->defaultpagetable)) {
		status = PTR_ERR(mmu->defaultpagetable);
		mmu->defaultpagetable = NULL;
		goto done;
	} else if (mmu->defaultpagetable == NULL) {
		status = -ENOMEM;
		goto done;
	}

	if (!mmu->secured)
		goto done;

@@ -1558,18 +1572,8 @@ static int _setup_user_context(struct kgsl_mmu *mmu)
	struct kgsl_iommu_pt *iommu_pt = NULL;
	unsigned int  sctlr_val;

	if (mmu->defaultpagetable == NULL) {
		mmu->defaultpagetable = kgsl_mmu_getpagetable(mmu,
				KGSL_MMU_GLOBAL_PT);
		/* if we don't have a default pagetable, nothing will work */
		if (IS_ERR(mmu->defaultpagetable)) {
			ret = PTR_ERR(mmu->defaultpagetable);
			mmu->defaultpagetable = NULL;
			return ret;
		} else if (mmu->defaultpagetable == NULL) {
	if (mmu->defaultpagetable == NULL)
		return -ENOMEM;
		}
	}

	iommu_pt = mmu->defaultpagetable->priv;
	if (iommu_pt == NULL)
@@ -1678,6 +1682,14 @@ static int kgsl_iommu_start(struct kgsl_mmu *mmu)
		wmb();
	}

	if (mmu->defaultpagetable != NULL && !mmu->globalpt_mapped) {
		status = kgsl_iommu_map_globals(mmu->defaultpagetable);
		if (status)
			return status;

		mmu->globalpt_mapped = true;
	}

	/* Make sure the hardware is programmed to the default pagetable */
	kgsl_iommu_set_pt(mmu, mmu->defaultpagetable);
	kgsl_iommu_disable_clk(mmu);
+2 −0
Original line number Diff line number Diff line
@@ -146,6 +146,7 @@ struct kgsl_mmu_pt_ops {
 * @defaultpagetable: Default pagetable object for the MMU
 * @securepagetable: Default secure pagetable object for the MMU
 * @mmu_ops: Function pointers for the MMU sub-type
 * @globalpt_mapped: True if global pagetable entries mapped
 * @secured: True if the MMU needs to be secured
 * @feature: Static list of MMU features
 * @secure_aligned_mask: Mask that secure buffers need to be aligned to
@@ -158,6 +159,7 @@ struct kgsl_mmu {
	struct kgsl_pagetable *defaultpagetable;
	struct kgsl_pagetable *securepagetable;
	const struct kgsl_mmu_ops *mmu_ops;
	bool globalpt_mapped;
	bool secured;
	unsigned long features;
	unsigned int secure_align_mask;