When we load a KMS driver, the following LOR is reported:
lock order reversal: 1st 0xffffffff8084bab8 vtdev (vtdev) @ /usr/home/kostik/work/build/bsd/DEV/src/sys/dev/vt/vt_core.c:2322 2nd 0xfffff8000d69ac08 ttymtx (ttymtx) @ /usr/home/kostik/work/build/bsd/DEV/src/sys/kern/subr_terminal.c:236
See Bugzilla: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=193597
This patch moves VT_LOCK(vd) after the call to terminal_mute(). The call to vt_suspend_flush_timer() is now outside the lock, but this function already uses an atomic cmpset to protect itself.