Bug 443986 - Use serial numbers to identify displays instead of interface names
Summary: Use serial numbers to identify displays instead of interface names
Status: RESOLVED NOT A BUG
Alias: None
Product: plasmashell
Classification: Plasma
Component: generic-multiscreen (show other bugs)
Version: 5.23.0
Platform: Other Linux
: NOR normal
Target Milestone: 1.0
Assignee: Aleix Pol
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-10-18 17:39 UTC by gudvinr+kde
Modified: 2022-08-01 17:40 UTC (History)
6 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 gudvinr+kde 2021-10-18 17:39:38 UTC
SUMMARY

Right now Plasma uses interface names as an unique identifier of display device (e.g. monitor).

This approach raises significant issues on systems that can't provide consistent names for interfaces.

For example, DisplayPort has support for using multiple displays over same physical interface on GPU. This is called Multi-Stream Transport (MST) or "daisy chaining".
To make it work, DRM driver would create virtual interface if it can detect additional displays.

This behaviour makes it impossible to predict which number will be assigned to display interface and thus makes identification by interface name (which includes interface number) unreliable.

I personally had an issue with MST on KDE: https://bugs.kde.org/show_bug.cgi?id=420616

Another example is a behaviour of AMDGPU driver which is related to MST but internal changes in driver also caused issues in systems that do not use MST: https://bugzilla.kernel.org/show_bug.cgi?id=206387

In short, AMD driver won't persist interface numbers so interface names are no longer guaranteed to uniquely identify display device.
I can't say for sure but I didn't find any indication of such guarantee in the past.
Probably relying on interface names in the past was a mistake that wasn't noticed until MST devices became more widespread.

This also gave me an issue on KDE: https://bugs.kde.org/show_bug.cgi?id=443832

You can experience similar problems by plugging monitor to different interface even if your drivers don't change interface numbers.


PROPOSED SOLUTION

Instead of using volatile interface names as monitor identifiers I suggest using serial numbers of display devices.
This information is resistant to any changes in interface naming.
It will be the same after using different interface and even after replacing GPU.

Information about serial number exists in EDID and XOrg can at least show it in logs:

[    47.193] (II) AMDGPU(0): Serial No: ABCXYZ123QWERTY
[    47.193] (II) AMDGPU(0): Monitor name: BenQ XX1234Q
--
[    47.196] (II) AMDGPU(0): Serial No: ASDF9876IOP321
[    47.196] (II) AMDGPU(0): Monitor name: DELL X4321P


SOFTWARE/OS VERSIONS
Operating System: Arch Linux
KDE Plasma Version: 5.23.0
KDE Frameworks Version: 5.87.0
Qt Version: 5.15.2
Kernel Version: 5.14.12-arch1-1 (64-bit)
Graphics Platform: X11
Graphics Processor: AMD VEGAM 

ADDITIONAL INFORMATION

This issue is very similar to problems that were causing problems in network/storage devices enumeration.
More on that here:
- https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/
- https://wiki.debian.org/Part-UUID
Comment 1 Nate Graham 2021-10-19 14:25:15 UTC
This seems like a very good idea to me and would fix multiple issues faced by users, in particular https://bugzilla.kernel.org/show_bug.cgi?id=206387.
Comment 2 Alexandre Pereira 2021-10-23 22:52:30 UTC
nice catch with that kernel bug report :)

I filed that kernel bug report because of exactly what this bug report describes :) ( the amdgpu.dc=1 enabled daisy chaining and amdgpu.dc=0 disables it )

btw ... I noticed that between 5.23.0 and 5.23.1, my plasma configuration switched monitors. Nothing a lastScreen switch in .config/plasma-org.kde.plasma.desktop-appletsrc didnt fix though.
Comment 3 David Edmundson 2021-10-23 23:20:26 UTC
>This seems like a very good idea to me

It's not. I have two monitors in this house with the same serial.

But even ignoring that, if you ever upgrade your single monitor you have unrecoverable data loss.

There is definitely work to do on screen management, see the open invent tickets, but this isn't it.
Comment 4 Vladimir Yerilov 2021-10-24 02:53:04 UTC
>>It's not

Why not? It just means that the algo used should take into account monitors' serials as well. And that the primary monitor/screen configuration should apply to any connected screen if it's the only one. Also, a concept of laptop screen should be introduced, which should be possible to be permanently set as a secondary one unless it's the only one in which case it becomes primary until another monitor is detected.

I also have 2 monitors and it's a total mess every time I login - in X it's race conditions resulting in weird bugs like Night Color failures to apply its settings, plasmashell crashes due to it trying to start while the external monitor is being detected; and in Wayland - there's no way to set the external monitor as a primary display, it's always a "reversed X" layout.
Comment 5 gudvinr+kde 2021-10-24 13:07:57 UTC
(In reply to David Edmundson from comment #3)
> if you ever upgrade your single monitor you have
> unrecoverable data loss.

This is kinda what it is now. If you reboot PC and DRM driver decides to mangle interface names it'll lead to configuration loss unless you mitigate it in some way.

So either way you need to work around that. But I really doubt that there are displays out there with changing serials.

Unless there is some way to get reliable and consistent data from DRM.
Comment 6 Daniel Noga 2022-08-01 17:40:50 UTC
For some reason it works correctly in Wayland, no constant changing of monitor IDs when using Thunderbolt dock station. Is it there implemented the better way?