We give up on TearFree if we ever see an error whilst page flipping (in
the hope that we can keep displaying via direct use of the scanout).
With the advent of MST, this can happen simply by the user unplugging a
dock causing connectors to disappear and if we flip before we see the
uevent telling us which outputs are disabled, we get an error.
So, lets try and re-enable TearFree on the next opportunity, when all
the outputs are off and we can rebuild the shadow buffer.
Reported-by: Martin Jørgensen <mkj@gotu.dk>
References: https://bugs.freedesktop.org/show_bug.cgi?id=96180
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
If the pixmap on a drawable changes between swap events, just queue a
normal vblank event rather than chaining up.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
In 46caee86db ("sna: Fix reporting of errno after setcrtc failure"),
the intention was to avoid reporting a fail to migrate whilst wedged for
a simple copy from the frontbuffer to TearFree's shadow buffer. However,
by skipping the migration, we never flushed any dirt from the CPU buffer
prior to doing the TearFree flip.
References: https://bugs.freedesktop.org/show_bug.cgi?id=95401#c7
References: https://bugs.freedesktop.org/show_bug.cgi?id=95414#c4
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
We avoid having to redraw the entire CRTC's buffer on every flip as we
know the contents from the previous flip are still available and only
need to invalidate the dirty region.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
We track how many mode sets have been made in order to detect stale
flips (i.e. a sequence that crosses a mode change). This was broken by
the logic inversion in setcrc in 46caee86db ("sna: Fix reporting of
errno after setcrtc failure")
References: https://bugs.freedesktop.org/show_bug.cgi?id=95401
Signed-off-by: Chris Bainbridge <chris.bainbridge@gmail.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Double check that we are not about to cache the common, untransformed,
shadow buffer for the per-CRTC transformed buffer.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
When doing a SETCRTC as a fallack for a failed pageflip, do not use the
then current CRTC bo as the next bo for pageflipping - as then we will
render into it prior to flipping and so cause tearing.
References: https://bugs.freedesktop.org/show_bug.cgi?id=95401
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Whilst waiting for the previous blit to complete, if we fail to queue
the vblank to wake up on the next frame, block before replying the blit
is complete.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
If the client sends an out-of-date swap request, first make sure that we
don't cause an error by chasing a NULL CRTC and secondly force them to
wait for a whole vblank before the next swap.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Enable copying onto a scanout buffer using a WC mmap - so long as it is
X-tiled and no swizzling.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
If acceleration is disabled, but we are using TearFree, then ideally we
want to flip the shadow buffer onto the scanout. If the shadow buffer is
already on the GPU, e.g. having been swapped in by a compositor, then we
do not want to move it to the CPU domain only to copy it back to a new
buffer and then flipped for a TearFree update.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
The pending back buffer is only the pending copy, the actual info->back
stores the client's view of the current back buffer which may be more
recent than the pending copy. So store the current back buffer, swap in
the pending to do the normal swap, then free the resultant back (which
may have been exchanged with the front), before restoring the client's
current back buffer.
References: https://bugs.freedesktop.org/show_bug.cgi?id=95200
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Since the naive implementation uses an 8bit temporary, we can only
support so many passes before the quantization artefacts become
apparent. We have to be extra conservation in order to support
multi-pass convolution algorithms (notable 2-pass separable Gaussian
kernels).
References: https://bugs.freedesktop.org/show_bug.cgi?id=95091
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Mesa wants to pass Y-tiled framebuffers onto scanout. Admittedly, this
isn't quite that but it does prevent them being jumbled up.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
As we now do more syscalls after the setcrtc, we cannot rely on errno
storing the pertinent error code. Instead we have to save it immediately
after the drmIoctl() and propagate that back.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
As the first choice of orientation and tiling may be invalid, e.g.
left/right rotation on Skylake, we need to force the second pass here to
try and an alternate non-native rotation.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Avoid postponing until the next vblank to avoid continually recursing
every TearFree update, and to minimise the presentation delay.
References: https://bugs.freedesktop.org/show_bug.cgi?id=94982
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Temporarily stopping the pointer whilst we try to queue the flip should
help keep the output latency down.
Reported-by: Rafael Ristovski <rafael.ristovski@gmail.com>
References: https://bugs.freedesktop.org/show_bug.cgi?id=94980
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
In order to actually stall the pipeline completely and to wait for
earlier flushes to complete, we have to set a flag in the pipecontrol.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Increment the target_msc by one, not the last known msc!
Reported-by: Rafael Ristovski <rafael.ristovski@gmail.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
When doing the misaligned copy from the start of the dst pointer, the
important check is whether there is enough bytes remaining to the next
alignment position, next from the last.
References: https://bugs.freedesktop.org/show_bug.cgi?id=94928
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
So that when we size from transformed cursors to non-transformed, we
remember to clear the entire area.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
When draining the flipqueue for TearFree, we may recurse from the vblank
handlers. Avoid this by delaying the Present vblank until next frame.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Kick the error back to the upper layer for it to sort out.
Reported-by: Timo Aaltonen <tjaalton@ubuntu.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
If we have to fake a vblank because the CRTC is off and we compute the
delay as being 0, then we would report the event immediately - but with
the earlier msc. Instead, we want to report the completion.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Each GT on Skylake is bigger than previous generations. For reusing the
placement logic, we then want to pretend that Skylake has a higher
GT-equivalence.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
We should be consistent in making the code simpler for the compiler and
so not rely on it eliminating the dead-code for a single loop of
sse64xN!
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Don't bake in the assumption that the CRTCs will always be allocated in
the low byte of the identifiers range. It is only used in a pair of
other functions (Xv plane updates), so not a big deal.
Reported-by: Mark Kettenis <kettenis@openbsd.org>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Timers can only be set for a maximum of int32_t milliseconds into the
future. Respect that - if we need more, we'll just requeue!
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
We store a flag on the vblank's CRTC to indicate whether we have marked
the target CRTC as having an immediately pending vblank. We should clear
this set of flags early so that we don't have to worry about the flag
whilst processing the vblank, and so that we don't get confused if we
have to requeue the vblank.
Reported-by: Christoph Haag <haagch@frickel.club>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94829#c32
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>