linux/drivers/gpu/drm/vc4
Mario Kleiner 56d1fe0979 drm/vc4: Make pageflip completion handling more robust.
Protect both the setup of the pageflip event and the
latching of the new requested displaylist head pointer
by the event lock, so we can't get into a situation
where vc4_atomic_flush latches the new display list via
HVS_WRITE, then immediately gets preempted before queueing
the pageflip event, then the page-flip completes in hw and
the vc4_crtc_handle_page_flip() runs and no-ops due to
lack of a pending pageflip event, then vc4_atomic_flush
continues and only then queues the pageflip event - after
the page flip handling already no-oped. This would cause
flip completion handling only at the next vblank - one
frame too late.

In vc4_crtc_handle_page_flip() check the actual DL head
pointer in SCALER_DISPLACTX against the requested pointer
for page flip to make sure that the flip actually really
completed in the current vblank and doesn't get deferred
to the next one because the DL head pointer was written
a bit too late into SCALER_DISPLISTX, after start of
vblank, and missed the boat. This avoids handling a
pageflip completion too early - one frame too early.

According to Eric, DL head pointer updates which were
written into the HVS DISPLISTX reg get committed to hardware
at the last pixel of active scanout. Our vblank interrupt
handler, as triggered by PV_INT_VFP_START irq, gets to run
earliest at the first pixel of HBLANK at the end of the
last scanline of active scanout, ie. vblank irq handling
runs at least 1 pixel duration after a potential pageflip
completion happened in hardware.

This ordering of events in the hardware, together with the
lock protection and SCALER_DISPLACTX sampling of this patch,
guarantees that pageflip completion handling only runs at
exactly the vblank irq of actual pageflip completion in all
cases.

Background info from Eric about the relative timing of
HVS, PV's and trigger points for interrupts, DL updates:

https://lists.freedesktop.org/archives/dri-devel/2016-May/107510.html

Tested on RPi 2B with hardware timing measurement equipment
and shown to no longer complete flips too early or too late.

Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
2016-06-06 13:00:40 -07:00
..
Kconfig drm/vc4: Add DPI driver 2016-04-14 12:22:53 -07:00
Makefile drm/vc4: Add DPI driver 2016-04-14 12:22:53 -07:00
vc4_bo.c drm: Remove unused drm_device from drm_gem_object_lookup() 2016-05-17 08:47:30 +02:00
vc4_crtc.c drm/vc4: Make pageflip completion handling more robust. 2016-06-06 13:00:40 -07:00
vc4_debugfs.c drm/vc4: Add DPI driver 2016-04-14 12:22:53 -07:00
vc4_dpi.c drm/vc4: Add DPI driver 2016-04-14 12:22:53 -07:00
vc4_drv.c drm/vc4: Fix ioctl permissions for render nodes. 2016-06-06 13:00:30 -07:00
vc4_drv.h drm/vc4: Add DPI driver 2016-04-14 12:22:53 -07:00
vc4_gem.c drm: Remove unused drm_device from drm_gem_object_lookup() 2016-05-17 08:47:30 +02:00
vc4_hdmi.c drm/vc4: Fix NULL deref in HDMI init error path 2016-04-14 12:23:11 -07:00
vc4_hvs.c drm/vc4: Add support for scaling of display planes. 2016-02-16 11:24:08 -08:00
vc4_irq.c drm/vc4: improve throughput by pipelining binning and rendering jobs 2016-03-13 17:05:05 -07:00
vc4_kms.c drm/vc4: Return -EBUSY if there's already a pending flip event. 2016-05-31 15:15:55 -07:00
vc4_packet.h drm/vc4: Add support for drawing 3D frames. 2015-12-07 20:05:10 -08:00
vc4_plane.c drm: Drop plane argument from __drm_atomic_helper_plane_destroy_state 2016-05-17 08:56:55 +02:00
vc4_qpu_defines.h drm/vc4: Add an API for creating GPU shaders in GEM BOs. 2015-12-07 20:05:09 -08:00
vc4_regs.h drm/vc4: Make pageflip completion handling more robust. 2016-06-06 13:00:40 -07:00
vc4_render_cl.c drm/vc4: Return an ERR_PTR from BO creation instead of NULL. 2016-02-16 12:20:58 -08:00
vc4_trace_points.c drm/vc4: Add support for drawing 3D frames. 2015-12-07 20:05:10 -08:00
vc4_trace.h drm/vc4: Add support for drawing 3D frames. 2015-12-07 20:05:10 -08:00
vc4_v3d.c drm/vc4: Recognize a more specific compatible string for V3D. 2016-03-13 18:54:24 -07:00
vc4_validate_shaders.c drm/vc4: Add an API for creating GPU shaders in GEM BOs. 2015-12-07 20:05:09 -08:00
vc4_validate.c drm/vc4: Return an ERR_PTR from BO creation instead of NULL. 2016-02-16 12:20:58 -08:00