# External monitors and laptop using modesetting and nouveau

## corin

Hi folks,

I'm struggling to get any external monitors to work with my laptop, the more I read the more confused I become. The problem manifests itself with X crashing as soon as I activate the outputs to the external monitors using xrandr. The strange thing is I did have it working at one point but then made some changes involving the display manager (i.e. installing and enabling one, prior I had been launching startx from a getty login).

At this point I'm prepared to admit that I don't know what I'm doing and I don't know where I went wrong. So, if you good folks could take a look at the following information and point me in the right direction I'd be much obliged.

lspci -k -->  https://paste.pound-python.org/show/qyrZ2BjqxMBKmLA4Vmhs/

grep -r . /etc/X11/xorg.conf.d -->  https://paste.pound-python.org/show/icGBwZs8jnoJbb2h5JX6/

grep -r . /etc/X11/xinit/xinitrc.d -->  https://paste.pound-python.org/show/VPmXpu04UTwPLAW1NKYM/

find /usr/lib64/{xorg,opengl} -->  https://paste.pound-python.org/show/DG5mtQ6ys6a009knr1RB/

glxinfo -->  https://paste.pound-python.org/show/dEHtmhNluJ4IrQ0qiDJF/

emerge --info --> https://paste.pound-python.org/show/SeXFdhw35Vfi2xVtksYu/

eselect opengl list -->  https://paste.pound-python.org/show/7Gz2Avyn7d2P6ddxeBMM/

When I execute this:

```
xrandr --output DP-1-1 --mode 1920x1080 --pos 0x0 --rotate normal --output HDMI-1-1 --off --output eDP-1 --primary --mode 1920x1080 --pos 0x1080 --rotate normal --output DP-1-2 --mode 1920x1080 --pos 1920x0 --rotate normal
```

X crashes and my display manager restarts it and I find the following in Xorg.0.log.old --> https://paste.pound-python.org/raw/fTI2nHJ0X9uh9O5EAIty/

```

...snip...

[  1241.636] (EE) NOUVEAU(G0): Failed to initialise context object: 2D_NVC0 (0)

[  1241.636] (EE) NOUVEAU(G0): Error initialising acceleration.  Falling back to NoAccel

[  1241.636] (**) NOUVEAU(G0): [COPY] acceleration disabled

[  1241.637] (II) NOUVEAU(G0): Hardware support for Present enabled

[  1241.637] (==) NOUVEAU(G0): Backing store enabled

[  1241.637] (==) NOUVEAU(G0): Silken mouse enabled

[  1241.637] (==) NOUVEAU(G0): DPMS enabled

[  1241.637] (II) NOUVEAU(G0): RandR 1.2 enabled, ignore the following RandR disabled message.

...snip...

[  2330.298] (II) modeset(0): Allocate new frame buffer 3840x2160 stride

[  2330.495] (EE) 

[  2330.495] (EE) Backtrace:

[  2330.495] (EE) 0: /usr/bin/X (xorg_backtrace+0x4a) [0x55976ea31cda]

[  2330.495] (EE) 1: /usr/bin/X (0x55976e882000+0x1b39e9) [0x55976ea359e9]

[  2330.495] (EE) 2: /lib64/libpthread.so.0 (0x7ff65fa05000+0x13ec0) [0x7ff65fa18ec0]

[  2330.495] (EE) 

[  2330.495] (EE) Segmentation fault at address 0x0

[  2330.495] (EE) 

Fatal server error:

[  2330.496] (EE) Caught signal 11 (Segmentation fault). Server aborting

[  2330.496] (EE) 

[  2330.496] (EE) 

Please consult the The X.Org Foundation support 

    at http://wiki.x.org

 for help. 

[  2330.496] (EE) Please also check the log file at "/var/log/Xorg.0.log" for additional information.

[  2330.496] (EE) 

[  2330.496] (II) AIGLX: Suspending AIGLX clients for VT switch

[  2330.572] (EE) Server terminated with error (1). Closing log file.

```

----------

## NeddySeagoon

corin,

Xorg is confused. You need two Section "Device" to bind the drivers to the card.

```
Section "Device"

    Identifier "Intel GPU"

    Driver     "modesetting"

    BusID      "PCI:0:0:2"

EndSection

Section "Device"

    Identifier "nVidia GPU"

    Driver     "nouveau"

    BusID      "PCI:0:1:0"

EndSection
```

Put that in a file in /etc/X11/xorg.conf.d.

Xorg is doing hardware detection.

```
[  1241.309] (==) Matched intel as autoconfigured driver 0

[  1241.309] (==) Matched nouveau as autoconfigured driver 1

[  1241.309] (==) Matched nv as autoconfigured driver 2

[  1241.309] (==) Matched intel as autoconfigured driver 3

[  1241.309] (==) Matched modesetting as autoconfigured driver 4

[  1241.309] (==) Matched fbdev as autoconfigured driver 5

[  1241.309] (==) Matched vesa as autoconfigured driver 6
```

The next warning is a bit odd ... 

```
[  1241.309] (WW) Warning, couldn't open module intel

[  1241.309] (II) UnloadModule: "intel"

[  1241.309] (II) Unloading intel

[  1241.309] (EE) Failed to load module "intel" (module does not exist, 0)
```

as intel is in your VIDEO_CARDS.

That suggests that it was added after the .old log was generated.  As you want to use modesetting, it won't actually matter.

```
[  1241.309] (II) LoadModule: "nv"

[  1241.310] (WW) Warning, couldn't open module nv

[  1241.310] (II) UnloadModule: "nv"

[  1241.310] (II) Unloading nv

[  1241.310] (EE) Failed to load module "nv" (module does not exist, 0)
```

Is OK. Its not in your VIDEO_CARDS and nobody uses it any more.

Likewise for the other two drivers.

----------

## corin

Thanks for the reply NeddySeagoon, I tried your suggestion, alas I now get this error message:

```
[   682.385] (EE) No devices detected.

[   682.385] (EE) 

Fatal server error:

[   682.385] (EE) no screens found(EE) 

[   682.385] (EE) 
```

Then I tried X -configure -->  https://paste.pound-python.org/show/44cIfIopq7CnLI8IuuZj/

And I notice that it found different BusIds so I tried those but when X starts I simply get a blank/black screen.

The last thing I tried was this:

/etc/X11/xorg.conf.d/10-cards.conf --> https://paste.pound-python.org/show/kWp4JVKEWnlXqH12PH8J/

/var/log/Xorg.0.log.old -->  https://paste.pound-python.org/show/BWLRpjzZihjYpC088D39/

----------

## NeddySeagoon

corin,

I took the BusIDs from 

```
[  1241.308] (--) PCI:*(0:0:2:0) 8086:591b: ...

[  1241.308] (--) PCI: (0:1:0:0) 10de:1c60: ...
```

and got the wrong sequence of three digits.

Sorry about that but you corrected it later.

 *corin wrote:*   

> And I notice that it found different BusIds so I tried those but when X starts I simply get a blank/black screen. 

 

That is actually encouraging.

How do you start Xorg and what do you expect it to do when it starts?

Unless you tell it to do something it ether appears to hang or to crash.

By default, startx tries to run three xterms and xclock wrapped in twm.

By default, none of these are installed in Gentoo.

```
emerge -1av xterms xclock twm
```

will add them.

The -1, or  --oneshot, prevents these package being recorded in the @world set, so --depclean will remove then.

----------

## corin

NeddySeagoon,

To be clear, X is initially working under the configuration of my first post and crashes when activating the external monitors. I currently have slim as my display manager, which autologins to my user and begins a i3wm session. 

You are right, I do seem a little closer. I tried my 10-cards.conf again (with the correct BusIds) and now my external monitors are working but the laptop screen is not working, I expect to see eDP-1 from xranr:

```

Screen 0: minimum 320 x 200, current 3840 x 1080, maximum 16384 x 16384

HDMI-1 disconnected primary (normal left inverted right x axis y axis)

DP-1 connected 1920x1080+0+0 (normal left inverted right x axis y axis) 531mm x 299mm

   1920x1080     60.00*+

   1680x1050     59.88  

   1600x900      60.00  

   1280x1024     75.02    60.02  

   1280x800      59.91  

   1152x864      75.00  

   1280x720      60.00  

   1024x768      75.03    60.00  

   832x624       74.55  

   800x600       75.00    60.32  

   640x480       75.00    59.94  

   720x400       70.08  

DP-2 connected 1920x1080+1920+0 (normal left inverted right x axis y axis) 531mm x 299mm

   1920x1080     60.00*+

   1680x1050     59.88  

   1600x900      60.00  

   1280x1024     75.02    60.02  

   1280x800      59.91  

   1152x864      75.00  

   1280x720      60.00  

   1024x768      75.03    60.00  

   832x624       74.55  

   800x600       75.00    60.32  

   640x480       75.00    59.94  

   720x400       70.08
```

I'll try some more config and get back to you.

----------

## NeddySeagoon

corin,

Lets have an overview of how xorg does what you want. The gory detail is in 

```
man xorg.conf
```

We will ignore the autoblackmagic for this. 

At the top level is the Serverlayout. With multiple display surfaces, you need this section as it describes the spatial relationships between the display surfaces.

It also calls up other sections by their identifier. In turn these other sections call up yet furthers sections.

So the  Serverlayout calls up Screen sections which in turn call up Device sections.

You have two device Sections already.  I think you will need a third, and three Screen Sections and a Serverlayout section to pull it all together.

Use descriptive Identifiers or your head will hurt.

The autoblackmagic works well for a single display surface and single GPU.

It will take care of the input devices on a multi head setup too.

----------

## corin

Ok, I read throught the xorg.conf man page and arrived with this config: https://paste.pound-python.org/show/udYljBCiafSELMs1Fzlt/

Which resulted in a crash: https://paste.pound-python.org/show/lezpAWUjxE2miImGvp4F/

Looking through that log I notice these lines:

```

[ 11738.214] (II) modeset(0): Output eDP-1 using monitor section eDP Monitor

[ 11738.217] (II) modeset(0): Output eDP-1 connected

[ 11738.219] (II) NOUVEAU(1): Output HDMI-1 using monitor section HDMI Monitor

[ 11738.355] (II) NOUVEAU(1): Allocated crtc nr. 0 to this screen.

[ 11738.356] (II) NOUVEAU(1): Output HDMI-1 disconnected

[ 11738.427] (II) NOUVEAU(2): Output DP-1 using monitor section DP1 Monitor

[ 11738.495] (II) NOUVEAU(2): Allocated crtc nr. 1 to this screen.

[ 11738.563] (II) NOUVEAU(2): Output DP-1 connected

[ 11738.671] (II) modeset(G0): Output DP-1-1 using monitor section eDP Monitor

[ 11738.878] (II) NOUVEAU(G1): Output DP-2-1 using monitor section eDP Monitor

[ 11738.946] (II) NOUVEAU(G1): Allocated crtc nr. 2 to this screen.

[ 11739.015] (EE) modeset(G0): drmSetMaster failed: Invalid argument

[ 11739.015] (EE) 

Fatal server error:

[ 11739.015] (EE) AddScreen/ScreenInit failed for gpu driver 0 -1

```

Both eDP-1 (laptop's builtin screen) and HDMI-1 (disconnected) are as expected. DP-1 also looks good (connected external monitor) I don't understand what modeset(G0) means or why there's another DP-1(-1). Likewise, I don't understand NOUVEAU(G1) or where DP-2-1 came from. What do the numbers and letters in parens refer to? I was expecting to see DP-2 (a second connected external monitor).

Finally, I can't figure out what `drmSetMaster failed: Invalid argument` means...

I tried simpler xorg.conf files but in every case X wound up unloading nouveau and I'd be left with only the builtin monitor working. E.g.

xorg.conf --> https://paste.pound-python.org/show/vuOjtohIpBhujMaujL1E/

Xorg.0.log --> https://paste.pound-python.org/show/kluS4As31YRV8LIfn2Er/

```

[  9024.505] EGL_MESA_drm_image required.

[  9024.505] (EE) modeset(G0): glamor initialization failed

[  9024.782] (II) UnloadModule: "nouveau"

[  9024.782] (II) Unloading nouveau

```

Again, I don't know what EGL_MESA_drm_image is, or where it's supposed to come from.

Sometimes, there'd be no error and X would simply say: "Screen 1 deleted because of no matching config section." I assume that is because I used the wrong xorg.conf settings...

----------

