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

eglstream-kms: Make It Work Again™ #415

Merged
merged 5 commits into from Aug 16, 2018

Conversation

Projects
None yet
3 participants
@RAOF
Member

RAOF commented Jun 14, 2018

No description provided.

@RAOF

This comment has been minimized.

Show comment
Hide comment
@RAOF

RAOF Jun 14, 2018

Member

@gerboland Hey, yo! Give this a whirl, will you? You'll also need #414 for probing to work correctly.

Member

RAOF commented Jun 14, 2018

@gerboland Hey, yo! Give this a whirl, will you? You'll also need #414 for probing to work correctly.

@RAOF

This comment has been minimized.

Show comment
Hide comment
@RAOF

RAOF Jun 19, 2018

Member

@gerboland Another ping!

Member

RAOF commented Jun 19, 2018

@gerboland Another ping!

@gerboland

This comment has been minimized.

Show comment
Hide comment
@gerboland

gerboland Jun 19, 2018

Contributor

Sorry, am missing the pings somehow

Running this I get

sudo XDG_RUNTIME_DIR=/tmp ./bin/miral-shell --vt 1
MIR_CLIENT_PLATFORM_PATH=./bin/../lib/client-modules/
MIR_SERVER_PLATFORM_PATH=./bin/../lib/server-modules/
LD_LIBRARY_PATH=./bin/../lib
exec=./bin/miral-shell.bin
[2018-06-19 18:07:52.677836] mirserver: Starting
[2018-06-19 18:07:52.678029] mircommon: Loading modules from: ./bin/../lib/server-modules/
[2018-06-19 18:07:52.678073] mircommon: Loading module: ./bin/../lib/server-modules/server-mesa-x11.so.15
[2018-06-19 18:07:52.678082] mircommon: Loading module: ./bin/../lib/server-modules/graphics-mesa-kms.so.15
[2018-06-19 18:07:52.678088] mircommon: Loading module: ./bin/../lib/server-modules/graphics-eglstream-kms.so.15
[2018-06-19 18:07:52.678093] mircommon: Loading module: ./bin/../lib/server-modules/input-evdev.so.7
[2018-06-19 18:07:52.679549] mirserver: Using Linux VT subsystem for session management
[2018-06-19 18:07:52.679584] mirplatform: Found graphics driver: mir:mesa-x11 (version 0.31.2)
[2018-06-19 18:07:52.681919] mirplatform: Found graphics driver: mir:mesa-kms (version 0.31.2)
[2018-06-19 18:07:52.681987] eglstream: Found EGLDeviceEXT with device extensions: EGL_NV_device_cuda EGL_EXT_device_drm
[2018-06-19 18:07:52.724791] mirplatform: Found graphics driver: mir:eglstream-kms (version 0.31.2)
[2018-06-19 18:07:52.724940] mirserver: Selected driver: mir:mesa-kms (version 0.31.2)
[2018-06-19 18:07:52.725100] mirserver: Using Linux VT subsystem for session management
ERROR: /home/gerry/dev/Canonical/mir/src/server/graphics/default_configuration.cpp(172): Throw in function mir::DefaultServerConfiguration::the_graphics_platform()::<lambda()>
Dynamic exception type: boost::exception_detail::clone_impl<boost::exception_detail::error_info_injectorstd::runtime_error >
std::exception::what: Exception while creating graphics platform
ERROR: /home/gerry/dev/Canonical/mir/src/server/console/linux_virtual_terminal.cpp(172): Throw in function {anonymous}::DRMDevice::DRMDevice(mir::VTFileOperations&, const char*, std::unique_ptrmir::Device::Observer, const std::shared_ptrmir::LinuxVirtualTerminal::DeviceList&)
Dynamic exception type: boost::exception_detail::clone_impl<boost::exception_detail::error_info_injectorstd::system_error >
std::exception::what: Failed to claim DRM master: Invalid argument
[boost::errinfo_file_name_*] = /dev/dri/card0

It isn't starting up. My bad?

Contributor

gerboland commented Jun 19, 2018

Sorry, am missing the pings somehow

Running this I get

sudo XDG_RUNTIME_DIR=/tmp ./bin/miral-shell --vt 1
MIR_CLIENT_PLATFORM_PATH=./bin/../lib/client-modules/
MIR_SERVER_PLATFORM_PATH=./bin/../lib/server-modules/
LD_LIBRARY_PATH=./bin/../lib
exec=./bin/miral-shell.bin
[2018-06-19 18:07:52.677836] mirserver: Starting
[2018-06-19 18:07:52.678029] mircommon: Loading modules from: ./bin/../lib/server-modules/
[2018-06-19 18:07:52.678073] mircommon: Loading module: ./bin/../lib/server-modules/server-mesa-x11.so.15
[2018-06-19 18:07:52.678082] mircommon: Loading module: ./bin/../lib/server-modules/graphics-mesa-kms.so.15
[2018-06-19 18:07:52.678088] mircommon: Loading module: ./bin/../lib/server-modules/graphics-eglstream-kms.so.15
[2018-06-19 18:07:52.678093] mircommon: Loading module: ./bin/../lib/server-modules/input-evdev.so.7
[2018-06-19 18:07:52.679549] mirserver: Using Linux VT subsystem for session management
[2018-06-19 18:07:52.679584] mirplatform: Found graphics driver: mir:mesa-x11 (version 0.31.2)
[2018-06-19 18:07:52.681919] mirplatform: Found graphics driver: mir:mesa-kms (version 0.31.2)
[2018-06-19 18:07:52.681987] eglstream: Found EGLDeviceEXT with device extensions: EGL_NV_device_cuda EGL_EXT_device_drm
[2018-06-19 18:07:52.724791] mirplatform: Found graphics driver: mir:eglstream-kms (version 0.31.2)
[2018-06-19 18:07:52.724940] mirserver: Selected driver: mir:mesa-kms (version 0.31.2)
[2018-06-19 18:07:52.725100] mirserver: Using Linux VT subsystem for session management
ERROR: /home/gerry/dev/Canonical/mir/src/server/graphics/default_configuration.cpp(172): Throw in function mir::DefaultServerConfiguration::the_graphics_platform()::<lambda()>
Dynamic exception type: boost::exception_detail::clone_impl<boost::exception_detail::error_info_injectorstd::runtime_error >
std::exception::what: Exception while creating graphics platform
ERROR: /home/gerry/dev/Canonical/mir/src/server/console/linux_virtual_terminal.cpp(172): Throw in function {anonymous}::DRMDevice::DRMDevice(mir::VTFileOperations&, const char*, std::unique_ptrmir::Device::Observer, const std::shared_ptrmir::LinuxVirtualTerminal::DeviceList&)
Dynamic exception type: boost::exception_detail::clone_impl<boost::exception_detail::error_info_injectorstd::system_error >
std::exception::what: Failed to claim DRM master: Invalid argument
[boost::errinfo_file_name_*] = /dev/dri/card0

It isn't starting up. My bad?

@AlanGriffiths

This comment has been minimized.

Show comment
Hide comment
@AlanGriffiths

AlanGriffiths Jul 17, 2018

Member

@gerboland "sudo XDG_RUNTIME_DIR=/tmp ./bin/miral-shell --vt 1"

Three things occur to me:

  1. doesn't gdm already hold DRM Master on VT1? Does a different VT work?
  2. Are you logged into VT1?
  3. how about switching to a VT and then using miral-shell without "--vt" (thereby using Logind, not LinuxVurtualTerminal)?
Member

AlanGriffiths commented Jul 17, 2018

@gerboland "sudo XDG_RUNTIME_DIR=/tmp ./bin/miral-shell --vt 1"

Three things occur to me:

  1. doesn't gdm already hold DRM Master on VT1? Does a different VT work?
  2. Are you logged into VT1?
  3. how about switching to a VT and then using miral-shell without "--vt" (thereby using Logind, not LinuxVurtualTerminal)?
@gerboland

This comment has been minimized.

Show comment
Hide comment
@gerboland

gerboland Jul 18, 2018

Contributor

Rebasing this on top of master, this error goes away. I'm testing on my NVidia machine, and Mir is still often choosing mesa-kms:

  • if launching via a logged-in VT (but not specifying a VT), mir doesn't consider the eglstream-kms platform, uses mesa-kms and fails with "libEGL warning: DRI2: failed to create dri screen". It does use logind.
  • If I launch exactly the same command, but from SSH, mir still uses mesa-kms, prints that libEGL error, but it does run and render (using llvmpipe).
  • if I try so specify a different VT to the one logged in, Mir fails with

[2018-07-18 10:08:00.202269] mirserver: Selected driver: mir:eglstream-kms (version 0.32.1) [2018-07-18 10:08:00.202414] <DEBUG> mirserver: Using Linux VT subsystem for session management ERROR: /home/gerry/dev/Canonical/mir/src/platforms/eglstream-kms/server/egl_output.cpp(281): Throw in function void mir::graphics::eglstream::kms::EGLOutput::configure(size_t) Dynamic exception type: boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<std::runtime_error> > std::exception::what: Failed to find EGLOutputEXT corresponding to DRM CRTC

Doesn't matter if via VT or SSH.

Contributor

gerboland commented Jul 18, 2018

Rebasing this on top of master, this error goes away. I'm testing on my NVidia machine, and Mir is still often choosing mesa-kms:

  • if launching via a logged-in VT (but not specifying a VT), mir doesn't consider the eglstream-kms platform, uses mesa-kms and fails with "libEGL warning: DRI2: failed to create dri screen". It does use logind.
  • If I launch exactly the same command, but from SSH, mir still uses mesa-kms, prints that libEGL error, but it does run and render (using llvmpipe).
  • if I try so specify a different VT to the one logged in, Mir fails with

[2018-07-18 10:08:00.202269] mirserver: Selected driver: mir:eglstream-kms (version 0.32.1) [2018-07-18 10:08:00.202414] <DEBUG> mirserver: Using Linux VT subsystem for session management ERROR: /home/gerry/dev/Canonical/mir/src/platforms/eglstream-kms/server/egl_output.cpp(281): Throw in function void mir::graphics::eglstream::kms::EGLOutput::configure(size_t) Dynamic exception type: boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<std::runtime_error> > std::exception::what: Failed to find EGLOutputEXT corresponding to DRM CRTC

Doesn't matter if via VT or SSH.

@gerboland

This comment has been minimized.

Show comment
Hide comment
@gerboland

gerboland Jul 18, 2018

Contributor

Oh, and manually specifying the graphics platform, via SSH:

sudo XDG_RUNTIME_DIR=/tmp  ./bin/miral-shell --platform-graphics-lib=lib/server-modules/graphics-eglstream-kms.so.15
MIR_CLIENT_PLATFORM_PATH=./bin/../lib/client-modules/
MIR_SERVER_PLATFORM_PATH=./bin/../lib/server-modules/
LD_LIBRARY_PATH=./bin/../lib
exec=./bin/miral-shell.bin
[2018-07-18 10:39:31.393549] mirserver: Starting
[2018-07-18 10:39:31.393785] mirserver: Selected driver: mir:eglstream-kms (version 0.32.1)
[2018-07-18 10:39:31.395914] <DEBUG> mirserver: Not using logind for session management: /home/gerry/dev/Canonical/mir/src/server/console/logind_console_services.cpp(182): Throw in function std::__cxx11::string {anonymous}::object_path_for_current_session(LogindSeat*)
Dynamic exception type: boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<std::runtime_error> >
std::exception::what: Seat has no active session

[2018-07-18 10:39:31.396188] <DEBUG> mirserver: Using Linux VT subsystem for session management
ERROR: /home/gerry/dev/Canonical/mir/src/platforms/eglstream-kms/server/egl_output.cpp(281): Throw in function void mir::graphics::eglstream::kms::EGLOutput::configure(size_t)
Dynamic exception type: boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<std::runtime_error> >
std::exception::what: Failed to find EGLOutputEXT corresponding to DRM CRTC

and in a VT, it crashes after printing "Using logind for session management"

Contributor

gerboland commented Jul 18, 2018

Oh, and manually specifying the graphics platform, via SSH:

sudo XDG_RUNTIME_DIR=/tmp  ./bin/miral-shell --platform-graphics-lib=lib/server-modules/graphics-eglstream-kms.so.15
MIR_CLIENT_PLATFORM_PATH=./bin/../lib/client-modules/
MIR_SERVER_PLATFORM_PATH=./bin/../lib/server-modules/
LD_LIBRARY_PATH=./bin/../lib
exec=./bin/miral-shell.bin
[2018-07-18 10:39:31.393549] mirserver: Starting
[2018-07-18 10:39:31.393785] mirserver: Selected driver: mir:eglstream-kms (version 0.32.1)
[2018-07-18 10:39:31.395914] <DEBUG> mirserver: Not using logind for session management: /home/gerry/dev/Canonical/mir/src/server/console/logind_console_services.cpp(182): Throw in function std::__cxx11::string {anonymous}::object_path_for_current_session(LogindSeat*)
Dynamic exception type: boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<std::runtime_error> >
std::exception::what: Seat has no active session

[2018-07-18 10:39:31.396188] <DEBUG> mirserver: Using Linux VT subsystem for session management
ERROR: /home/gerry/dev/Canonical/mir/src/platforms/eglstream-kms/server/egl_output.cpp(281): Throw in function void mir::graphics::eglstream::kms::EGLOutput::configure(size_t)
Dynamic exception type: boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<std::runtime_error> >
std::exception::what: Failed to find EGLOutputEXT corresponding to DRM CRTC

and in a VT, it crashes after printing "Using logind for session management"

@RAOF RAOF added the no-merge label Jul 23, 2018

@RAOF

This comment has been minimized.

Show comment
Hide comment
@RAOF

RAOF Jul 23, 2018

Member

OK, that's the same thing that I see locally, which means that it's not my laptop being all weird and hybrid-y.

Bah. Looks like something's changed in the NVIDIA driver?

Member

RAOF commented Jul 23, 2018

OK, that's the same thing that I see locally, which means that it's not my laptop being all weird and hybrid-y.

Bah. Looks like something's changed in the NVIDIA driver?

RAOF added some commits Jun 14, 2018

eglstream-kms: Ensure a current EGLContext before constructing displays.
The Display construction requires making EGL calls which assume a current context.
In the past Mir has accidentally made an appropriate EGL context current on the
thread which constructs the displays before trying to construct the displays,
but that was never guaranteed.

Ensure that the appropriate context is current before trying to construct the
KMSDisplayConfiguration.
kms-utils: Fix out-of-bounds array access.
A CRTC iterator should iterate from resources->crtcs to that address + num_crtcs,
*not* to resources->encoders + num_crtcs!
eglstream-kms: Find the EGLOutputLayer for the crtc, not the plane.
<Endless screaming>

The nvidia driver *used* to require that you use EGLOutputLayer for the primary plane of the
CRTC you were interested in, or else it would flicker terribly.

Now? Now, it doesn't *support* any EGLOutputLayers for planes, only for CRTCs. Urgh.

Switch to that, and we bring up output!
eglstream-kms: Fill dummy FB with black.
We've taken the effort to map the dumb buffer we've allocated to ensure that modesetting happens,
so we might as well fill it with 0 rather than possibly flash up a frame of uninitialized memory.
@@ -318,7 +318,7 @@ auto mgk::DRMModeResources::encoders() const -> detail::ObjectCollection<DRMMode
auto mgk::DRMModeResources::crtcs() const -> detail::ObjectCollection<DRMModeCrtcUPtr, &get_crtc>
{
return detail::ObjectCollection<DRMModeCrtcUPtr, &get_crtc>{drm_fd, resources->crtcs, resources->encoders + resources->count_crtcs};
return detail::ObjectCollection<DRMModeCrtcUPtr, &get_crtc>{drm_fd, resources->crtcs, resources->crtcs + resources->count_crtcs};

This comment has been minimized.

@RAOF

RAOF Aug 16, 2018

Member

Endless screaming

@RAOF

RAOF Aug 16, 2018

Member

Endless screaming

This comment has been minimized.

@gerboland

gerboland Aug 16, 2018

Contributor

ouch

@gerboland

gerboland Aug 16, 2018

Contributor

ouch

@RAOF

This comment has been minimized.

Show comment
Hide comment
@RAOF

RAOF Aug 16, 2018

Member

@gerboland Let's try this ping 😀

This successfully brings up a server on my machine.

Member

RAOF commented Aug 16, 2018

@gerboland Let's try this ping 😀

This successfully brings up a server on my machine.

@RAOF RAOF removed the no-merge label Aug 16, 2018

@gerboland

This comment has been minimized.

Show comment
Hide comment
@gerboland

gerboland Aug 16, 2018

Contributor

It works on my nvidia box. mir_demo_shell shows be black screen and cursor, and uses eglstream-kms and proper GL. I can run glmark2-wayland and see stuff (it is using llvmpipe)

Contributor

gerboland commented Aug 16, 2018

It works on my nvidia box. mir_demo_shell shows be black screen and cursor, and uses eglstream-kms and proper GL. I can run glmark2-wayland and see stuff (it is using llvmpipe)

@gerboland

Appears sensible, just one recommendation before merging. Overall I approve

@@ -44,6 +45,10 @@ namespace mgc = mir::graphics::common;
namespace mo = mir::options;
namespace mge = mir::graphics::eglstream;
namespace
{
int const EGL_DRM_MASTER_FD_EXT{0x333C};

This comment has been minimized.

@gerboland

gerboland Aug 16, 2018

Contributor

Can you put this, adds context to the magic

/* XXX khronos eglext.h does not yet have EGL_DRM_MASTER_FD_EXT */
#if !defined(EGL_DRM_MASTER_FD_EXT)
#define EGL_DRM_MASTER_FD_EXT                   0x333C
#endif
@gerboland

gerboland Aug 16, 2018

Contributor

Can you put this, adds context to the magic

/* XXX khronos eglext.h does not yet have EGL_DRM_MASTER_FD_EXT */
#if !defined(EGL_DRM_MASTER_FD_EXT)
#define EGL_DRM_MASTER_FD_EXT                   0x333C
#endif

This comment has been minimized.

@AlanGriffiths

AlanGriffiths Aug 16, 2018

Member

There's already a similar incantation in src/platforms/eglstream-kms/server/platform.cpp, so I would view this as pre-existing.

However, this code will break on any platform that #defines EGL_DRM_MASTER_FD_EXT. We should prevent that with an incantation similar to that @gerboland suggests. (I'd be happy to write or approve a follow-up PR fixing both instances.)

@AlanGriffiths

AlanGriffiths Aug 16, 2018

Member

There's already a similar incantation in src/platforms/eglstream-kms/server/platform.cpp, so I would view this as pre-existing.

However, this code will break on any platform that #defines EGL_DRM_MASTER_FD_EXT. We should prevent that with an incantation similar to that @gerboland suggests. (I'd be happy to write or approve a follow-up PR fixing both instances.)

This comment has been minimized.

@gerboland

gerboland Aug 16, 2018

Contributor

Ok, will approve now then
bors r+

@gerboland

gerboland Aug 16, 2018

Contributor

Ok, will approve now then
bors r+

bors bot added a commit that referenced this pull request Aug 16, 2018

Merge #415
415: eglstream-kms: Make It Work Again™ r=gerboland a=RAOF



Co-authored-by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors bot Aug 16, 2018

Contributor
Contributor

bors bot commented Aug 16, 2018

@bors bors bot merged commit 3f32518 into master Aug 16, 2018

2 checks passed

bors Build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@bors bors bot deleted the eglstream-kms-fixes branch Aug 16, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment