hc
2023-12-06 08f87f769b595151be1afeff53e144f543faa614
kernel/drivers/gpu/arm/bifrost/mali_kbase_fence_ops.c
....@@ -1,7 +1,7 @@
11 // SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note
22 /*
33 *
4
- * (C) COPYRIGHT 2020-2021 ARM Limited. All rights reserved.
4
+ * (C) COPYRIGHT 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
....@@ -21,7 +21,7 @@
2121
2222 #include <linux/atomic.h>
2323 #include <linux/list.h>
24
-#include <mali_kbase_fence_defs.h>
24
+#include <mali_kbase_fence.h>
2525 #include <mali_kbase.h>
2626
2727 static const char *
....@@ -41,7 +41,13 @@
4141 kbase_fence_get_timeline_name(struct dma_fence *fence)
4242 #endif
4343 {
44
+#if MALI_USE_CSF
45
+ struct kbase_kcpu_dma_fence *kcpu_fence = (struct kbase_kcpu_dma_fence *)fence;
46
+
47
+ return kcpu_fence->metadata->timeline_name;
48
+#else
4449 return kbase_timeline_name;
50
+#endif /* MALI_USE_CSF */
4551 }
4652
4753 static bool
....@@ -62,22 +68,44 @@
6268 #endif
6369 {
6470 #if (KERNEL_VERSION(5, 1, 0) > LINUX_VERSION_CODE)
65
- snprintf(str, size, "%u", fence->seqno);
71
+ const char *format = "%u";
6672 #else
67
- snprintf(str, size, "%llu", fence->seqno);
73
+ const char *format = "%llu";
6874 #endif
75
+ if (unlikely(!scnprintf(str, size, format, fence->seqno)))
76
+ pr_err("Fail to encode fence seqno to string");
6977 }
7078
79
+#if MALI_USE_CSF
80
+static void
7181 #if (KERNEL_VERSION(4, 10, 0) > LINUX_VERSION_CODE)
72
-const struct fence_ops kbase_fence_ops = {
73
- .wait = fence_default_wait,
82
+kbase_fence_release(struct fence *fence)
7483 #else
75
-const struct dma_fence_ops kbase_fence_ops = {
76
- .wait = dma_fence_default_wait,
84
+kbase_fence_release(struct dma_fence *fence)
7785 #endif
78
- .get_driver_name = kbase_fence_get_driver_name,
79
- .get_timeline_name = kbase_fence_get_timeline_name,
80
- .enable_signaling = kbase_fence_enable_signaling,
81
- .fence_value_str = kbase_fence_fence_value_str
82
-};
86
+{
87
+ struct kbase_kcpu_dma_fence *kcpu_fence = (struct kbase_kcpu_dma_fence *)fence;
8388
89
+ kbase_kcpu_dma_fence_meta_put(kcpu_fence->metadata);
90
+ kfree(kcpu_fence);
91
+}
92
+#endif
93
+
94
+#if (KERNEL_VERSION(4, 10, 0) > LINUX_VERSION_CODE)
95
+extern const struct fence_ops kbase_fence_ops; /* silence checker warning */
96
+const struct fence_ops kbase_fence_ops = { .wait = fence_default_wait,
97
+#else
98
+extern const struct dma_fence_ops kbase_fence_ops; /* silence checker warning */
99
+const struct dma_fence_ops kbase_fence_ops = { .wait = dma_fence_default_wait,
100
+#endif
101
+ .get_driver_name = kbase_fence_get_driver_name,
102
+ .get_timeline_name = kbase_fence_get_timeline_name,
103
+ .enable_signaling = kbase_fence_enable_signaling,
104
+#if MALI_USE_CSF
105
+ .fence_value_str = kbase_fence_fence_value_str,
106
+ .release = kbase_fence_release
107
+#else
108
+ .fence_value_str = kbase_fence_fence_value_str
109
+#endif
110
+};
111
+KBASE_EXPORT_TEST_API(kbase_fence_ops);