Skip to content

init_drm does not take into account the count_connectors of the drm device #782

Description

@tjallingt

The drm platform logic here

for (int i = 0; i < num_devices; ++i) {
drmDevice* device = devices[i];
if (!(device->available_nodes & (1 << DRM_NODE_PRIMARY)))
continue;
drm_data.fd = open (device->nodes[DRM_NODE_PRIMARY], O_RDWR);
if (drm_data.fd < 0)
continue;
drm_data.base_resources = drmModeGetResources (drm_data.fd);
if (drm_data.base_resources) {
g_debug ("init_drm: using device %p, DRM_NODE_PRIMARY %s",
device, device->nodes[DRM_NODE_PRIMARY]);
break;
}
close (drm_data.fd);
drm_data.fd = -1;
}

Is supposed to pick the right drm device for cog to use, however on my raspberry pi cm5 setup this logic ends up picking /dev/dri/card0 and then ends up failing here

for (int i = 0; i < drm_data.base_resources->count_connectors; ++i) {
drm_data.connector.obj = drmModeGetConnector (drm_data.fd, drm_data.base_resources->connectors[i]);
if (drm_data.connector.obj->connection == DRM_MODE_CONNECTED)
break;
g_clear_pointer (&drm_data.connector.obj, drmModeFreeConnector);
}
if (!drm_data.connector.obj)
return FALSE;

Because this card doesn't have any connectors.

I'm not 100% sure if card0 is supposed to work or not. But testing with kmscube --device=/dev/dri/card0 also fails with an error "no connected connector!" while kmscube --device=/dev/dri/card1 works correctly.

root@goingdutch:~# G_MESSAGES_DEBUG=all LIBWPE_DEBUG=all LIBGL_DEBUG=verbose COG_PLATFORM_PARAMS=renderer=gles cog -P drm
(process:690): Cog-Core-DEBUG: 20:02:02.568: ensure_extension_points: Extension points registered.
(process:690): Cog-Core-DEBUG: 20:02:02.568: cog_modules_add_directory: Scanning '/usr/lib/cog/modules'
Cog-INFO: 20:02:02.571: com.igalia.Cog.Platform:
Cog-INFO: 20:02:02.571:   wl - 500/CogWlPlatform
Cog-INFO: 20:02:02.571:   drm - 200/CogDrmPlatform
(cog:690): GLib-GIO-DEBUG: 20:02:02.574: _g_io_module_get_default: Found default implem[  329.916803] audit: type=1701 audit(1748548922.611:23): auid=4294967295 uid=0 gid=0 ses=4294967295 pid=690 comm="cog" exe="/usr/bin/cog" sig=5 res=1
entation local (GLocalVfs) for ?gio-vfs?
(cog:690): GLib-GIO-DEBUG: 20:02:02.575: Using cross-namespace EXTERNAL authentication (this will deadlock if server is GDBus < 2.73.3)
(process:694): GLib-GIO-DEBUG: 20:02:02.600: Failed to initialize portal (GNetworkMonitorPortal) for gio-network-monitor: Not using portals
(process:694): GLib-GIO-DEBUG: 20:02:02.601: Using cross-namespace EXTERNAL authentication (this will deadlock if server is GDBus < 2.73.3)
(process:694): GLib-GIO-DEBUG: 20:02:02.602: Failed to initialize networkmanager (GNetworkMonitorNM) for gio-network-monitor: NetworkManager not running
(process:694): GLib-GIO-DEBUG: 20:02:02.603: _g_io_module_get_default: Found default implementation netlink (GNetworkMonitorNetlink) for ?gio-network-monitor?
(cog:690): GLib-GIO-DEBUG: 20:02:02.610: Using cross-namespace EXTERNAL authentication (this will deadlock if server is GDBus < 2.73.3)
(cog:690): Cog-DEBUG: 20:02:02.611: platform_setup_once: Platform name: drm
(cog:690): Cog-DEBUG: 20:02:02.613: platform_setup_once: Platform params: renderer=gles
(cog:690): Cog-DRM-DEBUG: 20:02:02.613: init_config: overriding device_scale value, using 1.00 from shell
(cog:690): Cog-DRM-DEBUG: 20:02:02.614: init_drm: enumerated device 0x5555e055da10, available_nodes 1
(cog:690): Cog-DRM-DEBUG: 20:02:02.614: init_drm:   DRM_NODE_PRIMARY: /dev/dri/card0
(cog:690): Cog-DRM-DEBUG: 20:02:02.614: init_drm: enumerated device 0x5555e055dca0, available_nodes 5
(cog:690): Cog-DRM-DEBUG: 20:02:02.614: init_drm:   DRM_NODE_PRIMARY: /dev/dri/card2
(cog:690): Cog-DRM-DEBUG: 20:02:02.614: init_drm:   DRM_NODE_RENDER: /dev/dri/renderD128
(cog:690): Cog-DRM-DEBUG: 20:02:02.614: init_drm: enumerated device 0x5555e055e1e0, available_nodes 1
(cog:690): Cog-DRM-DEBUG: 20:02:02.614: init_drm:   DRM_NODE_PRIMARY: /dev/dri/card1
(cog:690): Cog-DRM-DEBUG: 20:02:02.614: init_drm: using device 0x5555e055da10, DRM_NODE_PRIMARY /dev/dri/card0
(cog:690): Cog-DRM-DEBUG: 20:02:02.614: init_drm: 0 connectors available

(cog:690): Cog-WARNING **: 20:02:02.614: Platform setup failed: Failed to initialize DRM
(cog:690): Cog-DEBUG: 20:02:02.614: Instantiating default WPE backend as fall-back.

** (cog:690): CRITICAL **: 20:02:02.614: WebKitWebViewBackend* webkit_web_view_backend_new(wpe_view_backend*, GDestroyNotify, gpointer): assertion 'backend' failed

(cog:690): Cog-ERROR **: 20:02:02.614: Could not instantiate any WPE backend.
Trace/breakpoint trap (core dumped)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions