diff options
Diffstat (limited to 'mali_kbase/mali_kbase_ccswe.c')
-rw-r--r-- | mali_kbase/mali_kbase_ccswe.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/mali_kbase/mali_kbase_ccswe.c b/mali_kbase/mali_kbase_ccswe.c index 6a1e7e4..a3c927d 100644 --- a/mali_kbase/mali_kbase_ccswe.c +++ b/mali_kbase/mali_kbase_ccswe.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note /* * - * (C) COPYRIGHT 2020-2021 ARM Limited. All rights reserved. + * (C) COPYRIGHT 2020-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 @@ -25,22 +25,21 @@ #include <linux/math64.h> #include <linux/time.h> -static u64 kbasep_ccswe_cycle_at_no_lock( - struct kbase_ccswe *self, u64 timestamp_ns) +static u64 kbasep_ccswe_cycle_at_no_lock(struct kbase_ccswe *self, u64 timestamp_ns) { s64 diff_s, diff_ns; u32 gpu_freq; lockdep_assert_held(&self->access); - diff_ns = timestamp_ns - self->timestamp_ns; + diff_ns = (s64)(timestamp_ns - self->timestamp_ns); gpu_freq = diff_ns > 0 ? self->gpu_freq : self->prev_gpu_freq; diff_s = div_s64(diff_ns, NSEC_PER_SEC); diff_ns -= diff_s * NSEC_PER_SEC; - return self->cycles_elapsed + diff_s * gpu_freq - + div_s64(diff_ns * gpu_freq, NSEC_PER_SEC); + return self->cycles_elapsed + (u64)diff_s * gpu_freq + + (u64)div_s64(diff_ns * gpu_freq, NSEC_PER_SEC); } void kbase_ccswe_init(struct kbase_ccswe *self) @@ -62,8 +61,7 @@ u64 kbase_ccswe_cycle_at(struct kbase_ccswe *self, u64 timestamp_ns) return result; } -void kbase_ccswe_freq_change( - struct kbase_ccswe *self, u64 timestamp_ns, u32 gpu_freq) +void kbase_ccswe_freq_change(struct kbase_ccswe *self, u64 timestamp_ns, u32 gpu_freq) { unsigned long flags; @@ -75,8 +73,7 @@ void kbase_ccswe_freq_change( /* If this is the first frequency change, cycles_elapsed is zero. */ if (self->timestamp_ns) - self->cycles_elapsed = kbasep_ccswe_cycle_at_no_lock( - self, timestamp_ns); + self->cycles_elapsed = kbasep_ccswe_cycle_at_no_lock(self, timestamp_ns); self->timestamp_ns = timestamp_ns; self->prev_gpu_freq = self->gpu_freq; |