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

Author: Rob Clark <[email protected]>
Date:   Mon Dec 11 13:51:17 2023 -0800

freedreno: Fix timestamp conversion

The kernel returns the 19.2MHz RBBM counter, same as what is used for
timestamp queries.  So it needs to be converted the same way.

Signed-off-by: Rob Clark <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26640>

---

 src/gallium/drivers/freedreno/freedreno_screen.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c 
b/src/gallium/drivers/freedreno/freedreno_screen.c
index 6cadea8c2eb..f9acfa8f9e7 100644
--- a/src/gallium/drivers/freedreno/freedreno_screen.c
+++ b/src/gallium/drivers/freedreno/freedreno_screen.c
@@ -141,8 +141,7 @@ fd_screen_get_timestamp(struct pipe_screen *pscreen)
    if (screen->has_timestamp) {
       uint64_t n;
       fd_pipe_get_param(screen->pipe, FD_TIMESTAMP, &n);
-      assert(screen->max_freq > 0);
-      return n * 1000000000 / screen->max_freq;
+      return ticks_to_ns(n);
    } else {
       int64_t cpu_time = os_time_get_nano();
       return cpu_time + screen->cpu_gpu_time_delta;
@@ -1113,10 +1112,11 @@ fd_screen_create(int fd,
       screen->max_freq = 0;
    } else {
       screen->max_freq = val;
-      if (fd_pipe_get_param(screen->pipe, FD_TIMESTAMP, &val) == 0)
-         screen->has_timestamp = true;
    }
 
+   if (fd_pipe_get_param(screen->pipe, FD_TIMESTAMP, &val) == 0)
+      screen->has_timestamp = true;
+
    screen->dev_id = fd_pipe_dev_id(screen->pipe);
 
    if (fd_pipe_get_param(screen->pipe, FD_GPU_ID, &val)) {

Reply via email to