hc
2024-05-10 9999e48639b3cecb08ffb37358bcba3b48161b29
kernel/drivers/gpu/drm/etnaviv/etnaviv_dump.c
....@@ -4,6 +4,8 @@
44 */
55
66 #include <linux/devcoredump.h>
7
+#include <linux/moduleparam.h>
8
+
79 #include "etnaviv_cmdbuf.h"
810 #include "etnaviv_dump.h"
911 #include "etnaviv_gem.h"
....@@ -91,9 +93,9 @@
9193 }
9294
9395 static void etnaviv_core_dump_mmu(struct core_dump_iterator *iter,
94
- struct etnaviv_gpu *gpu, size_t mmu_size)
96
+ struct etnaviv_iommu_context *mmu, size_t mmu_size)
9597 {
96
- etnaviv_iommu_dump(gpu->mmu, iter->data);
98
+ etnaviv_iommu_dump(mmu, iter->data);
9799
98100 etnaviv_core_dump_header(iter, ETDUMP_BUF_MMU, iter->data + mmu_size);
99101 }
....@@ -108,48 +110,35 @@
108110 etnaviv_core_dump_header(iter, type, iter->data + size);
109111 }
110112
111
-void etnaviv_core_dump(struct etnaviv_gpu *gpu)
113
+void etnaviv_core_dump(struct etnaviv_gem_submit *submit)
112114 {
115
+ struct etnaviv_gpu *gpu = submit->gpu;
113116 struct core_dump_iterator iter;
114
- struct etnaviv_vram_mapping *vram;
115117 struct etnaviv_gem_object *obj;
116
- struct etnaviv_gem_submit *submit;
117
- struct drm_sched_job *s_job;
118118 unsigned int n_obj, n_bomap_pages;
119119 size_t file_size, mmu_size;
120120 __le64 *bomap, *bomap_start;
121
+ int i;
121122
122123 /* Only catch the first event, or when manually re-armed */
123124 if (!etnaviv_dump_core)
124125 return;
125126 etnaviv_dump_core = false;
126127
127
- mutex_lock(&gpu->mmu->lock);
128
+ mutex_lock(&submit->mmu_context->lock);
128129
129
- mmu_size = etnaviv_iommu_dump_size(gpu->mmu);
130
+ mmu_size = etnaviv_iommu_dump_size(submit->mmu_context);
130131
131
- /* We always dump registers, mmu, ring and end marker */
132
- n_obj = 4;
132
+ /* We always dump registers, mmu, ring, hanging cmdbuf and end marker */
133
+ n_obj = 5;
133134 n_bomap_pages = 0;
134135 file_size = ARRAY_SIZE(etnaviv_dump_registers) *
135136 sizeof(struct etnaviv_dump_registers) +
136
- mmu_size + gpu->buffer.size;
137
-
138
- /* Add in the active command buffers */
139
- spin_lock(&gpu->sched.job_list_lock);
140
- list_for_each_entry(s_job, &gpu->sched.ring_mirror_list, node) {
141
- submit = to_etnaviv_submit(s_job);
142
- file_size += submit->cmdbuf.size;
143
- n_obj++;
144
- }
145
- spin_unlock(&gpu->sched.job_list_lock);
137
+ mmu_size + gpu->buffer.size + submit->cmdbuf.size;
146138
147139 /* Add in the active buffer objects */
148
- list_for_each_entry(vram, &gpu->mmu->mappings, mmu_node) {
149
- if (!vram->use)
150
- continue;
151
-
152
- obj = vram->object;
140
+ for (i = 0; i < submit->nr_bos; i++) {
141
+ obj = submit->bos[i].obj;
153142 file_size += obj->base.size;
154143 n_bomap_pages += obj->base.size >> PAGE_SHIFT;
155144 n_obj++;
....@@ -165,10 +154,10 @@
165154 file_size += sizeof(*iter.hdr) * n_obj;
166155
167156 /* Allocate the file in vmalloc memory, it's likely to be big */
168
- iter.start = __vmalloc(file_size, GFP_KERNEL | __GFP_NOWARN | __GFP_NORETRY,
169
- PAGE_KERNEL);
157
+ iter.start = __vmalloc(file_size, GFP_KERNEL | __GFP_NOWARN |
158
+ __GFP_NORETRY);
170159 if (!iter.start) {
171
- mutex_unlock(&gpu->mmu->lock);
160
+ mutex_unlock(&submit->mmu_context->lock);
172161 dev_warn(gpu->dev, "failed to allocate devcoredump file\n");
173162 return;
174163 }
....@@ -180,19 +169,18 @@
180169 memset(iter.hdr, 0, iter.data - iter.start);
181170
182171 etnaviv_core_dump_registers(&iter, gpu);
183
- etnaviv_core_dump_mmu(&iter, gpu, mmu_size);
172
+ etnaviv_core_dump_mmu(&iter, submit->mmu_context, mmu_size);
184173 etnaviv_core_dump_mem(&iter, ETDUMP_BUF_RING, gpu->buffer.vaddr,
185174 gpu->buffer.size,
186
- etnaviv_cmdbuf_get_va(&gpu->buffer));
175
+ etnaviv_cmdbuf_get_va(&gpu->buffer,
176
+ &submit->mmu_context->cmdbuf_mapping));
187177
188
- spin_lock(&gpu->sched.job_list_lock);
189
- list_for_each_entry(s_job, &gpu->sched.ring_mirror_list, node) {
190
- submit = to_etnaviv_submit(s_job);
191
- etnaviv_core_dump_mem(&iter, ETDUMP_BUF_CMD,
192
- submit->cmdbuf.vaddr, submit->cmdbuf.size,
193
- etnaviv_cmdbuf_get_va(&submit->cmdbuf));
194
- }
195
- spin_unlock(&gpu->sched.job_list_lock);
178
+ etnaviv_core_dump_mem(&iter, ETDUMP_BUF_CMD,
179
+ submit->cmdbuf.vaddr, submit->cmdbuf.size,
180
+ etnaviv_cmdbuf_get_va(&submit->cmdbuf,
181
+ &submit->mmu_context->cmdbuf_mapping));
182
+
183
+ mutex_unlock(&submit->mmu_context->lock);
196184
197185 /* Reserve space for the bomap */
198186 if (n_bomap_pages) {
....@@ -205,14 +193,13 @@
205193 bomap_start = bomap = NULL;
206194 }
207195
208
- list_for_each_entry(vram, &gpu->mmu->mappings, mmu_node) {
196
+ for (i = 0; i < submit->nr_bos; i++) {
197
+ struct etnaviv_vram_mapping *vram;
209198 struct page **pages;
210199 void *vaddr;
211200
212
- if (vram->use == 0)
213
- continue;
214
-
215
- obj = vram->object;
201
+ obj = submit->bos[i].obj;
202
+ vram = submit->bos[i].mapping;
216203
217204 mutex_lock(&obj->lock);
218205 pages = etnaviv_gem_get_pages(obj);
....@@ -235,8 +222,6 @@
235222 etnaviv_core_dump_header(&iter, ETDUMP_BUF_BO, iter.data +
236223 obj->base.size);
237224 }
238
-
239
- mutex_unlock(&gpu->mmu->lock);
240225
241226 etnaviv_core_dump_header(&iter, ETDUMP_BUF_END, iter.data);
242227