gpu: ion: Don't call virt_to_page on addresses from dma_alloc
The virtual address returned from dma_alloc_coherent is not
guaranteed to be valid for use with virt_to_phys. Use the physical
address returned from dma_alloc to calculate the page. This
technically may not work if the handle returned is not a physical
address but this is an acceptable workaround until patches are
integrated into the dma subsystem to generate sg_tables.
Change-Id: I658eab86bf69cc23adabe8ac059a8a960e41bdfd
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
diff --git a/drivers/gpu/ion/ion_cma_secure_heap.c b/drivers/gpu/ion/ion_cma_secure_heap.c
index d622a51..e1b3eea 100644
--- a/drivers/gpu/ion/ion_cma_secure_heap.c
+++ b/drivers/gpu/ion/ion_cma_secure_heap.c
@@ -52,7 +52,7 @@
int ion_secure_cma_get_sgtable(struct device *dev, struct sg_table *sgt,
void *cpu_addr, dma_addr_t handle, size_t size)
{
- struct page *page = virt_to_page(cpu_addr);
+ struct page *page = phys_to_page(handle);
int ret;
ret = sg_alloc_table(sgt, 1, GFP_KERNEL);