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

Commit b0a8796a authored by Jordan Crouse's avatar Jordan Crouse Committed by Tarun Karra
Browse files

msm: kgsl: Don't allocate SVM addresses inside the global range



If MAP_FIXED is specified when mmap()ing SVM buffers we try to honor that
request even if it falls outside of the defined SVM range.  The notable
exception is the global buffer range. Attempt no landings there.

Change-Id: Ic0dedbada933691e28a2f9b2c0fe5e25ba69e5be
Signed-off-by: default avatarJordan Crouse <jcrouse@codeaurora.org>
parent 0d6c8dbc
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -1884,6 +1884,10 @@ static uint64_t kgsl_iommu_find_svm_region(struct kgsl_pagetable *pagetable,
	return addr;
}

#define ADDR_IN_GLOBAL(_a) \
	(((_a) >= KGSL_MMU_GLOBAL_MEM_BASE) && \
	 ((_a) < (KGSL_MMU_GLOBAL_MEM_BASE + KGSL_MMU_GLOBAL_MEM_SIZE)))

static int kgsl_iommu_set_svm_region(struct kgsl_pagetable *pagetable,
		uint64_t gpuaddr, uint64_t size)
{
@@ -1891,6 +1895,10 @@ static int kgsl_iommu_set_svm_region(struct kgsl_pagetable *pagetable,
	struct kgsl_iommu_pt *pt = pagetable->priv;
	struct rb_node *node;

	/* Make sure the requested address doesn't fall in the global range */
	if (ADDR_IN_GLOBAL(gpuaddr) || ADDR_IN_GLOBAL(gpuaddr + size))
		return -ENOMEM;

	spin_lock(&pagetable->lock);
	node = pt->rbtree.rb_node;