xorg-wrapper.c: optimus and two cards
@arekm
Submitted by Arkadiusz Miskiewicz Assigned to Xorg Project Team
Description
My system (Dell XPS 15 9530 notebook) has two graphic cards. intel and nvidia.
$ dmesg|grep drm [ 0.776604] [drm] Initialized drm 1.1.0 20060810 [ 0.777058] [drm] Memory usable by graphics device = 2048M [ 0.777085] [drm] VT-d active for gfx access [ 0.777106] fb: switching to inteldrmfb from simple [ 0.777248] [drm] Replacing VGA console driver [ 0.783559] [drm] Supports vblank timestamp caching Rev 2 (21.10.2013). [ 0.783565] [drm] Driver supports precise vblank timestamp query. [ 0.783582] [drm] DMAR active, disabling use of stolen memory [ 0.819251] [drm] Initialized i915 1.6.0 20150731 for 0000:00:02.0 on minor 0 [ 0.891401] [drm] GMBUS [i915 gmbus vga] timed out, falling back to bit banging on pin 2 [ 0.922294] fbcon: inteldrmfb (fb0) is primary device [ 2.057677] i915 0000:00:02.0: fb0: inteldrmfb frame buffer device [ 9.337216] [drm] Initialized nouveau 1.3.0 20120801 for 0000:02:00.0 on minor 1
both have KMS drivers. But there is only one display and optimus method:
$ dmesg|grep -i optimus [ 8.564103] pci 0000:02:00.0: optimus capabilities: enabled, status dynamic power, hda bios codec supported [ 8.564105] VGA switcheroo: detected Optimus DSM method _SB_.PCI0.PEG0.PEGP handle
Code in xorg-wrapper.c:
/* Detect if we need root rights, except when overriden by the config */
if (needs_root_rights == -1) {
for (i = 0; i < 16; i++) {
snprintf(buf, sizeof(buf), DRM_DEV_NAME, DRM_DIR_NAME, i);
fd = open(buf, O_RDWR);
if (fd == -1)
continue;
total_cards++;
memset(&res, 0, sizeof(struct drm_mode_card_res));
r = ioctl(fd, DRM_IOCTL_MODE_GETRESOURCES, &res);
if (r == 0 && res.count_connectors > 0)
kms_cards++;
close(fd);
}
}
/* If we've found cards, and all cards support kms, drop root rights */
if (needs_root_rights == 0 || (total_cards && kms_cards == total_cards)) {
detects such system as total_cards == 2 and kms_cards == 1 so it doesn't drop rights.
So I guess that this code above needs to be improved to properly detect such situation and allow dropping rights. Or was there a reason for requiring connectors > 0?