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

Commit 7145a2a5 authored by Harsh Vardhan Dwivedi's avatar Harsh Vardhan Dwivedi
Browse files

msm: kgsl: Detect gpu mem entry collisions when using MAP_FIXED flag



When using MAP_FIXED flags, detect collisions with previous gpu memory
entries. Fail mmap() if previous gpu entries exist.

Change-Id: I09f456677e7fc81b8bdf1b2f5724569220c7e897
Signed-off-by: default avatarHarsh Vardhan Dwivedi <hdwivedi@codeaurora.org>
parent 4411c560
Loading
Loading
Loading
Loading
+6 −9
Original line number Diff line number Diff line
@@ -3530,14 +3530,11 @@ kgsl_get_unmapped_area(struct file *file, unsigned long addr,
	if (ret)
		return ret;

	if (!kgsl_memdesc_use_cpu_map(&entry->memdesc) || (flags & MAP_FIXED)) {
	/*
		 * If we're not going to use the same mapping on the gpu,
		 * any address is fine.
		 * For MAP_FIXED, hopefully the caller knows what they're doing,
		 * but we may fail in mmap() if there is already something
		 * at the virtual address chosen.
	 * If we're not going to use CPU map feature, get an ordinary mapping
	 * with nothing more to be done.
	 */
	if (!kgsl_memdesc_use_cpu_map(&entry->memdesc)) {
		ret = get_unmapped_area(NULL, addr, len, pgoff, flags);
		goto put;
	}
@@ -3629,7 +3626,7 @@ kgsl_get_unmapped_area(struct file *file, unsigned long addr,
		} else {
			ret = -EBUSY;
		}
	} while (mmap_range_valid(addr, len));
	} while (!(flags & MAP_FIXED) && mmap_range_valid(addr, len));

	if (IS_ERR_VALUE(ret))
		KGSL_MEM_ERR(device,