virgl: export resource_is_busy from winsys
authorChia-I Wu <olvaffe@gmail.com>
Tue, 19 Mar 2019 18:13:40 +0000 (11:13 -0700)
committerChia-I Wu <olvaffe@gmail.com>
Mon, 6 May 2019 17:20:38 +0000 (10:20 -0700)
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
src/gallium/drivers/virgl/virgl_winsys.h
src/gallium/winsys/virgl/drm/virgl_drm_winsys.c
src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c

index 9256bf97b03053a5153fe2cd038c8b0e6d66d00f..bab3dbaa2d13a64cc47c98c54ef9ee64a5682c23 100644 (file)
@@ -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);
index c35d58b05523fe7188ec92f270cedae46a03e372..48ee73f1e2f886a5a6c6b2ff6fcda16b9b5de26b 100644 (file)
@@ -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;
index 7d6761410706bce3812939d8dea534fad89579fe..24b574474678bf94d400a9c13aec050b82fd0ede 100644 (file)
@@ -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;