diff options
Diffstat (limited to 'mali_kbase/csf/mali_kbase_csf_tl_reader.c')
-rw-r--r-- | mali_kbase/csf/mali_kbase_csf_tl_reader.c | 111 |
1 files changed, 9 insertions, 102 deletions
diff --git a/mali_kbase/csf/mali_kbase_csf_tl_reader.c b/mali_kbase/csf/mali_kbase_csf_tl_reader.c index f40be8f..ce50683 100644 --- a/mali_kbase/csf/mali_kbase_csf_tl_reader.c +++ b/mali_kbase/csf/mali_kbase_csf_tl_reader.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note /* * - * (C) COPYRIGHT 2019-2021 ARM Limited. All rights reserved. + * (C) COPYRIGHT 2019-2023 ARM Limited. All rights reserved. * * This program is free software and is provided to you under the terms of the * GNU General Public License version 2 as published by the Free Software @@ -31,21 +31,14 @@ #include "mali_kbase_pm.h" #include "mali_kbase_hwaccess_time.h" -#include <linux/gcd.h> #include <linux/math64.h> -#include <asm/arch_timer.h> #if IS_ENABLED(CONFIG_DEBUG_FS) #include "tl/mali_kbase_timeline_priv.h" #include <linux/debugfs.h> - -#if (KERNEL_VERSION(4, 7, 0) > LINUX_VERSION_CODE) -#define DEFINE_DEBUGFS_ATTRIBUTE DEFINE_SIMPLE_ATTRIBUTE -#endif +#include <linux/version_compat_defs.h> #endif -/* Name of the CSFFW timeline tracebuffer. */ -#define KBASE_CSFFW_TRACEBUFFER_NAME "timeline" /* Name of the timeline header metatadata */ #define KBASE_CSFFW_TIMELINE_HEADER_NAME "timeline_header" @@ -92,93 +85,15 @@ DEFINE_DEBUGFS_ATTRIBUTE(kbase_csf_tl_poll_interval_fops, kbase_csf_tl_debugfs_poll_interval_read, kbase_csf_tl_debugfs_poll_interval_write, "%llu\n"); - void kbase_csf_tl_reader_debugfs_init(struct kbase_device *kbdev) { debugfs_create_file("csf_tl_poll_interval_in_ms", 0644, kbdev->debugfs_instr_directory, kbdev, &kbase_csf_tl_poll_interval_fops); - } #endif /** - * get_cpu_gpu_time() - Get current CPU and GPU timestamps. - * - * @kbdev: Kbase device. - * @cpu_ts: Output CPU timestamp. - * @gpu_ts: Output GPU timestamp. - * @gpu_cycle: Output GPU cycle counts. - */ -static void get_cpu_gpu_time( - struct kbase_device *kbdev, - u64 *cpu_ts, - u64 *gpu_ts, - u64 *gpu_cycle) -{ - struct timespec64 ts; - - kbase_pm_context_active(kbdev); - kbase_backend_get_gpu_time(kbdev, gpu_cycle, gpu_ts, &ts); - kbase_pm_context_idle(kbdev); - - if (cpu_ts) - *cpu_ts = ts.tv_sec * NSEC_PER_SEC + ts.tv_nsec; -} - - -/** - * kbase_ts_converter_init() - Initialize system timestamp converter. - * - * @self: System Timestamp Converter instance. - * @kbdev: Kbase device pointer - * - * Return: Zero on success, -1 otherwise. - */ -static int kbase_ts_converter_init( - struct kbase_ts_converter *self, - struct kbase_device *kbdev) -{ - u64 cpu_ts = 0; - u64 gpu_ts = 0; - u64 freq; - u64 common_factor; - - get_cpu_gpu_time(kbdev, &cpu_ts, &gpu_ts, NULL); - freq = arch_timer_get_cntfrq(); - - if (!freq) { - dev_warn(kbdev->dev, "arch_timer_get_rate() is zero!"); - return -1; - } - - common_factor = gcd(NSEC_PER_SEC, freq); - - self->multiplier = div64_u64(NSEC_PER_SEC, common_factor); - self->divisor = div64_u64(freq, common_factor); - self->offset = - cpu_ts - div64_u64(gpu_ts * self->multiplier, self->divisor); - - return 0; -} - -/** - * kbase_ts_converter_convert() - Convert GPU timestamp to CPU timestamp. - * - * @self: System Timestamp Converter instance. - * @gpu_ts: System timestamp value to converter. - * - * Return: The CPU timestamp. - */ -static void __maybe_unused -kbase_ts_converter_convert(const struct kbase_ts_converter *self, u64 *gpu_ts) -{ - u64 old_gpu_ts = *gpu_ts; - *gpu_ts = div64_u64(old_gpu_ts * self->multiplier, self->divisor) + - self->offset; -} - -/** * tl_reader_overflow_notify() - Emit stream overflow tracepoint. * * @self: CSFFW TL Reader instance. @@ -254,7 +169,6 @@ static void tl_reader_reset(struct kbase_csf_tl_reader *self) self->tl_header.btc = 0; } - int kbase_csf_tl_reader_flush_buffer(struct kbase_csf_tl_reader *self) { int ret = 0; @@ -279,7 +193,6 @@ int kbase_csf_tl_reader_flush_buffer(struct kbase_csf_tl_reader *self) return -EBUSY; } - /* Copying the whole buffer in a single shot. We assume * that the buffer will not contain partially written messages. */ @@ -301,7 +214,7 @@ int kbase_csf_tl_reader_flush_buffer(struct kbase_csf_tl_reader *self) dev_warn( kbdev->dev, "Unable to parse CSFFW tracebuffer event header."); - ret = -EBUSY; + ret = -EBUSY; break; } @@ -322,7 +235,7 @@ int kbase_csf_tl_reader_flush_buffer(struct kbase_csf_tl_reader *self) dev_warn(kbdev->dev, "event_id: %u, can't read with event_size: %u.", event_id, event_size); - ret = -EBUSY; + ret = -EBUSY; break; } @@ -330,8 +243,8 @@ int kbase_csf_tl_reader_flush_buffer(struct kbase_csf_tl_reader *self) { struct kbase_csffw_tl_message *msg = (struct kbase_csffw_tl_message *) csffw_data_it; - kbase_ts_converter_convert(&self->ts_converter, - &msg->timestamp); + msg->timestamp = + kbase_backend_time_convert_gpu_to_cpu(kbdev, msg->timestamp); } /* Copy the message out to the tl_stream. */ @@ -384,16 +297,13 @@ static int tl_reader_init_late( if (self->kbdev) return 0; - tb = kbase_csf_firmware_get_trace_buffer( - kbdev, KBASE_CSFFW_TRACEBUFFER_NAME); + tb = kbase_csf_firmware_get_trace_buffer(kbdev, KBASE_CSFFW_TIMELINE_BUF_NAME); hdr = kbase_csf_firmware_get_timeline_metadata( kbdev, KBASE_CSFFW_TIMELINE_HEADER_NAME, &hdr_size); if (!tb) { - dev_warn( - kbdev->dev, - "'%s' tracebuffer is not present in the firmware image.", - KBASE_CSFFW_TRACEBUFFER_NAME); + dev_warn(kbdev->dev, "'%s' tracebuffer is not present in the firmware image.", + KBASE_CSFFW_TIMELINE_BUF_NAME); return -1; } @@ -405,9 +315,6 @@ static int tl_reader_init_late( return -1; } - if (kbase_ts_converter_init(&self->ts_converter, kbdev)) - return -1; - self->kbdev = kbdev; self->trace_buffer = tb; self->tl_header.data = hdr; |