PM / devfreq: m4m-hwmon: Fix counter limit calculation

M4M counters are only 28-bit instead of 32-bit. Fix limit calculation
to use the right max value.

Change-Id: I91078842b72da80f6b6755bf8d808ff4b4142f10
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
This commit is contained in:
Junjie Wu 2015-08-12 17:48:46 -07:00 committed by David Keitel
parent 6b034b3c5f
commit 3c83b5f06c

View file

@ -50,6 +50,9 @@
#define CYC_CNTR_IDX 0
#define WASTED_CYC_CNTR_IDX 1
/* counter is 28-bit */
#define CNT_MAX 0x0FFFFFFFU
struct m4m_counter {
int idx;
u32 event_mask;
@ -144,7 +147,7 @@ static unsigned long _mon_get_count(struct m4m_hwmon *m,
}
if (ov)
cnt = U32_MAX - start + cur_cnt;
cnt = CNT_MAX - start + cur_cnt;
else
cnt = cur_cnt - start;
@ -160,7 +163,11 @@ static unsigned long mon_get_count(struct m4m_hwmon *m,
static inline void mon_set_limit(struct m4m_hwmon *m, enum request_group grp,
unsigned int limit)
{
u32 start = U32_MAX - limit;
u32 start;
if (limit >= CNT_MAX)
limit = CNT_MAX;
start = CNT_MAX - limit;
writel_relaxed(start, EVCNTR(m, m->cntr[grp].idx));
m->cntr[grp].last_start = start;