cma: Add API to get the start address of a CMA region

When setting CMA up at a fixed region, it is possible for the address
to be shared between multiple subsystems. If the address is placed
dynamically, there is no mechanism to be able to get the start address
of the region. Drivers may wish to do keep track of allocations relative
to the start address so add an API to get the start region of a CMA
address.

Change-Id: If0730c64496c876d3143064d767b22b984c6dc84
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
This commit is contained in:
Laura Abbott
2013-12-10 16:07:48 -08:00
parent 301d15843b
commit 2dcd9e61f7
2 changed files with 16 additions and 0 deletions
+7
View File
@@ -447,6 +447,13 @@ static int __init cma_init_reserved_areas(void)
}
core_initcall(cma_init_reserved_areas);
phys_addr_t cma_get_base(struct device *dev)
{
struct cma *cma = dev_get_cma_area(dev);
return cma->base_pfn << PAGE_SHIFT;
}
/**
* dma_alloc_from_contiguous() - allocate pages from contiguous area
* @dev: Pointer to device for which the allocation is performed.
+9
View File
@@ -65,6 +65,9 @@ struct device;
*/
#define MAX_CMA_AREAS (1 + CONFIG_CMA_AREAS)
phys_addr_t cma_get_base(struct device *dev);
extern struct cma *dma_contiguous_def_area;
void dma_contiguous_reserve(phys_addr_t addr_limit);
@@ -129,6 +132,12 @@ bool dma_release_from_contiguous(struct device *dev, struct page *pages,
return false;
}
static inline phys_addr_t cma_get_base(struct device *dev)
{
return 0;
}
#endif
#endif