hc
2024-05-16 8d2a02b24d66aa359e83eebc1ed3c0f85367a1cb
kernel/drivers/gpu/arm/bifrost/csf/mali_kbase_csf_tiler_heap_debugfs.c
....@@ -32,7 +32,7 @@
3232 * @file: The seq_file for printing to
3333 * @data: The debugfs dentry private data, a pointer to kbase_context
3434 *
35
- * Return: Negative error code or 0 on success.
35
+ * Return: 0 in any case.
3636 */
3737 static int kbasep_csf_tiler_heap_debugfs_show(struct seq_file *file, void *data)
3838 {
....@@ -65,13 +65,50 @@
6565 return 0;
6666 }
6767
68
+/**
69
+ * kbasep_csf_tiler_heap_total_debugfs_show() - Print the total memory allocated
70
+ * for all tiler heaps in a context.
71
+ *
72
+ * @file: The seq_file for printing to
73
+ * @data: The debugfs dentry private data, a pointer to kbase_context
74
+ *
75
+ * Return: 0 in any case.
76
+ */
77
+static int kbasep_csf_tiler_heap_total_debugfs_show(struct seq_file *file, void *data)
78
+{
79
+ struct kbase_context *kctx = file->private;
80
+
81
+ seq_printf(file, "MALI_CSF_TILER_HEAP_DEBUGFS_VERSION: v%u\n",
82
+ MALI_CSF_TILER_HEAP_DEBUGFS_VERSION);
83
+ seq_printf(file, "Total number of chunks of all heaps in the context: %lu\n",
84
+ (unsigned long)kctx->running_total_tiler_heap_nr_chunks);
85
+ seq_printf(file, "Total allocated memory of all heaps in the context: %llu\n",
86
+ (unsigned long long)kctx->running_total_tiler_heap_memory);
87
+ seq_printf(file, "Peak allocated tiler heap memory in the context: %llu\n",
88
+ (unsigned long long)kctx->peak_total_tiler_heap_memory);
89
+
90
+ return 0;
91
+}
92
+
6893 static int kbasep_csf_tiler_heap_debugfs_open(struct inode *in, struct file *file)
6994 {
7095 return single_open(file, kbasep_csf_tiler_heap_debugfs_show, in->i_private);
7196 }
7297
98
+static int kbasep_csf_tiler_heap_total_debugfs_open(struct inode *in, struct file *file)
99
+{
100
+ return single_open(file, kbasep_csf_tiler_heap_total_debugfs_show, in->i_private);
101
+}
102
+
73103 static const struct file_operations kbasep_csf_tiler_heap_debugfs_fops = {
74104 .open = kbasep_csf_tiler_heap_debugfs_open,
105
+ .read = seq_read,
106
+ .llseek = seq_lseek,
107
+ .release = single_release,
108
+};
109
+
110
+static const struct file_operations kbasep_csf_tiler_heap_total_debugfs_fops = {
111
+ .open = kbasep_csf_tiler_heap_total_debugfs_open,
75112 .read = seq_read,
76113 .llseek = seq_lseek,
77114 .release = single_release,
....@@ -93,6 +130,21 @@
93130 }
94131 }
95132
133
+void kbase_csf_tiler_heap_total_debugfs_init(struct kbase_context *kctx)
134
+{
135
+ struct dentry *file;
136
+
137
+ if (WARN_ON(!kctx || IS_ERR_OR_NULL(kctx->kctx_dentry)))
138
+ return;
139
+
140
+ file = debugfs_create_file("tiler_heaps_total", 0444, kctx->kctx_dentry,
141
+ kctx, &kbasep_csf_tiler_heap_total_debugfs_fops);
142
+
143
+ if (IS_ERR_OR_NULL(file)) {
144
+ dev_warn(kctx->kbdev->dev,
145
+ "Unable to create total tiler heap allocated memory debugfs entry");
146
+ }
147
+}
96148
97149 #else
98150 /*
....@@ -102,5 +154,9 @@
102154 {
103155 }
104156
157
+void kbase_csf_tiler_heap_total_debugfs_init(struct kbase_context *kctx)
158
+{
159
+}
160
+
105161 #endif /* CONFIG_DEBUG_FS */
106162