The ww_mutex API in Linux is supposed to implement the "Wound/Wait Deadlock-Proof Mutex" thing. Seems like we have a different deadlock-proof mutex in its place, which might be fine (I'm not a locking expert), but we definitely have to respect the API. Specifically, consumers expect the ctx field to actually be populated with the ctx the locking function was called with!
/* Double check that the BO is reserved by this CS */ if (dma_resv_locking_ctx((*bo)->tbo.base.resv) != &parser->ticket) return -EINVAL; // where dma_resv_locking_ctx(obj) just returns READ_ONCE(obj->lock.ctx)
When this fails (and it's failing due to ctx always being zero), VAAPI video codec acceleration on amdgpu breaks.
https://github.com/freebsd/drm-kmod/issues/32
For reference, DragonFly has a "basic, unoptimized implementation of wound/wait mutexes" that actually does use the context for the locking algorithm, and does not have a global mutex or the thread list stuff..
https://github.com/DragonFlyBSD/DragonFlyBSD/blob/master/sys/dev/drm/linux_wwmutex.c
https://github.com/DragonFlyBSD/DragonFlyBSD/blob/master/sys/dev/drm/include/linux/ww_mutex.h
*Maybe* adopting their thing would be more "correct"? But let's do the hot fix for the video acceleration first.