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

Commit d1740fff authored by Puranam V G Tejaswi's avatar Puranam V G Tejaswi
Browse files

msm: kgsl: Populate a valid pointer to page as vmf->page



The array of pages can have a valid pointer to page when checked under
the memdesc spinlock, but as soon as the lock is released, it can
become null in an attempt to reclaim the page. It is to be noted that
only the pointer in the array of pages became null and the actual page
would still be valid, as refcount on the page is incremented within the
lock which would fail the attempt to reclaim. So make sure that a valid
pointer to page is assigned to vmf->page. Also, avoid unnecessary
setting of the skip reclaim flag.

Change-Id: Iffde9d7a76ef4f46a1421bec226c1a828b05c63f
Signed-off-by: default avatarPuranam V G Tejaswi <pvgtejas@codeaurora.org>
parent 13cde485
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -58,8 +58,6 @@ static int kgsl_memdesc_get_reclaimed_pages(struct kgsl_mem_entry *entry)
		return ret;

	memdesc->priv &= ~KGSL_MEMDESC_RECLAIMED;
	/* Allow reclaim of memdesc again in case vmfault disabled it */
	memdesc->priv &= ~KGSL_MEMDESC_SKIP_RECLAIM;

	return 0;
}
+6 −11
Original line number Diff line number Diff line
@@ -484,17 +484,12 @@ static int kgsl_page_alloc_vmfault(struct kgsl_memdesc *memdesc,
	pgoff = offset >> PAGE_SHIFT;

	spin_lock(&memdesc->lock);
	if (memdesc->pages[pgoff])
		get_page(memdesc->pages[pgoff]);
	if (memdesc->pages[pgoff]) {
		page = memdesc->pages[pgoff];
		get_page(page);
	}
	else {
		/*
		 * We are here because the page is reclaimed.
		 * Mark the memdesc as non reclaimable to make
		 * sure that the page obtained here does not
		 * get reclaimed back leaving us with invalid
		 * page.
		 */
		memdesc->priv |= KGSL_MEMDESC_SKIP_RECLAIM;
		/* We are here because page was reclaimed */
		spin_unlock(&memdesc->lock);

		page = shmem_read_mapping_page_gfp(
@@ -518,7 +513,7 @@ static int kgsl_page_alloc_vmfault(struct kgsl_memdesc *memdesc,
	}
	spin_unlock(&memdesc->lock);

	vmf->page = memdesc->pages[pgoff];
	vmf->page = page;

	atomic_long_add(PAGE_SIZE, &memdesc->mapsize);