swaywm / wlroots

A modular Wayland compositor library
https://gitlab.freedesktop.org/wlroots/wlroots/
MIT License
2.15k stars 342 forks source link

Black screen after resume (dpms off/dpms on): Atomic commit failed (modeset): Invalid argument #2373

Open johnae opened 4 years ago

johnae commented 4 years ago

I know there are other, somewhat similar, reports. I wasn't sure whether this is a duplicate though. Sorry if it is.

I'm on a Dell XPS 13 9370. I've had this issue for quite some time, not sure exactly when it started but it's been several months now.

I've got swayidle set up to run dpms off after some time and to run dpms on resume. That's where this tends to happen (and I have to switch VT and kill and relaunch sway to get back to a good state). It seems to usually only affect the internal screen of the laptop - it happens both with and without external screen connected.

I can easily replicate this issue by just using swaymsg. Attaching a log from when I've done so.

Line 1749 is when I turn off the screens. Line 2299 is when I turn them on again (but the internal screen stays black). It looks as if this error occurs around that time:

2354   │ 00:02:34.197 [DEBUG] [backend/drm/drm.c:685] Initializing renderer on connector 'eDP-1'
2355   │ 00:02:34.202 [ERROR] [backend/drm/atomic.c:36] eDP-1: Atomic commit failed (modeset): Invalid argument
2356   │ 00:02:34.202 [INFO] [backend/drm/drm.c:723] Page-flip failed with primary FB modifiers enabled, retrying without modifiers
2357   │ 00:02:34.207 [ERROR] [backend/drm/atomic.c:36] eDP-1: Atomic commit failed (modeset): Invalid argument
2358   │ 00:02:34.207 [ERROR] [backend/drm/drm.c:736] Failed to initialize renderer on connector 'eDP-1': initial page-flip failed
2359   │ 00:02:34.207 [ERROR] [backend/drm/drm.c:809] Failed to initialize renderer for plane
2360   │ 00:02:34.207 [sway/config/output.c:414] Failed to commit output eDP-1

I've tested this with WLR_DRM_NO_MODIFIERS set but I experience the same problem. Will see if I can get a log from that as well.

sway.log


wlroots has migrated to gitlab.freedesktop.org. This issue has been moved to:

https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/2373

emersion commented 4 years ago

Can you obtain DRM debug logs? See https://github.com/swaywm/wlroots/wiki/DRM-Debugging

johnae commented 4 years ago

Sure. Attaching those logs.

dmesg.log sway.log

emersion commented 4 years ago
[59328.307332] i915 0000:00:02.0: [drm:skl_allocate_pipe_ddb [i915]] Requested display configuration exceeds system DDB limitations
[59328.307346] i915 0000:00:02.0: [drm:skl_allocate_pipe_ddb [i915]] minimum required 482/401
johnae commented 4 years ago

Ok. In the cases above, I do have an external display connected but it also happens without an external display. Not sure if the error is the same but the symptom is. What could lead to this? It seems odd that I would exceed anything by simply turning off and on the display...

johnae commented 4 years ago

I guess this might be a dupe of https://github.com/swaywm/wlroots/issues/1877 and will possibly be fixed in https://github.com/swaywm/wlroots/issues/1873 ?

emersion commented 4 years ago

1877 is fixed by WLR_DRM_NO_MODIFIERS

johnae commented 4 years ago

Yeah I tried that but it seemed it didn't do anything for me but trying it now again I can't reproduce the issue. So at the very least it helps. Thanks.

cyanreg commented 4 years ago

I've been able to replicate this randomly for years now on both my machines. I have keys bound to shut the display, which I use often, and every once in a while the screen remains either fully black or has the backlight lit. Clients still receive full inputs, so by habit I sometimes type in my user password expecting swaylock to show up and end up giving it away. To fix this, I either have to wait for the inactivity to wake swayidle up and for it to turn off the display again, or I have to use SSH or switch VTs and turn the display off, then on again. swayidle too sometimes bugs out like this, and you have to kill it before cycling. Its not a huge pain to live with, but its a big pain nonetheless.

emersion commented 4 years ago

This issue is about Invalid argument errors only. Please check your logs, maybe what you're experiencing is https://github.com/swaywm/wlroots/issues/2325.

emersion commented 4 years ago

Getting EINVAL after DPMS ON would be a kernel bug I think. It would be helpful to collect drm_info snapshots before the screen is DPMS'ed off, when it is off, and after trying to enable it again.

jpgrayson commented 3 years ago

This has been a problem for me on my Dell XPS 9360 (which uses the i915 driver for the HD 620 GPU) when using an external display.

I have found that using WLR_DRM_NO_MODIFIERS=1 successfully works-around the problem.

Without the workaround, I see the following in the sway log at init-time:

00:00:00.305 [INFO] [backend/drm/drm.c:803] Modesetting 'eDP-1' with '3200x1800@59982mHz'
00:00:00.313 [DEBUG] [backend/drm/drm.c:685] Initializing renderer on connector 'eDP-1'
00:00:00.313 [ERROR] [backend/drm/atomic.c:36] eDP-1: Atomic commit failed (modeset): Invalid argument
00:00:00.346 [INFO] [backend/drm/drm.c:723] Page-flip failed with primary FB modifiers enabled, retrying without modifiers
...
00:00:00. [DEBUG] [backend/drm/drm.c:685] Initializing renderer on connector 'DP-1'
00:00:00. [ERROR] [backend/drm/atomic.c:36] DP-1: Atomic commit failed (modeset): Invalid argument
00:00:00. [INFO] [backend/drm/drm.c:723] Page-flip failed with primary FB modifiers enabled, retrying without modifiers
00:00:00. [sway/config/output.c:455] Set DP-1 position to 3200, 0

And later, after dpms off then on:

00:00:03. [sway/config/output.c:348] Turning on output DP-1
00:00:03. [sway/config/output.c:409] Committing output DP-1
00:00:03. [INFO] [backend/drm/drm.c:803] Modesetting 'DP-1' with '3840x2160@59997mHz'
00:00:03. [DEBUG] [backend/drm/drm.c:685] Initializing renderer on connector 'DP-1'
00:00:03. [sway/config/output.c:455] Set DP-1 position to 3200, 0
00:00:03. [sway/tree/arrange.c:263] Usable area for ws: 3200x1800@0,0
00:00:03. [sway/tree/arrange.c:293] Arranging workspace '1' at 0.000000, 360.000000
00:00:03. [sway/tree/arrange.c:263] Usable area for ws: 3840x2160@0,0
00:00:03. [sway/tree/arrange.c:293] Arranging workspace '2' at 3200.000000, 0.000000
00:00:03. [sway/desktop/transaction.c:427] Transaction 0x55d2a4145780 committing with 2 instructions
00:00:03. [sway/desktop/transaction.c:281] Applying transaction 0x55d2a4145780
...
00:00:03. [sway/config/output.c:348] Turning on output eDP-1
00:00:03. [sway/config/output.c:409] Committing output eDP-1
00:00:03. [INFO] [backend/drm/drm.c:803] Modesetting 'eDP-1' with '3200x1800@59982mHz'
00:00:03. [DEBUG] [backend/drm/drm.c:685] Initializing renderer on connector 'eDP-1'
00:00:03. [ERROR] [backend/drm/renderer.c:381] Tried to acquire an FB with a NULL BO
00:00:03. [ERROR] [backend/drm/atomic.c:164] Failed to set plane 47 properties
00:00:03. [INFO] [backend/drm/drm.c:723] Page-flip failed with primary FB modifiers enabled, retrying without modifiers
00:00:03. [ERROR] [backend/drm/renderer.c:381] Tried to acquire an FB with a NULL BO
00:00:03. [ERROR] [backend/drm/atomic.c:164] Failed to set plane 47 properties
00:00:03. [ERROR] [backend/drm/drm.c:736] Failed to initialize renderer on connector 'eDP-1': initial page-flip failed
00:00:03. [ERROR] [backend/drm/drm.c:809] Failed to initialize renderer for plane
00:00:03. [sway/config/output.c:414] Failed to commit output eDP-1

The curious thing is that with WLR_DRM_NO_MODIFIERS=1, the log outputs are very similar and both contain ERROR lines, but with WLR_DRM_NO_MODIFIERS=1 both eDP-1 and DP-1 are on/rendered after the dpms off/on cycle.

Init-time with WLR_DRM_NO_MODIFIERS=1:

00:00:00. [INFO] [backend/drm/drm.c:803] Modesetting 'eDP-1' with '3200x1800@59982mHz'
00:00:00. [DEBUG] [backend/drm/drm.c:685] Initializing renderer on connector 'eDP-1'
00:00:00. [DEBUG] [backend/drm/drm.c:707] WLR_DRM_NO_MODIFIERS set, initializing planes without modifiers
00:00:00. [sway/config/output.c:455] Set eDP-1 position to 0, 360
...
00:00:00. [INFO] [backend/drm/drm.c:803] Modesetting 'DP-1' with '3840x2160@59997mHz'
00:00:00. [DEBUG] [backend/drm/drm.c:685] Initializing renderer on connector 'DP-1'
00:00:00. [DEBUG] [backend/drm/drm.c:707] WLR_DRM_NO_MODIFIERS set, initializing planes without modifiers
00:00:00. [sway/config/output.c:455] Set DP-1 position to 3200, 0

After dpms off/on with WLR_DRM_NO_MODIFIERS=1:

00:00:03. [sway/config/output.c:348] Turning on output DP-1
00:00:03. [sway/config/output.c:409] Committing output DP-1
00:00:03. [INFO] [backend/drm/drm.c:803] Modesetting 'DP-1' with '3840x2160@59997mHz'
00:00:03. [DEBUG] [backend/drm/drm.c:685] Initializing renderer on connector 'DP-1'
00:00:03. [DEBUG] [backend/drm/drm.c:707] WLR_DRM_NO_MODIFIERS set, initializing planes without modifiers
00:00:03. [sway/config/output.c:455] Set DP-1 position to 3200, 0
...
00:00:03. [sway/config/output.c:348] Turning on output eDP-1
00:00:03. [sway/config/output.c:409] Committing output eDP-1
00:00:03. [INFO] [backend/drm/drm.c:803] Modesetting 'eDP-1' with '3200x1800@59982mHz'
00:00:03. [DEBUG] [backend/drm/drm.c:685] Initializing renderer on connector 'eDP-1'
00:00:03. [DEBUG] [backend/drm/drm.c:707] WLR_DRM_NO_MODIFIERS set, initializing planes without modifiers
00:00:03. [ERROR] [backend/drm/renderer.c:381] Tried to acquire an FB with a NULL BO
00:00:03. [ERROR] [backend/drm/atomic.c:164] Failed to set plane 47 properties
00:00:03. [ERROR] [backend/drm/drm.c:715] Failed to initialize renderer on connector 'eDP-1': initial page-flip failed
00:00:03. [ERROR] [backend/drm/drm.c:809] Failed to initialize renderer for plane
00:00:03. [sway/config/output.c:414] Failed to commit output eDP-1

So in terms of the sway logs, it seems like the retry without modifiers is ineffective vs. when using WLR_DRM_NO_MODIFIERS=1 where ostensibly the only attempt is without modifiers. Both lead to scary ERROR messages, but the latter "works" in that eDP-1 actually comes on and renders.

The previous comment from @emersion requested drm_info snapshots for init, dpms off, and dpms on. I have attached those from my environment.

drm-info-init-modifiers.json.log drm-info-after-dpms-off-modifiers.json.log drm-info-after-dpms-on-modifiers.json.log dmesg-modifiers.log sway-modifiers.log

And here are the same drm_info snapshots and logs with WLR_DRM_NO_MODIFIERS=1:

drm-info-init-no-modifiers.json.log drm-info-after-dpms-off-no-modifiers.json.log drm-info-after-dpms-on-no-modifiers.json.log dmesg-no-modifiers.log sway-no-modifiers.log

emersion commented 3 years ago

@jpgrayson is hitting the usual

[93029.550071] i915 0000:00:02.0: [drm:skl_allocate_pipe_ddb [i915]] Requested display configuration exceeds system DDB limitations
[93029.550085] i915 0000:00:02.0: [drm:skl_allocate_pipe_ddb [i915]] minimum required 402/366
[93029.550108] i915 0000:00:02.0: [drm:intel_dump_pipe_config [i915]] [CRTC:51:pipe A] enable: yes [failed]

even with WLR_DRM_NO_MODIFIERS=1

emersion commented 3 years ago

https://github.com/swaywm/wlroots/commit/64a2ca4dbad9ae31b240ad8dd092c3664de3e02f may help making WLR_DRM_NO_MODIFIERS work better. I think we were doing allocations with modifiers even if it was set before (and only the KMS import without modifiers).

WhyNotHugo commented 3 years ago

I believe I'm having the same issue, I'm seeing this error when I hot-plug my external monitor.

I can reproduce it consistently; the only way for me to get my external monitor working is to plug it in and then reboot.

sway[636]: 11:06:59.227 [ERROR] [wlr] [backend/drm/atomic.c:35] connector DP-2: Atomic commit failed (modeset): Invalid argument
sway[636]: 11:06:59.231 [ERROR] [wlr] [backend/drm/atomic.c:35] connector DP-2: Atomic commit failed (modeset): Invalid argument
sway[636]: 11:06:59.231 [ERROR] [wlr] [backend/drm/drm.c:715] connector DP-2: Failed to initialize renderer:initial page-flip failed
sway[636]: 11:06:59.231 [ERROR] [wlr] [backend/drm/drm.c:785] connector DP-2: Failed to initialize renderer for plane
sway[636]: 11:06:59.231 [ERROR] [sway/config/output.c:417] Failed to commit output DP-2
emersion commented 3 years ago

Please open a separate issue. And try WLR_DRM_NO_MODIFIERS.