drivers: qcom: stats: define readq_relaxed for ARM variants

ARM cannot natively read 64-bit address. As such the readq_ variants
are not defined for this architecture. Add a 32-bit equivalent to read 2
sequential 4-byte memory into a u64 value. Let's keep them locally
defined for now, since they are not native to the ARM architecture.

Change-Id: Ib0ce08c3b8a37af85c12c2ad72803bf871847f67
Signed-off-by: Lina Iyer <ilina@codeaurora.org>
Signed-off-by: Tushar Nimkar <tnimkar@codeaurora.org>
This commit is contained in:
Lina Iyer 2020-05-06 15:06:44 -06:00 • committed by Tushar Nimkar
commit 8d6b711a9f
2 changed files with 26 additions and 6 deletions

View file

@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2019, The Linux Foundation. All rights reserved.
* Copyright (c) 2019-2020, The Linux Foundation. All rights reserved.
*/
#define pr_fmt(fmt) "%s: " fmt, __func__
@ -25,6 +25,15 @@
#define GET_PDATA_OF_ATTR(attr) \
(container_of(attr, struct ddr_stats_kobj_attr, ka)->pd)
#ifdef CONFIG_ARM
#define readq_relaxed(a) ({ \
u64 val = readl_relaxed((a) + 4); \
val <<= 32; \
val |= readl_relaxed((a)); \
val; \
})
#endif
struct ddr_stats_platform_data {
phys_addr_t phys_addr_base;
u32 phys_size;
@ -60,10 +69,12 @@ static ssize_t ddr_stats_append_data_to_buf(char *buf, int length, int *count,
{
u32 cp_idx = 0;
u32 name;
u32 duration;
u64 duration;
if (accumulated_duration)
duration = (data->duration * 100) / accumulated_duration;
if (accumulated_duration) {
duration = data->duration * 100;
do_div(duration, accumulated_duration);
}
name = (data->name >> 8) & 0xFF;
@ -71,7 +82,7 @@ static ssize_t ddr_stats_append_data_to_buf(char *buf, int length, int *count,
name = (data->name) & 0xFF;
*count = *count + 1;
return snprintf(buf, length,
"LPM %d:\tName:0x%x\tcount:%u\tTime(msec):%llu (~%d%%)\n",
"LPM %d:\tName:0x%x\tcount:%u\tTime(msec):%llu (~%llu%%)\n",
*count, name, data->count,
data->duration, duration);
} else if (name == 0x1) {
@ -82,7 +93,7 @@ static ssize_t ddr_stats_append_data_to_buf(char *buf, int length, int *count,
return 0;
return snprintf(buf, length,
"Freq %dMhz:\tCP IDX:%u\tcount:%u\tTime(msec):%llu (~%d%%)\n",
"Freq %dMhz:\tCP IDX:%u\tcount:%u\tTime(msec):%llu (~%llu%%)\n",
name, cp_idx, data->count,
data->duration, duration);
}

View file

@ -16,6 +16,15 @@
#include <clocksource/arm_arch_timer.h>
#ifdef CONFIG_ARM
#define readq_relaxed(a) ({ \
u64 val = readl_relaxed((a) + 4); \
val <<= 32; \
val |= readl_relaxed((a)); \
val; \
})
#endif
struct stats_config {
u32 offset_addr;
u32 num_records;