AMDGPU FreeSync Has A Last Minute Fix To Help Prevent Stuttering For Linux 5.0

Written by Michael Larabel in Radeon on 27 February 2019 at 03:06 PM EST. 21 Comments
One of the major end-user features of the new Linux 5.0 kernel that is due to be released this weekend is support for FreeSync / Variable Rate Refresh on AMD Radeon GPUs via the mainline AMDGPU driver. There's a last minute fix requested to help prevent stuttering with this long-awaited feature for Linux gamers.

The AMDGPU FreeSync support has largely been in great shape when using the Linux 5.0 mainline kernel now and the latest user-space bits. In the next few days I should hopefully have the time to do a recap of the state and other details to help Linux gamers in making use of this functionality designed to address tearing and stuttering during the rendering of games and other supported applications.

While overall it's great, there still are some corner cases to address. AMDGPU DRM maintainer Alex Deucher just submitted a pull request for this last minute fix to help prevent stuttering in certain instances.

The patch by independent Linux developer Mario Kleiner explains:
In VRR mode, keep track of the vblank count of the last completed pageflip in amdgpu_crtc->last_flip_vblank, as recorded in the pageflip completion handler after each completed flip.

Use that count to prevent mmio programming a new pageflip within the same vblank in which the last pageflip completed, iow. to throttle pageflips to at most one flip per video frame, while at the same time allowing to request a flip not only before start of vblank, but also anywhere within vblank.

The old logic did the same, and made sense for regular fixed refresh rate flipping, but in vrr mode it prevents requesting a flip anywhere inside the possibly huge vblank, thereby reducing framerate in vrr mode instead of improving it, by delaying a slightly delayed flip requests up to a maximum vblank duration + 1 scanout duration. This would limit VRR usefulness to only help applications with a very high GPU demand, which can submit the flip request before start of vblank, but then have to wait long for fences to complete.

With this method a flip can be both requested and - after fences have completed - executed, ie. it doesn't matter if the request (amdgpu_dm_do_flip()) gets delayed until deep into the extended vblank due to cpu execution delays. This also allows clients which want to regulate framerate within the vrr range a much more fine-grained control of flip timing, a feature that might be useful for video playback, and is very useful for neuroscience/vision research applications.

As we are just days away from the Linux 5.0 finish line, it's possible the DRM maintainers Daniel Vetter and David Airlie will hold off on this change until after the release and then get it back-ported, but as it's a fairly safe change and has already been reviewed by multiple AMD Linux developers, hopefully it will make it to mainline before the 5.0 release on Sunday.
Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via

Popular News This Week