|
@@ -140,9 +140,18 @@ static struct ion_heap_ops chunk_heap_ops = {
|
|
|
struct ion_heap *ion_chunk_heap_create(struct ion_platform_heap *heap_data)
|
|
|
{
|
|
|
struct ion_chunk_heap *chunk_heap;
|
|
|
- struct vm_struct *vm_struct;
|
|
|
- pgprot_t pgprot = pgprot_writecombine(PAGE_KERNEL);
|
|
|
- int i, ret;
|
|
|
+ int ret;
|
|
|
+ struct page *page;
|
|
|
+ size_t size;
|
|
|
+
|
|
|
+ page = pfn_to_page(PFN_DOWN(heap_data->base));
|
|
|
+ size = heap_data->size;
|
|
|
+
|
|
|
+ ion_pages_sync_for_device(NULL, page, size, DMA_BIDIRECTIONAL);
|
|
|
+
|
|
|
+ ret = ion_heap_pages_zero(page, size, pgprot_writecombine(PAGE_KERNEL));
|
|
|
+ if (ret)
|
|
|
+ return ERR_PTR(ret);
|
|
|
|
|
|
chunk_heap = kzalloc(sizeof(struct ion_chunk_heap), GFP_KERNEL);
|
|
|
if (!chunk_heap)
|
|
@@ -159,26 +168,6 @@ struct ion_heap *ion_chunk_heap_create(struct ion_platform_heap *heap_data)
|
|
|
chunk_heap->size = heap_data->size;
|
|
|
chunk_heap->allocated = 0;
|
|
|
|
|
|
- vm_struct = get_vm_area(PAGE_SIZE, VM_ALLOC);
|
|
|
- if (!vm_struct) {
|
|
|
- ret = -ENOMEM;
|
|
|
- goto error;
|
|
|
- }
|
|
|
- for (i = 0; i < chunk_heap->size; i += PAGE_SIZE) {
|
|
|
- struct page *page = pfn_to_page(PFN_DOWN(chunk_heap->base + i));
|
|
|
- struct page **pages = &page;
|
|
|
-
|
|
|
- ret = map_vm_area(vm_struct, pgprot, &pages);
|
|
|
- if (ret)
|
|
|
- goto error_map_vm_area;
|
|
|
- memset(vm_struct->addr, 0, PAGE_SIZE);
|
|
|
- unmap_kernel_range((unsigned long)vm_struct->addr, PAGE_SIZE);
|
|
|
- }
|
|
|
- free_vm_area(vm_struct);
|
|
|
-
|
|
|
- ion_pages_sync_for_device(NULL, pfn_to_page(PFN_DOWN(heap_data->base)),
|
|
|
- heap_data->size, DMA_BIDIRECTIONAL);
|
|
|
-
|
|
|
gen_pool_add(chunk_heap->pool, chunk_heap->base, heap_data->size, -1);
|
|
|
chunk_heap->heap.ops = &chunk_heap_ops;
|
|
|
chunk_heap->heap.type = ION_HEAP_TYPE_CHUNK;
|
|
@@ -188,10 +177,6 @@ struct ion_heap *ion_chunk_heap_create(struct ion_platform_heap *heap_data)
|
|
|
|
|
|
return &chunk_heap->heap;
|
|
|
|
|
|
-error_map_vm_area:
|
|
|
- free_vm_area(vm_struct);
|
|
|
-error:
|
|
|
- gen_pool_destroy(chunk_heap->pool);
|
|
|
error_gen_pool_create:
|
|
|
kfree(chunk_heap);
|
|
|
return ERR_PTR(ret);
|