Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modesetting failing on external monitor #59

Open
maaarghk opened this issue Aug 20, 2024 · 13 comments
Open

modesetting failing on external monitor #59

maaarghk opened this issue Aug 20, 2024 · 13 comments

Comments

@maaarghk
Copy link

maaarghk commented Aug 20, 2024

Since hyprland 0.42 / aquamarine I can't use my external monitor anymore. its an LG Ultrafine which is a 5k tiling monitor. I don't know my jargon particularly well but I believe it exposes 2xPHYs, to do 5k mode you set both to 2560x2880, OR, you can just disable DP-1 and set DP-2 to 3840x2160 and it'll upscale it for you. which is what I do because I got fucked off with having to manually build wlroots with the tiling patch applied all the time.

I think maybe there are several issues, firstly, since aqua, DP-1 is not getting disabled according to i915_display_info (even though it is not showing up in hyprctl monitors), when I've done this before the monitor just decides it is misconfigured and displays nothing.

Also between 0.3.3 and git, currentFormat goes from XRGB8888 to A XBGR8888 H Invalid. on wlroots it uses XRGB8888 and works fine.

But either way I can get it into several broken states and can't seem to make an image come up. Here's a log with tracing enabled, and various i915_display_info dumps - wlroots one works, term one mirrors e-DP1, the rest are various kinds of not working on aquamarine.

hyprland.log

i915_display_info_hypr_wlroots.txt
i915_display_info_on_term.txt
i915_display_info_hypr_aqua4.txt
i915_display_info_on_hypr_aqua3.txt
i915_display_info_on_hypr_aqua2.txt
i915_display_info_on_hypr_aqua.txt

@maaarghk
Copy link
Author

oh, and, an attempt to make search / google eventually work for future travellers -> [ERR] [AQ] atomic drm request: failed to commit: Invalid argument, flags: ATOMIC_ALLOW_MODESET PAGE_FLIP_EVENT

@vaxerski
Copy link
Member

vaxerski commented Aug 20, 2024

0.43 doesn't exist xd

can you try on aq-git and hl-git

@maaarghk
Copy link
Author

lol sorry, typo. what i meant by "between 0.3.3 and git" is that it did not work on 0.43 and 0.3.3 and it still doesn't work but different on git and git.

@vaxerski
Copy link
Member

@maaarghk
Copy link
Author

ok, a pretty useful thing happened and git worked one time. full trace logs from wlroots version, and aquamarine version, gen'ed using below script, attached below.

I done this:

  • Installed 0.41.2
  • Reboot
  • run the script below
  • Compile hl-git and aq-git
  • run the script below
  • hyprland works!
  • Reboot
  • run the script below
  • hyprland does not work :(

so it seems to depend on the state drm/i915 is in before hypr is started (and 0.41 leaves it in a good state.)

#!/bin/bash
sudo dmesg -C
logname=$$
echo 0x19F | sudo tee /sys/module/drm/parameters/debug
sudo dmesg -w > /home/mark/hypr_logging/$logname.dmesg.log &
logger_pid=$!
sudo cat /sys/kernel/debug/dri/128/i915_display_info > /home/mark/hypr_logging/$logname.i915_display_info_1_no_mon.log
echo "Plug in the monitor, press CTRL+D once the terminal shows on the screen to launch Hyprland."
cat

sudo cat /sys/kernel/debug/dri/128/i915_display_info > /home/mark/hypr_logging/$logname.i915_display_info_2_mon_vt.log

export HYPRLAND_TRACE=1
export HYPRLAND_LOG_WLR=1
export AQ_TRACE=1

sudo bash -c "sleep 5; cat /sys/kernel/debug/dri/128/i915_display_info" > /home/mark/hypr_logging/$logname.i915_display_info_3_hypr.log &

Hyprland > $logname.hyprstdout.log 2>&1

echo "Press CTRL+D again after a sec or two"
cat

sudo cat /sys/kernel/debug/dri/128/i915_display_info > /home/mark/hypr_logging/$logname.i915_display_info_4.mon_vt_after_hypr.log

sudo kill $logger_pid
echo 0 | sudo tee /sys/module/drm/parameters/debug

echo "go get the logs from XDG_RUNTIME_DIR"

wlroots_working.zip
aqua_broken.zip
aqua_working.zip

@maaarghk
Copy link
Author

ps: the "right" solution might be implement tiling : ) although this is probably still some kind of bug for other weird setups.

see below for a wlroots patch which won't get merged because they think that a "tiled display" is not a "display" and that some downstream thing should put a surface over two "displays", or a compositor should put one desktop over two surfaces.

https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4154

imo the two surfaces thing is a non starter due to screen tearing - mutter does it and its absolutely horrific. but i don't know enough to know whether that's because it's a broken implementation or because it's fundamentally a bad idea. there's lots of discussion in the above thread, would be interested to hear your take

@ikalco
Copy link
Contributor

ikalco commented Aug 31, 2024

@maaarghk
can you retry on hl-git and aq-git
there was a patch that might fix your problem, based on your hyprland.log

@maaarghk
Copy link
Author

which commit are you thinking of? I retried recently, I'll check whether I had it or not at the time

@ikalco
Copy link
Contributor

ikalco commented Aug 31, 2024

865cd94
it was done for hyprwm/Hyprland#7005

which has a very similar drm error message

[ 1162.761239] i915 0000:00:02.0: [drm:drm_atomic_check_only] [PLANE:76:plane 1C] invalid pixel format XR24 little-endian (0x34325258), modifier 0x100000000000004

to yours

[   52.791819] i915 0000:00:02.0: [drm:drm_atomic_check_only] [PLANE:76:plane 1C] invalid pixel format XR24 little-endian (0x34325258), modifier 0x100000000000004

@maaarghk
Copy link
Author

maaarghk commented Sep 1, 2024

good spot @ikalco - latest hyprland-git and aquamarine-git do improve the situation. thanks! For completeness sake here's an equivalent dump of logs from latest git. Maybe it will one day be useful for writing regression tests 😁 aqua_fixed.zip.

fwiw: This is a thunderbolt monitor which is going via a thunderbolt dock. I also am using prime render offload for firefox, and everything seems to work fine.

anyway, I still see bad behaviour which I did not see before on wlroots, which is that I can't reactivate eDP-1 after Hyprland has already started. (I have not tested whether both monitors activate properly if I save the config then fully exit and re-start Hyprland, so that may also be broken.) my Hyprland config looks like this:

monitor=eDP-1,disable
#monitor=eDP-1,preferred,auto,2.4
monitor=DP-1,disable
monitor=DP-2,preferred,auto,1.875

if I swap the commented line at the top, eDP-1 does not reactivate.

Monitor eDP-1 (ID 0):
        [email protected] at 2048x0
        description: Sharp Corporation 0x14D6
        make: Sharp Corporation
        model: 0x14D6
        serial: 
        active workspace: 4 (4)
        special workspace: 0 ()
        reserved: 0 30 0 0
        scale: 2.40
        transform: 0
        focused: yes
        dpmsStatus: 1
        vrr: 0
        activelyTearing: false
        disabled: false
        currentFormat: A Invalid H Invalid
        availableModes: [email protected] [email protected] 
[LOG] Applying monitor rule for eDP-1
[LOG] CMonitorState::ensureBufferPresent: no buffer or mismatched format, attaching one from the swapchain for modeset being possible
[ERR] [AQ] drm: No format for output
[WARN] state.commit() failed in CMonitor::onCommit
[LOG] Added new monitor with name eDP-1 at [2048, 0] with size [3840, 2400], pointer 615c35d8d370
[LOG] New monitor: WORKSPACEID 4, exists: 0
[LOG] [IWaylandProtocol] Registered global [WLOutput (eDP-1)]
[LOG] [CLinuxDMABufV1Protocol] Resetting format table
[LOG] Monitor eDP-1 is disabled but is requested to be enabled
[LOG] Setting preferred mode for eDP-1
[LOG] [AQ] GBM: Allocated a new buffer with size [Vector2D: x: 3840, y: 2400] and format XR24 with modifier 72057594037927940 aka Y_TILED_CCS
[LOG] [AQ] GBM: Allocated a new buffer with size [Vector2D: x: 3840, y: 2400] and format XR24 with modifier 72057594037927940 aka Y_TILED_CCS
[LOG] [AQ] Swapchain: Reconfigured a swapchain to [Vector2D: x: 3840, y: 2400] XR24 of length 2
[LOG] CMonitorState::ensureBufferPresent: no buffer or mismatched format, attaching one from the swapchain for modeset being possible
[LOG] [AQ] atomic drm request: failed to commit: Invalid argument, flags: ATOMIC_ALLOW_MODESET ATOMIC_TEST_ONLY 
[ERR] output eDP-1 failed basic test on format DRM_FORMAT_XRGB8888
[LOG] [AQ] GBM: Allocated a new buffer with size [Vector2D: x: 3840, y: 2400] and format XB24 with modifier 72057594037927940 aka Y_TILED_CCS
[LOG] [AQ] GBM: Allocated a new buffer with size [Vector2D: x: 3840, y: 2400] and format XB24 with modifier 72057594037927940 aka Y_TILED_CCS
[LOG] [AQ] Swapchain: Reconfigured a swapchain to [Vector2D: x: 3840, y: 2400] XB24 of length 2
[LOG] CMonitorState::ensureBufferPresent: no buffer or mismatched format, attaching one from the swapchain for modeset being possible
[LOG] [AQ] atomic drm request: failed to commit: Invalid argument, flags: ATOMIC_ALLOW_MODESET ATOMIC_TEST_ONLY 
[ERR] output eDP-1 failed basic test on format DRM_FORMAT_XBGR8888
[LOG] CMonitorState::ensureBufferPresent: no buffer or mismatched format, attaching one from the swapchain for modeset being possible
[ERR] [AQ] drm: No format for output
[ERR] output eDP-1 failed basic test on format DRM_FORMAT_INVALID
[LOG] CMonitorState::ensureBufferPresent: no buffer or mismatched format, attaching one from the swapchain for modeset being possible
[ERR] [AQ] drm: No format for output
[ERR] Couldn't commit output named eDP-1
[LOG] arrangeMonitors: 2 to arrange
[LOG] arrangeMonitors: DP-2 auto [0, 0]
[LOG] arrangeMonitors: eDP-1 auto [2048, 0]
[LOG] arrangeMonitors: DP-2 xwayland [0, 0]
[LOG] arrangeMonitors: eDP-1 xwayland [3840, 0]
[LOG] Monitor eDP-1 data dump: res [email protected], scale 2.40, transform 0, pos 2048x0, 10b 0
...
[LOG] Applying monitor rule for DP-1
[LOG] Applying monitor rule for DP-2
[LOG] Setting preferred mode for DP-2
[LOG] output DP-2 succeeded basic test on format DRM_FORMAT_XRGB8888
[LOG] [AQ] drm: Modesetting DP-2 with [email protected]
[LOG] arrangeMonitors: 2 to arrange
[LOG] arrangeMonitors: DP-2 auto [0, 0]
[LOG] arrangeMonitors: eDP-1 auto [2048, 0]
[LOG] arrangeMonitors: DP-2 xwayland [0, 0]
[LOG] arrangeMonitors: eDP-1 xwayland [3840, 0]
[LOG] Monitor DP-2 data dump: res [email protected], scale 1.88, transform 0, pos 0x0, 10b 0
...
[LOG] CMonitorState::ensureBufferPresent: no buffer or mismatched format, attaching one from the swapchain for modeset being possible
[ERR] [AQ] drm: No format for output
... repeats until monitor is disabled again

I have to do something else now so it'll be later (probably tomorrow) before I get more detailed logs if they're required. Maybe (on the hyprland side) eDP-1 shouldn't be added to the layout since it's probably possible to detect that it can't be displaying anything. I think the format is usually XRGB8888.

@maaarghk
Copy link
Author

maaarghk commented Sep 3, 2024

brief update - upgraded to latest git just now, still see this issue; I can't convince Hyprland to activate both displays at the same time, even by restarting. Unfortunately don't have enough time to do a better bug report at the moment

@romanstingler
Copy link
Contributor

please build yay -S hyprland-git aquamarine-git new and add env = AQ_NO_MODIFIERS,1 to your hyperland.conf

if it resolves your issue, please close the ticket, thx

@ryan77627
Copy link

ryan77627 commented Oct 23, 2024

Hi there, I seem to be having a similar issue as above. I can reproduce a condition where Aquamarine fails to reinitialize some monitors connected to a USB-C dock with or without AQ_NO_MODIFIERS set. If starting Hyprland with the monitors connected, it works fine, but it cannot handle (re-)attaching them after it has started. I can not reproduce this in sway or Hyprland 0.40 (last version I was on), leading me to believe it is an issue in Aquamarine still. I have a trace log from Hypr/Aquamarine plus the DRM logs. If this is a different issue than above, let me know and I can create a new issue for this. Running latest Hyprland-git and Aquamarine-git on Guix built from the Nix flakes.

Test below was ran with DRM logging, Aquamarine, and Hyprland logging where no monitors other than the laptop internal was plugged in, then the monitors were plugged in after starting hyprland. DP-3 and DP-4 were the monitors that should have activated. DP-4 was the one that failed to turn on.

Kernel: 6.10.11
Hyprland:

Hyprland 0.44.0 built from branch  at commit 5e96d738e698f22969ca502d042d5751711c6d8a  ().
Date: 2024-10-21
Tag: , commits: 
built against aquamarine 0.4.3


flags set:
debug

flake.nix inputs:

    hyprland = {
      url = "github:hyprwm/hyprland/main";
      inputs.nixpkgs.follows = "nixpkgs";
      inputs.aquamarine.url = "github:hyprwm/aquamarine/main";
    };

Hardware: Lenovo Thinkpad T480 with Integrated Graphics only (i915 driver), Anker 553 USB-C Hub

Only log I didn't get was the /sys/kernel/debug/dri/128/i915_display_info, let me know if it would be useful.


File explanations:

after_kill_drm_status: cat /sys/class/drm/card0/*/{status,enabled} after killing Hyprland, showing 3 monitors connected and 3 enabled.

dmesg_drm_trace: Self explanatory. Best guess as to where I initiated the re-plug event was around 55%-60% into the file

after_plug_drm_status: cat /sys/class/drm/card0/*/{status,enabled} after re-plug in Hyprland, showing 3 connected but 2 enabled monitors.

trace_log: AQ_TRACE=1 HYPRLAND_TRACE=1 nixGLIntel Hyprland

after_plug_drm: ls /sys/class/drm/card0 after plugging in monitors

before_plug_drm: ls /sys/class/drm/card0 before plugging in monitors

sway_dmesg_drm_trace: Same trace as with Hyprland, same testing scenario, but running Sway 1.9

after_kill_drm_status.txt
dmesg_drm_trace.txt
trace_log.txt
after_plug_drm_status.txt
after_plug_drm.txt
before_plug_drm.txt

sway_dmesg_drm_trace.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants