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

Commit 3ba19ae9 authored by Jordan Crouse's avatar Jordan Crouse Committed by Harshdeep Dhatt
Browse files

msm: kgsl: Use a token address for memstore



The user maps the memstore using the GPU address of the shadow memory.
Unfortunately, mmap() only uses a unsigned long which means that 32 bit
applications can handle when TTBR1 is enabled and the memstore is in
very high memory.

Instead of passing the real GPU address pass a dummy 32 bit value and use
that to identify the memstore instead.

Change-Id: Ic0dedbaddd6efda305953b20cfaa4a597020bff9
Signed-off-by: default avatarJordan Crouse <jcrouse@codeaurora.org>
parent 5bebd12b
Loading
Loading
Loading
Loading
+2 −6
Original line number Diff line number Diff line
@@ -2303,12 +2303,8 @@ static int adreno_prop_device_shadow(struct kgsl_device *device,
	struct kgsl_shadowprop shadowprop = { 0 };

	if (device->memstore->hostptr) {
		/*
		 * NOTE: with mmu enabled, gpuaddr doesn't mean
		 * anything to mmap().
		 */

		shadowprop.gpuaddr =  (unsigned long)device->memstore->gpuaddr;
		/* Pass a dummy address to identify memstore */
		shadowprop.gpuaddr =  KGSL_MEMSTORE_TOKEN_ADDRESS;
		shadowprop.size = device->memstore->size;

		shadowprop.flags = KGSL_FLAGS_INITIALIZED |
+2 −8
Original line number Diff line number Diff line
@@ -51,15 +51,9 @@ int adreno_getproperty_compat(struct kgsl_device *device,
			}
			memset(&shadowprop, 0, sizeof(shadowprop));
			if (device->memstore->hostptr) {
				/*
				 * NOTE: with mmu enabled, gpuaddr doesn't mean
				 * anything to mmap().
				 * NOTE: shadowprop.gpuaddr is uint32
				 * (because legacy) and the memstore gpuaddr is
				 * 64 bit. Cast the memstore gpuaddr to uint32.
				 */
				/* Give a token address to identify memstore */
				shadowprop.gpuaddr = (unsigned int)
					device->memstore->gpuaddr;
					KGSL_MEMSTORE_TOKEN_ADDRESS;
				shadowprop.size =
					(unsigned int) device->memstore->size;
				/*
+2 −2
Original line number Diff line number Diff line
@@ -4553,7 +4553,7 @@ kgsl_get_unmapped_area(struct file *file, unsigned long addr,
	struct kgsl_device *device = dev_priv->device;
	struct kgsl_mem_entry *entry = NULL;

	if (vma_offset == (unsigned long) device->memstore->gpuaddr)
	if (vma_offset == (unsigned long) KGSL_MEMSTORE_TOKEN_ADDRESS)
		return get_unmapped_area(NULL, addr, len, pgoff, flags);

	val = get_mmap_entry(private, &entry, pgoff, len);
@@ -4597,7 +4597,7 @@ static int kgsl_mmap(struct file *file, struct vm_area_struct *vma)

	/* Handle leagacy behavior for memstore */

	if (vma_offset == (unsigned long) device->memstore->gpuaddr)
	if (vma_offset == (unsigned long) KGSL_MEMSTORE_TOKEN_ADDRESS)
		return kgsl_mmap_memstore(file, device, vma);

	/*
+10 −0
Original line number Diff line number Diff line
@@ -15,6 +15,16 @@
#define KGSL_IOMMU_GLOBAL_MEM_BASE32	0xf8000000
#define KGSL_IOMMU_GLOBAL_MEM_BASE64	0xfc000000

/*
 * This is a dummy token address that we use to identify memstore when the user
 * wants to map it. mmap() uses a unsigned long for the offset so we need a 32
 * bit value that works with all sized apps. We chose a value that was purposely
 * unmapped so if you increase the global memory size make sure it doesn't
 * conflict
 */

#define KGSL_MEMSTORE_TOKEN_ADDRESS 0xfff00000

#define KGSL_IOMMU_GLOBAL_MEM_BASE(__mmu)	\
	(test_bit(KGSL_MMU_64BIT, &(__mmu)->features) ? \
		KGSL_IOMMU_GLOBAL_MEM_BASE64 : KGSL_IOMMU_GLOBAL_MEM_BASE32)