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

Commit 9ccb66aa authored by Neeti Desai's avatar Neeti Desai
Browse files

cma: Add support for cma_get_size



HLOS assumes the size of the CMA based heaps is equal to the
size specified with the "linux-contiguous-region" property.
This is not always true, and CMA might reserve more memory
to take care of alignment. This causes the secure world to
lockdown more memory than it is supposed to, thus denying
access to clients. The cma_get_size api returns the correct
size which is reserved for these heaps, thus preventing
client access issues.

CRs-Fixed: 737584
Change-Id: Idf5f3587c0a2b1a300b2102079b6796323254cc8
Signed-off-by: default avatarNeeti Desai <neetid@codeaurora.org>
parent c6297e1e
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -563,6 +563,13 @@ phys_addr_t cma_get_base(struct device *dev)
	return cma->base_pfn << PAGE_SHIFT;
}

unsigned long cma_get_size(struct device *dev)
{
	struct cma *cma = dev_get_cma_area(dev);

	return cma->count << PAGE_SHIFT;
}

static void clear_cma_bitmap(struct cma *cma, unsigned long pfn, int count)
{
	mutex_lock(&cma->lock);
+2 −1
Original line number Diff line number Diff line
@@ -66,13 +66,14 @@ static int msm_shared_heap_populate_base_and_size
	if (pnode != NULL) {
		const u32 *addr;
		u64 len;

		addr = of_get_address(pnode, 0, &len, NULL);
		if (!addr) {
			of_node_put(pnode);
			ret = -EINVAL;
			goto out;
		}
		*size = (size_t)len;
		*size = cma_get_size(priv);
		*base = cma_get_base(priv);
		of_node_put(pnode);
	} else {
+6 −0
Original line number Diff line number Diff line
@@ -67,6 +67,7 @@ struct device;


phys_addr_t cma_get_base(struct device *dev);
unsigned long cma_get_size(struct device *dev);

extern struct cma *dma_contiguous_def_area;

@@ -154,6 +155,11 @@ static inline phys_addr_t cma_get_base(struct device *dev)
	return 0;
}

static inline unsigned long cma_get_size(struct device *dev)
{
	return 0;
}

#endif

#endif