public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: ion : ion_cma_heap: fix bug for highmem cma
@ 2014-11-29  1:31 Zeng Tao
  2014-12-01 18:36 ` Laura Abbott
  0 siblings, 1 reply; 2+ messages in thread
From: Zeng Tao @ 2014-11-29  1:31 UTC (permalink / raw)
  To: gregkh, john.stultz, ccross, benjamin.gaignard, rebecca,
	fabio.estevam
  Cc: devel, linux-kernel

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 <prime.zeng@huawei.com>
---
 drivers/staging/android/ion/ion_cma_heap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/android/ion/ion_cma_heap.c b/drivers/staging/android/ion/ion_cma_heap.c
index f8cabcb..cc45fc0 100644
--- a/drivers/staging/android/ion/ion_cma_heap.c
+++ b/drivers/staging/android/ion/ion_cma_heap.c
@@ -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);
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] staging: ion : ion_cma_heap: fix bug for highmem cma
  2014-11-29  1:31 [PATCH] staging: ion : ion_cma_heap: fix bug for highmem cma Zeng Tao
@ 2014-12-01 18:36 ` Laura Abbott
  0 siblings, 0 replies; 2+ messages in thread
From: Laura Abbott @ 2014-12-01 18:36 UTC (permalink / raw)
  To: Zeng Tao, gregkh, john.stultz, ccross, benjamin.gaignard, rebecca,
	fabio.estevam
  Cc: devel, linux-kernel

On 11/28/2014 5:31 PM, Zeng Tao wrote:
> 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 <prime.zeng@huawei.com>
> ---
>   drivers/staging/android/ion/ion_cma_heap.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/android/ion/ion_cma_heap.c b/drivers/staging/android/ion/ion_cma_heap.c
> index f8cabcb..cc45fc0 100644
> --- a/drivers/staging/android/ion/ion_cma_heap.c
> +++ b/drivers/staging/android/ion/ion_cma_heap.c
> @@ -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.

>   	int ret;
>
>   	ret = sg_alloc_table(sgt, 1, GFP_KERNEL);
>

Thanks,
Laura

-- 
Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-12-01 18:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-29  1:31 [PATCH] staging: ion : ion_cma_heap: fix bug for highmem cma Zeng Tao
2014-12-01 18:36 ` Laura Abbott

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox