Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f2b23b8b authored by Patrick Daly's avatar Patrick Daly
Browse files

ion: Add hibernation support for secure cma heap



Verify there are no outstanding buffers to prevent loss of state
when resuming from hibernation.

Change-Id: Ibcd768d120ebdc7be51df90b515c7b28b7148a6f
Signed-off-by: default avatarPatrick Daly <pdaly@codeaurora.org>
parent c6eed32e
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -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)