11

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?

Rui F Ribeiro
  • 56,709
  • 26
  • 150
  • 232
Max N.
  • 211

7 Answers7

9

Problem

I suspect that your system has only 2 pixel clocks it can use to drive your 3 monitors.¹

To confirm my assumption, please provide

  • xrandr --verbose | egrep '^[^[:space:]]|curr|pref' | sed -e 's/(norm.*)//' when all monitors are correct
  • the same command executed when something is wrong
  • the command you tried to correct it & the error you got
  • check if those commands provoked any kernel output (fresh lines in dmesg)
  • xrandr --listproviders
  • echo $XDG_SESSION_TYPE
  • loginctl show-session -p Type $(loginctl session-status | head -1 | cut -d' ' -f1)

You 99% do not have this problem, but a different one if you use a USB-C docking station (I think USB-C uses an independent clock).

It is not totally clear to me how rebooting with the dock connected helps you here, but the --auto option of xrandr does not optimize for saving pixel clocks, but that is possible. (It only tries what the monitor prefers.)

Pixel clock details

The pixel clock is that MHz-number you see in some outputs. If you are limited by (e.g.) 2 pixel clocks, then the union of all desired “modelines” (resolution + refresh rate + even more) must only refer to a maximum of 2 different frequencies for the pixel clock.

When setting up monitors, xrandr tries to (re)configure the CRTCs (CRT-controllers) with the clock rates from those modelines and might fail for various reasons with the line (number varies):

xrandr: Configure crtc 1 failed

One reason to fail is missing further free clock pulse generators. (There are many other reasons as well!)

xrandr does not seem to get the details of the problem, but on my system I can simultaneously see errors from the video card driver in the kernel ring buffer (dmesg)—your messages might vary if you get any:

[drm:radeon_atom_pick_pll [radeon]] *ERROR* unable to allocate a PPLL
[drm:drm_crtc_helper_set_config [drm_kms_helper]] *ERROR* failed to set mode on [CRTC:44:crtc-1]

PLLs are used to generate clock ticks.

Solution

Use fewer dot-clock frequencies. In the rest of my answer I will focus on handling monitors in different ways with the final goal of reducing the number down to 1 or 2. Read the steps, understand them, use the ones you need adapted to your hardware.

Note that the same resolution with the same refresh rate might still require different clock frequencies if they do not use the same modeline. But also: different modelines might use exactly the same pixel frequency.

1. put all monitors on one clock with the standard modelines
1.1. find a good candidate frequency
xrandr --verbose | grep MHz | sort --key 3 --numeric-sort --reverse | uniq

This line reveals all modelines sorted by dot-clock.³ One way to go is looking for a frequency reported a lot even with different resolutions. I have this with 108.000MHz:

....
  1600x900 (0x5e) 108.000MHz +HSync +VSync
  1280x960 (0x10c1) 108.000MHz +HSync +VSync
  1280x1024 (0x5f) 108.000MHz +HSync +VSync
  1152x864 (0x6f) 108.000MHz +HSync +VSync
....
1.2. check if candidate is available on all monitors
xrandr --verbose | egrep '^[^[:space:]]|108.000MHz'

108.000MHz modelines are available for all my monitors:

Screen 0: minimum 320 x 200, current 5520 x 2160, maximum 8192 x 8192
DisplayPort-0 connected primary 1920x1080+0+1080 (0x184a) normal (normal left inverted right x axis y axis) 509mm x 286mm
  1280x1024 (0x5f) 108.000MHz +HSync +VSync
  1280x960 (0x10c1) 108.000MHz +HSync +VSync
  1152x864 (0x6f) 108.000MHz +HSync +VSync
HDMI-0 connected 1920x1080+1920+1080 (0x184a) normal (normal left inverted right x axis y axis) 527mm x 296mm
  1600x900 (0x5e) 108.000MHz +HSync +VSync
  1280x1024 (0x5f) 108.000MHz +HSync +VSync
DVI-0 connected 1920x1080+3600+0 (0x5a) normal (normal left inverted right x axis y axis) 477mm x 268mm
  1280x1024 (0x5f) 108.000MHz +HSync +VSync
  1280x960 (0x10c1) 108.000MHz +HSync +VSync
  1152x864 (0x6f) 108.000MHz +HSync +VSync
DVI-1 connected 1680x1050+1920+0 (0x172a) normal (normal left inverted right x axis y axis) 433mm x 270mm
  1280x1024 (0x5f) 108.000MHz +HSync +VSync
  1152x864 (0x6f) 108.000MHz +HSync +VSync

If some monitors show no modelines, check other frequencies of common resolutions from 1.1.

1.3. Set all monitors to one frequency

For fun, I even use 4 different resolutions, picked from the output in 1.2. But first free all but one clock tick generator:

xrandr --output DisplayPort-0 --off \
       --output DVI-0 --off \
       --output DVI-1 --off \
       --output HDMI-0 --mode 0x5e

Then set the others to the same clock:

xrandr --output DVI-1 --mode 0x6f \
       --output DVI-0 --mode 0x10c1 \
       --output DisplayPort-0 --mode 0x5f

Setting all at once might fail because of temporary usage of 3 different clocks.—Use hex mode numbers (from 1.2. in parenthesis) instead of resolution names, because the resolution name unifies several modelines and the automatism might pick the wrong one.

2. Set all monitors to the desired resolution
2.1. Set the most challenging first

Start with the most demanding monitor (i.e. the highest required pixel clock), which is almost always the highest resolution. Check recommended modelines (marked with “+” for each monitor in xrandr --verbose).

As we are now running all on a single dot-clock, you can set any monitor (but just one) to anything your graphic card can generate. This will make use of the second clock tick generator, and I assume your graphic card has at least two of those.

Often this is good enough:

xrandr --output W_BIGGEST_MON --auto
2.2. Set all other monitors

Check the other monitors and see if you find a suitable modeline with a clock already in use. With custom modelines you should definitively get by with two clocks unless you run an array of totally dislike monitor generations!

2.3. How to create and use custom modelines

You might end up with the situation where you want to run a resolution on a secondary monitor slightly below the “best” monitor. The modeline will probably have a lower pixel clock, but it is easy to pump that one up. You can not get overboard with this trick, because that secondary monitor will not accept dot-clocks far beyond what is necessary for its highest resolution.

Example: My best monitors are only full-HD, and run with 148.500MHz, but one is a little smaller, preferring a mode with 146.250MHz as seen here:

xrandr --verbose | egrep '^[^[:space:]]|current|preferred'

output (shortened):

DisplayPort-0 connected primary 1920x1080+0+1080 (0x5a)
  1920x1080 (0x5a) 148.500MHz +HSync +VSync *current +preferred
HDMI-0 connected 1920x1080+1920+1080 (0x5a)
  1920x1080 (0x5a) 148.500MHz +HSync +VSync *current +preferred
DVI-0 connected 1920x1080+3600+0 (0x5a)
  1920x1080 (0x5a) 148.500MHz +HSync +VSync *current +preferred
DVI-1 connected 1152x864+1920+0 (0x6f)
  1680x1050 (0x6d) 146.250MHz -HSync +VSync +preferred

Now I need a 1680x1050 modeline with a 148.500MHz dot-clock. There are many tools to generate modelines. cvt is not good. You can not set the dot-clock with that one. But this xtiming website is good enough:

  • leave all boxes empty/on default
  • set the desired visible resolution (for me 1680 and 1050)
  • set the refresh rate to e.g. 60 (move this between 50 and 75 to move the dot-clock really quick)
  • calculate and check the resulting dot-clock frequency (I get 154.19MHz)
  • fine-tune the horizontal sync time (3.8 → 3.7 → 3.4 → 3.35µs)
  • ...and recalculate and check the dot-clock (... ... ... 148.29MHz) until close to the target
    • this trick is the most focused on raising (or lowering) the dot-clock while leaving every other aspect of the modeline almost the same
    • it changes the waiting time between lines as transparent as possible
    • most (all?) LCDs are pretty flexible on this one (1-7µs) if they can actually handle the resulting (higher?) dot-clock
    • (Modeline "name" dot-clock HDataEnd HSyncStart HSyncStop HFinish VDataEnd VSyncStart VSyncStop VFinish)
    • it changes the gap between HSyncStart and HSyncStop
  • now finally change the dot-clock to the exact target dot-clock (148.500) and clear the refresh rate (that will keep the clock while adjusting the refresh by almost nothing) and calculate
  • I get Modeline "1680x1050@60" 148.50 1680 1712 2208 2240 1050 1071 1081 1103 (top of web page)
  • in the following command I use the last 9 numbers of that line (i.e. all the numbers)
  • xrandr --newmode my-148.5MHz 148.50 1680 1712 2208 2240 1050 1071 1081 1103
  • xrandr --addmode DVI-1 my-148.5MHz (add on monitor where needed)
  • xrandr --ouput DVI-1 --mode my-148.5MHz

And voila: your resolution and refresh on the clock you need.


¹ On my system I have only 2 pixel clocks to drive 4 monitors.
³ dot-clock is a synonym for pixel clock

3

I have the same problem with a Lenovo docking station: When I connect my (running) Laptop to it, I can't simultaneously enable both external displays and disable the laptop display in one xrandr command. It gives the same xrandr: Configure crtc 1 failed message.

But instead of randomly deactivating/reactivating monitors, what I'm doing is to split it into two steps similar to Niklas:

  1. Enable first external display and disable laptop display
  2. Enable second external display

This works reproducibly for me, but I'd also be interested in a proper solution!

2

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!

Levi
  • 29
  • The issue for me basically was, that the 4K setup is never activated in the first place. But I will try that and post the results here. I will also try it with undocking and putting it back on again. – Max N. Sep 21 '19 at 18:41
1

Try to split your xrandr command into multiple commands like this:

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

It's a work-around.

Rui F Ribeiro
  • 56,709
  • 26
  • 150
  • 232
Niklas
  • 11
  • as I cannot comment your post: The problem occurred on my box after adding 'Option "DRI" "2"' to my xorg.conf. This also changed the names of all my displays… Maybe somebody more knowledgeable can explain… – Niklas Nov 30 '18 at 12:55
  • I already had this on my work environment. And I had the same issue with it. On initial startup, when connected to the dockingstation it works, after removing the notebook and putting it back on it doesn't. At home with the 4K setup it does not work at all. – Max N. Nov 30 '18 at 13:08
1

My solution was to suspend/sleep the notebook while still on the dock station and wake it up and then it worked again like a charm.

  • Ok, but I already have a workaround (randomly de- and re-activating the monitors until it works :)). And for my home-setup with 4k resolution I don't even get it to work in the first place. So I would assume, that starting from suspend will not help me there.. – Max N. Jan 09 '19 at 11:40
  • hm interesting, this helped me but I'd love to figure out what the problem is. It seems to only happen randomly when trying to re-dock for me. – aiguofer Jul 03 '19 at 20:13
  • This actually worked!?? Interestingly, after I did that, all the output descriptors changed (e.g., from DP-4-2 to DP-3-2). – Martin Becker Jan 31 '23 at 15:11
  • Never mind, this actually did not work consistently :( What helped me was to plug in my docking station on another USB-C port. Not a good solution either but it works so far. – Martin Becker Feb 01 '23 at 20:28
0

I had the same problem using a Lenovo Thinkpad on a dockingstation.

To fix it I had to reduce the refresh rate, because one monitor defaults to 144Hz.

xrandr --output DP-2-3 --auto --primary --crtc 0 --rotate normal --mode 2560x1440 --rate 59.95
xrandr --output eDP-1 --off
xrandr --output DP-2-2 --auto --right-of DP-2-3 --rotate left

Apparently the bandwidth is limited.

svenwltr
  • 117
0

Lenovo X230 on a dock connected to a BenQ PD2500Q using the DP-3 port here. Also getting Configure crtc X failed error when trying to manually assign the resolution. Was able to consistently get auto detection of the resolution by falling back to the 'Displayport 1.1' setting from 1.2 in the monitor's menu. This setting seems like it must be switched to, it cannot simply be left in 1.1 and plugged in. xrandr --verbose now shows 2560x1440 (0x1f1) 241.500MHz +HSync -VSync *current +preferred h: width 2560 start 2607 end 2639 total 2720 skew 0 clock 88.79KHz v: height 1440 start 1443 end 1448 total 1481 clock 59.95Hz as the highest resolution. Can confirm this survives a restart without needing to cycle the monitor's settings again.

  • Did you launch any commands to solve your problem? Which? – Can you turn this into a list of steps which reliably and reproducible solve the issue for you? – Your single paragraph answer mixed with unformatted command line output is really confusing. – Robert Siemer Jan 17 '23 at 00:12
  • The highest resolution you quote is probably 100% useless, because it does not contrast it to any other working or non-working state. I’m not even sure what your problem was. – The only thing I suspect is: you did something and believe that that might solve the problem of the OP as well. But I’m not sure. – Robert Siemer Jan 17 '23 at 00:17