crosvm/devices
Daniel Almeida 6f6e8e5193 virtio: video: vaapi: fix the reset implementation
The reset implementation for the VAAPI backend was wrong for a couple of
reasons.

It would create a new session, thereby invalidating the eventfd file
descriptor passed to the WaitContext. This meant that events would not
get signalled from that point on.

Also it would recreate the codec instance, but the right thing to do
here is to flush, which resets the internal state without needlessly
invalidating the allocations already made.

The above is also the same logic done by the ffmpeg decoder, which calls
avcodec_flush_buffers instead of recreating the AVCodecContext.

The previous implementation would also not clear the submit and ready
queues.

Not clearing the submit queue meant we could not return the buffers to
crosvm, which is against the contract for reset(). This is because this
queue keeps a reference to GuestResourceHandle.

Not clearing the ready queue meant that we would return stale buffers
once/if decoding resumed.

Lastly, it would reset the state of the output queue to
AwaitingOutputBuffers, but we can resume decoding with no new buffers
provided, so this is incorrect.

In particular, this change eliminates the following error reported by
the virtio video kernel driver:

virtio-video virtio-video.5: timed out waiting for queue clear

And also the related CrosVM virtio video worker error: returning async
error response: invalid operation

As the ResetCompleted event is correctly signalled now.

BUG=b:214478588
TEST="Decoding in the guest does not cause these two warnings to be
emitted: virtio-video virtio-video.5: timed out waiting for queue clear
and returning async error response: invalid operation right after that"

Change-Id: I0ed2fc59819875fb3cc4462d401811f3126ab686
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3903093
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2022-10-28 07:18:30 +00:00
..
src virtio: video: vaapi: fix the reset implementation 2022-10-28 07:18:30 +00:00
tests/irqchip Extract devices integration tests 2022-10-26 17:53:08 +00:00
Cargo.toml video: decoder: vaapi: port the VAAPI backend to cros-codecs 2022-10-28 03:23:31 +00:00