summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Cho <stevecho@google.com>2021-06-03 13:57:45 -0700
committerCommit Bot <commit-bot@chromium.org>2021-06-04 16:02:00 +0000
commit69bce332223577b4a609bb82ec97e84edb710eda (patch)
tree206bc55e78385d071bb569f9cfb88928969e0fc6
parent2b70ba8a678c2d87500a5aa0fd8f83f13d54f2d0 (diff)
downloaddrm-tests-69bce332223577b4a609bb82ec97e84edb710eda.zip
drm-tests-69bce332223577b4a609bb82ec97e84edb710eda.tar.xz
v4l2_stateful_decoder: fix file descriptor issue
This CL fixes an issue where too many file descriptors were left open. This happened because file descriptor was not closed after |gbm_bo_get_fd_for_plane| call. This affected all VP9 webm group 4 60fps tests, which had 600+ frames. BUG=b:189120157 TEST=tast run root@DUT_IP video.PlatformDecoding.v4l2_vp9_0_group4_buf on trogdor Change-Id: If653cd43af6fe315bf418377df777dcb97206646 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/drm-tests/+/2937742 Tested-by: Steve Cho <stevecho@chromium.org> Reviewed-by: Miguel Casas <mcasas@chromium.org> Commit-Queue: Steve Cho <stevecho@chromium.org>
-rw-r--r--v4l2_stateful_decoder.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/v4l2_stateful_decoder.c b/v4l2_stateful_decoder.c
index ebc36b0..ec0f47a 100644
--- a/v4l2_stateful_decoder.c
+++ b/v4l2_stateful_decoder.c
@@ -506,6 +506,7 @@ int queue_buffer_CAPTURE(struct queue* queue, uint32_t index) {
for (uint32_t i = 0; i < queue->num_planes; ++i) {
if (queue->memory == V4L2_MEMORY_DMABUF) {
v4l2_buffer.m.planes[i].m.fd = gbm_bo_get_fd_for_plane(bo, i);
+ assert(v4l2_buffer.m.planes[i].m.fd);
} else if (queue->memory == V4L2_MEMORY_MMAP) {
struct mmap_buffers* buffers = queue->buffers;
@@ -519,6 +520,16 @@ int queue_buffer_CAPTURE(struct queue* queue, uint32_t index) {
if (ret != 0)
LOG_ERROR("VIDIOC_QBUF failed: %s.", strerror(errno));
+ if (queue->memory == V4L2_MEMORY_DMABUF) {
+ for (uint32_t i = 0; i < queue->num_planes; ++i) {
+ ret = close(v4l2_buffer.m.planes[i].m.fd);
+ if (ret != 0) {
+ LOG_ERROR("close failed with v4l2_buffer.m.planes[%d].m.fd: %s.", i,
+ strerror(errno));
+ }
+ }
+ }
+
return ret;
}
@@ -635,6 +646,7 @@ void write_file_to_disk(FILE* fp,
if (V4L2_MEMORY_DMABUF == CAPTURE_queue->memory) {
struct gbm_bo* bo = CAPTURE_queue->buffers[queue_index].bo;
int bo_fd = gbm_bo_get_fd(bo);
+ assert(bo_fd);
size_t buffer_size = lseek(bo_fd, 0, SEEK_END);
lseek(bo_fd, 0, SEEK_SET);
@@ -647,6 +659,8 @@ void write_file_to_disk(FILE* fp,
fwrite(buffer_nv12, buffer_size, 1, fp);
munmap(buffer_nv12, buffer_size);
+
+ close(bo_fd);
} else {
if (CAPTURE_queue->num_planes == 1) {
size_t buffer_size =