xserver-multidpi/hw/xfree86
Mario Kleiner c9afd8cb5e modesetting: Fix and improve ms_kernel_msc_to_crtc_msc()
The old 32-Bit wraparound handling didn't actually work, due to some
integer casting bug, and the mapping was ill equipped to deal with input
from the new true 64-bit GetCrtcSequence/QueueCrtcSequence api's
introduced in Linux 4.15.

For 32-Bit truncated input from pageflip events and old vblank events
and old drmWaitVblank ioctl, implement new wraparound handling, which
also allows to deal with wraparound in the other direction, e.g., if a
32-Bit truncated sequence value is passed in, whose true 64-Bit
in-kernel hw value is within 2^30 counts of the previous processed
value, but whose 32-bit truncated sequence value happens to lie just
above or below a 2^32 boundary, iow. one of the two values 'sequence'
vs. 'msc_prev' lies above a 2^32 border, the other one below it.

The method is directly translated from Mesa's proven implementation of
the INTEL_swap_events extension, where a true underlying 64-Bit wide
swapbuffers count (SBC) needs to get reconstructed from a 32-Bit LSB
truncated SBC transported over the X11 protocol wire. Same conditions
apply, ie. successive true 64-Bit SBC values are close to each other,
but don't always get received in strictly monotonically increasing
order. See Mesa commit cc5ddd584d17abd422ae4d8e83805969485740d9 ("glx:
Handle out-of-sequence swap completion events correctly. (v2)") for
explanation.

Additionally add a separate path for true 64-bit msc input originating
from Linux 4.15+ drmCrtcGetSequence/QueueSequence ioctl's and
corresponding 64-bit vblank events. True 64-bit msc's don't need
remapping and must be passed through.

As a reliability bonus, they are also used here to update the tracking
values msc_prev and ms_high with perfect 64-Bit ground truth as baseline
for mapping msc from pageflip completion events, because pageflip events
are always 32-bit wide, even when the new kernel api's are used. Because
each pageflip(-event) is always preceeded close in time (and vblank
count) by a drmCrtcQueueSequence queued event or drmCrtcGetSequence
query as part of DRI2 or DRI3+Present swap scheduling, we can be certain
that each pageflip event will get its truncated 32-bit msc remapped
reliably to the true 64-bit msc of flip completion whenever the sequence
api is available, ie. on Linux 4.15 or later.

Note: In principle at least the 32-bit mapping path could also be
backported to earlier server branches, as this seems to be broken for at
least server 1.16 to 1.19.

Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Cc: Keith Packard <keithp@keithp.com>
Cc: Michel Dänzer <michel.daenzer@amd.com>
2018-05-07 14:01:01 -04:00
..
common xfree86: Restore newline before "X Protocol Version" string 2018-04-03 14:59:25 +10:00
ddc Add a Meson build system alongside autotools. 2017-04-26 15:25:27 -07:00
dixmods miinitext: Load GLX on the mi path 2018-02-14 17:04:48 -05:00
doc docs: remove resource management references 2018-04-02 14:10:58 -04:00
dri hw/xfree86: unvalidated lengths 2017-10-10 23:33:44 +02:00
dri2 dri2: Sync i965_pci_ids.h from mesa 2018-05-07 12:18:28 -04:00
drivers modesetting: Fix and improve ms_kernel_msc_to_crtc_msc() 2018-05-07 14:01:01 -04:00
exa meson: Install man pages 2018-03-27 10:28:33 -04:00
fbdevhw meson: Install man pages 2018-03-27 10:28:33 -04:00
glamor_egl glamor: Make Xv extension initialize at depth 30. 2018-02-27 10:18:06 -05:00
i2c Add a Meson build system alongside autotools. 2017-04-26 15:25:27 -07:00
int10 meson: Silence -Wformat-nonliteral for x86emu 2017-10-20 13:15:35 -04:00
loader Use ARRAY_SIZE all over the tree 2017-10-30 13:45:20 -04:00
man glamor: Hide new DRI behind Option "Debug" "dmabuf_capable" 2018-03-28 16:34:28 -04:00
modes Add RandR leases with modesetting driver support [v6] 2018-02-27 12:39:50 -05:00
os-support xfree86: drop KDSKBMUTE handling 2018-04-06 13:21:00 -04:00
parser os, xfree86: Stop being so weird about <limits.h> 2017-05-12 09:49:07 -04:00
ramdac ramdac: Check ScreenPriv != NULL in xf86ScreenSetCursor() 2017-10-25 09:52:44 -04:00
shadowfb meson: Fix linkage of loadable modules for PE/COFF 2017-10-12 15:22:04 -04:00
utils gtf: Warning fix 2018-04-05 14:18:16 -04:00
vbe meson: Build libvbe.so 2017-04-27 15:19:45 -04:00
vgahw meson: Build libvgahw.so 2017-04-27 15:19:41 -04:00
x86emu x86emu: Teach the debug code about varargs 2018-01-16 16:08:38 -05:00
xkb Move statically linked xorgxkb files from dixmods to a separate directory 2017-06-27 12:42:06 -04:00
.gitignore Xorg: Add Xorg.wrap to hw/xfree86/.gitignore 2014-04-18 11:39:16 +02:00
Makefile.am glx: Use vnd layer for dispatch (v4) 2018-02-14 17:04:44 -05:00
meson.build meson: Build cvt and gtf 2018-03-27 10:28:33 -04:00
sdksyms.sh sdksyms: Cope with __pid_t and __uint32_t 2018-04-23 14:56:17 -04:00
xorg-wrapper.c suid: Include sysmacros.h to fix build after glibc-2.25 2017-09-25 13:04:25 -04:00
Xorg.sh.in xfree86: rename Xorg.bin to Xorg 2015-01-05 09:53:58 +10:00
xorgconf.cpp xfree86: fix wrong DontZap documentation (#71113) 2014-05-24 20:02:56 +10:00