Commit 81f28601 authored by Alexandre Courbot's avatar Alexandre Courbot Committed by Commit Bot

media/gpu/v4l2svda: poll() requests before reusing them

The only way to be sure that a request has completed and can be reused
is to poll() it. Add this missing step in the V4L2RequestDecodeSurface
constructor.

Bug: 917279
Test: VDA unittest passes on Kukui with required IP CL.
Change-Id: I0927e7025ca7fb2d8e28c47f6847de48010c5162
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1731012
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: default avatarHirokazu Honda <hiroh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#683544}
parent 987282a4
......@@ -6,6 +6,7 @@
#include <linux/media.h>
#include <linux/videodev2.h>
#include <poll.h>
#include <sys/ioctl.h>
#include "base/logging.h"
......@@ -128,8 +129,19 @@ V4L2RequestDecodeSurface::Create(V4L2WritableBufferRef input_buffer,
V4L2WritableBufferRef output_buffer,
scoped_refptr<VideoFrame> frame,
int request_fd) {
// First reinit the request to make sure we can use it for a new submission.
int ret = HANDLE_EINTR(ioctl(request_fd, MEDIA_REQUEST_IOC_REINIT));
constexpr int kPollTimeoutMs = 500;
int ret;
struct pollfd poll_fd = {request_fd, POLLPRI, 0};
// First poll the request to ensure its previous task is done
ret = poll(&poll_fd, 1, kPollTimeoutMs);
if (ret != 1) {
VPLOGF(1) << "Failed to poll request: ";
return base::nullopt;
}
// Then reinit the request to make sure we can use it for a new submission.
ret = HANDLE_EINTR(ioctl(request_fd, MEDIA_REQUEST_IOC_REINIT));
if (ret < 0) {
VPLOGF(1) << "Failed to reinit request: ";
return base::nullopt;
......
......@@ -1936,8 +1936,12 @@ V4L2SliceVideoDecodeAccelerator::CreateSurface() {
nullptr, request.get());
requests_.push(std::move(request));
if (!ret)
// Not being able to create the decode surface at this stage is a
// fatal error.
if (!ret) {
NOTIFY_ERROR(PLATFORM_FAILURE);
return nullptr;
}
dec_surface = std::move(ret).value();
} else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment