hc
2023-12-06 08f87f769b595151be1afeff53e144f543faa614
kernel/drivers/gpu/arm/bifrost/backend/gpu/mali_kbase_cache_policy_backend.c
....@@ -1,7 +1,7 @@
11 // SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note
22 /*
33 *
4
- * (C) COPYRIGHT 2014-2016, 2018, 2020-2021 ARM Limited. All rights reserved.
4
+ * (C) COPYRIGHT 2014-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
....@@ -22,12 +22,71 @@
2222 #include "backend/gpu/mali_kbase_cache_policy_backend.h"
2323 #include <device/mali_kbase_device.h>
2424
25
+/**
26
+ * kbasep_amba_register_present() - Check AMBA_<> register is present
27
+ * in the GPU.
28
+ * @kbdev: Device pointer
29
+ *
30
+ * Note: Only for arch version 12.x.1 onwards.
31
+ *
32
+ * Return: true if AMBA_FEATURES/ENABLE registers are present.
33
+ */
34
+static bool kbasep_amba_register_present(struct kbase_device *kbdev)
35
+{
36
+ return (ARCH_MAJOR_REV_REG(kbdev->gpu_props.props.raw_props.gpu_id) >=
37
+ GPU_ID2_ARCH_MAJOR_REV_MAKE(12, 1));
38
+}
39
+
2540 void kbase_cache_set_coherency_mode(struct kbase_device *kbdev,
2641 u32 mode)
2742 {
2843 kbdev->current_gpu_coherency_mode = mode;
2944
30
- if (kbase_hw_has_feature(kbdev, BASE_HW_FEATURE_COHERENCY_REG))
45
+ if (kbasep_amba_register_present(kbdev)) {
46
+ u32 val = kbase_reg_read(kbdev, AMBA_ENABLE);
47
+
48
+ val = AMBA_ENABLE_COHERENCY_PROTOCOL_SET(val, mode);
49
+ kbase_reg_write(kbdev, AMBA_ENABLE, val);
50
+ } else
3151 kbase_reg_write(kbdev, COHERENCY_ENABLE, mode);
3252 }
3353
54
+u32 kbase_cache_get_coherency_features(struct kbase_device *kbdev)
55
+{
56
+ u32 coherency_features;
57
+
58
+ if (kbasep_amba_register_present(kbdev))
59
+ coherency_features =
60
+ kbase_reg_read(kbdev, GPU_CONTROL_REG(AMBA_FEATURES));
61
+ else
62
+ coherency_features = kbase_reg_read(
63
+ kbdev, GPU_CONTROL_REG(COHERENCY_FEATURES));
64
+
65
+ return coherency_features;
66
+}
67
+
68
+void kbase_amba_set_memory_cache_support(struct kbase_device *kbdev,
69
+ bool enable)
70
+{
71
+ if (kbasep_amba_register_present(kbdev)) {
72
+ u32 val = kbase_reg_read(kbdev, AMBA_ENABLE);
73
+
74
+ val = AMBA_ENABLE_MEMORY_CACHE_SUPPORT_SET(val, enable);
75
+ kbase_reg_write(kbdev, AMBA_ENABLE, val);
76
+
77
+ } else {
78
+ WARN(1, "memory_cache_support not supported");
79
+ }
80
+}
81
+
82
+void kbase_amba_set_invalidate_hint(struct kbase_device *kbdev, bool enable)
83
+{
84
+ if (kbasep_amba_register_present(kbdev)) {
85
+ u32 val = kbase_reg_read(kbdev, AMBA_ENABLE);
86
+
87
+ val = AMBA_ENABLE_INVALIDATE_HINT_SET(val, enable);
88
+ kbase_reg_write(kbdev, AMBA_ENABLE, val);
89
+ } else {
90
+ WARN(1, "invalidate_hint not supported");
91
+ }
92
+}