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

Commit 71ab5ced authored by Shrenuj Bansal's avatar Shrenuj Bansal
Browse files

msm: kgsl: Add an align mask property in the device tree



Add an alignment mask property in the DT to distinguish between
secure allocation requirements for different targets. For example,
8994 requires secure allocations to be 1M aligned, whereas
8996 has no such restriction.

Change-Id: I7d812057b4069616ca052e60b69c33df5ffdc453
Signed-off-by: default avatarShrenuj Bansal <shrenujb@codeaurora.org>
parent fecfa940
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -38,6 +38,8 @@ Optional properties:
			     When not set we use per process pagetables
	 - qcom,hyp_secure_alloc : A bool specifying if the hypervisor is used on
				   this target for secure buffer allocation
	 - qcom,secure_align_mask: A mask for determining how secure buffers need to
				   be aligned

Example:

@@ -50,6 +52,7 @@ Example:
			<&clock_mmss clk_mmss_mmagic_cfg_ahb_clk>;
		clock-names = "gpu_ahb_clk", "bimc_gfx_clk", "mmagic_ahb_clk", "mmagic_cfg_ahb_clk";
		num_cb = <2>;
		qcom,secure_align_mask = <0xfff>;
		retention;
		qcom,global_pt;

+1 −0
Original line number Diff line number Diff line
@@ -185,6 +185,7 @@
		clock-names = "mmagic_ahb_clk", "mmagic_cfg_ahb_clk", "gpu_ahb_clk",
			"gcc_mmss_bimc_gfx_clk", "gcc_bimc_gfx_clk";
		num_cb = <2>;
		qcom,secure_align_mask = <0xfff>;
		retention;

		iommu_kgsl_cb2: iommu_kgsl_cb2 {
+4 −0
Original line number Diff line number Diff line
@@ -250,6 +250,10 @@ static int kgsl_iommu_pdev_probe(struct platform_device *pdev)
	if (result)
		goto err;

	if (of_property_read_u32(pdev->dev.of_node,
			"qcom,secure_align_mask", &data->secure_align_mask))
		data->secure_align_mask = 0xfff;

	if (!data->iommu_ctx_count) {
		KGSL_CORE_ERR(
			"dt: KGSL IOMMU context bank count cannot be zero\n");
+6 −4
Original line number Diff line number Diff line
@@ -2533,6 +2533,7 @@ long kgsl_ioctl_map_user_mem(struct kgsl_device_private *dev_priv,
	struct kgsl_map_user_mem *param = data;
	struct kgsl_mem_entry *entry = NULL;
	struct kgsl_process_private *private = dev_priv->process_priv;
	struct kgsl_mmu *mmu = &dev_priv->device->mmu;
	unsigned int memtype;

	/*
@@ -2542,7 +2543,7 @@ long kgsl_ioctl_map_user_mem(struct kgsl_device_private *dev_priv,

	if (param->flags & KGSL_MEMFLAGS_SECURE) {
		/* Log message and return if context protection isn't enabled */
		if (!kgsl_mmu_is_secured(&dev_priv->device->mmu)) {
		if (!kgsl_mmu_is_secured(mmu)) {
			dev_WARN_ONCE(dev_priv->device->dev, 1,
				"Secure buffer not supported");
			return -EOPNOTSUPP;
@@ -2610,10 +2611,11 @@ long kgsl_ioctl_map_user_mem(struct kgsl_device_private *dev_priv,
		goto error;

	if ((param->flags & KGSL_MEMFLAGS_SECURE) &&
		!IS_ALIGNED(entry->memdesc.size, SZ_1M)) {
		(entry->memdesc.size & mmu->secure_align_mask)) {
			KGSL_DRV_ERR(dev_priv->device,
				"Secure buffer size %lld must be 1MB aligned",
				entry->memdesc.size);
				"Secure buffer size %lld not aligned to %x alignment",
				entry->memdesc.size,
				mmu->secure_align_mask + 1);
		result = -EINVAL;
		goto error_attach;
	}
+7 −3
Original line number Diff line number Diff line
@@ -806,6 +806,8 @@ static int _iommu_set_register_map(struct kgsl_mmu *mmu)
	/* set iommu features */
	mmu->features = data->features;

	mmu->secure_align_mask = data->secure_align_mask;

	/* set up the IOMMU register map */
	if (!data->regstart || !data->regsize) {
		KGSL_CORE_ERR("The register range for IOMMU not specified\n");
@@ -1148,10 +1150,12 @@ int _iommu_add_guard_page(struct kgsl_pagetable *pt,
		 * mapped to save 1MB of memory if CPZ is not used.
		 */
		if (kgsl_memdesc_is_secured(memdesc)) {
			unsigned int sgp_size = pt->mmu->secure_align_mask + 1;
			if (!kgsl_secure_guard_page_memdesc.physaddr) {
				if (kgsl_cma_alloc_secure(pt->mmu->device,
					&kgsl_secure_guard_page_memdesc,
					SZ_1M)) {
				if (kgsl_allocate_user(pt->mmu->device,
					&kgsl_secure_guard_page_memdesc, pt,
					sgp_size, sgp_size,
					KGSL_MEMFLAGS_SECURE)) {
					KGSL_CORE_ERR(
					"Secure guard page alloc failed\n");
					return -ENOMEM;
Loading