Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/etnaviv: fix deadlock in GPU coredump

The GPU coredump function violates the locking order by holding the MMU
context lock while trying to acquire the etnaviv_gem_object lock. This
results in a possible ABBA deadlock with other codepaths which follow
the established locking order.
Fortunately this is easy to fix by dropping the MMU context lock
earlier, as the BO dumping doesn't need the MMU context to be stable.
The only thing the BO dumping cares about are the BO mappings, which
are stable across the lifetime of the job.

Fixes: 27b67278e007 (drm/etnaviv: rework MMU handling)
[ Not really the first bad commit, but the one where this fix applies
cleanly. Stable kernels need a manual backport. ]
Reported-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Tested-by: Christian Gmeiner <christian.gmeiner@gmail.com>

+2 -2
+2 -2
drivers/gpu/drm/etnaviv/etnaviv_dump.c
··· 180 180 etnaviv_cmdbuf_get_va(&submit->cmdbuf, 181 181 &gpu->mmu_context->cmdbuf_mapping)); 182 182 183 + mutex_unlock(&gpu->mmu_context->lock); 184 + 183 185 /* Reserve space for the bomap */ 184 186 if (n_bomap_pages) { 185 187 bomap_start = bomap = iter.data; ··· 222 220 etnaviv_core_dump_header(&iter, ETDUMP_BUF_BO, iter.data + 223 221 obj->base.size); 224 222 } 225 - 226 - mutex_unlock(&gpu->mmu_context->lock); 227 223 228 224 etnaviv_core_dump_header(&iter, ETDUMP_BUF_END, iter.data); 229 225