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

Commit 0d2b34e4 authored by Laura Abbott's avatar Laura Abbott
Browse files

gpu: ion: Don't recursively take secure chunk lock



During allocation, the chunk_lock is taken to protect the chunk
list. dma_alloc_coherent may invoke the shrinker which also tries
to take the chunk_lock. This leads to a deadlock. If the mutex is
already locked in the shrinker, just return -1 as specifed by the
shrinker API to signal this condition.

Change-Id: I5525ecfcdc6deea61024f0008c62026103728571
Signed-off-by: default avatarLaura Abbott <lauraa@codeaurora.org>
parent e01f2c24
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -356,7 +356,14 @@ static int ion_secure_cma_shrinker(struct shrinker *shrinker,
	if (!(sc->gfp_mask & __GFP_MOVABLE))
		return atomic_read(&sheap->total_pool_size);

	mutex_lock(&sheap->chunk_lock);
	/*
	 * Allocation path may invoke the shrinker. Proceeding any further
	 * would cause a deadlock in several places so don't shrink if that
	 * happens.
	 */
	if (!mutex_trylock(&sheap->chunk_lock))
		return -1;

	list_for_each_safe(entry, _n, &sheap->chunks) {
		struct ion_cma_alloc_chunk *chunk = container_of(entry,
					struct ion_cma_alloc_chunk, entry);