drivers: soc: qcom: fix underflow in read_event

in function read_event, total can be less than previous count as
cached_total_count is not always updated.
Fix this by updating cached_total_count in read_event
when CPU is not idle.

Change-Id: I76a92a41cc6d79eb55c02f96025950576a5c5808
Signed-off-by: Shivnandan Kumar <kshivnan@codeaurora.org>
This commit is contained in:
Shivnandan Kumar 2021-10-02 17:37:44 +05:30 • committed by Gerrit - the friendly Code Review server
commit 4e1ccaa456
2 changed files with 9 additions and 5 deletions

View file

@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2014-2020, The Linux Foundation. All rights reserved.
* Copyright (c) 2014-2021, The Linux Foundation. All rights reserved.
*/
#define pr_fmt(fmt) "arm-memlat-mon: " fmt
@ -174,11 +174,13 @@ static inline void read_event(struct event_data *event)
return;
if (!per_cpu(cpu_is_idle, event->pevent->cpu) &&
!per_cpu(cpu_is_hp, event->pevent->cpu))
!per_cpu(cpu_is_hp, event->pevent->cpu)) {
total = perf_event_read_value(event->pevent, &enabled,
&running);
else
event->cached_total_count = total;
} else {
total = event->cached_total_count;
}
event->last_delta = total - event->prev_count;
event->prev_count = total;
}

View file

@ -560,10 +560,12 @@ static inline void msm_perf_read_event(struct event_data *event)
}
if (!per_cpu(cpu_is_idle, event->pevent->cpu) &&
!per_cpu(cpu_is_hp, event->pevent->cpu))
!per_cpu(cpu_is_hp, event->pevent->cpu)) {
total = perf_event_read_value(event->pevent, &enabled, &running);
else
event->cached_total_count = total;
} else {
total = event->cached_total_count;
}
ev_count = total - event->prev_count;
event->prev_count = total;