On 08/11/2021 17:00, Daniel Vetter wrote:
On Mon, Nov 08, 2021 at 04:34:53PM +0100, Jocelyn Falempe wrote:
When using Xorg/Logind and an external monitor connected with an MST dock. After disconnecting the external monitor, switching to VT may not work, the (internal) monitor sill display Xorg, and you can't see what you are typing in the VT.
This is related to commit e2809c7db818 ("drm/fb_helper: move deferred fb checking into restore mode (v2)")
When switching to VT, with Xorg and logind, if there are pending hotplug event (like MST unplugged), the hotplug path may not be fulfilled, because logind may drop the master a bit later. It leads to the console not showing up on the monitor.
So when dropping the drm master, call the delayed hotplug function if needed.
v2: rewrote the patch by calling the hotplug function after dropping master
Signed-off-by: Jocelyn Falempe jfalempe@redhat.com
Lastclose console restore is a very gross hack, and generally doesn't work well.
The way this is supposed to work is:
- userspace drops drm master (because drm master always wins)
- userspace switches the console back to text mode (which will restore the console)
I guess we could also do this from dropmaster once more (like from lastclose), but that really feels like papering over userspace bugs. And given what a massive mess this entire area is already, I'm not eager to add more hacks here.
So ... can't we fix userspace?
But the kernel still needs to support older version of userspace applications anyway ?
Ofc if it's a regression then that's different, but then I think we need a bit clearer implementation. I'm not clear on why you clear the callback (plus the locking looks busted).
It's a race condition, in the current code there are two workarounds:
[1] e2809c7db818df6bbd0edf843e1beb2fbc9d8541 which introduced delayed hotplug for MST [2] dc5bdb68b5b369d5bc7d1de96fa64cc1737a6320 which introduced a workaround for Xorg and logind, and add a force parameter to __drm_fb_helper_restore_fbdev_mode_unlocked() in this case.
The problem here is when we need both workarounds at the same time, it doesn't work (so using Xorg, and playing with MST monitor).
v1 patch, was to also force hotplug() after forcing the restore() v2 patch is to call the hotplug() after the drm drop. it's a bit hacky, because I replaced the boolean "delayed_hotplug" with a callback, that's why it's cleared. A cleaner way would be to have a function in drm_auth.c to register a callback on drm_drop().
For the locking, the hotplug() function should be called without the dev->master_mutex, because it will try to take it.