hc
2023-12-06 08f87f769b595151be1afeff53e144f543faa614
kernel/drivers/gpu/arm/bifrost/ipa/mali_kbase_ipa_simple.c
....@@ -1,7 +1,7 @@
11 // SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note
22 /*
33 *
4
- * (C) COPYRIGHT 2016-2018, 2020-2021 ARM Limited. All rights reserved.
4
+ * (C) COPYRIGHT 2016-2018, 2020-2022 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
....@@ -34,6 +34,8 @@
3434 #include "mali_kbase_ipa_simple.h"
3535 #include "mali_kbase_ipa_debugfs.h"
3636
37
+#if MALI_USE_CSF
38
+
3739 /* This is used if the dynamic power for top-level is estimated separately
3840 * through the counter model. To roughly match the contribution of top-level
3941 * power in the total dynamic power, when calculated through counter model,
....@@ -43,6 +45,8 @@
4345 * core power and then averaging it across all samples.
4446 */
4547 #define TOP_LEVEL_DYN_COEFF_SCALER (3)
48
+
49
+#endif /* MALI_USE_CSF */
4650
4751 #if MALI_UNIT_TEST
4852
....@@ -232,14 +236,12 @@
232236 (struct kbase_ipa_model_simple_data *)model->model_data;
233237
234238 err = kbase_ipa_model_add_param_s32(model, "static-coefficient",
235
- &model_data->static_coefficient,
236
- 1, true);
239
+ (s32 *)&model_data->static_coefficient, 1, true);
237240 if (err)
238241 goto end;
239242
240243 err = kbase_ipa_model_add_param_s32(model, "dynamic-coefficient",
241
- &model_data->dynamic_coefficient,
242
- 1, true);
244
+ (s32 *)&model_data->dynamic_coefficient, 1, true);
243245 if (err)
244246 goto end;
245247
....@@ -307,8 +309,12 @@
307309 model_data->gpu_tz = NULL;
308310 } else {
309311 char tz_name[THERMAL_NAME_LENGTH];
312
+ u32 string_len = strscpy(tz_name, model_data->tz_name, sizeof(tz_name));
310313
311
- strlcpy(tz_name, model_data->tz_name, sizeof(tz_name));
314
+ string_len += sizeof(char);
315
+ /* Make sure that the source string fit into the buffer. */
316
+ KBASE_DEBUG_ASSERT(string_len <= sizeof(tz_name));
317
+ CSTD_UNUSED(string_len);
312318
313319 /* Release ipa.lock so that thermal_list_lock is not acquired
314320 * with ipa.lock held, thereby avoid lock ordering violation
....@@ -322,8 +328,9 @@
322328 mutex_lock(&model->kbdev->ipa.lock);
323329
324330 if (IS_ERR_OR_NULL(tz)) {
325
- pr_warn_ratelimited("Error %ld getting thermal zone \'%s\', not yet ready?\n",
326
- PTR_ERR(tz), tz_name);
331
+ pr_warn_ratelimited(
332
+ "Error %d getting thermal zone \'%s\', not yet ready?\n",
333
+ PTR_ERR_OR_ZERO(tz), tz_name);
327334 return -EPROBE_DEFER;
328335 }
329336