From b4da53b0c342eaa0dee522e3a3859a93cb77aa84 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 19 Mar 2019 11:13:40 -0700 Subject: [PATCH] virgl: export resource_is_busy from winsys Signed-off-by: Chia-I Wu Reviewed-by: Gurchetan Singh --- src/gallium/drivers/virgl/virgl_winsys.h | 2 ++ src/gallium/winsys/virgl/drm/virgl_drm_winsys.c | 13 +++++++------ src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c | 12 +++++++----- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/gallium/drivers/virgl/virgl_winsys.h b/src/gallium/drivers/virgl/virgl_winsys.h index 9256bf97b03..bab3dbaa2d1 100644 --- a/src/gallium/drivers/virgl/virgl_winsys.h +++ b/src/gallium/drivers/virgl/virgl_winsys.h @@ -74,6 +74,8 @@ struct virgl_winsys { void *(*resource_map)(struct virgl_winsys *vws, struct virgl_hw_res *res); void (*resource_wait)(struct virgl_winsys *vws, struct virgl_hw_res *res); + boolean (*resource_is_busy)(struct virgl_winsys *vws, + struct virgl_hw_res *res); struct virgl_hw_res *(*resource_create_from_handle)(struct virgl_winsys *vws, struct winsys_handle *whandle); diff --git a/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c b/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c index c35d58b0552..48ee73f1e2f 100644 --- a/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c +++ b/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c @@ -76,9 +76,10 @@ static void virgl_hw_res_destroy(struct virgl_drm_winsys *qdws, FREE(res); } -static boolean virgl_drm_resource_is_busy(struct virgl_drm_winsys *qdws, +static boolean virgl_drm_resource_is_busy(struct virgl_winsys *vws, struct virgl_hw_res *res) { + struct virgl_drm_winsys *vdws = virgl_drm_winsys(vws); struct drm_virtgpu_3d_wait waitcmd; int ret; @@ -86,7 +87,7 @@ static boolean virgl_drm_resource_is_busy(struct virgl_drm_winsys *qdws, waitcmd.handle = res->bo_handle; waitcmd.flags = VIRTGPU_WAIT_NOWAIT; - ret = drmIoctl(qdws->fd, DRM_IOCTL_VIRTGPU_WAIT, &waitcmd); + ret = drmIoctl(vdws->fd, DRM_IOCTL_VIRTGPU_WAIT, &waitcmd); if (ret && errno == EBUSY) return TRUE; return FALSE; @@ -239,7 +240,7 @@ static inline int virgl_is_res_compat(struct virgl_drm_winsys *qdws, if (res->size > size * 2) return 0; - if (virgl_drm_resource_is_busy(qdws, res)) { + if (virgl_drm_resource_is_busy(&qdws->base, res)) { return -1; } @@ -862,7 +863,6 @@ static bool virgl_fence_wait(struct virgl_winsys *vws, struct pipe_fence_handle *_fence, uint64_t timeout) { - struct virgl_drm_winsys *vdws = virgl_drm_winsys(vws); struct virgl_drm_fence *fence = virgl_drm_fence(_fence); if (vws->supports_fences) { @@ -883,12 +883,12 @@ static bool virgl_fence_wait(struct virgl_winsys *vws, } if (timeout == 0) - return !virgl_drm_resource_is_busy(vdws, fence->hw_res); + return !virgl_drm_resource_is_busy(vws, fence->hw_res); if (timeout != PIPE_TIMEOUT_INFINITE) { int64_t start_time = os_time_get(); timeout /= 1000; - while (virgl_drm_resource_is_busy(vdws, fence->hw_res)) { + while (virgl_drm_resource_is_busy(vws, fence->hw_res)) { if (os_time_get() - start_time >= timeout) return FALSE; os_time_sleep(10); @@ -1008,6 +1008,7 @@ virgl_drm_winsys_create(int drmFD) qdws->base.resource_get_handle = virgl_drm_winsys_resource_get_handle; qdws->base.resource_map = virgl_drm_resource_map; qdws->base.resource_wait = virgl_drm_resource_wait; + qdws->base.resource_is_busy = virgl_drm_resource_is_busy; qdws->base.cmd_buf_create = virgl_drm_cmd_buf_create; qdws->base.cmd_buf_destroy = virgl_drm_cmd_buf_destroy; qdws->base.submit_cmd = virgl_drm_winsys_submit_cmd; diff --git a/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c b/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c index 7d676141070..24b57447467 100644 --- a/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c +++ b/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c @@ -179,9 +179,11 @@ static void virgl_hw_res_destroy(struct virgl_vtest_winsys *vtws, FREE(res); } -static boolean virgl_vtest_resource_is_busy(struct virgl_vtest_winsys *vtws, +static boolean virgl_vtest_resource_is_busy(struct virgl_winsys *vws, struct virgl_hw_res *res) { + struct virgl_vtest_winsys *vtws = virgl_vtest_winsys(vws); + /* implement busy check */ int ret; ret = virgl_vtest_busy_wait(vtws, res->res_handle, 0); @@ -391,7 +393,7 @@ static inline int virgl_is_res_compat(struct virgl_vtest_winsys *vtws, if (res->size > size * 2) return 0; - if (virgl_vtest_resource_is_busy(vtws, res)) { + if (virgl_vtest_resource_is_busy(&vtws->base, res)) { return -1; } @@ -660,16 +662,15 @@ static bool virgl_fence_wait(struct virgl_winsys *vws, struct pipe_fence_handle *fence, uint64_t timeout) { - struct virgl_vtest_winsys *vdws = virgl_vtest_winsys(vws); struct virgl_hw_res *res = virgl_hw_res(fence); if (timeout == 0) - return !virgl_vtest_resource_is_busy(vdws, res); + return !virgl_vtest_resource_is_busy(vws, res); if (timeout != PIPE_TIMEOUT_INFINITE) { int64_t start_time = os_time_get(); timeout /= 1000; - while (virgl_vtest_resource_is_busy(vdws, res)) { + while (virgl_vtest_resource_is_busy(vws, res)) { if (os_time_get() - start_time >= timeout) return FALSE; os_time_sleep(10); @@ -757,6 +758,7 @@ virgl_vtest_winsys_wrap(struct sw_winsys *sws) vtws->base.resource_unref = virgl_vtest_winsys_resource_unref; vtws->base.resource_map = virgl_vtest_resource_map; vtws->base.resource_wait = virgl_vtest_resource_wait; + vtws->base.resource_is_busy = virgl_vtest_resource_is_busy; vtws->base.cmd_buf_create = virgl_vtest_cmd_buf_create; vtws->base.cmd_buf_destroy = virgl_vtest_cmd_buf_destroy; vtws->base.submit_cmd = virgl_vtest_winsys_submit_cmd; -- 2.30.2