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

Commit a3c08076 authored by Liam Mark's avatar Liam Mark Committed by Saravana Kannan
Browse files

ANDROID: GKI: dma-coherent: Expose device base address and size



Allow clients to be able to determine the device base address and
size of a dma coherent memory region.

This is required for clients that want to explicitly manage that memory.

Change-Id: I3e5b721d9d318526422ec26995cc1af7b7f04077
Signed-off-by: default avatarLiam Mark <lmark@codeaurora.org>
(cherry picked from commit 63585739d1881d987c0c0f06199cf749ad62c6d1)
Bug: 155522481
Signed-off-by: default avatarMark Salyzyn <salyzyn@google.com>
[saravanak conflict resolution due to file move and Change EXPORT_SYMBOL
to EXPORT_SYMBOL_GPL]
Signed-off-by: default avatarSaravana Kannan <saravanak@google.com>
parent 4ac42c44
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -771,6 +771,10 @@ int dma_declare_coherent_memory(struct device *dev, phys_addr_t phys_addr,
void dma_release_declared_memory(struct device *dev);
void *dma_mark_declared_memory_occupied(struct device *dev,
					dma_addr_t device_addr, size_t size);
dma_addr_t dma_get_device_base(struct device *dev,
			       struct dma_coherent_mem *mem);
unsigned long dma_get_size(struct dma_coherent_mem *mem);

#else
static inline int
dma_declare_coherent_memory(struct device *dev, phys_addr_t phys_addr,
@@ -790,6 +794,17 @@ dma_mark_declared_memory_occupied(struct device *dev,
{
	return ERR_PTR(-EBUSY);
}
static inline dma_addr_t
dma_get_device_base(struct device *dev, struct dma_coherent_mem *mem)
{
	return 0;
}

static inline unsigned long dma_get_size(struct dma_coherent_mem *mem)
{
	return 0;
}

#endif /* CONFIG_HAVE_GENERIC_DMA_COHERENT */

#ifdef CONFIG_HAS_DMA
+9 −2
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ static inline struct dma_coherent_mem *dev_get_coherent_memory(struct device *de
	return NULL;
}

static inline dma_addr_t dma_get_device_base(struct device *dev,
dma_addr_t dma_get_device_base(struct device *dev,
			       struct dma_coherent_mem *mem)
{
	if (mem->use_dev_dma_pfn_offset)
@@ -37,6 +37,13 @@ static inline dma_addr_t dma_get_device_base(struct device *dev,
	else
		return mem->device_base;
}
EXPORT_SYMBOL_GPL(dma_get_device_base);

unsigned long dma_get_size(struct dma_coherent_mem *mem)
{
	return mem->size << PAGE_SHIFT;
}
EXPORT_SYMBOL_GPL(dma_get_size);

static int dma_init_coherent_memory(
	phys_addr_t phys_addr, dma_addr_t device_addr, size_t size, int flags,