Age | Commit message (Collapse) | Author |
|
TimerSet scales linearly with the number of elements in the queue as it
performs an insertion sort, duplicating the sorting we also perform to
keep the per-crtc vblank queue in an orderly fashion. As we already
maintain the ordered timeline of vblanks, we can simply queue the next
when the current vblank completes.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
|
|
TearFree wants to grab the most recently used scanout for rendering the
next frame into. If the flip event was still pending, we would then
query the drm event buffer for any pending completions, but this would
proceed to execute all the other events before the flip events as well.
Since we they were out of sequence, we pushed them into a buffer to
execute afterwards, however we forgot the side effects of the flip
handlers, for example see commit af36a4ab78cc ("sna: Defer submission
of the next shadow frame until halfway through") and that there may have
been events read from drm into a local buffer inside sna_mode_wakeup()
that haven't been processed yet.
Eliminate the need for calling sna_mode_wakeup() by ensuring that all
flip events have been completed first before handing the vblank
callbacks and potential drawing, ensuring the correct ordering.
References: https://bugs.freedesktop.org/show_bug.cgi?id=105720
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
|
|
Insert the keepalive vblank into the sorted list of msc carefully. This
way we can discard redundant keepalives - as we don't want to queue a
second event for the same vblank needlessly.
Reported-by: Adric Blake <promarbler14@gmail.com>
References: https://bugs.freedesktop.org/show_bug.cgi?id=103025#c13
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
|
|
There are more reasons than just TearFree as to why the shadow may be
disabled (such as no outputs), so without taking those into account the
assert is bogus.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
|
|
Present only unflips after a resize, after it has lost control of the
Screen. It's unflip request is stale and triggers an assert about the
graphical glitch - just reorder the assert to ignore the snafu.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
|
|
If we don't see the flip event completion in time for the next Present
flip, just report failure - rather than block indefinitely.
References: https://bugs.freedesktop.org/show_bug.cgi?id=100162
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
|
|
If we are not careful, we may process an unflip in the middle of
resizing the frontbuffer - when the ScreenPixmap state is ill-defined.
First flush all the pending flip events, cancel any residual unflips,
then update the screen pixmap. This should be enough to close the race.
References: https://bugs.freedesktop.org/show_bug.cgi?id=98855#c11
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
|
|
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>
|
|
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 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>
|
|
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>
|
|
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>
|
|
For delays over a frame, we aim to fire a frame early and so
compensating again for less than a whole frame is irrelevant.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
|
|
Rather than queuing vblanks for future events up to 4000 years and
setting the hardware to stay awake for all that period (reporting a tick
every refresh), use the timer for the first part. (The timer should
allow a precise-(ish) single wakeup of the hardware.) We set the timer a
frame ahead, so that we can then queue an actual hw event for the final
vblank for precision.
References: https://bugs.freedesktop.org/show_bug.cgi?id=94829
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
|
|
If the screen is already scanning out from the desired framebuffer
(because we failed when flipping and already restored the mode), skip
the unflip.
References: https://bugs.freedesktop.org/show_bug.cgi?id=94829
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
|
|
If we wake up early from the timer, we can use the hw to give us a more
precise wakeup for the vblank (rather than estimating to the approximate
millisecond).
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
|
|
Since commit 02f535e8f3659f1147c6f2e698bd5d8730dec19b
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date: Thu Mar 24 09:39:06 2016 +0000
sna/present: Requeue early vblank completions
we may hit the fake vblank timer path with an old hw struct that may have
multiple associated events. The assert that we only called the fake
vblank from sna_present_queue_vblank is no longer correct.
Reported-by: Christoph Haag <haagch@frickel.club>
References: https://bugs.freedesktop.org/show_bug.cgi?id=94829#c15
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
|
|
After doing a blocking wait (rather than event driven) for the imminent
arrival of the next frame (when it is expected less than 1ms in the
future), update the timestamp and frame counter that we then report back
to present.
Reported-by: Christoph Haag <haagch@frickel.club>
References: https://bugs.freedesktop.org/show_bug.cgi?id=94829#c15
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
|
|
Don't forget that along the vblank path, we may use a timer instead of
the hw event in which case, we don't actually count the info as queued
(to hardware)
Reported-by: Christoph Haag <haagch@frickel.club>
References: https://bugs.freedesktop.org/show_bug.cgi?id=94829#c13
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
|
|
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
|
|
If we cancel a flip, we may try to restore the current mode and this may
flush the partial flip (in a multi-monitor setup). We report the completed
event back to present and free the event info. Then we report the error
back to present, and free the event info a second time. Chaos and
corruption ensues.
Reported-and-tested-by: Christoph Haag <haagch@frickel.club>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94829
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
|
|
The kernel checks for past vblanks using an int32_t comparison, so we
can only program up to 31bits into the future (and similarly programing
a timer that large would also overflow).
References: https://bugs.freedesktop.org/show_bug.cgi?id=94685
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
|
|
If the vblank completes too early (e.g. due to a modeset), try
requeueing it so that it fires at the expected time (and so after the
modeset).
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
|
|
Otherwise we try to flip back before we complete the mode change.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
|
|
As we cannot queue a vblank further than 1<<32 into the future, nor can
we set a Timer to expire that far into the future, creating such a
vblank event is futile. Report BadValue and hope for the best.
References: https://bugs.freedesktop.org/show_bug.cgi?id=94515
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
|
|
Framebuffers are restricted to pitches with a multiple of 64. Check
before we flip.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
|
|
When a Window is resized, a new Pixmap is attached to the Window and the
DRI2 buffers invalidated. However, the client may have requested a swap
before it is notified of the resize and so we have to discard the stale
swap. In doing so, we do not want to start a swap chain as it references
the wrong frontbuffer and causes dire confusion when we start swapping
for real.
Reported-by: Jiri Slaby <jirislaby@gmail.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=70461#c131
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
|
|
If we need to report the vblank after the pipe is off, just use the
current system time rather than the last swap time from the pipe.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
|
|
References: https://bugs.freedesktop.org/show_bug.cgi?id=94515
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
|
|
When juggling Present and TearFree, we have to hide the extra flips from
Present as it cannot account for them. Preferrably we want to schedule
the Present flip following completion of the TearFree flip, but for the
moment simply block and wait until TearFree completes before starting
Present.
Reported-by: Andreas Reis <andreas.reis@gmail.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=91467
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
|
|
References: https://bugs.freedesktop.org/show_bug.cgi?id=91467#c12
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
|
|
We know Present is sending garbage msc into the wait_vblank, so just
warn about the error so that we do not prevent usage of --enable-debug
due to somebody else's bug.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
|
|
Querying the known swap values is much slower than not!
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
|
|
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
|
|
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
|
|
In cases of stress, we use a timer to create a fake vblank event and
then we adjust the timer when it fires to match it up with the CRTC msc.
However, sometimes we fire before the vblank but less than a millisecond
and so below the precision of the timer causing us to send notifies too
early. Use a blocking vblank wait to fixup these rare cases.
Testcase: present/notify/accuracy
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
|
|
We were not updating the window->crtc for the immediate swaps with the
result that after switching CRTCs, we were requesting a vblank on the
wrong pipe and triggering an error path (forcing the blit and negating
the elision).
Testcase: test/dri2-speed
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
|
|
present.flush is called on the Window after a copy from a Pixmap is
completed - which will be naturally flushed anyway. What the API should
be passing is the Pixmap, since we do want to flush the operations from
it before sending the idle event. C'est la vie.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
|
|
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
|
|
event_id is now an array - but the misprint was hidden on 64bit systems,
the warning only apparent because of the pointer mismatch on 32bit
systems.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
|
|
Remember vblanks are private to a CRTC, the same MSC on another CRTC may
fire at completely different times...
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
|
|
Try to avoid more clflushing on the current Pixmap if we have a
scanout-ready bo in the cache. We also note that since we unflip before
any other drawing takes place, we do not need to mark the flipped Pixmap
as being pinned to the scanout.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
|
|
If we have multiple events for the same vblank, append the notification
to an existing vblank. This is particularly useful as we it ensures that
we then report notifications in the same order as queued.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
|
|
Modifying the flag may cause havoc if we need to modeset whilst Present
is in control as the CRTC will be setup without reference to TearFree, but
then when Present unflips, we restore the stale configuration. So let's
have a separate flag just to disable TearFree flips when a Present flip
chain is active.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
|
|
Following on from the previous attempt is the realisation that we can
simply disable TearFree during a Present flip queue, and re-enable
TearFree upon unflip.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
|
|
These two don't mix, so remove the claim that we do support async flips
when TearFree is enabled.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
|