Mesa (main): v3dv: Use util/os_time helpers

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Apr 13 17:57:18 UTC 2022


Module: Mesa
Branch: main
Commit: e5a0e2122f671093b26f5d106df1d2b9e2f1f87c
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=e5a0e2122f671093b26f5d106df1d2b9e2f1f87c

Author: Jason Ekstrand <jason.ekstrand at collabora.com>
Date:   Mon Apr  4 10:22:45 2022 -0500

v3dv: Use util/os_time helpers

Reviewed-by: Alejandro Piñeiro <apinheiro at igalia.com>
Reviewed-by: Iago Toral Quiroga <itoral at igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15704>

---

 src/broadcom/vulkan/v3dv_limits.h |  2 --
 src/broadcom/vulkan/v3dv_queue.c  | 24 +++---------------------
 2 files changed, 3 insertions(+), 23 deletions(-)

diff --git a/src/broadcom/vulkan/v3dv_limits.h b/src/broadcom/vulkan/v3dv_limits.h
index 52bf2dd5ee1..9cda9f0d6d2 100644
--- a/src/broadcom/vulkan/v3dv_limits.h
+++ b/src/broadcom/vulkan/v3dv_limits.h
@@ -23,8 +23,6 @@
 #ifndef V3DV_LIMITS_H
 #define V3DV_LIMITS_H
 
-#define NSEC_PER_SEC 1000000000ull
-
 /* From vulkan spec "If the multiple viewports feature is not enabled,
  * scissorCount must be 1", ditto for viewportCount. For now we don't support
  * that feature.
diff --git a/src/broadcom/vulkan/v3dv_queue.c b/src/broadcom/vulkan/v3dv_queue.c
index f88c7ce032a..cd1018efd72 100644
--- a/src/broadcom/vulkan/v3dv_queue.c
+++ b/src/broadcom/vulkan/v3dv_queue.c
@@ -25,6 +25,7 @@
 #include "drm-uapi/v3d_drm.h"
 
 #include "broadcom/clif/clif_dump.h"
+#include "util/os_time.h"
 
 #include <errno.h>
 #include <time.h>
@@ -67,25 +68,6 @@ v3dv_clif_dump(struct v3dv_device *device,
    clif_dump_destroy(clif);
 }
 
-static uint64_t
-gettime_ns()
-{
-   struct timespec current;
-   clock_gettime(CLOCK_MONOTONIC, &current);
-   return (uint64_t)current.tv_sec * NSEC_PER_SEC + current.tv_nsec;
-}
-
-static uint64_t
-get_absolute_timeout(uint64_t timeout)
-{
-   uint64_t current_time = gettime_ns();
-   uint64_t max_timeout = (uint64_t) INT64_MAX - current_time;
-
-   timeout = MIN2(max_timeout, timeout);
-
-   return (current_time + timeout);
-}
-
 static VkResult
 queue_submit_job(struct v3dv_queue *queue,
                  struct v3dv_job *job,
@@ -2056,7 +2038,7 @@ v3dv_WaitForFences(VkDevice _device,
    if (vk_device_is_lost(&device->vk))
       return VK_ERROR_DEVICE_LOST;
 
-   const uint64_t abs_timeout = get_absolute_timeout(timeout);
+   const uint64_t abs_timeout = os_time_get_absolute_timeout(timeout);
 
    uint32_t *syncobjs = vk_alloc(&device->vk.alloc,
                                  sizeof(*syncobjs) * fenceCount, 8,
@@ -2077,7 +2059,7 @@ v3dv_WaitForFences(VkDevice _device,
    do {
       ret = drmSyncobjWait(device->pdevice->render_fd, syncobjs, fenceCount,
                            timeout, flags, NULL);
-   } while (ret == -ETIME && gettime_ns() < abs_timeout);
+   } while (ret == -ETIME && os_time_get_nano() < abs_timeout);
 
    vk_free(&device->vk.alloc, syncobjs);
 



More information about the mesa-commit mailing list