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

Commit c3173590 authored by Jordan Crouse's avatar Jordan Crouse
Browse files

msm: kgsl: Restrict GPU memory object alignment to 32MB



The code was being very generous in giving the user the ability to
align GPU objects on 4GB boundaries. Cut the restriction down to
32MB which is still pretty generous but within the realm of
possiblity (especially for a 32 bit GPU).  While we are at it fix
a bug in the page_alloc code that was accidently resetting the
alignment to the alloc page size.  The alignment cannot be _less_
than the max page_alloc size but there certainly isn't any reason
why you couldn't specify a larger alignment if you so wished.

Change-Id: Ic0dedbadebd4c6fd98e3bf2f3d6d5bb924223157
Signed-off-by: default avatarJordan Crouse <jcrouse@codeaurora.org>
parent 65c7182d
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -3241,6 +3241,9 @@ static int kgsl_filter_cachemode(unsigned int flags)
}
#endif

/* The largest allowable alignment for a GPU object is 32MB */
#define KGSL_MAX_ALIGN (32 * SZ_1M)

/*
 * The common parts of kgsl_ioctl_gpumem_alloc and kgsl_ioctl_gpumem_alloc_id.
 */
@@ -3276,11 +3279,13 @@ _gpumem_alloc(struct kgsl_device_private *dev_priv,
	/* Cap the alignment bits to the highest number we can handle */

	align = (flags & KGSL_MEMALIGN_MASK) >> KGSL_MEMALIGN_SHIFT;
	if (align >= 32) {
		KGSL_CORE_ERR("Alignment too big, restricting to 2^31\n");
	if (align >= ilog2(KGSL_MAX_ALIGN)) {
		KGSL_CORE_ERR("Alignment too large; restricting to %dK\n",
			KGSL_MAX_ALIGN >> 10);

		flags &= ~KGSL_MEMALIGN_MASK;
		flags |= (31 << KGSL_MEMALIGN_SHIFT) & KGSL_MEMALIGN_MASK;
		flags |= (ilog2(KGSL_MAX_ALIGN) << KGSL_MEMALIGN_SHIFT) &
			KGSL_MEMALIGN_MASK;
	}

	flags = kgsl_filter_cachemode(flags);
+6 −2
Original line number Diff line number Diff line
@@ -574,8 +574,12 @@ _kgsl_sharedmem_page_alloc(struct kgsl_memdesc *memdesc,

	page_size = get_page_size(size, align);

	/* update align flags for what we actually use */
	if (page_size != PAGE_SIZE)
	/*
	 * The alignment cannot be less than the intended page size - it can be
	 * larger however to accomodate hardware quirks
	 */

	if (ilog2(align) < page_size)
		kgsl_memdesc_set_align(memdesc, ilog2(page_size));

	/*