mirror of
https://github.com/followmsi/android_kernel_google_msm.git
synced 2024-11-06 23:17:41 +00:00
gpu: ion: Check for release/request functions before calling
Not all heaps will implement the release/request callbacks. Check those function pointers are valid before calling. Change-Id: I848e31495e45c7eaa4497b82be590d291d77980a Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
This commit is contained in:
parent
3f40f8db92
commit
7c5b6e0ac9
1 changed files with 14 additions and 7 deletions
|
@ -147,7 +147,8 @@ void *ion_carveout_heap_map_kernel(struct ion_heap *heap,
|
|||
container_of(heap, struct ion_carveout_heap, heap);
|
||||
|
||||
if (atomic_inc_return(&carveout_heap->map_count) == 1)
|
||||
carveout_heap->request_region(carveout_heap->bus_id);
|
||||
if (carveout_heap->request_region)
|
||||
carveout_heap->request_region(carveout_heap->bus_id);
|
||||
|
||||
if (ION_IS_CACHED(buffer->flags))
|
||||
return ioremap_cached(buffer->priv_phys, buffer->size);
|
||||
|
@ -165,7 +166,8 @@ void ion_carveout_heap_unmap_kernel(struct ion_heap *heap,
|
|||
buffer->vaddr = NULL;
|
||||
|
||||
if (atomic_dec_and_test(&carveout_heap->map_count))
|
||||
carveout_heap->release_region(carveout_heap->bus_id);
|
||||
if (carveout_heap->release_region)
|
||||
carveout_heap->release_region(carveout_heap->bus_id);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -177,7 +179,8 @@ int ion_carveout_heap_map_user(struct ion_heap *heap, struct ion_buffer *buffer,
|
|||
container_of(heap, struct ion_carveout_heap, heap);
|
||||
|
||||
if (atomic_inc_return(&carveout_heap->map_count) == 1)
|
||||
carveout_heap->request_region(carveout_heap->bus_id);
|
||||
if (carveout_heap->request_region)
|
||||
carveout_heap->request_region(carveout_heap->bus_id);
|
||||
|
||||
if (ION_IS_CACHED(buffer->flags))
|
||||
return remap_pfn_range(vma, vma->vm_start,
|
||||
|
@ -198,7 +201,8 @@ void ion_carveout_heap_unmap_user(struct ion_heap *heap,
|
|||
container_of(heap, struct ion_carveout_heap, heap);
|
||||
|
||||
if (atomic_dec_and_test(&carveout_heap->map_count))
|
||||
carveout_heap->release_region(carveout_heap->bus_id);
|
||||
if (carveout_heap->release_region)
|
||||
carveout_heap->release_region(carveout_heap->bus_id);
|
||||
}
|
||||
|
||||
int ion_carveout_cache_ops(struct ion_heap *heap, struct ion_buffer *buffer,
|
||||
|
@ -387,9 +391,12 @@ struct ion_heap *ion_carveout_heap_create(struct ion_platform_heap *heap_data)
|
|||
carveout_heap->heap.type = ION_HEAP_TYPE_CARVEOUT;
|
||||
carveout_heap->allocated_bytes = 0;
|
||||
carveout_heap->total_size = heap_data->size;
|
||||
carveout_heap->bus_id = heap_data->setup_region();
|
||||
carveout_heap->request_region = heap_data->request_region;
|
||||
carveout_heap->release_region = heap_data->release_region;
|
||||
if (heap_data->setup_region)
|
||||
carveout_heap->bus_id = heap_data->setup_region();
|
||||
if (heap_data->request_region)
|
||||
carveout_heap->request_region = heap_data->request_region;
|
||||
if (heap_data->release_region)
|
||||
carveout_heap->release_region = heap_data->release_region;
|
||||
|
||||
return &carveout_heap->heap;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue