forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 223293205a7265c8b02882461ba8996650048ade
kernel/drivers/gpu/arm/bifrost/ipa/backend/mali_kbase_ipa_counter_jm.c
....@@ -1,7 +1,7 @@
11 // SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note
22 /*
33 *
4
- * (C) COPYRIGHT 2016-2021 ARM Limited. All rights reserved.
4
+ * (C) COPYRIGHT 2016-2023 ARM Limited. All rights reserved.
55 *
66 * This program is free software and is provided to you under the terms of the
77 * GNU General Public License version 2 as published by the Free Software
....@@ -23,25 +23,19 @@
2323
2424 #include "mali_kbase_ipa_counter_common_jm.h"
2525 #include "mali_kbase.h"
26
-
26
+#include <backend/gpu/mali_kbase_model_linux.h>
2727
2828 /* Performance counter blocks base offsets */
2929 #define JM_BASE (0 * KBASE_IPA_NR_BYTES_PER_BLOCK)
30
-#define TILER_BASE (1 * KBASE_IPA_NR_BYTES_PER_BLOCK)
3130 #define MEMSYS_BASE (2 * KBASE_IPA_NR_BYTES_PER_BLOCK)
3231
3332 /* JM counter block offsets */
3433 #define JM_GPU_ACTIVE (KBASE_IPA_NR_BYTES_PER_CNT * 6)
3534
36
-/* Tiler counter block offsets */
37
-#define TILER_ACTIVE (KBASE_IPA_NR_BYTES_PER_CNT * 45)
38
-
3935 /* MEMSYS counter block offsets */
4036 #define MEMSYS_L2_ANY_LOOKUP (KBASE_IPA_NR_BYTES_PER_CNT * 25)
4137
4238 /* SC counter block offsets */
43
-#define SC_FRAG_ACTIVE (KBASE_IPA_NR_BYTES_PER_CNT * 4)
44
-#define SC_EXEC_CORE_ACTIVE (KBASE_IPA_NR_BYTES_PER_CNT * 26)
4539 #define SC_EXEC_INSTR_FMA (KBASE_IPA_NR_BYTES_PER_CNT * 27)
4640 #define SC_EXEC_INSTR_COUNT (KBASE_IPA_NR_BYTES_PER_CNT * 28)
4741 #define SC_EXEC_INSTR_MSG (KBASE_IPA_NR_BYTES_PER_CNT * 30)
....@@ -49,16 +43,14 @@
4943 #define SC_TEX_COORD_ISSUE (KBASE_IPA_NR_BYTES_PER_CNT * 40)
5044 #define SC_TEX_TFCH_NUM_OPERATIONS (KBASE_IPA_NR_BYTES_PER_CNT * 42)
5145 #define SC_VARY_INSTR (KBASE_IPA_NR_BYTES_PER_CNT * 49)
52
-#define SC_VARY_SLOT_32 (KBASE_IPA_NR_BYTES_PER_CNT * 50)
53
-#define SC_VARY_SLOT_16 (KBASE_IPA_NR_BYTES_PER_CNT * 51)
54
-#define SC_BEATS_RD_LSC (KBASE_IPA_NR_BYTES_PER_CNT * 56)
55
-#define SC_BEATS_WR_LSC (KBASE_IPA_NR_BYTES_PER_CNT * 61)
5646 #define SC_BEATS_WR_TIB (KBASE_IPA_NR_BYTES_PER_CNT * 62)
5747
5848 /**
59
- * get_jm_counter() - get performance counter offset inside the Job Manager block
49
+ * kbase_g7x_power_model_get_jm_counter() - get performance counter offset
50
+ * inside the Job Manager block
6051 * @model_data: pointer to GPU model data.
61
- * @counter_block_offset: offset in bytes of the performance counter inside the Job Manager block.
52
+ * @counter_block_offset: offset in bytes of the performance counter inside
53
+ * the Job Manager block.
6254 *
6355 * Return: Block offset in bytes of the required performance counter.
6456 */
....@@ -69,9 +61,11 @@
6961 }
7062
7163 /**
72
- * get_memsys_counter() - get performance counter offset inside the Memory System block
64
+ * kbase_g7x_power_model_get_memsys_counter() - get performance counter offset
65
+ * inside the Memory System block
7366 * @model_data: pointer to GPU model data.
74
- * @counter_block_offset: offset in bytes of the performance counter inside the (first) Memory System block.
67
+ * @counter_block_offset: offset in bytes of the performance counter inside
68
+ * the (first) Memory System block.
7569 *
7670 * Return: Block offset in bytes of the required performance counter.
7771 */
....@@ -85,47 +79,61 @@
8579 }
8680
8781 /**
88
- * get_sc_counter() - get performance counter offset inside the Shader Cores block
82
+ * kbase_g7x_power_model_get_sc_counter() - get performance counter offset
83
+ * inside the Shader Cores block
8984 * @model_data: pointer to GPU model data.
90
- * @counter_block_offset: offset in bytes of the performance counter inside the (first) Shader Cores block.
85
+ * @counter_block_offset: offset in bytes of the performance counter inside
86
+ * the (first) Shader Cores block.
9187 *
9288 * Return: Block offset in bytes of the required performance counter.
9389 */
9490 static u32 kbase_g7x_power_model_get_sc_counter(struct kbase_ipa_model_vinstr_data *model_data,
9591 u32 counter_block_offset)
9692 {
93
+#if IS_ENABLED(CONFIG_MALI_BIFROST_NO_MALI)
94
+ const u32 sc_base = MEMSYS_BASE +
95
+ (KBASE_DUMMY_MODEL_MAX_MEMSYS_BLOCKS *
96
+ KBASE_IPA_NR_BYTES_PER_BLOCK);
97
+#else
9798 const u32 sc_base = MEMSYS_BASE +
9899 (model_data->kbdev->gpu_props.props.l2_props.num_l2_slices *
99100 KBASE_IPA_NR_BYTES_PER_BLOCK);
101
+#endif
100102 return sc_base + counter_block_offset;
101103 }
102104
103105 /**
104
- * memsys_single_counter() - calculate energy for a single Memory System performance counter.
105
- * @model_data: pointer to GPU model data.
106
- * @coeff: default value of coefficient for IPA group.
107
- * @offset: offset in bytes of the counter inside the block it belongs to.
106
+ * kbase_g7x_sum_all_memsys_blocks() - calculate energy for a single Memory
107
+ * System performance counter.
108
+ * @model_data: pointer to GPU model data.
109
+ * @coeff: default value of coefficient for IPA group.
110
+ * @counter_block_offset: offset in bytes of the counter inside the block it
111
+ * belongs to.
108112 *
109113 * Return: Energy estimation for a single Memory System performance counter.
110114 */
111115 static s64 kbase_g7x_sum_all_memsys_blocks(
112116 struct kbase_ipa_model_vinstr_data *model_data,
113117 s32 coeff,
114
- u32 offset)
118
+ u32 counter_block_offset)
115119 {
116120 u32 counter;
117121
118
- counter = kbase_g7x_power_model_get_memsys_counter(model_data, offset);
122
+ counter = kbase_g7x_power_model_get_memsys_counter(model_data,
123
+ counter_block_offset);
119124 return kbase_ipa_sum_all_memsys_blocks(model_data, coeff, counter);
120125 }
121126
122127 /**
123
- * sum_all_shader_cores() - calculate energy for a Shader Cores performance counter for all cores.
128
+ * kbase_g7x_sum_all_shader_cores() - calculate energy for a Shader Cores
129
+ * performance counter for all cores.
124130 * @model_data: pointer to GPU model data.
125131 * @coeff: default value of coefficient for IPA group.
126
- * @counter_block_offset: offset in bytes of the counter inside the block it belongs to.
132
+ * @counter_block_offset: offset in bytes of the counter inside the block it
133
+ * belongs to.
127134 *
128
- * Return: Energy estimation for a Shader Cores performance counter for all cores.
135
+ * Return: Energy estimation for a Shader Cores performance counter for all
136
+ * cores.
129137 */
130138 static s64 kbase_g7x_sum_all_shader_cores(
131139 struct kbase_ipa_model_vinstr_data *model_data,
....@@ -140,7 +148,7 @@
140148 }
141149
142150 /**
143
- * jm_single_counter() - calculate energy for a single Job Manager performance counter.
151
+ * kbase_g7x_jm_single_counter() - calculate energy for a single Job Manager performance counter.
144152 * @model_data: pointer to GPU model data.
145153 * @coeff: default value of coefficient for IPA group.
146154 * @counter_block_offset: offset in bytes of the counter inside the block it belongs to.
....@@ -160,7 +168,7 @@
160168 }
161169
162170 /**
163
- * get_active_cycles() - return the GPU_ACTIVE counter
171
+ * kbase_g7x_get_active_cycles() - return the GPU_ACTIVE counter
164172 * @model_data: pointer to GPU model data.
165173 *
166174 * Return: the number of cycles the GPU was active during the counter sampling
....@@ -447,16 +455,14 @@
447455 },
448456 };
449457
450
-
451
-#define IPA_POWER_MODEL_OPS(gpu, init_token) \
452
- const struct kbase_ipa_model_ops kbase_ ## gpu ## _ipa_model_ops = { \
453
- .name = "mali-" #gpu "-power-model", \
454
- .init = kbase_ ## init_token ## _power_model_init, \
455
- .term = kbase_ipa_vinstr_common_model_term, \
456
- .get_dynamic_coeff = kbase_ipa_vinstr_dynamic_coeff, \
457
- .reset_counter_data = kbase_ipa_vinstr_reset_data, \
458
- }; \
459
- KBASE_EXPORT_TEST_API(kbase_ ## gpu ## _ipa_model_ops)
458
+#define IPA_POWER_MODEL_OPS(gpu, init_token) \
459
+ static const struct kbase_ipa_model_ops kbase_##gpu##_ipa_model_ops = { \
460
+ .name = "mali-" #gpu "-power-model", \
461
+ .init = kbase_##init_token##_power_model_init, \
462
+ .term = kbase_ipa_vinstr_common_model_term, \
463
+ .get_dynamic_coeff = kbase_ipa_vinstr_dynamic_coeff, \
464
+ .reset_counter_data = kbase_ipa_vinstr_reset_data, \
465
+ }
460466
461467 #define STANDARD_POWER_MODEL(gpu, reference_voltage) \
462468 static int kbase_ ## gpu ## _power_model_init(\
....@@ -522,8 +528,8 @@
522528
523529 const char *kbase_ipa_counter_model_name_from_id(u32 gpu_id)
524530 {
525
- const u32 prod_id = (gpu_id & GPU_ID_VERSION_PRODUCT_ID) >>
526
- GPU_ID_VERSION_PRODUCT_ID_SHIFT;
531
+ const u32 prod_id =
532
+ (gpu_id & GPU_ID_VERSION_PRODUCT_ID) >> KBASE_GPU_ID_VERSION_PRODUCT_ID_SHIFT;
527533
528534 switch (GPU_ID2_MODEL_MATCH_VALUE(prod_id)) {
529535 case GPU_ID2_PRODUCT_TMIX: