Xrandr fails randomly with “Configure crtc X failed” on dock with multiple monitors

graphicsxorgxrandr

TL;DR: xrandr fails randomly on my system with the error message xrandr: Configure crtc X failed on my setup with two monitors, that are connected to a dockingstation. After I turn on and off single monitors multiple times, I most of the times get it working.

I have a setup with a Lenovo Thinkpad on a dockingstation. To that dockingstation two monitors are connected by display port. Here's the output of xrandr:

razr@notebook [~]
-> % xrandr
Screen 0: minimum 8 x 8, current 7680 x 1440, maximum 32767 x 32767
eDP1 connected 2560x1440+5120+0 (normal left inverted right x axis y axis) 340mm x 190mm
   2880x1620     59.96 +  50.00
   2560x1600     59.97
   2560x1440     59.95*
   2048x1536     60.00
   1920x1440     60.00
   1856x1392     60.01
   1792x1344     60.01
   2048x1152     60.00    59.90    59.91
   1920x1200     59.88    59.95
   1920x1080     59.96    60.00    59.93
   1600x1200     60.00
   1680x1050     59.95    59.88
   1400x1050     59.98
   1600x900      60.00    59.95    59.82
   1280x1024     60.02
   1400x900      59.96    59.88
   1280x960      60.00
   1440x810      60.00
   1368x768      60.00    59.88    59.85
   1280x800      59.81    59.91
   1280x720      59.86    60.00    59.74
   1024x768      60.00
   1024x576      60.00    59.90    59.82
   960x540       60.00    59.63    59.82
   800x600       60.32    56.25
   864x486       60.00    59.92    59.57
   640x480       59.94
   720x405       59.51    60.00    58.99
   640x360       59.84    59.32    60.00
DP1 disconnected (normal left inverted right x axis y axis)
DP2 disconnected (normal left inverted right x axis y axis)
DP2-1 connected 2560x1440+2560+0 (normal left inverted right x axis y axis) 610mm x 350mm
   3840x2160     60.00 +  30.00    29.97
   2560x1440     59.95*
   1920x1080     60.00    59.94
   1680x1050     59.95
   1600x900      60.00
   1280x1024     75.02    60.02
   1440x900      59.89
   1280x800      59.81
   1152x864      75.00
   1280x720      60.00    59.94
   1024x768      75.03    70.07    60.00
   832x624       74.55
   800x600       72.19    75.00    60.32    56.25
   640x480       75.00    72.81    66.67    60.00    59.94
   720x400       70.08
DP2-2 connected primary 2560x1440+0+0 (normal left inverted right x axis y axis) 610mm x 350mm
   3840x2160     60.00 +  30.00    29.97
   2560x1440     59.95*
   1920x1080     60.00    59.94
   1680x1050     59.95
   1600x900      60.00
   1280x1024     75.02    60.02
   1440x900      59.89
   1280x800      59.81
   1152x864      75.00
   1280x720      60.00    59.94
   1024x768      75.03    70.07    60.00
   832x624       74.55
   800x600       72.19    75.00    60.32    56.25
   640x480       75.00    72.81    66.67    60.00    59.94
   720x400       70.08
DP2-3 disconnected (normal left inverted right x axis y axis)
HDMI1 disconnected (normal left inverted right x axis y axis)
HDMI2 disconnected (normal left inverted right x axis y axis)
VIRTUAL1 disconnected (normal left inverted right x axis y axis)
razr@notebook [~]
-> %

I have no xorg.conf on my system. I have a shell script that is called by lightdm on startup, that checks if those monitors are connected (hence the notebook is on the dockingstation) and if that is the case, executes the following command:

xrandr --output eDP1 --mode "1920x1080" --output DP2-1 --mode auto --left-of eDP1 --output DP2-2 --mode auto --primary --left-of DP2-1

Otherwise it just sets the mode of the notebook display to "1920x1080".

But this does not work at all. I always get an error message like xrandr: Configure crtc 1 failed. I think the number changes from time to time.

I already have some experience with a similar issue at work (seen end of my question) and so I know, that I can, most of the time, fix this by deactivating and reactivating the monitors again and again. I installed arandr for that, because it's made it a little easier to do this over and over again. With only one monitor and the notebook display activated it works all the time. It doesn't matter which monitor is active. Only the two monitors (without the notebook display) does not work.

For my (new) setup at home I cannot get this working. I kind-of to get it working, but only with mode "2560x1440" on both monitors. And this also does not work all the time. Sometimes I have to, again, open arandr and de-/reactivate the monitors randomly to get to a state where it works. I couldn't figure out any pattern there until now. Sometimes I just give up, restart my machine and hope that it works afterwards.

As already stated, I have a pretty similar setup at work, where I do basically the same. At work this works at least when I start my machine on the dockingstation. If I start the machine, then connect it to the dockingstation and run the command above, I get the same error. Here the randomly de-/reactivate the monitors works as well, most of the times.

Has anyone any idea why this happens and how I can fix this?

Best Answer

Niklas's answer pointed me towards a solution if you are using arandr. You may find (like I did) that when you unplug the dock, arandr will only show the primary monitor (my laptop in this case). Your other two monitors are still detected by xrandr though, so you just need to re-activate the two other monitors by right-clicking the background of the GUI and turning on 'activate' for the two monitors.

BUT, if you do this for both monitors, you will get the error razr was mentioning. Just activate each monitor one at a time -- by clicking the check-mark button between activations -- and you should be good :)

EDIT:

Seemed to have also found a foolproof way to do this without having to work through arandr. Activate the first monitor:

xrandr --output DP2-1 --auto

Then, if you are like me, it won't work if you try to activate the second monitor (you'll still get the error razr mentioned):

xrandr --output DP2-2 --auto

Instead, just run the arandr script you have saved. This was for my case:

./dual_monitor_home.sh

And it auto-detected the second screen and worked!

Related Question