Loading drivers/staging/android/ion/ion_carveout_heap.c +34 −0 Original line number Diff line number Diff line Loading @@ -186,6 +186,8 @@ struct ion_sc_entry { struct list_head list; struct ion_heap *heap; u32 token; u64 base; u64 size; }; struct ion_sc_heap { Loading Loading @@ -242,9 +244,39 @@ static void ion_sc_heap_free(struct ion_buffer *buffer) kfree(table); } static int ion_secure_carveout_pm_freeze(struct ion_heap *heap) { long sz; sz = atomic_long_read(&heap->total_allocated); if (sz) { pr_err("%s: %lx bytes won't be saved across hibernation. Aborting.", __func__, sz); return -EINVAL; } return 0; } static int ion_secure_carveout_pm_restore(struct ion_heap *heap) { struct ion_sc_heap *manager; struct ion_sc_entry *child; manager = container_of(heap, struct ion_sc_heap, heap); list_for_each_entry(child, &manager->children, list) ion_hyp_assign_from_flags( child->base, child->size, child->token); return 0; } static struct ion_heap_ops ion_sc_heap_ops = { .allocate = ion_sc_heap_allocate, .free = ion_sc_heap_free, .pm = { .freeze = ion_secure_carveout_pm_freeze, .restore = ion_secure_carveout_pm_restore, } }; static int ion_sc_get_dt_token(struct ion_sc_entry *entry, Loading Loading @@ -298,6 +330,8 @@ static int ion_sc_add_child(struct ion_sc_heap *manager, heap_data.priv = dev; heap_data.base = base; heap_data.size = size; entry->base = base; entry->size = size; /* This will zero memory initially */ entry->heap = __ion_carveout_heap_create(&heap_data, false); Loading drivers/staging/android/ion/ion_cma_heap.c +17 −0 Original line number Diff line number Diff line Loading @@ -264,12 +264,29 @@ static int ion_secure_cma_map_user(struct ion_heap *mapper, return ion_heap_map_user(mapper, buffer, vma); } static int ion_secure_cma_pm_freeze(struct ion_heap *heap) { long sz; sz = atomic_long_read(&heap->total_allocated); if (sz) { pr_err("%s: %lx bytes won't be saved across hibernation. Aborting.", __func__, sz); return -EINVAL; } return 0; } static struct ion_heap_ops ion_secure_cma_ops = { .allocate = ion_secure_cma_allocate, .free = ion_secure_cma_free, .map_user = ion_secure_cma_map_user, .map_kernel = ion_secure_cma_map_kernel, .unmap_kernel = ion_heap_unmap_kernel, .pm = { .freeze = ion_secure_cma_pm_freeze, } }; struct ion_heap *ion_cma_secure_heap_create(struct ion_platform_heap *data) Loading Loading
drivers/staging/android/ion/ion_carveout_heap.c +34 −0 Original line number Diff line number Diff line Loading @@ -186,6 +186,8 @@ struct ion_sc_entry { struct list_head list; struct ion_heap *heap; u32 token; u64 base; u64 size; }; struct ion_sc_heap { Loading Loading @@ -242,9 +244,39 @@ static void ion_sc_heap_free(struct ion_buffer *buffer) kfree(table); } static int ion_secure_carveout_pm_freeze(struct ion_heap *heap) { long sz; sz = atomic_long_read(&heap->total_allocated); if (sz) { pr_err("%s: %lx bytes won't be saved across hibernation. Aborting.", __func__, sz); return -EINVAL; } return 0; } static int ion_secure_carveout_pm_restore(struct ion_heap *heap) { struct ion_sc_heap *manager; struct ion_sc_entry *child; manager = container_of(heap, struct ion_sc_heap, heap); list_for_each_entry(child, &manager->children, list) ion_hyp_assign_from_flags( child->base, child->size, child->token); return 0; } static struct ion_heap_ops ion_sc_heap_ops = { .allocate = ion_sc_heap_allocate, .free = ion_sc_heap_free, .pm = { .freeze = ion_secure_carveout_pm_freeze, .restore = ion_secure_carveout_pm_restore, } }; static int ion_sc_get_dt_token(struct ion_sc_entry *entry, Loading Loading @@ -298,6 +330,8 @@ static int ion_sc_add_child(struct ion_sc_heap *manager, heap_data.priv = dev; heap_data.base = base; heap_data.size = size; entry->base = base; entry->size = size; /* This will zero memory initially */ entry->heap = __ion_carveout_heap_create(&heap_data, false); Loading
drivers/staging/android/ion/ion_cma_heap.c +17 −0 Original line number Diff line number Diff line Loading @@ -264,12 +264,29 @@ static int ion_secure_cma_map_user(struct ion_heap *mapper, return ion_heap_map_user(mapper, buffer, vma); } static int ion_secure_cma_pm_freeze(struct ion_heap *heap) { long sz; sz = atomic_long_read(&heap->total_allocated); if (sz) { pr_err("%s: %lx bytes won't be saved across hibernation. Aborting.", __func__, sz); return -EINVAL; } return 0; } static struct ion_heap_ops ion_secure_cma_ops = { .allocate = ion_secure_cma_allocate, .free = ion_secure_cma_free, .map_user = ion_secure_cma_map_user, .map_kernel = ion_secure_cma_map_kernel, .unmap_kernel = ion_heap_unmap_kernel, .pm = { .freeze = ion_secure_cma_pm_freeze, } }; struct ion_heap *ion_cma_secure_heap_create(struct ion_platform_heap *data) Loading