swaywm / wlroots

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

Monitors do not wake from DPMS #2567

Open JordanL2 opened 3 years ago

JordanL2 commented 3 years ago

GPU: AMD Vega 64 Displays: 2x4k connected by DisplayPort 1.2 Distro: Arch Kernel: 5.4.85-1-lts Mesa: 20.3.1-1

Using wlroots master branch, and Wayfire master branch. This issue is most likely due to a commit to wlroots in the last week, as I can reproduce it with wayfire code that hasn't been updated in the last week. The last time I updated wlroots prior to today (when I first saw this bug) was (I think) 12-DEC. I've also updated the kernel and mesa though.

When my monitors are switched off due to DPMS, and I try waking them up, they now do not switch back on. At this point rebooting is the only option.

This is what I see in the logs from when it goes to sleep (wake up is at 15:46:54). I should mention, normally when my monitors wake up from DPMS they actually immediately reconnect. It seems they just disconnect now.

DD 22-12-20 15:46:45.685 - [backend/drm/drm.c:1075] Reallocating CRTCs
DD 22-12-20 15:46:45.686 - [backend/drm/drm.c:1086] State before reallocation:
DD 22-12-20 15:46:45.686 - [backend/drm/drm.c:1092]   'DP-1' crtc=0 state=3 desired_enabled=0
DD 22-12-20 15:46:45.686 - [backend/drm/drm.c:1092]   'DP-2' crtc=1 state=3 desired_enabled=1
DD 22-12-20 15:46:45.686 - [backend/drm/drm.c:1092]   'HDMI-A-1' crtc=-1 state=0 desired_enabled=0
DD 22-12-20 15:46:45.686 - [backend/drm/drm.c:1092]   'HDMI-A-2' crtc=-1 state=0 desired_enabled=0
DD 22-12-20 15:46:45.686 - [backend/drm/drm.c:1143] State after reallocation:
DD 22-12-20 15:46:45.686 - [backend/drm/drm.c:1150]   'DP-1' crtc=0 state=3 desired_enabled=0
DD 22-12-20 15:46:45.686 - [backend/drm/drm.c:1150]   'DP-2' crtc=1 state=3 desired_enabled=1
DD 22-12-20 15:46:45.686 - [backend/drm/drm.c:1150]   'HDMI-A-1' crtc=-1 state=0 desired_enabled=0
DD 22-12-20 15:46:45.686 - [backend/drm/drm.c:1150]   'HDMI-A-2' crtc=-1 state=0 desired_enabled=0
DD 22-12-20 15:46:45.719 - [backend/drm/drm.c:1075] Reallocating CRTCs
DD 22-12-20 15:46:45.719 - [backend/drm/drm.c:1086] State before reallocation:
DD 22-12-20 15:46:45.719 - [backend/drm/drm.c:1092]   'DP-1' crtc=0 state=3 desired_enabled=0
DD 22-12-20 15:46:45.719 - [backend/drm/drm.c:1092]   'DP-2' crtc=1 state=3 desired_enabled=0
DD 22-12-20 15:46:45.719 - [backend/drm/drm.c:1092]   'HDMI-A-1' crtc=-1 state=0 desired_enabled=0
DD 22-12-20 15:46:45.719 - [backend/drm/drm.c:1092]   'HDMI-A-2' crtc=-1 state=0 desired_enabled=0
DD 22-12-20 15:46:45.719 - [backend/drm/drm.c:1143] State after reallocation:
DD 22-12-20 15:46:45.719 - [backend/drm/drm.c:1150]   'DP-1' crtc=0 state=3 desired_enabled=0
DD 22-12-20 15:46:45.719 - [backend/drm/drm.c:1150]   'DP-2' crtc=1 state=3 desired_enabled=0
DD 22-12-20 15:46:45.719 - [backend/drm/drm.c:1150]   'HDMI-A-1' crtc=-1 state=0 desired_enabled=0
DD 22-12-20 15:46:45.719 - [backend/drm/drm.c:1150]   'HDMI-A-2' crtc=-1 state=0 desired_enabled=0
II 22-12-20 15:46:54.467 - [backend/drm/drm.c:793] connector DP-1: Modesetting with '3840x2160@59997mHz'
DD 22-12-20 15:46:54.467 - [backend/drm/drm.c:679] connector DP-1: Initializing renderer
II 22-12-20 15:46:54.483 - [backend/drm/drm.c:793] connector DP-2: Modesetting with '3840x2160@59997mHz'
DD 22-12-20 15:46:54.483 - [backend/drm/drm.c:679] connector DP-2: Initializing renderer
II 22-12-20 15:46:56.808 - [backend/drm/drm.c:1219] Scanning DRM connectors on /dev/dri/card0
II 22-12-20 15:46:56.810 - [backend/drm/drm.c:1388] 'DP-2' disconnected
DD 22-12-20 15:46:56.907 - [backend/drm/drm.c:1075] Reallocating CRTCs
DD 22-12-20 15:46:56.907 - [backend/drm/drm.c:1086] State before reallocation:
DD 22-12-20 15:46:56.907 - [backend/drm/drm.c:1092]   'DP-1' crtc=0 state=3 desired_enabled=1
DD 22-12-20 15:46:56.907 - [backend/drm/drm.c:1092]   'DP-2' crtc=1 state=3 desired_enabled=0
DD 22-12-20 15:46:56.907 - [backend/drm/drm.c:1092]   'HDMI-A-1' crtc=-1 state=0 desired_enabled=0
DD 22-12-20 15:46:56.907 - [backend/drm/drm.c:1092]   'HDMI-A-2' crtc=-1 state=0 desired_enabled=0
DD 22-12-20 15:46:56.907 - [backend/drm/drm.c:1143] State after reallocation:
DD 22-12-20 15:46:56.907 - [backend/drm/drm.c:1150]   'DP-1' crtc=0 state=3 desired_enabled=1
DD 22-12-20 15:46:56.907 - [backend/drm/drm.c:1150]   'DP-2' crtc=1 state=3 desired_enabled=0
DD 22-12-20 15:46:56.907 - [backend/drm/drm.c:1150]   'HDMI-A-1' crtc=-1 state=0 desired_enabled=0
DD 22-12-20 15:46:56.907 - [backend/drm/drm.c:1150]   'HDMI-A-2' crtc=-1 state=0 desired_enabled=0
DD 22-12-20 15:46:56.907 - [backend/drm/drm.c:1049] connector DP-2: De-allocating CRTC 1
DD 22-12-20 15:46:56.908 - [backend/drm/drm.c:1075] Reallocating CRTCs
DD 22-12-20 15:46:56.908 - [backend/drm/drm.c:1086] State before reallocation:
DD 22-12-20 15:46:56.908 - [backend/drm/drm.c:1092]   'DP-1' crtc=0 state=3 desired_enabled=1
DD 22-12-20 15:46:56.908 - [backend/drm/drm.c:1092]   'DP-2' crtc=-1 state=0 desired_enabled=0
DD 22-12-20 15:46:56.908 - [backend/drm/drm.c:1092]   'HDMI-A-1' crtc=-1 state=0 desired_enabled=0
DD 22-12-20 15:46:56.908 - [backend/drm/drm.c:1092]   'HDMI-A-2' crtc=-1 state=0 desired_enabled=0
DD 22-12-20 15:46:56.908 - [backend/drm/drm.c:1143] State after reallocation:
DD 22-12-20 15:46:56.908 - [backend/drm/drm.c:1150]   'DP-1' crtc=0 state=3 desired_enabled=1
DD 22-12-20 15:46:56.908 - [backend/drm/drm.c:1150]   'DP-2' crtc=-1 state=0 desired_enabled=0
DD 22-12-20 15:46:56.908 - [backend/drm/drm.c:1150]   'HDMI-A-1' crtc=-1 state=0 desired_enabled=0
DD 22-12-20 15:46:56.908 - [backend/drm/drm.c:1150]   'HDMI-A-2' crtc=-1 state=0 desired_enabled=0
DD 22-12-20 15:46:56.908 - [backend/drm/drm.c:1442] No connector for CRTC 49
II 22-12-20 15:46:57.102 - [backend/drm/drm.c:1219] Scanning DRM connectors on /dev/dri/card0
II 22-12-20 15:46:57.102 - [backend/drm/drm.c:1388] 'DP-1' disconnected
DD 22-12-20 15:46:57.173 - [backend/drm/drm.c:1075] Reallocating CRTCs
DD 22-12-20 15:46:57.173 - [backend/drm/drm.c:1086] State before reallocation:
DD 22-12-20 15:46:57.173 - [backend/drm/drm.c:1092]   'DP-1' crtc=0 state=3 desired_enabled=0
DD 22-12-20 15:46:57.173 - [backend/drm/drm.c:1092]   'DP-2' crtc=-1 state=0 desired_enabled=0
DD 22-12-20 15:46:57.173 - [backend/drm/drm.c:1092]   'HDMI-A-1' crtc=-1 state=0 desired_enabled=0
DD 22-12-20 15:46:57.173 - [backend/drm/drm.c:1092]   'HDMI-A-2' crtc=-1 state=0 desired_enabled=0
DD 22-12-20 15:46:57.174 - [backend/drm/drm.c:1143] State after reallocation:
DD 22-12-20 15:46:57.174 - [backend/drm/drm.c:1150]   'DP-1' crtc=0 state=3 desired_enabled=0
DD 22-12-20 15:46:57.174 - [backend/drm/drm.c:1150]   'DP-2' crtc=-1 state=0 desired_enabled=0
DD 22-12-20 15:46:57.174 - [backend/drm/drm.c:1150]   'HDMI-A-1' crtc=-1 state=0 desired_enabled=0
DD 22-12-20 15:46:57.174 - [backend/drm/drm.c:1150]   'HDMI-A-2' crtc=-1 state=0 desired_enabled=0
DD 22-12-20 15:46:57.174 - [backend/drm/drm.c:1049] connector DP-1: De-allocating CRTC 0
DD 22-12-20 15:46:57.174 - [backend/drm/drm.c:1075] Reallocating CRTCs
DD 22-12-20 15:46:57.174 - [backend/drm/drm.c:1086] State before reallocation:
DD 22-12-20 15:46:57.174 - [backend/drm/drm.c:1092]   'DP-1' crtc=-1 state=0 desired_enabled=0
DD 22-12-20 15:46:57.174 - [backend/drm/drm.c:1092]   'DP-2' crtc=-1 state=0 desired_enabled=0
DD 22-12-20 15:46:57.174 - [backend/drm/drm.c:1092]   'HDMI-A-1' crtc=-1 state=0 desired_enabled=0
DD 22-12-20 15:46:57.174 - [backend/drm/drm.c:1092]   'HDMI-A-2' crtc=-1 state=0 desired_enabled=0
DD 22-12-20 15:46:57.175 - [backend/drm/drm.c:1143] State after reallocation:
DD 22-12-20 15:46:57.175 - [backend/drm/drm.c:1150]   'DP-1' crtc=-1 state=0 desired_enabled=0
DD 22-12-20 15:46:57.175 - [backend/drm/drm.c:1150]   'DP-2' crtc=-1 state=0 desired_enabled=0
DD 22-12-20 15:46:57.175 - [backend/drm/drm.c:1150]   'HDMI-A-1' crtc=-1 state=0 desired_enabled=0
DD 22-12-20 15:46:57.175 - [backend/drm/drm.c:1150]   'HDMI-A-2' crtc=-1 state=0 desired_enabled=0

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

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

emersion commented 3 years ago

Weird, we get unplug signals from DRM right after doing the modesets.

JordanL2 commented 3 years ago

Yeah, that normally happens for me for some reason but then it immediately reconnects. But now it's not reconnecting either. The backed-out wlroots change that stopped force-probing connectors (https://github.com/swaywm/wlroots/commit/713c1661b742f93a7d2167321837c0d99541ca87) stopped the disconnect/reconnect happening.

emersion commented 3 years ago

So it didn't work before 713c166?

I don't think we can do much about this. Please report a kernel bug for the driver you're using.

JordanL2 commented 3 years ago

It "worked" in that the monitors would reconnect again after disconnecting, that patch stopped it disconnecting at all.

I raised a kernel bug a few weeks ago, no activity yet. (https://bugzilla.kernel.org/show_bug.cgi?id=210429)

emersion commented 3 years ago

Does running drm_info fix it?

Emantor commented 3 years ago

I raised a kernel bug a few weeks ago, no activity yet. (https://bugzilla.kernel.org/show_bug.cgi?id=210429)

The kernel bugzilla is not and unfortunately was never used by the AMD DRM people, they used the freedesktop bugzilla before switching over to gitlab, please re-raise your issue there.

JordanL2 commented 3 years ago

Does running drm_info fix it?

Do you mean running it after wakeup while the screens are still disconnected? It didn't fix it, I left it running in a loop in a terminal.

I raised a kernel bug a few weeks ago, no activity yet. (https://bugzilla.kernel.org/show_bug.cgi?id=210429)

The kernel bugzilla is not and unfortunately was never used by the AMD DRM people, they used the freedesktop bugzilla before switching over to gitlab, please re-raise your issue there.

Oh thank you, will raise it there.

emersion commented 3 years ago

Do you mean running it after wakeup while the screens are still disconnected? It didn't fix it, I left it running in a loop in a terminal.

OK. Does it show the connectors as being disconnected as well, or connected?

JordanL2 commented 3 years ago

Connected.

dpms_log_once.txt

emersion commented 3 years ago

OK, not detecting the monitors as connected really sounds like a wlroots bug. If I had to guess, probably caused by https://github.com/swaywm/wlroots/pull/2531.

Since I can't reproduce locally, I can't easily figure out what's going on. Can you provide full debug logs as a start?

JordanL2 commented 3 years ago

Sure, logs starting from boot? Setting Wayfire to debug produces all possibly logs, right? There's no environment var or something for wlroots debug logs?

emersion commented 3 years ago

logs starting from boot?

Logs starting from when your compositor is launched.

Setting Wayfire to debug produces all possibly logs, right? There's no environment var or something for wlroots debug logs?

Yeah, I think so.

JordanL2 commented 3 years ago

dpms_logs.txt

This is odd, I started wayfire with -d and redirected all output to this log file, and now I'm not seeing the backend/drm logs saying the output is disconnected.

EDIT: The actual behaviour is the same though.

JordanL2 commented 3 years ago

dpms_logs2.txt

Exactly the same steps, but now the backend/drm logs are saying the outputs are disconnected. Looking at the wayfire logs it really looks like wlroots actually saw the outputs as connected in the first logs - but the behaviour was the same, the screens were still off.

emersion commented 3 years ago

Can you pull the latest wlroots commit, apply this patch, and post debug logs again?

diff --git a/backend/drm/drm.c b/backend/drm/drm.c
index d1e6cc5da33e..94eda49d6051 100644
--- a/backend/drm/drm.c
+++ b/backend/drm/drm.c
@@ -1290,6 +1290,8 @@ void scan_drm_connectors(struct wlr_drm_backend *drm) {
            seen[index] = true;
        }

+       wlr_log(WLR_DEBUG, "DEBUG %s: drm_state=%d wlr_state=%d", wlr_conn->name, drm_conn->connection, wlr_conn->state);
+
        if (curr_enc) {
            for (size_t i = 0; i < drm->num_crtcs; ++i) {
                if (drm->crtcs[i].id == curr_enc->crtc_id) {
emersion commented 3 years ago

(Also, please try git-bisect to figure out the exact commit causing issues.)

JordanL2 commented 3 years ago

Will do. Yesterday when testing, I had it disconnect and then successfully reconnect the outputs after DPMS twice, and then fail to reconnect on the third time. So, this is pretty random, seems there's three things that can happen.

JordanL2 commented 3 years ago

wayfire-logs-2.txt

Reproduced with the debug line. Sleep occurs at 13:02:02, wakeup at 13:02:14.

Also, I've found a pattern. The wakeup works perfectly if I have no windows open. Only if I have one or more windows open does this issue happen. I wonder if this is anything to do with Wayfire creating a NOOP output to move windows to when there are no outputs.

EDIT: wayfire-logs-3.txt

Logs when DPMS happens when no windows open, for comparison. Sleep occurs at 13:11:50, wakeup at 13:12:04. The outputs disconnect after wakeup, but then reconnect.

JordanL2 commented 3 years ago

Finished bisecting, apparently the first bad commit is this:

https://github.com/swaywm/wlroots/commit/768131e4883ed8b04ced6b453721fc28dbf61577

EDIT: I just took the latest master and re-added this line back into types/wlr_output.c and it works now:

output->frame_pending = true;
emersion commented 3 years ago

Hm, thanks, that's definitely helpful. That's pretty weird because at this revision, wlr_output_init is only executed when the connector is found the first time, not when it's connected/disconnected. So this doesn't really make sense to me.

JordanL2 commented 3 years ago

Since getting new monitors this issue is no longer reproducible, so it seems to be an issue specific to a quirk of the model of monitors I had previously (which I bought in 2015). Since it only apparently affected me and I can no longer reproduce it I guess this issue could be closed.

ammen99 commented 3 years ago

Since getting new monitors this issue is no longer reproducible, so it seems to be an issue specific to a quirk of the model of monitors I had previously (which I bought in 2015). Since it only apparently affected me and I can no longer reproduce it I guess this issue could be closed.

This sounds very strange, however, there is an upstream bug in Qt so yes, we could close this.

Sorry, I thought this was about a Wayfire issue, not a wlroots one :) not sure what we should do here.

droc12345 commented 3 years ago

Not sure if this is related. I run the latest git versions of wayfire and wlroots and when I manually turned off the monitor, and then turned it back on later, the monitor powered up, but was in a disconnected state, keyboard effectively dead. I managed to ssh into the box and went to /sys/class/drm/ and checked dpms, enabled, and status. dpms Off enabled not enabled status. not connected Tried what JordanL2 mentioned in his last post, and that fixed the problem for me also. Now if I power off the monitor I get these (which is the way it was working in wlroots 12 and wayfire 0.7.0 dpms On enabled enabled status connected

Just another person to ack that it works with "output->frame_pending = true;" being added back.