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

Use DrmOutputManager/DrmOutput #1020

Merged
merged 15 commits into from
Jan 6, 2025
Merged

Use DrmOutputManager/DrmOutput #1020

merged 15 commits into from
Jan 6, 2025

Conversation

Drakulix
Copy link
Member

@Drakulix Drakulix commented Nov 29, 2024

Draft / test branch for Smithay/smithay#1576.

Supersedes / Attempts to solve issues lied out in #969.

Needs more work to actually solve those issues:

@Drakulix Drakulix force-pushed the drm-output-test branch 2 times, most recently from 51afda0 to 95ce3d0 Compare December 4, 2024 16:30
@Drakulix Drakulix force-pushed the drm-output-test branch 3 times, most recently from 6310cde to cc49b16 Compare December 13, 2024 14:04
@Drakulix Drakulix mentioned this pull request Dec 13, 2024
1 task
@Drakulix Drakulix marked this pull request as ready for review January 2, 2025 20:33
@Drakulix
Copy link
Member Author

Drakulix commented Jan 2, 2025

Okay code-wise this should be good now, just needs a bunch of testing.

@hojjatabdollahi
Copy link

I can help test it.

Crashes on boot. I also removed the configs in .local/state/cosmic-comp but it produces the same error. It tries a few times, and then gives up showing this error.

Jan 02 14:26:13 Cosmic systemd[1]: cosmic-greeter.service: Scheduled restart job, restart counter is at 4.
Jan 02 14:26:13 Cosmic systemd[1]: Starting gpu-manager.service - Detect the available GPUs and deal with any system changes...
Jan 02 14:26:08 Cosmic greetd[2984]: gkr-pam: couldn't unlock the login keyring.
Jan 02 14:26:08 Cosmic cosmic-comp[2996]: Failed to read config 'workspaces'
Jan 02 14:26:08 Cosmic cosmic-comp[2996]: failed to read local shortcuts config 'system_actions': NoConfigDirectory
Jan 02 14:26:08 Cosmic cosmic-comp[2996]: Key-Binding 'Period' only matched case insensitive for "period"
Jan 02 14:26:08 Cosmic cosmic-comp[2996]: Key-Binding 'Comma' only matched case insensitive for "comma"
Jan 02 14:26:08 Cosmic cosmic-comp[2996]: Key-Binding 'Period' only matched case insensitive for "period"
Jan 02 14:26:08 Cosmic cosmic-comp[2996]: Key-Binding 'Comma' only matched case insensitive for "comma"
Jan 02 14:26:08 Cosmic cosmic-comp[2996]: shortcuts custom config error: GetKey("custom", Os { code: 2, kind: NotFound, message: "No such file or directory" })
Jan 02 14:26:08 Cosmic cosmic-comp[2996]: tiling exceptions custom config error: GetKey("tiling_exception_custom", Os { code: 2, kind: NotFound, message: "No such file or directory" })
Jan 02 14:26:08 Cosmic cosmic-comp[2996]: Unable to become drm master, assuming unprivileged mode
Jan 02 14:26:08 Cosmic cosmic-comp[2996]: thread 'main' panicked at 'called `Option::unwrap()` on a `None` value': src/shell/mod.rs:977
                                             0: <backtrace::capture::Backtrace as core::default::Default>::default
                                             1: log_panics::Config::install_panic_hook::{{closure}}
                                             2: std::panicking::rust_panic_with_hook
                                             3: std::panicking::begin_panic_handler::{{closure}}
                                             4: std::sys_common::backtrace::__rust_end_short_backtrace
                                             5: rust_begin_unwind
                                             6: core::panicking::panic_fmt
                                             7: core::panicking::panic
                                             8: core::option::unwrap_failed
                                             9: cosmic_comp::shell::Workspaces::active
                                            10: cosmic_comp::backend::render::output_elements
                                            11: cosmic_comp::backend::kms::KmsState::apply_config_for_outputs
                                            12: cosmic_comp::state::BackendData::apply_config_for_outputs
                                            13: cosmic_comp::config::Config::read_outputs
                                            14: cosmic_comp::backend::kms::device::<impl cosmic_comp::state::State>::device_added
                                            15: cosmic_comp::backend::kms::init_backend
                                            16: cosmic_comp::main
                                            17: std::sys_common::backtrace::__rust_begin_short_backtrace
                                            18: main
                                            19: __libc_start_call_main
                                                       at ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
                                            20: __libc_start_main_impl
                                                       at ./csu/../csu/libc-start.c:360:3
                                            21: _start
Jan 02 14:26:08 Cosmic cosmic-comp[2996]: Failed to restore previous state. Error: Permission denied (os error 13)
Jan 02 14:26:08 Cosmic cosmic-comp[2996]: Xwayland terminated: exit status: 1

@ids1024
Copy link
Member

ids1024 commented Jan 3, 2025

I'm seeing a segfault in DRM threads on a release build. In a debug build it shows this:

Jan 03 09:58:04 Superficies cosmic-comp[2382599]: thread 'surface-DP-9' panicked at 'misaligned pointer dereference: address must be a multiple of 0x4 but is 0x1': /home/ian/.cargo/registry/src/index.crates.io-6f17d22bba15001f/libdisplay-info-0.1.0/src/edid.rs:712
                                                     0: <backtrace::capture::Backtrace as core::default::Default>::default
                                                               at /home/ian/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.73/src/capture.rs:422:9
                                                     1: log_panics::Config::install_panic_hook::{{closure}}
                                                               at /home/ian/.cargo/registry/src/index.crates.io-6f17d22bba15001f/log-panics-2.1.0/src/lib.rs:115:29
                                                     2: <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call
                                                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/alloc/src/boxed.rs:2077:9
                                                        std::panicking::rust_panic_with_hook
                                                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/std/src/panicking.rs:799:13
                                                     3: std::panicking::begin_panic_handler::{{closure}}
                                                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/std/src/panicking.rs:664:13
                                                     4: std::sys_common::backtrace::__rust_end_short_backtrace
                                                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/std/src/sys_common/backtrace.rs:171:18
                                                     5: rust_begin_unwind
                                                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/std/src/panicking.rs:652:5
                                                     6: core::panicking::panic_nounwind_fmt::runtime
                                                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/core/src/panicking.rs:110:18
                                                        core::panicking::panic_nounwind_fmt
                                                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/core/src/panicking.rs:120:5
                                                     7: core::panicking::panic_misaligned_pointer_dereference
                                                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/core/src/panicking.rs:287:5
                                                     8: <libdisplay_info::edid::DisplayRangeLimits as core::convert::From<libdisplay_info_sys::edid::di_edid_display_range_limits>>::from
                                                               at /home/ian/.cargo/registry/src/index.crates.io-6f17d22bba15001f/libdisplay-info-0.1.0/src/edid.rs:712:30
                                                     9: libdisplay_info::edid::DisplayDescriptorRef::range_limits
                                                               at /home/ian/.cargo/registry/src/index.crates.io-6f17d22bba15001f/libdisplay-info-0.1.0/src/edid.rs:554:18
                                                    10: cosmic_comp::backend::kms::drm_helpers::get_minimum_refresh_rate
                                                               at /home/ian/src/pop/cosmic-epoch/cosmic-comp/src/backend/kms/drm_helpers.rs:251:17
                                                    11: cosmic_comp::backend::kms::surface::SurfaceThreadState::resume::{{closure}}
                                                               at /home/ian/src/pop/cosmic-epoch/cosmic-comp/src/backend/kms/surface/mod.rs:672:17
                                                    12: smithay::backend::drm::output::DrmOutput<A,F,U,G>::with_compositor
                                                               at /home/ian/.cargo/git/checkouts/smithay-0141b1fcb9e16729/14c7e43/src/backend/drm/output.rs:703:9
                                                    13: cosmic_comp::backend::kms::surface::SurfaceThreadState::resume
                                                               at /home/ian/src/pop/cosmic-epoch/cosmic-comp/src/backend/kms/surface/mod.rs:669:30
                                                    14: cosmic_comp::backend::kms::surface::surface_thread::{{closure}}
                                                               at /home/ian/src/pop/cosmic-epoch/cosmic-comp/src/backend/kms/surface/mod.rs:556:37
                                                    15: <core::cell::RefCell<calloop::sources::DispatcherInner<S,F>> as calloop::sources::EventDispatcher<Data>>::process_events::{{closure}}
                                                               at /home/ian/.cargo/registry/src/index.crates.io-6f17d22bba15001f/calloop-0.14.1/src/sources/mod.rs:327:61
                                                    16: <calloop::sources::channel::Channel<T> as calloop::sources::EventSource>::process_events::{{closure}}
                                                               at /home/ian/.cargo/registry/src/index.crates.io-6f17d22bba15001f/calloop-0.14.1/src/sources/channel.rs:223:36
                                                    17: <calloop::sources::ping::eventfd::PingSource as calloop::sources::EventSource>::process_events::{{closure}}
                                                               at /home/ian/.cargo/registry/src/index.crates.io-6f17d22bba15001f/calloop-0.14.1/src/sources/ping/eventfd.rs:139:21
                                                    18: <calloop::sources::generic::Generic<F,E> as calloop::sources::EventSource>::process_events
                                                               at /home/ian/.cargo/registry/src/index.crates.io-6f17d22bba15001f/calloop-0.14.1/src/sources/generic.rs:290:9
                                                    19: <calloop::sources::ping::eventfd::PingSource as calloop::sources::EventSource>::process_events
                                                               at /home/ian/.cargo/registry/src/index.crates.io-6f17d22bba15001f/calloop-0.14.1/src/sources/ping/eventfd.rs:128:9
                                                    20: <calloop::sources::channel::Channel<T> as calloop::sources::EventSource>::process_events
                                                               at /home/ian/.cargo/registry/src/index.crates.io-6f17d22bba15001f/calloop-0.14.1/src/sources/channel.rs:216:22
                                                    21: <core::cell::RefCell<calloop::sources::DispatcherInner<S,F>> as calloop::sources::EventDispatcher<Data>>::process_events
                                                               at /home/ian/.cargo/registry/src/index.crates.io-6f17d22bba15001f/calloop-0.14.1/src/sources/mod.rs:326:9
                                                    22: calloop::loop_logic::EventLoop<Data>::dispatch_events
                                                               at /home/ian/.cargo/registry/src/index.crates.io-6f17d22bba15001f/calloop-0.14.1/src/loop_logic.rs:445:31
                                                    23: calloop::loop_logic::EventLoop<Data>::dispatch
                                                               at /home/ian/.cargo/registry/src/index.crates.io-6f17d22bba15001f/calloop-0.14.1/src/loop_logic.rs:550:9
                                                    24: calloop::loop_logic::EventLoop<Data>::run
                                                               at /home/ian/.cargo/registry/src/index.crates.io-6f17d22bba15001f/calloop-0.14.1/src/loop_logic.rs:587:13
                                                    25: cosmic_comp::backend::kms::surface::surface_thread
                                                               at /home/ian/src/pop/cosmic-epoch/cosmic-comp/src/backend/kms/surface/mod.rs:642:5
                                                    26: cosmic_comp::backend::kms::surface::Surface::new::{{closure}}
                                                               at /home/ian/src/pop/cosmic-epoch/cosmic-comp/src/backend/kms/surface/mod.rs:276:35
                                                    27: std::sys_common::backtrace::__rust_begin_short_backtrace
                                                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/std/src/sys_common/backtrace.rs:155:18
                                                    28: std::thread::Builder::spawn_unchecked_::{{closure}}::{{closure}}
                                                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/std/src/thread/mod.rs:542:17
                                                    29: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
                                                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/core/src/panic/unwind_safe.rs:272:9
                                                    30: std::panicking::try::do_call
                                                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/std/src/panicking.rs:559:40
                                                    31: __rust_try
                                                    32: std::panicking::try
                                                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/std/src/panicking.rs:523:19
                                                    33: std::panic::catch_unwind
                                                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/std/src/panic.rs:149:14
                                                        std::thread::Builder::spawn_unchecked_::{{closure}}
                                                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/std/src/thread/mod.rs:541:30
                                                    34: core::ops::function::FnOnce::call_once{{vtable.shim}}
                                                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/core/src/ops/function.rs:250:5
                                                    35: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                                                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/alloc/src/boxed.rs:2063:9
                                                        <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                                                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/alloc/src/boxed.rs:2063:9
                                                        std::sys::pal::unix::thread::Thread::new::thread_start
                                                               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/std/src/sys/pal/unix/thread.rs:108:17
                                                    36: start_thread
                                                               at ./nptl/pthread_create.c:447:8
                                                    37: __GI___clone3
                                                               at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78

Edit: Presumably di_edid_display_range_limits shouldn't contain a 0x1 pointer... hm.

@ids1024
Copy link
Member

ids1024 commented Jan 3, 2025

[/home/ian/src/libdisplay-info-rs/libdisplay-info/src/edid.rs:554:43] unsafe { *display_range_limits } = di_edid_display_range_limits {
    min_vert_rate_hz: 24,
    max_vert_rate_hz: 120,
    min_horiz_rate_hz: 15000,
    max_horiz_rate_hz: 130000,
    max_pixel_clock_hz: 300000000,
    type_: 0,
    secondary_gtf: 0x0000000000000001,
    cvt: 0x0000000000000000,
}

This is defined as:

	/* For SECONDARY_GTF limits, NULL otherwise */
	const struct di_edid_display_range_limits_secondary_gtf *secondary_gtf;

So should be a valid pointer or null, and everything else in the struct looks okay and not just garbage (I assume those are reasonable values). Could this be a bug in libdisplay-info itself?

@hojjatabdollahi
Copy link

Can not move my displays around in cosmic settings. It just pops back where it was (it works once in a while):

Jan 03 13:48:05 Cosmic cosmic-comp[22574]: Failed to apply config. Resetting
Jan 03 13:48:05 Cosmic cosmic-comp[22574]: Failed to reset output config.
Jan 03 13:48:05 Cosmic cosmic-panel[22662]: com.system76.CosmicAppletPower: Error: "configuration failed"
Jan 03 13:48:07 Cosmic cosmic-comp[22574]: Failed to apply config. Resetting
Jan 03 13:48:07 Cosmic cosmic-comp[22574]: Failed to reset output config.
Jan 03 13:48:07 Cosmic cosmic-panel[22662]: com.system76.CosmicAppletPower: Error: "configuration failed"
Jan 03 13:48:10 Cosmic cosmic-comp[22574]: Failed to apply config. Resetting
Jan 03 13:48:10 Cosmic cosmic-comp[22574]: Failed to reset output config.
Jan 03 13:48:10 Cosmic cosmic-panel[22662]: com.system76.CosmicAppletPower: Error: "configuration failed"
Jan 03 13:48:12 Cosmic cosmic-comp[22574]: Failed to apply config. Resetting
Jan 03 13:48:12 Cosmic cosmic-comp[22574]: Failed to reset output config.
Jan 03 13:48:12 Cosmic cosmic-panel[22662]: com.system76.CosmicAppletPower: Error: "configuration failed"
Jan 03 13:48:13 Cosmic cosmic-comp[22574]: Failed to apply config. Resetting
Jan 03 13:48:13 Cosmic cosmic-comp[22574]: Failed to reset output config.
Jan 03 13:48:13 Cosmic cosmic-panel[22662]: com.system76.CosmicAppletPower: Error: "configuration failed"

@hojjatabdollahi
Copy link

hojjatabdollahi commented Jan 3, 2025

I deleted outputs.ron file. Now my displays are laid out far from each other and I can not move them either, there is a small graphical glitch in cosmic settings and the displays pop back where they were.

Not sure why it would decide to put the displays that far apart if there is no outputs.ron file (although this particular bug was there before the more recent commits too).
screenshot-2025-01-03-21-00-24

edit: I restored a backup of outputs.ron from this morning and looks like cosmic-comp can load it and apply it just fine. Not sure why I can't do the same from the settings.

@Drakulix
Copy link
Member Author

Drakulix commented Jan 6, 2025

@hojjatabdollahi Thanks!

I found the problem preventing positioning and well as a problem affecting initial positioning (for not taking scaling into account).

@Drakulix
Copy link
Member Author

Drakulix commented Jan 6, 2025

Alright, this builds on noble, master_jammy was split off, so good for merge now.

@Drakulix Drakulix merged commit 578c77c into master Jan 6, 2025
5 of 9 checks passed
@Drakulix Drakulix deleted the drm-output-test branch January 6, 2025 19:23
@Tiedye
Copy link

Tiedye commented Jan 7, 2025

I deleted outputs.ron file. Now my displays are laid out far from each other and I can not move them either, there is a small graphical glitch in cosmic settings and the displays pop back where they were.

Not sure why it would decide to put the displays that far apart if there is no outputs.ron file (although this particular bug was there before the more recent commits too).
screenshot-2025-01-03-21-00-24

edit: I restored a backup of outputs.ron from this morning and looks like cosmic-comp can load it and apply it just fine. Not sure why I can't do the same from the settings.

I'm seeing this too

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

Successfully merging this pull request may close these issues.

4 participants