staging: ion : ion_cma_heap: fix bug for highmem cma
PATCH 1/1 staging: ion : ion_cma_heap: fix bug for highmem cma
when cma is located in highmem, virt_to_page will not work the right way, use pfn_to_page instead.
Signed-off-by Zeng Tao <[email protected]>
--- drivers/staging/android/ion/ion_cma_heap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/android/ion/ion_cma_heap.c +1 -1
@@ -47,7 +47,7 @@ struct ion_cma_buffer_info {static int ion_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 =pfn_to_page (handle >>PAGE_SHIFT );int ret; ret =sg_alloc_table (sgt,1 ,GFP_KERNEL );
Signature · 1 line
1.9.1
Quoted 13 lines · Zeng Tao
when cma is located in highmem,
virt_to_pagewill not work the right way, usepfn_to_pageinstead.Signed-off-by Zeng Tao <[email protected]>--- drivers/staging/android/ion/ion_cma_heap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/android/ion/ion_cma_heap.c +0
-0
drivers/staging/android/ion/ion_cma_heap.c struct ion_cma_buffer_info { · line 50
Quoted 5 lines
drivers/staging/android/ion/ion_cma_heap.c +1
-1@@ -47,7 +47,7 @@ struct ion_cma_buffer_info {static int ion_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 =pfn_to_page (handle >>PAGE_SHIFT );
There's a comment right above this that notes this function could be replaced with dma_common_get_sgtable when it's available. That function is now present in drivers/base/dma-mapping.c although it has the same bug. I'd suggest fixing the bug in dma_common_get_sgtable and switching Ion to use that function instead.
drivers/staging/android/ion/ion_cma_heap.c struct ion_cma_buffer_info { · line 53
Quoted 4 lines
drivers/staging/android/ion/ion_cma_heap.c +0
-0int ret; ret =sg_alloc_table (sgt,1 ,GFP_KERNEL );
Thanks,
Laura
Signature · 3 lines
Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project