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

Sway fails to release GPU on udev remove command #8097

Open
redrampage opened this issue Mar 30, 2024 · 5 comments
Open

Sway fails to release GPU on udev remove command #8097

redrampage opened this issue Mar 30, 2024 · 5 comments
Labels
bug Not working as intended

Comments

@redrampage
Copy link

  • Sway Version:
    sway version 1.9 (debian 1.9-1+b1)

  • Debug Log:

Mar 30 18:15:46 hostname sway[192985]: 00:00:48.294 [DEBUG] [sway/criteria.c:726] Found pair: con_id=9
Mar 30 18:15:46 hostname sway[192985]: 00:00:48.294 [INFO] [sway/commands.c:261] Handling command 'opacity 0.8'
Mar 30 18:15:50 hostname sway[192985]: 00:00:51.461 [DEBUG] [wlr] [backend/session/session.c:181] udev event for card1 (remove)
Mar 30 18:15:50 hostname sway[192985]: 00:00:51.461 [DEBUG] [wlr] [backend/session/session.c:215] DRM device card1 removed
Mar 30 18:15:50 hostname sway[192985]: 00:00:51.461 [INFO] [wlr] [backend/drm/backend.c:172] Destroying DRM backend for /dev/dri/card1
Mar 30 18:15:50 hostname sway[192985]: 00:00:51.461 [DEBUG] [sway/tree/output.c:264] Disabling output 'DP-3'
Mar 30 18:15:50 hostname sway[192985]: 00:00:51.461 [DEBUG] [sway/desktop/layer_shell.c:386] Layer surface destroyed (wallpaper)
Mar 30 18:15:50 hostname sway[192985]: 00:00:51.461 [DEBUG] [sway/desktop/layer_shell.c:386] Layer surface destroyed (waybar)
Mar 30 18:15:50 hostname sway[192985]: 00:00:51.461 [DEBUG] [sway/desktop/layer_shell.c:229] Usable area changed, rearranging output
Mar 30 18:15:50 hostname sway[192985]: 00:00:51.461 [DEBUG] [sway/tree/arrange.c:263] Usable area for ws: 2560x1407@0,0
Mar 30 18:15:50 hostname sway[192985]: 00:00:51.461 [DEBUG] [sway/tree/arrange.c:297] Arranging workspace '2' at 2570.000000, 10.000000
Mar 30 18:15:50 hostname sway[192985]: 00:00:51.461 [DEBUG] [sway/desktop/transaction.c:398] Transaction 0x5640b72eb5b0 committing with 1 instructions
Mar 30 18:15:50 hostname sway[192985]: 00:00:51.461 [DEBUG] [sway/desktop/transaction.c:294] Applying transaction 0x5640b72eb5b0
Mar 30 18:15:50 hostname sway[192985]: 00:00:51.461 [DEBUG] [sway/desktop/layer_shell.c:386] Layer surface destroyed (waybar)
Mar 30 18:15:50 hostname sway[192985]: 00:00:51.461 [DEBUG] [sway/desktop/layer_shell.c:229] Usable area changed, rearranging output
Mar 30 18:15:50 hostname sway[192985]: 00:00:51.461 [DEBUG] [sway/tree/arrange.c:263] Usable area for ws: 2560x1440@0,0
Mar 30 18:15:50 hostname sway[192985]: 00:00:51.461 [DEBUG] [sway/tree/arrange.c:297] Arranging workspace '2' at 2570.000000, 10.000000
Mar 30 18:15:50 hostname sway[192985]: 00:00:51.461 [DEBUG] [sway/desktop/transaction.c:398] Transaction 0x5640b6771b80 committing with 1 instructions
Mar 30 18:15:50 hostname sway[192985]: 00:00:51.461 [DEBUG] [sway/desktop/transaction.c:294] Applying transaction 0x5640b6771b80
Mar 30 18:15:50 hostname sway[192985]: 00:00:51.461 [DEBUG] [sway/tree/workspace.c:145] Destroying workspace '2'
Mar 30 18:15:50 hostname sway[192985]: 00:00:51.461 [DEBUG] [sway/ipc-server.c:301] Sending workspace::empty event
Mar 30 18:15:50 hostname sway[192985]: 00:00:51.461 [DEBUG] [sway/tree/arrange.c:263] Usable area for ws: 2560x1014@0,33
Mar 30 18:15:50 hostname sway[192985]: 00:00:51.461 [DEBUG] [sway/tree/arrange.c:297] Arranging workspace '1' at 0.000000, 33.000000
Mar 30 18:15:50 hostname sway[192985]: 00:00:51.461 [DEBUG] [sway/tree/arrange.c:77] Arranging 0x7fff61e73ad0 horizontally
Mar 30 18:15:50 hostname sway[192985]: 00:00:51.461 [DEBUG] [sway/input/seat.c:722] Applying input mapping to 4919:4919:EvdevProxyAIO
Mar 30 18:15:50 hostname sway[192985]: 00:00:51.461 [DEBUG] [sway/input/seat.c:722] Applying input mapping to 1133:16519:Logitech
Mar 30 18:15:50 hostname sway[192985]: 00:00:51.462 [DEBUG] [sway/input/seat.c:722] Applying input mapping to 13364:353:Keychron
Mar 30 18:15:50 hostname sway[192985]: 00:00:51.462 [DEBUG] [sway/input/seat.c:722] Applying input mapping to 13364:353:Keychron
Mar 30 18:15:50 hostname sway[192985]: 00:00:51.462 [DEBUG] [sway/tree/output.c:287] Destroying output 'DP-3'
Mar 30 18:15:50 hostname sway[192985]: 00:00:51.462 [DEBUG] [sway/desktop/transaction.c:398] Transaction 0x5640b702c8e0 committing with 5 instructions
Mar 30 18:15:50 hostname sway[192985]: 00:00:51.462 [DEBUG] [sway/desktop/transaction.c:294] Applying transaction 0x5640b702c8e0
Mar 30 18:15:50 hostname sway[192985]: 00:00:51.462 [DEBUG] [sway/tree/arrange.c:263] Usable area for ws: 2560x1014@0,33
Mar 30 18:15:50 hostname sway[192985]: 00:00:51.462 [DEBUG] [sway/tree/arrange.c:297] Arranging workspace '1' at 0.000000, 33.000000
Mar 30 18:15:50 hostname sway[192985]: 00:00:51.462 [DEBUG] [sway/tree/arrange.c:77] Arranging 0x7fff61e73ad0 horizontally
Mar 30 18:15:50 hostname sway[192985]: 00:00:51.462 [DEBUG] [sway/desktop/transaction.c:398] Transaction 0x5640b702c8e0 committing with 3 instructions
Mar 30 18:15:50 hostname sway[192985]: 00:00:51.462 [DEBUG] [sway/desktop/transaction.c:294] Applying transaction 0x5640b702c8e0
Mar 30 18:15:50 hostname sway[192985]: 00:00:51.462 [DEBUG] [wlr] [types/wlr_drm_lease_v1.c:103] Destroying wlr_drm_lease_device_v1 for /dev/dri/card1
Mar 30 18:15:50 hostname sway[192985]: 00:00:51.614 [ERROR] [wlr] [libseat] [libseat/backend/logind.c:199] Could not close device: Device not taken
Mar 30 18:15:50 hostname sway[192985]: 00:00:51.614 [ERROR] [wlr] [backend/session/session.c:356] Failed to close device 12: Resource temporarily unavailable
Mar 30 18:15:50 hostname sway[192985]: 2024-03-30 18:15:50 - [main.c:237] Destroying output DP-3 (Ancor Communications ...)
Mar 30 18:15:50 hostname sway[192985]: 00:00:51.616 [INFO] [sway/ipc-server.c:571] IPC Client 102 disconnected
Mar 30 18:15:50 hostname sway[192985]: 00:00:51.616 [INFO] [sway/ipc-server.c:571] IPC Client 104 disconnected
Mar 30 18:15:50 hostname sway[192985]: 00:00:51.616 [INFO] [sway/ipc-server.c:571] IPC Client 98 disconnected
Mar 30 18:15:50 hostname sway[192985]: 00:00:51.616 [INFO] [sway/ipc-server.c:571] IPC Client 100 disconnected
Mar 30 18:15:50 hostname sway[192985]: 00:00:51.616 [INFO] [sway/ipc-server.c:571] IPC Client 90 disconnected
Mar 30 18:15:50 hostname sway[192985]: 00:00:51.616 [INFO] [sway/ipc-server.c:571] IPC Client 92 disconnected
Mar 30 18:15:50 hostname sway[192985]: 00:00:51.616 [INFO] [sway/ipc-server.c:571] IPC Client 94 disconnected
Mar 30 18:15:50 hostname sway[192985]: 00:00:51.616 [INFO] [sway/ipc-server.c:571] IPC Client 96 disconnected
Mar 30 18:15:50 hostname sway[192985]: [2024-03-30 18:15:50.287] [info] Bar removed from output: DP-3
Mar 30 18:15:50 hostname sway[192985]: [2024-03-30 18:15:50.289] [info] Bar removed from output: DP-3
Mar 30 18:15:58 hostname sway[192985]: 00:00:59.975 [DEBUG] [sway/desktop/transaction.c:398] Transaction 0x5640b6aedce0 committing with 1 instructions
  • Configuration File:
    Reproduceable with default config file

  • Stack Trace:
    N/A

  • Description:

Hi, I'm running into problems with swaywm releasing videocard DRI device.

I'm running sway on two AMD GPU virtualization setup, one is for host system (card0), other one is dynamically plugged/unplugged for guest(card1).
They are configured on start via WLR_DRM_DEVICES=/dev/dri/card0:/dev/dri/card1.

When I need to release latter GPU for guest VM, I run udev command:

/usr/bin/udevadm trigger --settle --type=devices --action=remove --subsystem-match=drm --property-match="DEVNAME=/dev/dri/card1"

and then check for GPU release with:

fuser /dev/dri/card1

Some time ago this trick stopped working, now on udev command sway shutdown second display, but still keep it's device open. Log messages indicate that sway cannot release GPU for some reason:

Mar 30 18:15:50 hostname sway[192985]: 00:00:51.614 [ERROR] [wlr] [libseat] [libseat/backend/logind.c:199] Could not close device: Device not taken
Mar 30 18:15:50 hostname sway[192985]: 00:00:51.614 [ERROR] [wlr] [backend/session/session.c:356] Failed to close device 12: Resource temporarily unavailable

TLDR Steps to reproduce:

# export WLR_DRM_DEVICES=/dev/dri/card0:/dev/dri/card1

# sway

# fuser /dev/dri/card1
/dev/dri/card1:          1  1511 206814

# /usr/bin/udevadm trigger --settle --type=devices --action=remove --subsystem-match=drm --property-match="DEVNAME=/dev/dri/card1"

# fuser /dev/dri/card1
/dev/dri/card1:      206814
@redrampage redrampage added the bug Not working as intended label Mar 30, 2024
@emersion
Copy link
Member

That's expected: WLR_DRM_DEVICES disables hotplug and unplug handling.

@redrampage
Copy link
Author

Are you sure about that? Sway still reacts on udev command and disables output, this worked before and there is error message now (I've checked old logs).

I've tried to run sway without WLR_DRM_DEVICES set, on aforementioned udev command it disabled both outputs, but still kept both dri cards open.

@emersion
Copy link
Member

emersion commented Apr 2, 2024

Hm, yeah, nevermind, we still listen for the udev remove event in that case.

cc @kennylevinsen for the libseat bits

@kennylevinsen
Copy link
Member

Mar 30 18:15:50 hostname sway[192985]: 00:00:51.614 [ERROR] [wlr] [libseat] [libseat/backend/logind.c:199] Could not close device: Device not taken
Mar 30 18:15:50 hostname sway[192985]: 00:00:51.614 [ERROR] [wlr] [backend/session/session.c:356] Failed to close device 12: Resource temporarily unavailable

I suspect these errors are just because logind reacted to the event in parallel, removing the devices from the seat before we tried to clean them up. Neither libseat nor wlroots considers them fatal and proceeds with cleanup.

My gut-feeling would be the renderer's fd, which is a lease off the master fd. I imagine it's invalidated when the master status is lost, but that does not close it.

@emersion
Copy link
Member

emersion commented Apr 2, 2024

But a renderer is only created for the primary DRM device, not for secondary devices?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Not working as intended
Development

No branches or pull requests

3 participants