Page flip event timestamps missing for cursor plane updates
Brief summary of the problem:
When the cursor plane (DRM_PLANE_TYPE_CURSOR
) is the only plane present in an atomic commit (drmModeAtomicCommit
) and a page flip event is requested for that commit (using the PAGE_FLIP_EVENT
flag), the resulting page flip event contains no timing information.
This issue results in jitter and missed frames in display servers and other KMS applications that time their page flip commits according to the timing information received through page flip events.
Atomic commit that contains only a cursor plane update: (i.e., "Bad")
KMS: [atomic] Processing update 130
KMS: [atomic] Assigning cursor plane (52, /dev/dri/card0) to 103, 128x128+0+0 -> 128x128+2294+1292
KMS: [atomic] Setting plane 52 (/dev/dri/card0) property 'FB_ID' (17) to 103
KMS: [atomic] Setting plane 52 (/dev/dri/card0) property 'CRTC_ID' (20) to 53
KMS: [atomic] Setting plane 52 (/dev/dri/card0) property 'SRC_X' (9) to 0.00
KMS: [atomic] Setting plane 52 (/dev/dri/card0) property 'SRC_Y' (10) to 0.00
KMS: [atomic] Setting plane 52 (/dev/dri/card0) property 'SRC_W' (11) to 128.00
KMS: [atomic] Setting plane 52 (/dev/dri/card0) property 'SRC_H' (12) to 128.00
KMS: [atomic] Setting plane 52 (/dev/dri/card0) property 'CRTC_X' (13) to 2294
KMS: [atomic] Setting plane 52 (/dev/dri/card0) property 'CRTC_Y' (14) to 1292
KMS: [atomic] Setting plane 52 (/dev/dri/card0) property 'CRTC_W' (15) to 128
KMS: [atomic] Setting plane 52 (/dev/dri/card0) property 'CRTC_H' (16) to 128
KMS: [atomic] Committing update 130, flags: ATOMIC_NONBLOCK|PAGE_FLIP_EVENT
KMS: [atomic] Adding page flip data for (53, /dev/dri/card0): 0x55865b2945a0
KMS: [atomic] Page flip callback for CRTC (53, /dev/dri/card0), data: 0x55865b2945a0
KMS: Setting page flip timings, sequence: 0, sec: 0, usec: 0
You can see the timing information is missing: (all values are 0)
KMS: Setting page flip timings, sequence: 0, sec: 0, usec: 0
Atomic commit that contains a primary plane update: (i.e., "Good")
KMS: [atomic] Processing update 120
KMS: [atomic] Assigning primary plane (50, /dev/dri/card0) to 92, 2560x1440+0+0 -> 2560x1440+0+0
KMS: [atomic] Setting plane 50 (/dev/dri/card0) property 'FB_ID' (17) to 92
KMS: [atomic] Setting plane 50 (/dev/dri/card0) property 'CRTC_ID' (20) to 53
KMS: [atomic] Setting plane 50 (/dev/dri/card0) property 'SRC_X' (9) to 0.00
KMS: [atomic] Setting plane 50 (/dev/dri/card0) property 'SRC_Y' (10) to 0.00
KMS: [atomic] Setting plane 50 (/dev/dri/card0) property 'SRC_W' (11) to 2560.00
KMS: [atomic] Setting plane 50 (/dev/dri/card0) property 'SRC_H' (12) to 1440.00
KMS: [atomic] Setting plane 50 (/dev/dri/card0) property 'CRTC_X' (13) to 0
KMS: [atomic] Setting plane 50 (/dev/dri/card0) property 'CRTC_Y' (14) to 0
KMS: [atomic] Setting plane 50 (/dev/dri/card0) property 'CRTC_W' (15) to 2560
KMS: [atomic] Setting plane 50 (/dev/dri/card0) property 'CRTC_H' (16) to 1440
KMS: [atomic] Setting plane (50, /dev/dri/card0) rotation to 1
KMS: [atomic] Setting plane 50 (/dev/dri/card0) property 'rotation' (51) to 1
KMS: [atomic] Committing update 120, flags: ATOMIC_NONBLOCK|PAGE_FLIP_EVENT
KMS: [atomic] Adding page flip data for (53, /dev/dri/card0): 0x55865dbd6a60
KMS: [atomic] Page flip callback for CRTC (53, /dev/dri/card0), data: 0x55865dbd6a60
KMS: Setting page flip timings, sequence: 11737044, sec: 199038, usec: 187440
You can see the timing information is present:
KMS: Setting page flip timings, sequence: 11737044, sec: 199038, usec: 187440
Hardware description:
- CPU: Intel(R) Core(TM) i5-4670 CPU @ 3.40GHz
- GPU: Advanced Micro Devices, Inc. [AMD/ATI] Ellesmere [Radeon RX 470/480/570/570X/580/580X/590] [1002:67df] (rev e7)
- System Memory: 12GB
- Display(s): Asus VG27AQ
- Type of Display Connection: DP
System information:
- Distro name and Version: Fedora 36
- Kernel version: Linux 5.17.6-301.fsync.fc36.x86_64 #1 SMP PREEMPT Thu May 12 22:30:04 UTC 2022
- Custom kernel: Kernel from the Nobara project (COPR link, package commit)
- AMD official driver version: N/A
How to reproduce the issue:
I found this issue when using Mutter (gnome-shell's compositor), but it most likely occurs for any KMS app that only updates the cursor plane.
For Mutter/gnome-shell:
- Add a print in code to show the timing information received in page flip events. (You can use this commit)
- Run Mutter or gnome-shell in their Wayland sessions:
- For gnome-shell, run it using the following command in a new VT:
$ dbus-run-session env MUTTER_DEBUG=kms gnome-shell --wayland
- For Mutter, run it with the following command in a new VT:
$ MUTTER_DEBUG=kms mutter --wayland
- For gnome-shell, run it using the following command in a new VT:
- Move the cursor around on a desktop without any windows open, or where windows' update rate is less than the display refresh rate (most non-game applications).
- Check
journalctl
or the terminal for the debug output shown above.