Skip to content

freedreno/drm/virtio: Fix deadlock on exit

Rob Clark requested to merge robclark/mesa:fd/fortify-mtx-abort into main

What does this MR do and why?

freedreno/drm/virtio: Fix deadlock on exit

We don't want the retire work to be the one to drop the last reference
to the pipe, as that would result in trying to free the retire_queue
from the retire_queue thread.

Signed-off-by: Rob Clark <robdclark@chromium.org>

In particular, we were seeing intermittent flake/crashes like:

02-07 06:52:41.097 10076  4070  4070 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
02-07 06:52:41.097 10076  4070  4070 F DEBUG   : Build fingerprint: 'google/strongbad/strongbad_cheets:13/R123-15771.0.0/11412324:user/release-keys'
02-07 06:52:41.097 10076  4070  4070 F DEBUG   : Revision: '0'
02-07 06:52:41.097 10076  4070  4070 F DEBUG   : ABI: 'arm64'
02-07 06:52:41.097 10076  4070  4070 F DEBUG   : Timestamp: 2024-02-07 06:52:40.678895376-0600
02-07 06:52:41.097 10076  4070  4070 F DEBUG   : Process uptime: 23s
02-07 06:52:41.097 10076  4070  4070 F DEBUG   : Cmdline: android.mediastress.cts
02-07 06:52:41.097 10076  4070  4070 F DEBUG   : pid: 3854, tid: 4038, name: android.me:rq0  >>> android.mediastress.cts <<<
02-07 06:52:41.097 10076  4070  4070 F DEBUG   : uid: 10076
02-07 06:52:41.097 10076  4070  4070 F DEBUG   : tagged_addr_ctrl: 0000000000000001 (PR_TAGGED_ADDR_ENABLE)
02-07 06:52:41.097 10076  4070  4070 F DEBUG   : signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
02-07 06:52:41.097 10076  4070  4070 F DEBUG   : Abort message: 'FORTIFY: pthread_mutex_lock called on a destroyed mutex (0x6fdf62f368)'
02-07 06:52:41.097 10076  4070  4070 F DEBUG   :     x0  0000000000000000  x1  0000000000000fc6  x2  0000000000000006  x3  00000070383b9910
02-07 06:52:41.097 10076  4070  4070 F DEBUG   :     x4  0000000000008080  x5  0000000000008080  x6  0000000000008080  x7  8080000000000000
02-07 06:52:41.097 10076  4070  4070 F DEBUG   :     x8  00000000000000f0  x9  00000070dda78a30  x10 0000000000000001  x11 00000070ddaed040
02-07 06:52:41.097 10076  4070  4070 F DEBUG   :     x12 0101010101010101  x13 000000007fffffff  x14 000000000000ae9c  x15 0000000000000078
02-07 06:52:41.097 10076  4070  4070 F DEBUG   :     x16 00000070ddb5da48  x17 00000070ddb36110  x18 0000006fce88a000  x19 00000000000000ac
02-07 06:52:41.097 10076  4070  4070 F DEBUG   :     x20 00000000000000b2  x21 0000000000000f0e  x22 0000000000000fc6  x23 00000000ffffffff
02-07 06:52:41.097 10076  4070  4070 F DEBUG   :     x24 0000006fc68a0b40  x25 0000000000000000  x26 0000006fc68a0bf8  x27 0000006fd1471518
02-07 06:52:41.097 10076  4070  4070 F DEBUG   :     x28 0000006fd1471568  x29 00000070383b9990
02-07 06:52:41.097 10076  4070  4070 F DEBUG   :     lr  00000070ddadda14  sp  00000070383b98f0  pc  00000070ddadda44  pst 0000000000001000
02-07 06:52:41.097 10076  4070  4070 F DEBUG   : backtrace:
02-07 06:52:41.097 10076  4070  4070 F DEBUG   :       #00 pc 000000000008ca44  /apex/com.android.runtime/lib64/bionic/libc.so (abort+180) (BuildId: 4d41410a5ba4cb17f60f2c04eb0d5154)
02-07 06:52:41.097 10076  4070  4070 F DEBUG   :       #01 pc 000000000008e8bc  /apex/com.android.runtime/lib64/bionic/libc.so (__fortify_fatal(char const*, ...)+124) (BuildId: 4d41410a5ba4cb17f60f2c04eb0d5154)
02-07 06:52:41.097 10076  4070  4070 F DEBUG   :       #02 pc 00000000000fc9ac  /apex/com.android.runtime/lib64/bionic/libc.so (HandleUsingDestroyedMutex(pthread_mutex_t*, char const*)+60) (BuildId: 4d41410a5ba4cb17f60f2c04eb0d5154)
02-07 06:52:41.097 10076  4070  4070 F DEBUG   :       #03 pc 00000000000fc830  /apex/com.android.runtime/lib64/bionic/libc.so (pthread_mutex_lock+240) (BuildId: 4d41410a5ba4cb17f60f2c04eb0d5154)
02-07 06:52:41.097 10076  4070  4070 F DEBUG   :       #04 pc 00000000000a09c8  /apex/com.android.runtime/lib64/bionic/libc.so (mtx_lock+8) (BuildId: 4d41410a5ba4cb17f60f2c04eb0d5154)
02-07 06:52:41.097 10076  4070  4070 F DEBUG   :       #05 pc 00000000005ab20c  /vendor/lib64/dri/virtio_gpu_dri.so (BuildId: 3a3c59d847e888a898a2ed10278c00f35e74c618)
02-07 06:52:41.097 10076  4070  4070 F DEBUG   :       #06 pc 00000000000a0c08  /apex/com.android.runtime/lib64/bionic/libc.so (__bionic_thrd_trampoline(void*)+24) (BuildId: 4d41410a5ba4cb17f60f2c04eb0d5154)
02-07 06:52:41.097 10076  4070  4070 F DEBUG   :       #07 pc 00000000000fb540  /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+208) (BuildId: 4d41410a5ba4cb17f60f2c04eb0d5154)
02-07 06:52:41.097 10076  4070  4070 F DEBUG   :       #08 pc 000000000008e270  /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64) (BuildId: 4d41410a5ba4cb17f60f2c04eb0d5154)

Also bonus vdrm nctx fix for builds with asserts enabled

Merge request reports