summaryrefslogtreecommitdiff
path: root/src/sna/sna_present.c
AgeCommit message (Collapse)Author
2018-04-15sna/present: Only add the first element to the Timer queueChris Wilson
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>
2018-04-03sna: Reorder vblank/flip event handling to avoid TearFree recursionChris Wilson
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>
2017-10-08sna/present: Queue the keepalive vblankChris Wilson
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>
2017-06-07sna/present: Drop TearFree assert at the end of unflipChris Wilson
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>
2017-06-07sna/present: Move too-late unflip check earlierChris Wilson
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>
2017-03-12sna: Don't stall indefinitely for a missing flip eventChris Wilson
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>
2016-12-05sna: Reorder frontbuffer resize vs flip event queue drainingChris Wilson
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>
2016-09-20sna/present: Prime the msc cache on first queryChris Wilson
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-04-18sna/present: Postpone recursed vblank during TearFree by 1msChris Wilson
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>
2016-04-17sna/present: Fix requeuing after interrupting TearFreeChris Wilson
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>
2016-04-10sna/present: Prevent recursion when handling TearFree waitsChris Wilson
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>
2016-04-08sna/present: Refuse to queue a vblank on a disabled CRTCChris Wilson
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>
2016-04-08sna/present: Handle 64bit wraparound in msc comparisonsChris Wilson
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-04-08sna/present: Fixup msc when reporting a fake vblank with 0 delayChris Wilson
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>
2016-04-07sna/present: Clamp to maximum timer delayChris Wilson
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>
2016-04-06sna/present: Clear flags on the vblank event's CRTC earlyChris Wilson
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>
2016-04-06sna/present: Only compensate the timer delay on the final frameChris Wilson
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>
2016-04-06sna/present: Only use the HW vblank for the last frameChris Wilson
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>
2016-04-06sna/present: Skip the unflip if a no-opChris Wilson
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>
2016-04-05sna/present: Arm the fake vblank timer to wake up one frame earlyChris Wilson
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>
2016-04-05sna/present: Remove stale assert that fake vblanks only have one eventChris Wilson
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>
2016-04-05sna/present: Update the vblank timestamp after a blocking waitChris Wilson
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>
2016-04-05sna/present: And drop bogus queued assertionChris Wilson
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>
2016-04-05sna/present: Markup hw vbanks queued after a fake vblankChris Wilson
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-04-05sna/present: Prevent reporting an incomplete eventChris Wilson
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>
2016-03-24sna/present: Restrict vblank.sequence range to 31bitsChris Wilson
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>
2016-03-24sna/present: Requeue early vblank completionsChris Wilson
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>
2016-03-24sna/present: Cancel pending unflips when resizing the screenChris Wilson
Otherwise we try to flip back before we complete the mode change. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-03-22sna/present: Report BadValue if target_msc exceeds last known msc by 1<<32Chris Wilson
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>
2016-03-16sna/present: Check incoming pitch before flippingChris Wilson
Framebuffers are restricted to pitches with a multiple of 64. Check before we flip. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-03-15sna/dri2: Prevent starting a swap chain for a decoupled PixmapChris Wilson
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>
2016-03-15sna/present: Use the current system time when providing a vblank off notifyChris Wilson
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>
2016-03-13sna/present: Add a modicum more debug infoChris Wilson
References: https://bugs.freedesktop.org/show_bug.cgi?id=94515 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2015-07-26sna: Stall for outstanding TearFree flips when taking over with PresentChris Wilson
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>
2015-07-26sna: Add a few more DBG and assertions around Present/TearFree interactionsChris Wilson
References: https://bugs.freedesktop.org/show_bug.cgi?id=91467#c12 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2015-06-11sna/present: Downgrade a known assert failure to a warningChris Wilson
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>
2015-04-18sna/present: Reuse last cached swap msc/ust during a flip chainChris Wilson
Querying the known swap values is much slower than not! Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2015-04-17sna/present: Check earlier for an incompatilble tiled PixmapChris Wilson
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2015-04-06sna/present: Free Timer when converting to vblank eventChris Wilson
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2015-04-05sna/present: Use a vblank wait to fix up a timer firing too earlyChris Wilson
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>
2015-04-02sna/dri2: Fix multimonitor swap elisionChris Wilson
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>
2015-04-01sna/present: flush is not requiredChris Wilson
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>
2015-03-24sna: Detect Y-tiled scanout featureChris Wilson
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2015-02-18sna/present: Fixup a few DBGChris Wilson
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>
2015-02-16sna/present: Only share vblanks on the same CRTCChris Wilson
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>
2015-02-16sna/present: Try exchanging the Pixmap with a scanout-ready boChris Wilson
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>
2015-02-16sna/present: Append duplicates onto queued vblanksChris Wilson
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>
2015-02-15sna/present: Avoid tricks with the TearFree flagChris Wilson
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>
2015-02-14sna/present: Integrate into TearFree, take 2Chris Wilson
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>
2015-02-14sna/present: Disable hardware async flips with TearFreeChris Wilson
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>