Bug 416720 - Multiseat with single GPU fails
Summary: Multiseat with single GPU fails
Status: RESOLVED INTENTIONAL
Alias: None
Product: kwin
Classification: Plasma
Component: multi-screen (show other bugs)
Version: 5.17.4
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-01-25 03:28 UTC by logan
Modified: 2021-12-31 18:51 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description logan 2020-01-25 03:28:19 UTC
SUMMARY
When Wayland compositors start, they are supposed to limit themselves to only the hardware which is attached to the seat on which the compositor is running loginctl can split the outputs of a single graphics card into multiple seats; these split outputs count as primary devices for seats, allowing them to start up.  kwin breaks in 2 ways when trying this.

STEPS TO REPRODUCE
1. Set up kwin wayland, with logind or elogind
2. With a multi-output GPU, assign one port to seat1
3. Ask startplasma-wayland to start on seat0; note failure mode 1
4. Ask startplasma-wayland to start on seat1; note failure mode 2

OBSERVED RESULT
In the seat0 case, kwin_wayland fails to start.  It doesn't matter if there is a monitor attached to the output in question, or which output gets moved to seat1, it fails to start.

In the seat1 case, it starts, and grabs all connected screens, regardless of which seat they are assigned.  Seat1 doesn't own the tty, so you actually get the mouse cursor *over* the text of the tty, with various repaints fighting back and forth between kwin and the tty shell.  

EXPECTED RESULT
In the worst case, a clear error message that split-gpu multiseat is not supported on KDE.  In the ideal case, it should be possible to run a multi-seat setup with a single GPU the same as you can with multiple GPUs.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Gentoo 17.0, Linux 5.3.9
(available in About System)
KDE Plasma Version: 5.17.4
KDE Frameworks Version: 19.08.3
Qt Version: 5.12.5

ADDITIONAL INFORMATION
Comment 1 Zamundaaa 2021-12-26 15:18:03 UTC
Sorry but this can't really be done. Managing output devices requires access and control to global resources of the GPU. On the kms/drm level that's also reflected by there only being one drm master per GPU - I'm surprised you could make KWin run while a tty was active at all, it definitely doesn't work with multiple compositors.
If you want multiple seats on a single GPU then you need a compositor that manages that explicitly. In terms of running multiple compositors at once that could be done by running them nested in a special compositor. AFAIK compositors allowing such things don't really exist yet though
Comment 2 Luke-Jr 2021-12-26 20:23:32 UTC
X11 could do it, so is Wayland a big step backward?
Comment 3 Zamundaaa 2021-12-27 01:41:46 UTC
It's not about Wayland, it's about hardware and kernel API restrictions. From what I could find out multi seat on Xorg worked exactly like what I'm describing would be needed for Wayland, too: one instance ("normal" Xorg) runs on the hardware, multiple other instances (Xephyr) run nested on the outputs.
Comment 4 Luke-Jr 2021-12-27 01:48:54 UTC
Admittedly, it hasn't worked since systemd invaded, but it used to be possible to just run two Xorg servers, each controlling a monitor. Possibly pre-compositing (but many of us still don't use compositors even today)
Comment 5 logan 2021-12-31 18:51:11 UTC
(In reply to Zamundaaa from comment #1)
> Sorry but this can't really be done. Managing output devices requires access
> and control to global resources of the GPU. On the kms/drm level that's also
> reflected by there only being one drm master per GPU - I'm surprised you
> could make KWin run while a tty was active at all, it definitely doesn't
> work with multiple compositors.
> If you want multiple seats on a single GPU then you need a compositor that
> manages that explicitly. In terms of running multiple compositors at once
> that could be done by running them nested in a special compositor. AFAIK
> compositors allowing such things don't really exist yet though

I was under the impression that the login1 provider handled the kernel/drm level resource allocation, so handing the per-screen render plane to the compositor should be possible, but it might have poor security implications if the kernel-level (or hardware level) isolation aren't what they'd need to be.  Given that a major goal of wayland is to resolve the security concerns that existed under X11, it's probably not worth pursuing further.

That said, the poor behavior exhibited is not ideal, a clear error message that split-card-multiseat is unsupported by kwin shouldn't be too difficult to add, and would avoid the silent breakage / corrupted output.