summaryrefslogtreecommitdiff
path: root/mali_kbase/ipa
diff options
context:
space:
mode:
authorSidath Senanayake <sidaths@google.com>2017-11-08 13:23:34 +0100
committerSidath Senanayake <sidaths@google.com>2017-11-08 13:23:34 +0100
commitdbd2655766535ffc24e24503a7279f3abfd40d7e (patch)
tree87f651aaa936267783d365eab5502d24f6be2d14 /mali_kbase/ipa
parentc19c62718d90e8efa4675528aae6ab6fde13a12f (diff)
downloadgpu-dbd2655766535ffc24e24503a7279f3abfd40d7e.tar.gz
Mali Bifrost DDK r9p0 KMD
Provenance: b336f554d (collaborate/EAC/b_r9p0) BX304L01B-BU-00000-r9p0-01rel0 BX304L06A-BU-00000-r9p0-01rel0 BX304X07X-BU-00000-r9p0-01rel0 Signed-off-by: Sidath Senanayake <sidaths@google.com> Change-Id: Iaff4ad1413fa7d768d5d250afadbb24d19e1e2e2
Diffstat (limited to 'mali_kbase/ipa')
-rw-r--r--mali_kbase/ipa/mali_kbase_ipa.c27
-rw-r--r--mali_kbase/ipa/mali_kbase_ipa_debugfs.c30
-rw-r--r--mali_kbase/ipa/mali_kbase_ipa_debugfs.h14
-rw-r--r--mali_kbase/ipa/mali_kbase_ipa_simple.c11
-rw-r--r--mali_kbase/ipa/mali_kbase_ipa_vinstr_common.c20
-rw-r--r--mali_kbase/ipa/mali_kbase_ipa_vinstr_common.h18
-rw-r--r--mali_kbase/ipa/mali_kbase_ipa_vinstr_g71.c171
7 files changed, 236 insertions, 55 deletions
diff --git a/mali_kbase/ipa/mali_kbase_ipa.c b/mali_kbase/ipa/mali_kbase_ipa.c
index e7e2299..1450c2c 100644
--- a/mali_kbase/ipa/mali_kbase_ipa.c
+++ b/mali_kbase/ipa/mali_kbase_ipa.c
@@ -390,7 +390,7 @@ static u32 kbase_scale_dynamic_power(const u32 c, const u32 freq,
const u64 v2fc = (u64) c * (u64) v2f;
/* Range: 0 < v2fc / 1000 < 2^13 mW */
- return v2fc / 1000;
+ return div_u64(v2fc, 1000);
}
/**
@@ -419,7 +419,7 @@ u32 kbase_scale_static_power(const u32 c, const u32 voltage)
const u64 v3c_big = (u64) c * (u64) v3;
/* Range: 0 < v3c_big / 1000000 < 2^13 mW */
- return v3c_big / 1000000;
+ return div_u64(v3c_big, 1000000);
}
static struct kbase_ipa_model *get_current_model(struct kbase_device *kbdev)
@@ -455,7 +455,8 @@ static u32 get_static_power_locked(struct kbase_device *kbdev,
return power;
}
-#ifdef CONFIG_MALI_PWRSOFT_765
+#if defined(CONFIG_MALI_PWRSOFT_765) || \
+ LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)
static unsigned long kbase_get_static_power(struct devfreq *df,
unsigned long voltage)
#else
@@ -464,7 +465,8 @@ static unsigned long kbase_get_static_power(unsigned long voltage)
{
struct kbase_ipa_model *model;
u32 power = 0;
-#ifdef CONFIG_MALI_PWRSOFT_765
+#if defined(CONFIG_MALI_PWRSOFT_765) || \
+ LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)
struct kbase_device *kbdev = dev_get_drvdata(&df->dev);
#else
struct kbase_device *kbdev = kbase_find_device(-1);
@@ -477,14 +479,16 @@ static unsigned long kbase_get_static_power(unsigned long voltage)
mutex_unlock(&kbdev->ipa.lock);
-#ifndef CONFIG_MALI_PWRSOFT_765
+#if !(defined(CONFIG_MALI_PWRSOFT_765) || \
+ LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0))
kbase_release_device(kbdev);
#endif
return power;
}
-#ifdef CONFIG_MALI_PWRSOFT_765
+#if defined(CONFIG_MALI_PWRSOFT_765) || \
+ LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)
static unsigned long kbase_get_dynamic_power(struct devfreq *df,
unsigned long freq,
unsigned long voltage)
@@ -496,7 +500,8 @@ static unsigned long kbase_get_dynamic_power(unsigned long freq,
struct kbase_ipa_model *model;
u32 power_coeff = 0, power = 0;
int err = 0;
-#ifdef CONFIG_MALI_PWRSOFT_765
+#if defined(CONFIG_MALI_PWRSOFT_765) || \
+ LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)
struct kbase_device *kbdev = dev_get_drvdata(&df->dev);
#else
struct kbase_device *kbdev = kbase_find_device(-1);
@@ -517,7 +522,8 @@ static unsigned long kbase_get_dynamic_power(unsigned long freq,
mutex_unlock(&kbdev->ipa.lock);
-#ifndef CONFIG_MALI_PWRSOFT_765
+#if !(defined(CONFIG_MALI_PWRSOFT_765) || \
+ LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0))
kbase_release_device(kbdev);
#endif
@@ -557,7 +563,7 @@ int kbase_get_real_power(struct devfreq *df, u32 *power,
unsigned long total_time = max(status->total_time, 1ul);
u64 busy_time = min(status->busy_time, total_time);
- *power = ((u64) *power * (u64) busy_time) / total_time;
+ *power = div_u64((u64) *power * (u64) busy_time, total_time);
}
*power += get_static_power_locked(kbdev, model, voltage);
@@ -576,7 +582,8 @@ struct devfreq_cooling_power kbase_ipa_power_model_ops = {
#endif
.get_static_power = &kbase_get_static_power,
.get_dynamic_power = &kbase_get_dynamic_power,
-#ifdef CONFIG_MALI_PWRSOFT_765
+#if defined(CONFIG_MALI_PWRSOFT_765) || \
+ LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)
.get_real_power = &kbase_get_real_power,
#endif
};
diff --git a/mali_kbase/ipa/mali_kbase_ipa_debugfs.c b/mali_kbase/ipa/mali_kbase_ipa_debugfs.c
index eafc140..d3ac7c3 100644
--- a/mali_kbase/ipa/mali_kbase_ipa_debugfs.c
+++ b/mali_kbase/ipa/mali_kbase_ipa_debugfs.c
@@ -142,6 +142,12 @@ int kbase_ipa_model_param_add(struct kbase_ipa_model *model, const char *name,
/* 'name' is stack-allocated for array elements, so copy it into
* heap-allocated storage */
param->name = kstrdup(name, GFP_KERNEL);
+
+ if (!param->name) {
+ kfree(param);
+ return -ENOMEM;
+ }
+
param->addr.voidp = addr;
param->size = size;
param->type = type;
@@ -207,6 +213,30 @@ static void kbase_ipa_model_debugfs_init(struct kbase_ipa_model *model)
}
}
+void kbase_ipa_model_param_set_s32(struct kbase_ipa_model *model,
+ const char *name, s32 val)
+{
+ struct kbase_ipa_model_param *param;
+
+ mutex_lock(&model->kbdev->ipa.lock);
+
+ list_for_each_entry(param, &model->params, link) {
+ if (!strcmp(param->name, name)) {
+ if (param->type == PARAM_TYPE_S32) {
+ *param->addr.s32p = val;
+ } else {
+ dev_err(model->kbdev->dev,
+ "Wrong type for %s parameter %s\n",
+ model->ops->name, param->name);
+ }
+ break;
+ }
+ }
+
+ mutex_unlock(&model->kbdev->ipa.lock);
+}
+KBASE_EXPORT_TEST_API(kbase_ipa_model_param_set_s32);
+
void kbase_ipa_debugfs_init(struct kbase_device *kbdev)
{
mutex_lock(&kbdev->ipa.lock);
diff --git a/mali_kbase/ipa/mali_kbase_ipa_debugfs.h b/mali_kbase/ipa/mali_kbase_ipa_debugfs.h
index ec06e20..f624de9 100644
--- a/mali_kbase/ipa/mali_kbase_ipa_debugfs.h
+++ b/mali_kbase/ipa/mali_kbase_ipa_debugfs.h
@@ -31,6 +31,20 @@ int kbase_ipa_model_param_add(struct kbase_ipa_model *model, const char *name,
enum kbase_ipa_model_param_type type);
void kbase_ipa_model_param_free_all(struct kbase_ipa_model *model);
+/**
+ * kbase_ipa_model_param_set_s32 - Set an integer model parameter
+ *
+ * @model: pointer to IPA model
+ * @name: name of corresponding debugfs entry
+ * @val: new value of the parameter
+ *
+ * This function is only exposed for use by unit tests running in
+ * kernel space. Normally it is expected that parameter values will
+ * instead be set via debugfs.
+ */
+void kbase_ipa_model_param_set_s32(struct kbase_ipa_model *model,
+ const char *name, s32 val);
+
#else /* CONFIG_DEBUG_FS */
static inline int kbase_ipa_model_param_add(struct kbase_ipa_model *model,
diff --git a/mali_kbase/ipa/mali_kbase_ipa_simple.c b/mali_kbase/ipa/mali_kbase_ipa_simple.c
index de6c3e6..70e08b3 100644
--- a/mali_kbase/ipa/mali_kbase_ipa_simple.c
+++ b/mali_kbase/ipa/mali_kbase_ipa_simple.c
@@ -46,7 +46,7 @@ static int dummy_temp;
static int kbase_simple_power_model_get_dummy_temp(
struct thermal_zone_device *tz,
- int *dummy_temp)
+ int *temp)
{
*temp = ACCESS_ONCE(dummy_temp);
return 0;
@@ -113,10 +113,10 @@ struct kbase_ipa_model_simple_data {
static u32 calculate_temp_scaling_factor(s32 ts[4], s64 t)
{
/* Range: -2^24 < t2 < 2^24 m(Deg^2) */
- const s64 t2 = (t * t) / 1000;
+ const s64 t2 = div_s64((t * t), 1000);
/* Range: -2^31 < t3 < 2^31 m(Deg^3) */
- const s64 t3 = (t * t2) / 1000;
+ const s64 t3 = div_s64((t * t2), 1000);
/*
* Sum the parts. t^[1-3] are in m(Deg^N), but the coefficients are in
@@ -129,7 +129,7 @@ static u32 calculate_temp_scaling_factor(s32 ts[4], s64 t)
+ ts[0] * 1000; /* +/- 2^41 */
/* Range: -2^60 < res_unclamped < 2^60 */
- s64 res_unclamped = res_big / 1000;
+ s64 res_unclamped = div_s64(res_big, 1000);
/* Clamp to range of 0x to 10x the static power */
return clamp(res_unclamped, (s64) 0, (s64) 10000000);
@@ -192,7 +192,7 @@ static int model_static_coeff(struct kbase_ipa_model *model, u32 *coeffp)
* 0 <= static_coefficient < 2^28.
*/
coeff_big = (u64) model_data->static_coefficient * (u64) temp_scaling_factor;
- *coeffp = coeff_big / 1000000;
+ *coeffp = div_u64(coeff_big, 1000000);
return 0;
}
@@ -320,3 +320,4 @@ struct kbase_ipa_model_ops kbase_simple_ipa_model_ops = {
.get_static_coeff = &model_static_coeff,
.do_utilization_scaling_in_framework = true,
};
+KBASE_EXPORT_TEST_API(kbase_simple_ipa_model_ops);
diff --git a/mali_kbase/ipa/mali_kbase_ipa_vinstr_common.c b/mali_kbase/ipa/mali_kbase_ipa_vinstr_common.c
index d3964d0..9b9fa0e 100644
--- a/mali_kbase/ipa/mali_kbase_ipa_vinstr_common.c
+++ b/mali_kbase/ipa/mali_kbase_ipa_vinstr_common.c
@@ -24,6 +24,8 @@ static ktime_t dummy_time;
#ifdef ktime_get
#undef ktime_get
#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0)
#define ktime_get() (ACCESS_ONCE(dummy_time))
void kbase_ipa_set_dummy_time(ktime_t t)
@@ -31,6 +33,16 @@ void kbase_ipa_set_dummy_time(ktime_t t)
ACCESS_ONCE(dummy_time) = t;
}
KBASE_EXPORT_TEST_API(kbase_ipa_set_dummy_time);
+#else
+#define ktime_get() (READ_ONCE(dummy_time))
+
+void kbase_ipa_set_dummy_time(ktime_t t)
+{
+ WRITE_ONCE(dummy_time, t);
+}
+KBASE_EXPORT_TEST_API(kbase_ipa_set_dummy_time);
+
+#endif
#endif /* MALI_UNIT_TEST */
@@ -85,7 +97,7 @@ s64 kbase_ipa_sum_all_shader_cores(
/* Range: -2^54 < ret < 2^54 */
ret *= coeff;
- return ret / 1000000;
+ return div_s64(ret, 1000000);
}
s64 kbase_ipa_single_counter(
@@ -99,7 +111,7 @@ s64 kbase_ipa_single_counter(
const s64 multiplied = (s64) counter_value * (s64) coeff;
/* Range: -2^29 < return < 2^29 */
- return multiplied / 1000000;
+ return div_s64(multiplied, 1000000);
}
int kbase_ipa_attach_vinstr(struct kbase_ipa_model_vinstr_data *model_data)
@@ -173,7 +185,7 @@ int kbase_ipa_vinstr_dynamic_coeff(struct kbase_ipa_model *model, u32 *coeffp,
s32 coeff, group_energy;
coeff = model_data->group_values[i];
- group_energy = group->op(model_data, coeff, group->counter);
+ group_energy = group->op(model_data, coeff, group->counter_block_offset);
energy = kbase_ipa_add_saturate(energy, group_energy);
}
@@ -199,7 +211,7 @@ int kbase_ipa_vinstr_dynamic_coeff(struct kbase_ipa_model *model, u32 *coeffp,
/* Range: 2^20 < num_cycles < 2^40 mCycles */
num_cycles = (u64) current_freq * (u64) time_since_last_sample_ms;
/* Range: 2^10 < num_cycles < 2^30 Cycles */
- num_cycles /= 1000000;
+ num_cycles = div_u64(num_cycles, 1000000);
/* num_cycles should never be 0 in _normal_ usage (because we expect
* frequencies on the order of MHz and >10ms polling intervals), but
diff --git a/mali_kbase/ipa/mali_kbase_ipa_vinstr_common.h b/mali_kbase/ipa/mali_kbase_ipa_vinstr_common.h
index 25b36c8..d212c87 100644
--- a/mali_kbase/ipa/mali_kbase_ipa_vinstr_common.h
+++ b/mali_kbase/ipa/mali_kbase_ipa_vinstr_common.h
@@ -69,21 +69,22 @@ struct kbase_ipa_model_vinstr_data {
* Coefficients are interpreted as fractions where the
* denominator is 1000000.
* @op: which operation to be performed on the counter values
- * @counter: counter used to calculate energy for IPA group
+ * @counter_block_offset: block offset in bytes of the counter used to calculate energy for IPA group
*/
struct kbase_ipa_group {
char name[KBASE_IPA_MAX_GROUP_NAME_LEN + 1];
s32 default_value;
s64 (*op)(struct kbase_ipa_model_vinstr_data *, s32, u32);
- u32 counter;
+ u32 counter_block_offset;
};
-/*
+/**
* sum_all_shader_cores() - sum a counter over all cores
* @model_data pointer to model data
* @coeff model coefficient. Unity is ~2^20, so range approx
* +/- 4.0: -2^22 < coeff < 2^22
-
+ * @counter offset in bytes of the counter used to calculate energy for IPA group
+ *
* Calculate energy estimation based on hardware counter `counter'
* across all shader cores.
*
@@ -93,12 +94,13 @@ s64 kbase_ipa_sum_all_shader_cores(
struct kbase_ipa_model_vinstr_data *model_data,
s32 coeff, u32 counter);
-/*
+/**
* sum_single_counter() - sum a single counter
* @model_data pointer to model data
* @coeff model coefficient. Unity is ~2^20, so range approx
* +/- 4.0: -2^22 < coeff < 2^22
-
+ * @counter offset in bytes of the counter used to calculate energy for IPA group
+ *
* Calculate energy estimation based on hardware counter `counter'.
*
* Return: Counter value. Range: -2^34 < ret < 2^34
@@ -107,7 +109,7 @@ s64 kbase_ipa_single_counter(
struct kbase_ipa_model_vinstr_data *model_data,
s32 coeff, u32 counter);
-/*
+/**
* attach_vinstr() - attach a vinstr_buffer to an IPA model.
* @model_data pointer to model data
*
@@ -119,7 +121,7 @@ s64 kbase_ipa_single_counter(
*/
int kbase_ipa_attach_vinstr(struct kbase_ipa_model_vinstr_data *model_data);
-/*
+/**
* detach_vinstr() - detach a vinstr_buffer from an IPA model.
* @model_data pointer to model data
*
diff --git a/mali_kbase/ipa/mali_kbase_ipa_vinstr_g71.c b/mali_kbase/ipa/mali_kbase_ipa_vinstr_g71.c
index 81f6fdd..4e4c059 100644
--- a/mali_kbase/ipa/mali_kbase_ipa_vinstr_g71.c
+++ b/mali_kbase/ipa/mali_kbase_ipa_vinstr_g71.c
@@ -21,54 +21,169 @@
#include "mali_kbase_ipa_debugfs.h"
-#define JM_BASE (0 * KBASE_IPA_NR_BYTES_PER_BLOCK)
-#define TILER_BASE (1 * KBASE_IPA_NR_BYTES_PER_BLOCK)
-#define MMU_BASE (2 * KBASE_IPA_NR_BYTES_PER_BLOCK)
-#define SC0_BASE (3 * KBASE_IPA_NR_BYTES_PER_BLOCK)
-
-#define GPU_ACTIVE (JM_BASE + KBASE_IPA_NR_BYTES_PER_CNT * 6)
-#define TILER_ACTIVE (TILER_BASE + KBASE_IPA_NR_BYTES_PER_CNT * 45)
-#define L2_ANY_LOOKUP (MMU_BASE + KBASE_IPA_NR_BYTES_PER_CNT * 25)
-#define FRAG_ACTIVE (SC0_BASE + KBASE_IPA_NR_BYTES_PER_CNT * 4)
-#define EXEC_CORE_ACTIVE (SC0_BASE + KBASE_IPA_NR_BYTES_PER_CNT * 26)
-#define EXEC_INSTR_COUNT (SC0_BASE + KBASE_IPA_NR_BYTES_PER_CNT * 28)
-#define TEX_COORD_ISSUE (SC0_BASE + KBASE_IPA_NR_BYTES_PER_CNT * 40)
-#define VARY_SLOT_32 (SC0_BASE + KBASE_IPA_NR_BYTES_PER_CNT * 50)
-#define VARY_SLOT_16 (SC0_BASE + KBASE_IPA_NR_BYTES_PER_CNT * 51)
-#define BEATS_RD_LSC (SC0_BASE + KBASE_IPA_NR_BYTES_PER_CNT * 56)
-#define BEATS_WR_LSC (SC0_BASE + KBASE_IPA_NR_BYTES_PER_CNT * 61)
-#define BEATS_WR_TIB (SC0_BASE + KBASE_IPA_NR_BYTES_PER_CNT * 62)
+/* Performance counter blocks base offsets */
+#define JM_BASE (0 * KBASE_IPA_NR_BYTES_PER_BLOCK)
+#define TILER_BASE (1 * KBASE_IPA_NR_BYTES_PER_BLOCK)
+#define MEMSYS_BASE (2 * KBASE_IPA_NR_BYTES_PER_BLOCK)
+#define SC0_BASE_ONE_MEMSYS (3 * KBASE_IPA_NR_BYTES_PER_BLOCK)
+#define SC0_BASE_TWO_MEMSYS (4 * KBASE_IPA_NR_BYTES_PER_BLOCK)
+
+/* JM counter block offsets */
+#define JM_GPU_ACTIVE (KBASE_IPA_NR_BYTES_PER_CNT * 6)
+
+/* Tiler counter block offsets */
+#define TILER_ACTIVE (KBASE_IPA_NR_BYTES_PER_CNT * 45)
+
+/* MEMSYS counter block offsets */
+#define MEMSYS_L2_ANY_LOOKUP (KBASE_IPA_NR_BYTES_PER_CNT * 25)
+
+/* SC counter block offsets */
+#define SC_FRAG_ACTIVE (KBASE_IPA_NR_BYTES_PER_CNT * 4)
+#define SC_EXEC_CORE_ACTIVE (KBASE_IPA_NR_BYTES_PER_CNT * 26)
+#define SC_EXEC_INSTR_COUNT (KBASE_IPA_NR_BYTES_PER_CNT * 28)
+#define SC_TEX_COORD_ISSUE (KBASE_IPA_NR_BYTES_PER_CNT * 40)
+#define SC_VARY_SLOT_32 (KBASE_IPA_NR_BYTES_PER_CNT * 50)
+#define SC_VARY_SLOT_16 (KBASE_IPA_NR_BYTES_PER_CNT * 51)
+#define SC_BEATS_RD_LSC (KBASE_IPA_NR_BYTES_PER_CNT * 56)
+#define SC_BEATS_WR_LSC (KBASE_IPA_NR_BYTES_PER_CNT * 61)
+#define SC_BEATS_WR_TIB (KBASE_IPA_NR_BYTES_PER_CNT * 62)
+
+/** Maximum number of cores for which a single Memory System block of performance counters is present. */
+#define KBASE_G71_SINGLE_MEMSYS_MAX_NUM_CORES ((u8)4)
+
+
+/**
+ * get_jm_counter() - get performance counter offset inside the Job Manager block
+ * @model_data: pointer to GPU model data.
+ * @counter_block_offset: offset in bytes of the performance counter inside the Job Manager block.
+ *
+ * Return: Block offset in bytes of the required performance counter.
+ */
+static u32 kbase_g71_power_model_get_jm_counter(struct kbase_ipa_model_vinstr_data *model_data,
+ u32 counter_block_offset)
+{
+ return JM_BASE + counter_block_offset;
+}
+
+/**
+ * get_memsys_counter() - get peformance counter offset inside the Memory System block
+ * @model_data: pointer to GPU model data.
+ * @counter_block_offset: offset in bytes of the performance counter inside the (first) Memory System block.
+ *
+ * Return: Block offset in bytes of the required performance counter.
+ */
+static u32 kbase_g71_power_model_get_memsys_counter(struct kbase_ipa_model_vinstr_data *model_data,
+ u32 counter_block_offset)
+{
+ /* The base address of Memory System performance counters is always the same, although their number
+ * may vary based on the number of cores. For the moment it's ok to return a constant.
+ */
+ return MEMSYS_BASE + counter_block_offset;
+}
+
+/**
+ * get_sc_counter() - get performance counter offset inside the Shader Cores block
+ * @model_data: pointer to GPU model data.
+ * @counter_block_offset: offset in bytes of the performance counter inside the (first) Shader Cores block.
+ *
+ * Return: Block offset in bytes of the required performance counter.
+ */
+static u32 kbase_g71_power_model_get_sc_counter(struct kbase_ipa_model_vinstr_data *model_data,
+ u32 counter_block_offset)
+{
+ const u32 sc_base = model_data->kbdev->gpu_props.num_cores <= KBASE_G71_SINGLE_MEMSYS_MAX_NUM_CORES ?
+ SC0_BASE_ONE_MEMSYS :
+ SC0_BASE_TWO_MEMSYS;
+
+ return sc_base + counter_block_offset;
+}
+
+/**
+ * memsys_single_counter() - calculate energy for a single Memory System performance counter.
+ * @model_data: pointer to GPU model data.
+ * @coeff: default value of coefficient for IPA group.
+ * @counter_block_offset: offset in bytes of the counter inside the block it belongs to.
+ *
+ * Return: Energy estimation for a single Memory System performance counter.
+ */
+static s64 kbase_g71_memsys_single_counter(
+ struct kbase_ipa_model_vinstr_data *model_data,
+ s32 coeff,
+ u32 counter_block_offset)
+{
+ return kbase_ipa_single_counter(model_data, coeff,
+ kbase_g71_power_model_get_memsys_counter(model_data, counter_block_offset));
+}
+
+/**
+ * sum_all_shader_cores() - calculate energy for a Shader Cores performance counter for all cores.
+ * @model_data: pointer to GPU model data.
+ * @coeff: default value of coefficient for IPA group.
+ * @counter_block_offset: offset in bytes of the counter inside the block it belongs to.
+ *
+ * Return: Energy estimation for a Shader Cores performance counter for all cores.
+ */
+static s64 kbase_g71_sum_all_shader_cores(
+ struct kbase_ipa_model_vinstr_data *model_data,
+ s32 coeff,
+ u32 counter_block_offset)
+{
+ return kbase_ipa_sum_all_shader_cores(model_data, coeff,
+ kbase_g71_power_model_get_sc_counter(model_data, counter_block_offset));
+}
+
+/**
+ * jm_single_counter() - calculate energy for a single Job Manager performance counter.
+ * @model_data: pointer to GPU model data.
+ * @coeff: default value of coefficient for IPA group.
+ * @counter_block_offset: offset in bytes of the counter inside the block it belongs to.
+ *
+ * Return: Energy estimation for a single Job Manager performance counter.
+ */
+static s64 kbase_g71_jm_single_counter(
+ struct kbase_ipa_model_vinstr_data *model_data,
+ s32 coeff,
+ u32 counter_block_offset)
+{
+ return kbase_ipa_single_counter(model_data, coeff,
+ kbase_g71_power_model_get_jm_counter(model_data, counter_block_offset));
+}
+/** Table of IPA group definitions.
+ *
+ * For each IPA group, this table defines a function to access the given performance block counter (or counters,
+ * if the operation needs to be iterated on multiple blocks) and calculate energy estimation.
+ */
static const struct kbase_ipa_group ipa_groups_def[] = {
{
.name = "l2_access",
.default_value = 526300,
- .op = kbase_ipa_single_counter,
- .counter = L2_ANY_LOOKUP,
+ .op = kbase_g71_memsys_single_counter,
+ .counter_block_offset = MEMSYS_L2_ANY_LOOKUP,
},
{
.name = "exec_instr_count",
.default_value = 301100,
- .op = kbase_ipa_sum_all_shader_cores,
- .counter = EXEC_INSTR_COUNT,
+ .op = kbase_g71_sum_all_shader_cores,
+ .counter_block_offset = SC_EXEC_INSTR_COUNT,
},
{
.name = "tex_issue",
.default_value = 197400,
- .op = kbase_ipa_sum_all_shader_cores,
- .counter = TEX_COORD_ISSUE,
+ .op = kbase_g71_sum_all_shader_cores,
+ .counter_block_offset = SC_TEX_COORD_ISSUE,
},
{
.name = "tile_wb",
.default_value = -156400,
- .op = kbase_ipa_sum_all_shader_cores,
- .counter = BEATS_WR_TIB,
+ .op = kbase_g71_sum_all_shader_cores,
+ .counter_block_offset = SC_BEATS_WR_TIB,
},
{
.name = "gpu_active",
.default_value = 115800,
- .op = kbase_ipa_single_counter,
- .counter = GPU_ACTIVE,
+ .op = kbase_g71_jm_single_counter,
+ .counter_block_offset = JM_GPU_ACTIVE,
},
};
@@ -99,7 +214,7 @@ static int kbase_g71_power_model_init(struct kbase_ipa_model *model)
goto exit;
}
- model_data->scaling_factor = 15000;
+ model_data->scaling_factor = 5;
err = kbase_ipa_model_add_param_s32(model, "scale",
&model_data->scaling_factor,
1, false);