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

Commit 7cbe2a5c authored by Hareesh Gundu's avatar Hareesh Gundu Committed by Gerrit - the friendly Code Review server
Browse files

msm: kgsl: Get pages from the system incase mempool is not configured



Allow driver to get pages from the system incase mempool configuration
is not defined from the device tree. This will fix kgsl driver probe
failure for without gpu mempool configuration devices.

Change-Id: I3142a5d2e13ed40f643c91594fd868c37620ce54
Signed-off-by: default avatarHareesh Gundu <hareeshg@codeaurora.org>
Signed-off-by: default avatarArchana Sriram <apsrir@codeaurora.org>
parent edc93d8c
Loading
Loading
Loading
Loading
+23 −1
Original line number Diff line number Diff line
/* Copyright (c) 2016, The Linux Foundation. All rights reserved.
/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -303,6 +303,27 @@ int kgsl_pool_alloc_page(int *page_size, struct page **pages,
	if ((pages == NULL) || pages_len < (*page_size >> PAGE_SHIFT))
		return -EINVAL;

	/* If the pool is not configured get pages from the system */
	if (!kgsl_num_pools) {
		gfp_t gfp_mask = kgsl_gfp_mask(order);

		page = alloc_pages(gfp_mask, order);
		if (page == NULL) {
			/* Retry with lower order pages */
			if (order > 0) {
				size_t size = PAGE_SIZE << --order;
				*page_size = kgsl_get_page_size(size,
							ilog2(size));
				*align = ilog2(*page_size);
				return -EAGAIN;

			} else
				return -ENOMEM;
		}
		_kgsl_pool_zero_page(page, order);
		goto done;
	}

	pool = _kgsl_get_pool_from_order(order);
	if (pool == NULL)
		return -EINVAL;
@@ -338,6 +359,7 @@ int kgsl_pool_alloc_page(int *page_size, struct page **pages,
		_kgsl_pool_zero_page(page, order);
	}

done:
	for (j = 0; j < (*page_size >> PAGE_SHIFT); j++) {
		p = nth_page(page, j);
		pages[pcount] = p;
+2 −21
Original line number Diff line number Diff line
@@ -613,25 +613,6 @@ int kgsl_cache_range_op(struct kgsl_memdesc *memdesc, uint64_t offset,
}
EXPORT_SYMBOL(kgsl_cache_range_op);

#ifndef CONFIG_ALLOC_BUFFERS_IN_4K_CHUNKS
static inline int get_page_size(size_t size, unsigned int align)
{
	if (align >= ilog2(SZ_1M) && size >= SZ_1M)
		return SZ_1M;
	else if (align >= ilog2(SZ_64K) && size >= SZ_64K)
		return SZ_64K;
	else if (align >= ilog2(SZ_8K) && size >= SZ_8K)
		return SZ_8K;
	else
		return PAGE_SIZE;
}
#else
static inline int get_page_size(size_t size, unsigned int align)
{
	return PAGE_SIZE;
}
#endif

int
kgsl_sharedmem_page_alloc_user(struct kgsl_memdesc *memdesc,
			uint64_t size)
@@ -648,7 +629,7 @@ kgsl_sharedmem_page_alloc_user(struct kgsl_memdesc *memdesc,

	align = (memdesc->flags & KGSL_MEMALIGN_MASK) >> KGSL_MEMALIGN_SHIFT;

	page_size = get_page_size(size, align);
	page_size = kgsl_get_page_size(size, align);

	/*
	 * The alignment cannot be less than the intended page size - it can be
@@ -719,7 +700,7 @@ kgsl_sharedmem_page_alloc_user(struct kgsl_memdesc *memdesc,
		memdesc->page_count += page_count;

		/* Get the needed page size for the next iteration */
		page_size = get_page_size(len, align);
		page_size = kgsl_get_page_size(len, align);
	}

	/* Call to the hypervisor to lock any secure buffer allocations */
+26 −0
Original line number Diff line number Diff line
@@ -346,4 +346,30 @@ static inline void kgsl_free_sgt(struct sg_table *sgt)
	}
}

/**
 * kgsl_get_page_size() - Get supported pagesize
 * @size: Size of the page
 * @align: Desired alignment of the size
 *
 * Return supported pagesize
 */
#ifndef CONFIG_ALLOC_BUFFERS_IN_4K_CHUNKS
static inline int kgsl_get_page_size(size_t size, unsigned int align)
{
	if (align >= ilog2(SZ_1M) && size >= SZ_1M)
		return SZ_1M;
	else if (align >= ilog2(SZ_64K) && size >= SZ_64K)
		return SZ_64K;
	else if (align >= ilog2(SZ_8K) && size >= SZ_8K)
		return SZ_8K;
	else
		return PAGE_SIZE;
}
#else
static inline int kgsl_get_page_size(size_t size, unsigned int align)
{
	return PAGE_SIZE;
}
#endif

#endif /* __KGSL_SHAREDMEM_H */