From 0e6029757be8c698f81bac34554a83ea3d94a382 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Thu, 24 Sep 2020 14:36:59 -0700 Subject: [PATCH] vtest: tidy up vtest_resource_busy_wait a bit Signed-off-by: Chia-I Wu Reviewed-by: Ryan Neph Reviewed-by: Gert Wollny --- vtest/vtest_renderer.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/vtest/vtest_renderer.c b/vtest/vtest_renderer.c index 9d9f517..2e2d082 100644 --- a/vtest/vtest_renderer.c +++ b/vtest/vtest_renderer.c @@ -1399,24 +1399,18 @@ int vtest_resource_busy_wait(UNUSED uint32_t length_dw) /* handle = bw_buf[VCMD_BUSY_WAIT_HANDLE]; unused as of now */ flags = bw_buf[VCMD_BUSY_WAIT_FLAGS]; - if (flags == VCMD_BUSY_WAIT_FLAG_WAIT) { - do { - if (renderer.last_fence == (renderer.fence_id - 1)) { - break; - } - - fd = virgl_renderer_get_poll_fd(); - if (fd != -1) { - vtest_wait_for_fd_read(fd); - } - - virgl_renderer_poll(); - } while (1); - - busy = false; - } else { + do { busy = renderer.last_fence != (renderer.fence_id - 1); - } + if (!busy || !(flags & VCMD_BUSY_WAIT_FLAG_WAIT)) + break; + + /* TODO this is bad when there are multiple clients */ + fd = virgl_renderer_get_poll_fd(); + if (fd != -1) { + vtest_wait_for_fd_read(fd); + } + virgl_renderer_poll(); + } while (true); hdr_buf[VTEST_CMD_LEN] = 1; hdr_buf[VTEST_CMD_ID] = VCMD_RESOURCE_BUSY_WAIT;