Bug 432707

Summary: [Wayland] KScreen does not detect external displays such as DisplayPort on laptops
Product: [Plasma] kwin Reporter: Shawn Starr <shawn.starr>
Component: platform-drmAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: aleixpol, alex765, nate, ngompa13, rdieter, slackmase2, thunderstormpolska, xaver.hugl
Priority: VHI Keywords: wayland
Version: git master   
Target Milestone: ---   
Platform: Fedora RPMs   
OS: Linux   
Latest Commit: Version Fixed In: 5.22.0
Sentry Crash Report:
Attachments: Wayland Errors/Session log from SDDM
Wayland Error log #2
Stack dump
Wayland Session Errors from multiple kwin spawn attempts by SDDM
New Wayland Session log
kwin Xwayland - wayland-errors.log
Kwin Kwayland-server new log
Wayland Errors Log - with work/zamundaaa/dumb-import branch for kwin
Wayland Errors Log - New user - with work/zamundaaa/dumb-import branch for kwin
Wayland Errors Log - Existing user - Laptop screen made primary - with work/zamundaaa/dumb-import branch for kwin
New log from latest code changes
Coredump from Kwin
Wayland Error logs - with dumb-import + primary-gpu-context branches
New log from latest testing - dumb-import + primary-gpu-context + fix-hotplug
dumb-import + primary-gpu-context + fix-hotplug w/o SDDM/Xorg VT
dumb-import + primary-gpu-context log
dumb-import branch only
dumb-import branch only - latest test
dumb-import - April 23rd - log
dumb-import - April 23rd - log - Latest
Kwin + latest KWayland server + protocols - both displays turn on

Description Shawn Starr 2021-02-09 21:04:30 UTC
SUMMARY

I have two laptops, one is a Dell Precision M6800, with an integrated GPU and dedicated GPU:

Laptop #1
=========

Model: Dell Precision M6800
Integrated GPU: Intel HD Graphics 4600 (HSW GT2)
Dedicated GPU: AMD FirePro M6100 (AMD Radeon HD 8950)

Xrandr info - Xorg
------------------

Screen 0: minimum 320 x 200, current 2560 x 1440, maximum 16384 x 16384
DisplayPort-1 connected primary 2560x1440+0+0 (normal left inverted right x axis y axis) 597mm x 336mm
   2560x1440    144.00*+ 120.00    59.95  
   1920x1080    239.76   143.98   120.00   119.88    60.00    50.00    59.94  
   1680x1050     59.95  
   1600x900      60.00  
   1280x1024     75.02    60.02  
   1440x900      59.89  
   1280x800      59.81  
   1152x864      75.00  
   1280x720      60.00    50.00    59.94  
   1024x768      75.03    70.07    60.00  
   832x624       74.55  
   800x600       72.19    75.00    60.32    56.25  
   720x576       50.00  
   720x480       60.00    59.94  
   640x480       75.00    72.81    66.67    60.00    59.94  
   720x400       70.08  
DisplayPort-2 disconnected (normal left inverted right x axis y axis)
DisplayPort-3 disconnected (normal left inverted right x axis y axis)
eDP-1-1 connected (normal left inverted right x axis y axis)
   1920x1080     60.01 +  60.01    59.97    59.96    59.93  
   1680x1050     59.95    59.88  
   1400x1050     59.98  
   1600x900      59.99    59.94    59.95    59.82  
   1280x1024     60.02  
   1400x900      59.96    59.88  
   1280x960      60.00  
   1440x810      60.00    59.97  
   1368x768      59.88    59.85  
   1280x800      59.99    59.97    59.81    59.91  
   1280x720      60.00    59.99    59.86    59.74  
   1024x768      60.04    60.00  
   960x720       60.00  
   928x696       60.05  
   896x672       60.01  
   1024x576      59.95    59.96    59.90    59.82  
   960x600       59.93    60.00  
   960x540       59.96    59.99    59.63    59.82  
   800x600       60.00    60.32    56.25  
   840x525       60.01    59.88  
   864x486       59.92    59.57  
   700x525       59.98  
   800x450       59.95    59.82  
   640x512       60.02  
   700x450       59.96    59.88  
   640x480       60.00    59.94  
   720x405       59.51    58.99  
   684x384       59.88    59.85  
   640x400       59.88    59.98  
   640x360       59.86    59.83    59.84    59.32  
   512x384       60.00  
   512x288       60.00    59.92  
   480x270       59.63    59.82  
   400x300       60.32    56.34  
   432x243       59.92    59.57  
   320x240       60.05  
   360x202       59.51    59.13  
   320x180       59.84    59.32  
VGA-1-1 disconnected (normal left inverted right x axis y axis)
DP-1-1 disconnected (normal left inverted right x axis y axis)
HDMI-1-1 disconnected (normal left inverted right x axis y axis)
  1680x1050 (0x4c) 146.250MHz -HSync +VSync
        h: width  1680 start 1784 end 1960 total 2240 skew    0 clock  65.29KHz
        v: height 1050 start 1053 end 1059 total 1089           clock  59.95Hz
  1280x1024 (0x53) 108.000MHz +HSync +VSync
        h: width  1280 start 1328 end 1440 total 1688 skew    0 clock  63.98KHz
        v: height 1024 start 1025 end 1028 total 1066           clock  60.02Hz
  1280x800 (0x5d) 83.500MHz -HSync +VSync
        h: width  1280 start 1352 end 1480 total 1680 skew    0 clock  49.70KHz
        v: height  800 start  803 end  809 total  831           clock  59.81Hz
  1024x768 (0x64) 65.000MHz -HSync -VSync
        h: width  1024 start 1048 end 1184 total 1344 skew    0 clock  48.36KHz
        v: height  768 start  771 end  777 total  806           clock  60.00Hz
  800x600 (0x73) 40.000MHz +HSync +VSync
        h: width   800 start  840 end  968 total 1056 skew    0 clock  37.88KHz
        v: height  600 start  601 end  605 total  628           clock  60.32Hz
  800x600 (0x74) 36.000MHz +HSync +VSync
        h: width   800 start  824 end  896 total 1024 skew    0 clock  35.16KHz
        v: height  600 start  601 end  603 total  625           clock  56.25Hz
  640x480 (0x80) 25.175MHz -HSync -VSync
        h: width   640 start  656 end  752 total  800 skew    0 clock  31.47KHz
        v: height  480 start  490 end  492 total  525           clock  59.94Hz


Laptop #2:
==========

Model: ThinkPad W500 (4058CTO)
Integrated GPU: disabled in BIOS
Dedicated GPU: Mobility Radeon HD 3650 (RV635)

xrandr info - Xorg
------------------

Screen 0: minimum 320 x 200, current 2560 x 1440, maximum 8192 x 8192
DVI-0 disconnected (normal left inverted right x axis y axis)
LVDS connected (normal left inverted right x axis y axis)
   1920x1200     60.00 +
   1920x1080     60.00  
   1600x1200     60.00    59.95  
   1680x1050     60.00  
   1400x1050     60.00  
   1280x1024     59.95    60.02  
   1440x900      59.99  
   1280x960      59.99  
   1280x854      59.95  
   1280x800      59.96  
   1280x720      59.97  
   1152x768      59.95  
   1024x768      60.00    59.95  
   800x600       60.32    59.96  
   848x480       59.94  
   720x480       59.94  
   640x480       59.94    59.94  
DisplayPort-0 connected primary 2560x1440+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
   1024x768      60.00  
   800x600       60.32    56.25  
   848x480       60.00  
   640x480       59.94  
VGA-0 disconnected (normal left inverted right x axis y axis)
  2560x1440 (0x6e4) 311.862MHz -HSync +VSync
        h: width  2560 start 2744 end 3024 total 3488 skew    0 clock  89.41KHz
        v: height 1440 start 1441 end 1444 total 1490           clock  60.01Hz


STEPS TO REPRODUCE
1. Try to run Plasma Wayland
2. External Display does not turn on

OBSERVED RESULT
External Display does not turn on

EXPECTED RESULT
External Display turns on


SOFTWARE/OS VERSIONS
Linux/KDE Plasma: 5.20.90
(available in About System)
KDE Plasma Version: 5.20.90 
KDE Frameworks Version: 5.77.0
Qt Version: 5.15.2

ADDITIONAL INFORMATION

It also seems interesting that the internal display sometimes does not show any widgets from Plasma only the Workspace can be popped open, nothing else is available...

I wonder if KScreen/Plasma is getting confused with Xorg config settings vs any Wayland setting?
Comment 1 Nate Graham 2021-02-09 21:28:13 UTC
This works on X11, right?
Comment 2 Shawn Starr 2021-02-10 07:05:52 UTC
Yes, X11 its fine.
Comment 3 Zamundaaa 2021-02-11 12:39:59 UTC
The external displays in laptops are often (or rather were, in newer laptops it's AFAIK different) connected to the dedicated GPU, so it'll most likely work with 5.21
Comment 4 Shawn Starr 2021-02-11 21:48:41 UTC
Seeing im on 5.20.90, 5.21 will not fix issue since it is 5.21 beta :)
Comment 5 Zamundaaa 2021-02-11 22:13:39 UTC
Ah, sorry, please attach ~/.local/share/sddm/wayland-session.log
Comment 6 Shawn Starr 2021-02-17 03:27:26 UTC
I will later this week provide the log.
Comment 7 Shawn Starr 2021-02-21 18:21:03 UTC
Ill provide log tonight
Comment 8 Shawn Starr 2021-02-23 02:53:50 UTC
I don't see this log file in my $HOME or anywhere?
Comment 9 Shawn Starr 2021-02-23 03:11:49 UTC
Created attachment 136070 [details]
Wayland Errors/Session log from SDDM

I've found the log here it is attached
Comment 10 Shawn Starr 2021-02-23 03:13:35 UTC
I should note, with latest Fedora Plasma:

plasma-workspace-5.21.0-1.fc35.x86_64

Kscreen now does see two displays but the DisplayPort screen does not turn on, it remains powered off

Even though Kscreen reports correct resolution, refresh rates.

So some progress here.
Comment 11 Shawn Starr 2021-02-23 03:31:39 UTC
I notice this in the log:

kwin_wayland_drm: Could not find a fitting mode with size=2560x1440 and refresh rate 144000 for output 815efd90c2

kwin_wayland_drm: Could not find a fitting mode with size=1920x1080 and refresh rate 60012 for output 3a7a96dd23

Where:  

815efd90c2 (/dev/dri/card0) == Integrated GPU: Intel HD Graphics 4600 (HSW GT2)
3a7a96dd23 (/dev/dri/card1) == Dedicated GPU: AMD FirePro M6100 (AMD Radeon HD 8950)

Kwin's DRM code seems correct, but not correct in failing to determine the display can handle these resolutions.

When it can in X... seems like a bug
Comment 12 Shawn Starr 2021-02-23 03:35:15 UTC
The Laptop display lights up:

kwin_wayland_drm: For new output use mode  1920x1080 1920 1080
kwin_wayland_drm: Initialized primary plane 31 on CRTC 45
kwin_core: Adding mode 1: QSize(1920, 1080) [60012]
Comment 13 Zamundaaa 2021-02-25 07:01:05 UTC
The "can't find fitting mode" warning just means that on KWin can't find the intial mode it wants, it just falls back to the first mode. The relevant error is

drmModeAddFB failed

It's possible that part of the problem is driver or hardware support - I'll find out how to get relevant information for that.
Comment 14 Shawn Starr 2021-02-25 16:48:08 UTC
hmm, well since it works with Xorg, the driver seems ok, both the DRM kernel, DRI side at least.
Comment 15 Zamundaaa 2021-02-25 22:09:09 UTC
What I mean is that there's probably some edge-case or assumption about the driver that we're not handling correctly.

Are you using the amdgpu or radeon kernel driver? IIRC for a few of those old cards radeon is still the default. If that affects your card, could you try what happens with amdgpu?
Comment 16 Shawn Starr 2021-02-26 16:59:04 UTC
I use amdgpu, disabled radeon for CIK.
Comment 17 Bug Janitor Service 2021-03-06 15:28:04 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/756
Comment 18 Zamundaaa 2021-03-06 15:29:44 UTC
Does the patch fix the problem (or at least change anything)? In theory the two function calls should do the same but it's worth a try
Comment 19 Shawn Starr 2021-03-06 20:08:54 UTC
I need to refresh my KDE build outside of using Fedora RPMs, ill gget back to you on this,
Comment 20 Shawn Starr 2021-03-06 20:09:20 UTC
Or if I can apply this patch as part of building the Fedora RPM.. might try that first
Comment 21 Shawn Starr 2021-03-15 21:42:44 UTC
Well I got built, it is failing attached is wayland-errors log.
Comment 22 Shawn Starr 2021-03-15 21:43:05 UTC
Created attachment 136708 [details]
Wayland Error log #2

Wayland Error log #2
Comment 23 Zamundaaa 2021-03-16 13:26:16 UTC
Can you get a backtrace of the crash? And can you reproduce it on master?
Comment 24 Shawn Starr 2021-03-16 13:33:58 UTC
This was from master branch, in this case how can I get a gdb crash dump? Are you on IRC? :)
Comment 25 Shawn Starr 2021-03-16 13:49:53 UTC
KWin debugging isntructions:

echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
sudo gdb -pid $(pidof kwin_wayland) -batch -ex "set logging file kwin_wayland.gdb" -ex "set logging on" -ex "continue" -ex "thread apply all backtrace" -ex "quit"

Except im not sure how do I wrap kwin_wayland to use gdb via SDDM via my /usr/share/wayland-sessions/plasmawayland-dev.desktop?

Since I get no display while kwin crashes on start.
Comment 26 Zamundaaa 2021-03-16 14:59:56 UTC
Log one is from 5.21, and log two is from my merge request.
As I undertand it, 5.21 doesn't show anything and my merge request makes the session crash? It would be interesting if master crashes as well.

You can get the backtrace by using coredumpctl (if the coredump isn't truncated) or by using gdb over ssh
Comment 27 Shawn Starr 2021-03-16 16:47:10 UTC
I tried using:

gdb -batch -ex "set logging file kwin_wayland.gdb" -ex "set logging on" -ex "continue" -ex "thread apply all backtrace"-ex quit --args kwin_wayland --libinput --drm

While that worked, oddly the DisplayPort turned *on* though froze..

This is difficult to debug if I can't reproduce this with SDDM -> plasmastart --> kwin.

Will coredumpctl work even with this?

The wiki says:

"Warning
The kwin_wayland process is not dumpable, which means coredumpctl is unable to fetch a full backtrace, rendering only truncated core dumps. Those are still useful, but if possible, SSH into your session and attach GDB directly."

So, If you can provide some step for me to try to debug this consistently.
Comment 28 Shawn Starr 2021-03-16 19:09:17 UTC
GDB stack dump

$ sudo gdb --core core.kwin_wayland.1000.55d0822d350d434bb3a76b384eae7800.1445.1615920868000000
GNU gdb (GDB) Fedora 10.1-14.fc35
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word".

warning: Can't open file /memfd:JSGCHeap:QtQml (deleted) during file-backed mapping note processing

warning: Can't open file anon_inode:i915.gem which was expanded to anon_inode:i915.gem during file-backed mapping note processing

warning: Can't open file anon_inode:i915.gem which was expanded to anon_inode:i915.gem during file-backed mapping note processing

warning: Can't open file anon_inode:i915.gem which was expanded to anon_inode:i915.gem during file-backed mapping note processing

warning: Can't open file anon_inode:i915.gem which was expanded to anon_inode:i915.gem during file-backed mapping note processing

warning: Can't open file anon_inode:i915.gem which was expanded to anon_inode:i915.gem during file-backed mapping note processing

warning: Can't open file anon_inode:i915.gem which was expanded to anon_inode:i915.gem during file-backed mapping note processing

warning: Can't open file /memfd:JSVMStack:QtQml (deleted) during file-backed mapping note processing

warning: Can't open file anon_inode:i915.gem which was expanded to anon_inode:i915.gem during file-backed mapping note processing

warning: Can't open file /memfd:unknown-usage:QtQml (deleted) during file-backed mapping note processing

warning: Can't open file anon_inode:i915.gem which was expanded to anon_inode:i915.gem during file-backed mapping note processing

warning: Can't open file anon_inode:i915.gem which was expanded to anon_inode:i915.gem during file-backed mapping note processing

warning: Can't open file anon_inode:i915.gem which was expanded to anon_inode:i915.gem during file-backed mapping note processing

warning: Can't open file anon_inode:i915.gem which was expanded to anon_inode:i915.gem during file-backed mapping note processing

warning: Can't open file anon_inode:i915.gem which was expanded to anon_inode:i915.gem during file-backed mapping note processing

warning: Can't open file anon_inode:i915.gem which was expanded to anon_inode:i915.gem during file-backed mapping note processing

warning: Can't open file anon_inode:i915.gem which was expanded to anon_inode:i915.gem during file-backed mapping note processing

warning: Can't open file anon_inode:i915.gem which was expanded to anon_inode:i915.gem during file-backed mapping note processing

warning: Can't open file anon_inode:i915.gem which was expanded to anon_inode:i915.gem during file-backed mapping note processing

warning: Can't open file anon_inode:i915.gem which was expanded to anon_inode:i915.gem during file-backed mapping note processing

warning: Can't open file anon_inode:i915.gem which was expanded to anon_inode:i915.gem during file-backed mapping note processing

warning: Can't open file anon_inode:i915.gem which was expanded to anon_inode:i915.gem during file-backed mapping note processing
[New LWP 1445]
[New LWP 1446]
[New LWP 1452]
[New LWP 1459]
[New LWP 1448]
[New LWP 1462]
[New LWP 1447]
[New LWP 1468]
[New LWP 1461]
[New LWP 1453]
[New LWP 1465]
[New LWP 1451]
[New LWP 1464]
[New LWP 1454]
[New LWP 1455]
[New LWP 1467]
[New LWP 1458]
[New LWP 1470]
[New LWP 1475]
[New LWP 1460]
[New LWP 1477]
[New LWP 1463]
[New LWP 1472]
[New LWP 1457]
[New LWP 1469]
[New LWP 1466]
Reading symbols from /usr/lib64/libffi.so.6.0.2...
Reading symbols from /usr/lib/debug/usr/lib64/libffi.so.6.0.2-3.1-28.fc34.x86_64.debug...

warning: Ignoring non-absolute filename: <linux-vdso.so.1>
Missing separate debuginfo for linux-vdso.so.1
Try: dnf --enablerepo='*debug*' install /usr/lib/debug/.build-id/0c/f00d2ae4f266ffbda56d7c5c61fcf64c5c439a
Warning: couldn't activate thread debugging using libthread_db: Cannot find new threads: generic error

warning: File "/usr/lib64/libthread_db-1.0.so" auto-loading has been declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto-load:/usr/lib/golang/src/runtime/runtime-gdb.py".
To enable execution of this file add
Missing separate debuginfos, use: dnf debuginfo-install kf5-frameworkintegration-libs-5.79.0-2.fc34.x86_64 kf5-kactivities-5.79.0-2.fc34.x86_64 kf5-karchive-5.79.0-2.fc34.x86_64 kf5-kbookmarks-5.79.0-2.fc34.x86_64 kf5-kdbusaddons-5.79.0-2.fc34.x86_64 kf5-kdeclarative-5.79.0-2.fc34.x86_64 kf5-kio-core-libs-5.79.0-3.fc34.x86_64 kf5-kio-file-widgets-5.79.0-3.fc34.x86_64 kf5-kio-gui-5.79.0-3.fc34.x86_64 kf5-kio-widgets-libs-5.79.0-3.fc34.x86_64 kf5-kxmlgui-5.79.0-2.fc34.x86_64 kf5-plasma-5.79.0-2.fc34.x86_64 libacl-2.2.53-10.fc34.x86_64 libattr-2.4.48-11.fc34.x86_64 libselinux-3.2-0.rc2.1.fc34.x86_64 libxkbcommon-1.0.3-2.fc34.x86_64 ncurses-libs-6.2-4.20200222.fc34.x86_64 qt5-qtsvg-5.15.2-3.fc34.x86_64 systemd-libs-248~rc2-3.fc35.x86_64
--Type <RET> for more, q to quit, c to continue without paging--
        add-auto-load-safe-path /usr/lib64/libthread_db-1.0.so
line to your configuration file "/root/.gdbinit".
To completely disable this security protection add
        set auto-load safe-path /
line to your configuration file "/root/.gdbinit".
For more information about this security protection see the
"Auto-loading safe path" section in the GDB manual.  E.g., run from the shell:
        info "(gdb)Auto-loading safe path"

warning: Unable to find libthread_db matching inferior's thread library, thread debugging will not be available.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Core was generated by `kwin_wayland --wayland_fd 4 --xwayland /usr/libexec/startplasma-waylandsession'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00007fcb6377bedf in gbm_bo_destroy (bo=0x55c54b914380) at ../src/gbm/main/gbm.c:445
445        bo->gbm->bo_destroy(bo);
[Current thread is 1 (Thread 0x7fcb71a2ae00 (LWP 1445))]
(gdb) bt
#0  0x00007fcb6377bedf in gbm_bo_destroy (bo=0x55c54b914380) at ../src/gbm/main/gbm.c:445
#1  0x00007fcb637f1d9e in KWin::EglGbmBackend::renderFramebufferToSurface(KWin::EglGbmBackend::Output&) (this=this@entry=0x55c54accae00, output=...)
    at /usr/src/debug/kwin-5.22.0-1.fc35.x86_64/src/plugins/platforms/drm/egl_gbm_backend.cpp:457
#2  0x00007fcb637f848b in KWin::EglGbmBackend::endFrame(int, QRegion const&, QRegion const&)
    (this=0x55c54accae00, screenId=<optimized out>, renderedRegion=<optimized out>, damagedRegion=...)
    at /usr/src/debug/kwin-5.22.0-1.fc35.x86_64/src/plugins/platforms/drm/egl_gbm_backend.cpp:676
#3  0x00007fcb637f1671 in KWin::EglMultiBackend::endFrame(int, QRegion const&, QRegion const&)
    (this=<optimized out>, screenId=<optimized out>, damage=..., damagedRegion=...)
    at /usr/src/debug/kwin-5.22.0-1.fc35.x86_64/src/plugins/platforms/drm/egl_multi_backend.cpp:72
#4  0x00007fcb61c26ee2 in KWin::SceneOpenGL::paint(int, QRegion const&, QList<KWin::Toplevel*> const&, KWin::RenderLoop*)
    (renderLoop=<optimized out>, toplevels=<optimized out>, damage=<optimized out>, screenId=1, this=0x55c54aebba00)
    at /usr/src/debug/kwin-5.22.0-1.fc35.x86_64/src/plugins/scenes/opengl/scene_opengl.cpp:699
#5  KWin::SceneOpenGL::paint(int, QRegion const&, QList<KWin::Toplevel*> const&, KWin::RenderLoop*)
    (this=0x55c54aebba00, screenId=1, damage=<optimized out>, toplevels=<optimized out>, renderLoop=<optimized out>)
    at /usr/src/debug/kwin-5.22.0-1.fc35.x86_64/src/plugins/scenes/opengl/scene_opengl.cpp:605
#6  0x00007fcb780eac15 in KWin::Compositor::handleFrameRequested(KWin::RenderLoop*) (renderLoop=0x55c54ac87fb0, this=<optimized out>)
    at /usr/src/debug/kwin-5.22.0-1.fc35.x86_64/src/composite.cpp:665
#7  KWin::Compositor::handleFrameRequested(KWin::RenderLoop*) (this=<optimized out>, renderLoop=0x55c54ac87fb0)
    at /usr/src/debug/kwin-5.22.0-1.fc35.x86_64/src/composite.cpp:589
#8  0x00007fcb785c74b0 in QtPrivate::QSlotObjectBase::call(QObject*, void**) (a=0x7fffcb2ca230, r=<optimized out>, this=0x55c54b6b60d0)
    at ../../include/QtCore/../../src/corelib/kernel/qobjectdefs_impl.h:398
#9  doActivate<false>(QObject*, int, void**) (sender=0x55c54ac87fb0, signal_index=5, argv=0x7fffcb2ca230) at kernel/qobject.cpp:3886
#10 0x00007fcb785c19e7 in QMetaObject::activate(QObject*, QMetaObject const*, int, void**)
    (sender=<optimized out>, m=m@entry=0x7fcb782fe560 <KWin::RenderLoop::staticMetaObject>, local_signal_index=local_signal_index@entry=2, argv=argv@entry=0x7fffcb2ca230)
    at kernel/qobject.cpp:3946
#11 0x00007fcb780abe26 in KWin::RenderLoop::frameRequested(KWin::RenderLoop*) (this=<optimized out>, _t1=<optimized out>)
    at /usr/src/debug/kwin-5.22.0-1.fc35.x86_64/x86_64-redhat-linux-gnu/src/kwin_autogen/EWIEGA46WW/moc_renderloop.cpp:193
#12 0x00007fcb78176c17 in KWin::RenderLoopPrivate::dispatch() (this=0x55c54acaf2b0) at /usr/src/debug/kwin-5.22.0-1.fc35.x86_64/src/renderloop.cpp:143
#13 0x00007fcb785c74b0 in QtPrivate::QSlotObjectBase::call(QObject*, void**) (a=0x7fffcb2ca350, r=<optimized out>, this=0x55c54abf8c20)
    at ../../include/QtCore/../../src/corelib/kernel/qobjectdefs_impl.h:398
#14 doActivate<false>(QObject*, int, void**) (sender=0x55c54acaf2c8, signal_index=3, argv=0x7fffcb2ca350) at kernel/qobject.cpp:3886
#15 0x00007fcb785c19e7 in QMetaObject::activate(QObject*, QMetaObject const*, int, void**)
    (sender=<optimized out>, m=m@entry=0x7fcb7885c580 <QTimer::staticMetaObject>, local_signal_index=local_signal_index@entry=0, argv=argv@entry=0x7fffcb2ca350)
    at kernel/qobject.cpp:3946
#16 0x00007fcb785ca5ae in QTimer::timeout(QTimer::QPrivateSignal) (this=<optimized out>, _t1=...) at .moc/moc_qtimer.cpp:205
#17 0x00007fcb785be21f in QObject::event(QEvent*) (this=0x55c54acaf2c8, e=0x7fffcb2ca4a0) at kernel/qobject.cpp:1336
#18 0x00007fcb775c8e73 in QApplicationPrivate::notify_helper(QObject*, QEvent*) (this=<optimized out>, receiver=0x55c54acaf2c8, e=0x7fffcb2ca4a0)
    at kernel/qapplication.cpp:3632
#19 0x00007fcb78596f48 in QCoreApplication::notifyInternal2(QObject*, QEvent*) (receiver=0x55c54acaf2c8, event=0x7fffcb2ca4a0) at kernel/qcoreapplication.cpp:1063
#20 0x00007fcb785e29e3 in QTimerInfoList::activateTimers() (this=this@entry=0x55c54ab34c98) at kernel/qtimerinfo_unix.cpp:643
#21 0x00007fcb785dfe60 in QEventDispatcherUNIXPrivate::activateTimers() (this=this@entry=0x55c54ab34c10) at kernel/qeventdispatcher_unix.cpp:249
#22 0x00007fcb785e0ee0 in QEventDispatcherUNIX::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) (this=<optimized out>, flags=...)
    at kernel/qeventdispatcher_unix.cpp:516
#23 0x000055c549976621 in  ()
--Type <RET> for more, q to quit, c to continue without paging--
#24 0x000055c54abf1dac in  ()
#25 0x0000000000000024 in  ()
#26 0x000055c54abf1d50 in  ()
#27 0x00007fcb785959b2 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) (this=this@entry=0x7fffcb2ca620, flags=..., flags@entry=...)
    at ../../include/QtCore/../../src/corelib/global/qflags.h:69
#28 0x00007fcb7859d544 in QCoreApplication::exec() () at ../../include/QtCore/../../src/corelib/global/qflags.h:121
#29 0x000055c5499223f4 in  ()
#30 0x0000000000000000 in  ()
Comment 29 Shawn Starr 2021-03-16 19:11:10 UTC
Created attachment 136749 [details]
Stack dump

Stack dump
Comment 30 Shawn Starr 2021-03-16 21:46:05 UTC
Created attachment 136754 [details]
Wayland Session Errors from multiple kwin spawn attempts by SDDM

Wayland Session Errors from multiple kwin spawn attempts by SDDM
Comment 31 Zamundaaa 2021-03-18 17:44:18 UTC
Git commit 6569bf80c37ea46e7507fac17b9f1162b9a9978e by Xaver Hugl.
Committed on 18/03/2021 at 14:22.
Pushed by zamundaaa into branch 'master'.

EglGbmBackend: use output reference

M  +2    -2    src/plugins/platforms/drm/egl_gbm_backend.cpp

https://invent.kde.org/plasma/kwin/commit/6569bf80c37ea46e7507fac17b9f1162b9a9978e
Comment 32 Shawn Starr 2021-03-18 18:26:27 UTC
Will test this commit and report back
Comment 33 Zamundaaa 2021-03-18 18:29:52 UTC
Test https://invent.kde.org/plasma/kwin/-/merge_requests/756 that's rebased. The crash should be fixed, the behavior of the monitor will most likely not change though
Comment 34 Shawn Starr 2021-03-18 23:03:36 UTC
Well, the coredump is fixed, and it shows a lot more of the error...
Comment 35 Shawn Starr 2021-03-18 23:04:06 UTC
Created attachment 136828 [details]
New Wayland Session log

New Wayland Session log
Comment 36 Aleix Pol 2021-03-18 23:33:51 UTC
Can you provide that new coredump then? (in addition to the session log)
Comment 37 Shawn Starr 2021-03-18 23:38:34 UTC
Oh there's no coredump now, systemd coredumpctl shows none.

This core issue remains, I just happened to crash kwin before the above commit is already in the master branch.
Comment 38 Zamundaaa 2021-03-19 00:50:13 UTC
I'll be adding a CPU fallback mode for multi-GPU soon™, that would definitely work.

Ideally we can still get it working with hardware acceleration for 5.22 though...
Could you check if on master a fullscreen game running through Xwayland and on the dedicated GPU makes the display work? Even if there is no PRIME support for the hardware that should show something. If it does show something, could you then test the same but with the game running on the integrated graphics?
Comment 39 Shawn Starr 2021-03-19 01:00:31 UTC
Well, its not even a game that works, Plasma/Kscreen doesnt detect the screen.
Comment 40 Zamundaaa 2021-03-19 01:16:51 UTC
I know that the display doesn't turn on but you should be able to move windows to it on master.
Comment 41 Shawn Starr 2021-03-19 01:19:35 UTC
Well, right now when i try starting with XWayland via SDDM, it just locks up the screen I can VT switch however..

I will create a new user and see if any .config from KDE is causing XWayland/X11 confusion with Kwin/Kscreen
Comment 42 Shawn Starr 2021-03-19 06:12:19 UTC
Yes, if I make a new user, XWayland starts only on the Laptop display, I *can* drag windows to the external display.

Kscreen does detect this but no display, I do see attempts to power it on then it fails the kernel shows:

[   91.494549] amdgpu: VI should always have 2 performance levels
[  126.275199] [drm] PCIE gen 3 link speeds already enabled
[  126.277690] [drm] PCIE GART of 1024M enabled (table at 0x000000F400000000).
[  126.282206] amdgpu 0000:01:00.0: amdgpu: SRBM_SOFT_RESET=0x00100040
[  126.449983] [drm] Got external EDID base block and 2 extensions from "edid/Samsung-LC27G7xT.edid.bin" for connector "DP-2"
[  126.510293] [drm] UVD initialized successfully.
[  126.631314] [drm] VCE initialized successfully.
[  132.760379] amdgpu: VI should always have 2 performance levels
[  139.011159] [drm] PCIE gen 3 link speeds already enabled
[  139.012180] [drm] PCIE GART of 1024M enabled (table at 0x000000F400000000).
[  139.014696] amdgpu 0000:01:00.0: amdgpu: SRBM_SOFT_RESET=0x00100040
[  139.173110] [drm] Got external EDID base block and 2 extensions from "edid/Samsung-LC27G7xT.edid.bin" for connector "DP-2"
[  139.232354] [drm] UVD initialized successfully.
[  139.353376] [drm] VCE initialized successfully.
[  159.485632] amdgpu: VI should always have 2 performance levels
[  182.866884] [drm] PCIE gen 3 link speeds already enabled
[  182.869354] [drm] PCIE GART of 1024M enabled (table at 0x000000F400000000).
[  182.873968] amdgpu 0000:01:00.0: amdgpu: SRBM_SOFT_RESET=0x00100040
[  183.037980] [drm] Got external EDID base block and 2 extensions from "edid/Samsung-LC27G7xT.edid.bin" for connector "DP-2"
[  183.097016] [drm] UVD initialized successfully.
[  183.218037] [drm] VCE initialized successfully.
[  188.819090] amdgpu: VI should always have 2 performance levels
[  193.681966] [drm] PCIE gen 3 link speeds already enabled
[  193.684447] [drm] PCIE GART of 1024M enabled (table at 0x000000F400000000).
[  193.688981] amdgpu 0000:01:00.0: amdgpu: SRBM_SOFT_RESET=0x00100040
[  193.853029] [drm] Got external EDID base block and 2 extensions from "edid/Samsung-LC27G7xT.edid.bin" for connector "DP-2"
[  193.913052] [drm] UVD initialized successfully.
[  194.034072] [drm] VCE initialized successfully.
[  194.405045] broken atomic modeset userspace detected, disabling atomic
[  207.167245] amdgpu: [powerplay] 
                failed to send message 146 ret is 0
Comment 43 Shawn Starr 2021-03-19 06:26:37 UTC
I even tried disconnecting from my DisplayPort KVM switch, same result, so that eliminates that.

If this is a kernel bug, why does this only manifest with XWayland and not X11?
Comment 44 Zamundaaa 2021-03-19 07:57:28 UTC
Okay now the interesting bit would be if fullscreen apps running through Xwayland make the display work - with direct scanout they bypass the normal multi-GPU mechanism. So just use any game from Steam or install Xonotic or something like that from your distros repo, make it fullscreen and drag the fullscreen window to the not-working display with Meta + Left Click. If I'm right then the display should light up.

(In reply to Shawn Starr from comment #43)
> If this is a kernel bug, why does this only manifest with Wayland and not
> X11?

Either X is doing hardware accelerated multi-GPU differently in some way that works or it's using the CPU fallback
Comment 45 Shawn Starr 2021-03-19 13:16:27 UTC
I will try that in a moment...
Comment 46 Shawn Starr 2021-03-19 19:26:57 UTC
Does not work.

I even tried Wine with League of Legends, moved window to other screen, alt+enter but it moved the full screen to the laptop output.

Attached the is the log with League of Legends
Comment 47 Shawn Starr 2021-03-19 19:28:41 UTC
Created attachment 136854 [details]
kwin Xwayland - wayland-errors.log

kwin Xwayland - wayland-errors.log
Comment 48 Zamundaaa 2021-03-20 00:43:01 UTC
Are you sure the game ran on the dedicated GPU? The log suggests to me that it probably wasn't
Comment 49 Shawn Starr 2021-03-20 20:22:25 UTC
Should be, DRI_PRIME is set, but I'll double check and or enforce if its not.
Comment 50 Shawn Starr 2021-03-25 05:51:05 UTC
From my Xorg config I have DRI_PRIME=0 

OpenGL renderer string: AMD Radeon HD 8950 (BONAIRE, DRM 3.40.0, 5.10.14-200.fc33.x86_64, LLVM 11.1.0)
OpenGL core profile version string: 4.6 (Core Profile) Mesa 21.0.0
OpenGL core profile shading language version string: 4.60

When in standard X

I don't know how Kwin/KWayland-server handles integrated vs dedicated GPUs here.

But if I move the window to the DisplayPort nothing lights up...
Comment 51 Shawn Starr 2021-03-25 06:02:17 UTC
I tried again, explicitly even set DRI_PRIME to right GPU, attached is new wayland-errors log file.
Comment 52 Shawn Starr 2021-03-25 06:02:54 UTC
Created attachment 137046 [details]
Kwin Kwayland-server new log

Kwin Kwayland-server new log
Comment 53 Shawn Starr 2021-03-25 06:11:39 UTC
I should note when I moved the screen to the DisplayPort, then maximized it was returned to the laptop screen. So it was not allowing it to be displayed on the DisplayPort output which didn't light up.

I did see in logs:

kwin_wayland_drm: drmModeAddFB2WithModifiers failed! Invalid argument
kwin_wayland_drm: drmModeAddFB2 and drmModeAddFB both failed! Invalid argument

So, drmModeAddFB2WithModifiers is new...
Comment 54 Nate Graham 2021-03-28 21:24:12 UTC
*** Bug 425586 has been marked as a duplicate of this bug. ***
Comment 55 Nate Graham 2021-04-06 04:31:37 UTC
*** Bug 435265 has been marked as a duplicate of this bug. ***
Comment 56 Zamundaaa 2021-04-06 16:58:44 UTC
Can you test if https://invent.kde.org/plasma/kwin/-/merge_requests/832 works?
Comment 57 Shawn Starr 2021-04-06 17:12:35 UTC
Will compile and report back today
Comment 58 Shawn Starr 2021-04-08 05:06:41 UTC
Well, something appeared but it was garbage output on the DisplayPort.

I had to alt-tab to switch VT then back and then I noticed my laptop display lit up.

Attached is log.
Comment 59 Shawn Starr 2021-04-08 05:07:44 UTC
Created attachment 137423 [details]
Wayland Errors Log - with work/zamundaaa/dumb-import branch for kwin

Wayland Errors Log - with work/zamundaaa/dumb-import branch for kwin
Comment 60 Shawn Starr 2021-04-09 00:28:08 UTC
Results:

In the first log, I created a new user
- Started Plasma Wayland session, Laptop screen and DisplayPort didnt turn on, VT switched, the DisplayPort turned on saw an X cursor but nothing else, laptop screen did not turn on.

In the second log, before I switched to Wayland from X11, I forced Kscreen to make the laptop screen primary and DisplayPort secondary.

- Started Plasma Wayland session, Laptop screen and DisplayPort didn't turn on, VT switched. Laptop screen turned on, DisplayPort screen failed...

Still no go with latest test branch.

Attached are both logs.
Comment 61 Shawn Starr 2021-04-09 00:28:41 UTC
Created attachment 137442 [details]
Wayland Errors Log - New user - with work/zamundaaa/dumb-import branch for kwin

Wayland Errors Log - New user - with work/zamundaaa/dumb-import branch for kwin
Comment 62 Shawn Starr 2021-04-09 00:29:19 UTC
Created attachment 137443 [details]
Wayland Errors Log - Existing user - Laptop screen made primary  - with work/zamundaaa/dumb-import branch for kwin

Wayland Errors Log - Existing user - Laptop screen made primary  - with work/zamundaaa/dumb-import branch for kwin
Comment 63 Zamundaaa 2021-04-10 12:56:31 UTC
The laptop display not turning on is unexpected... Maybe I can still find a solution that can be implemented somwhat quickly but it looks like it's gonna take a while
Comment 64 Shawn Starr 2021-04-13 20:56:17 UTC
I hate to bring this up but: https://gitlab.com/kwinft/kwinft/-/issues/137

Why exactly are we not using wlroots? It's not exactly 'fun' to have to implement your own drm plugin for kwin, deal with all the complexities of display management .... like Xorg DDX did for us behind the scenes..
Comment 65 Neal Gompa 2021-04-13 21:05:12 UTC
(In reply to Shawn Starr from comment #64)
> I hate to bring this up but: https://gitlab.com/kwinft/kwinft/-/issues/137
> 
> Why exactly are we not using wlroots? It's not exactly 'fun' to have to
> implement your own drm plugin for kwin, deal with all the complexities of
> display management .... like Xorg DDX did for us behind the scenes..

Among other things, wlroots will *never* support NVIDIA.
Comment 66 Shawn Starr 2021-04-13 21:09:34 UTC
That's not confirmed... and wlroots devs dispute this im told on IRC so...
Comment 67 Neal Gompa 2021-04-13 21:12:36 UTC
(In reply to Shawn Starr from comment #66)
> That's not confirmed... and wlroots devs dispute this im told on IRC so...

* https://github.com/swaywm/sway/wiki#nvidia-users
* https://drewdevault.com/2017/10/26/Fuck-you-nvidia.html

The wlroots/sway devs are very public about not supporting NVIDIA.
Comment 68 Shawn Starr 2021-04-13 21:29:01 UTC
You should sort that out with them. Upon installing Sway for Fedora, starting Sway from SDDM, both displays turned on immediately.

So...
Comment 69 Fervi 2021-04-13 21:46:05 UTC
Sway supports Nvidia, but without support
https://github.com/swaywm/sway/blob/master/sway/main.c#L103
Comment 70 Shawn Starr 2021-04-16 18:31:36 UTC
Coming back to the KDE side of things.. right now nothing works for me. I can wait and will have to wait. I would prefer we have a common EDID/display detection framework not one for every DE though...
Comment 71 Shawn Starr 2021-04-19 03:53:33 UTC
Created attachment 137697 [details]
New log from latest code changes

New log from latest code changes
Comment 72 Shawn Starr 2021-04-19 04:24:43 UTC
Created attachment 137698 [details]
Coredump from Kwin

Coredump from the session tested,segfaulted
Comment 73 Shawn Starr 2021-04-21 13:44:38 UTC
Interesting results with kwin branches:

work/zamundaaa/dumb-import + work/primary-gpu-context
 merged together with latest kwayland-server master + protocols.

I *DO* get the DisplayPort turning on, although only *one* screen is able to turn on now..

Log attached
Comment 74 Shawn Starr 2021-04-21 13:45:37 UTC
Created attachment 137761 [details]
Wayland Error logs - with dumb-import + primary-gpu-context branches

Wayland Error logs - with dumb-import + primary-gpu-context branches
Comment 75 Shawn Starr 2021-04-22 05:12:50 UTC
Created attachment 137781 [details]
New log from latest testing - dumb-import + primary-gpu-context + fix-hotplug

New log from latest testing - dumb-import + primary-gpu-context + fix-hotplug
Comment 76 Shawn Starr 2021-04-22 06:10:56 UTC
Created attachment 137782 [details]
dumb-import + primary-gpu-context + fix-hotplug w/o SDDM/Xorg VT

dumb-import + primary-gpu-context + fix-hotplug w/o SDDM/Xorg VT
Comment 77 Shawn Starr 2021-04-22 15:23:23 UTC
Created attachment 137797 [details]
dumb-import + primary-gpu-context log

dumb-import + primary-gpu-context log
Comment 78 Shawn Starr 2021-04-22 21:43:53 UTC
Created attachment 137810 [details]
dumb-import branch only

dumb-import branch only
Comment 79 Shawn Starr 2021-04-23 16:17:26 UTC
Created attachment 137838 [details]
dumb-import branch only - latest test

dumb-import branch only - latest test
Comment 80 Shawn Starr 2021-04-23 20:40:53 UTC
Created attachment 137848 [details]
dumb-import - April 23rd - log

dumb-import - April 23rd - log
Comment 81 Shawn Starr 2021-04-23 23:46:37 UTC
Created attachment 137851 [details]
dumb-import - April 23rd - log - Latest

 dumb-import - April 23rd - log - Latest
Comment 82 Shawn Starr 2021-05-04 05:26:08 UTC
With latest changes to dumb-import both displays turn on now!

Attached outputs
Comment 83 Shawn Starr 2021-05-04 05:26:48 UTC
Created attachment 138131 [details]
Kwin + latest KWayland server + protocols - both displays turn on

Kwin + latest KWayland server + protocols - both displays turn on
Comment 84 Zamundaaa 2021-05-18 13:05:11 UTC
Git commit 7de0f1f2ad022241fb5644ab6798b60b5a94d90f by Xaver Hugl.
Committed on 18/05/2021 at 12:54.
Pushed by zamundaaa into branch 'master'.

platforms/drm: CPU copy for multi-gpu

Not all GPUs can scan out linear buffers, so if import with a dmabuf
fails manually copy the data into a non-linear gbm buffer instead.

M  +1    -0    src/plugins/platforms/drm/CMakeLists.txt
M  +13   -2    src/plugins/platforms/drm/abstract_egl_drm_backend.h
M  +3    -1    src/plugins/platforms/drm/drm_buffer.h
M  +26   -2    src/plugins/platforms/drm/drm_buffer_gbm.cpp
M  +12   -0    src/plugins/platforms/drm/drm_buffer_gbm.h
A  +54   -0    src/plugins/platforms/drm/dumb_swapchain.cpp     [License: GPL(v2.0+)]
A  +45   -0    src/plugins/platforms/drm/dumb_swapchain.h     [License: GPL(v2.0+)]
M  +165  -81   src/plugins/platforms/drm/egl_gbm_backend.cpp
M  +13   -3    src/plugins/platforms/drm/egl_gbm_backend.h
M  +2    -8    src/plugins/platforms/drm/egl_multi_backend.cpp
M  +7    -23   src/plugins/platforms/drm/scene_qpainter_drm_backend.cpp
M  +3    -2    src/plugins/platforms/drm/scene_qpainter_drm_backend.h

https://invent.kde.org/plasma/kwin/commit/7de0f1f2ad022241fb5644ab6798b60b5a94d90f
Comment 85 Zamundaaa 2021-05-31 07:53:30 UTC
Git commit 592d2aac05946a8c329e1e8c3d49368160f6af2c by Xaver Hugl.
Committed on 31/05/2021 at 07:53.
Pushed by zamundaaa into branch 'Plasma/5.22'.

platforms/drm: CPU copy for multi-gpu

Not all GPUs can scan out linear buffers, so if import with a dmabuf
fails manually copy the data into a non-linear gbm buffer instead.


(cherry picked from commit 7de0f1f2ad022241fb5644ab6798b60b5a94d90f)

M  +1    -0    src/plugins/platforms/drm/CMakeLists.txt
M  +13   -2    src/plugins/platforms/drm/abstract_egl_drm_backend.h
M  +3    -1    src/plugins/platforms/drm/drm_buffer.h
M  +26   -2    src/plugins/platforms/drm/drm_buffer_gbm.cpp
M  +12   -0    src/plugins/platforms/drm/drm_buffer_gbm.h
A  +54   -0    src/plugins/platforms/drm/dumb_swapchain.cpp     [License: GPL(v2.0+)]
A  +45   -0    src/plugins/platforms/drm/dumb_swapchain.h     [License: GPL(v2.0+)]
M  +165  -81   src/plugins/platforms/drm/egl_gbm_backend.cpp
M  +13   -3    src/plugins/platforms/drm/egl_gbm_backend.h
M  +2    -8    src/plugins/platforms/drm/egl_multi_backend.cpp
M  +7    -23   src/plugins/platforms/drm/scene_qpainter_drm_backend.cpp
M  +3    -2    src/plugins/platforms/drm/scene_qpainter_drm_backend.h

https://invent.kde.org/plasma/kwin/commit/592d2aac05946a8c329e1e8c3d49368160f6af2c