panfrost: Pipe the GPU ID into compiler and disassembler
authorTomeu Vizoso <tomeu.vizoso@collabora.com>
Thu, 7 Nov 2019 07:27:53 +0000 (08:27 +0100)
committerTomeu Vizoso <tomeu.vizoso@collabora.co.uk>
Thu, 7 Nov 2019 08:48:45 +0000 (08:48 +0000)
Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
src/gallium/drivers/panfrost/pan_assemble.c
src/gallium/drivers/panfrost/pan_blend_shaders.c
src/gallium/drivers/panfrost/pan_job.c
src/panfrost/midgard/compiler.h
src/panfrost/midgard/disassemble.c
src/panfrost/midgard/disassemble.h
src/panfrost/midgard/midgard_compile.c
src/panfrost/midgard/midgard_compile.h
src/panfrost/pandecode/decode.c
src/panfrost/pandecode/public.h

index 2d1d1d172aada82586317abb47d8b23564d6ccdb..5a36465500ecb1212a59696f5a3db0ef1d5b31e0 100644 (file)
@@ -65,7 +65,7 @@ panfrost_shader_compile(
                 .alpha_ref = state->alpha_state.ref_value
         };
 
-        midgard_compile_shader_nir(&ctx->compiler, s, &program, false);
+        midgard_compile_shader_nir(&ctx->compiler, s, &program, false, screen->gpu_id);
 
         /* Prepare the compiled binary for upload */
         int size = program.compiled.size;
index 2ee86b4e7db3c3af1630c6e462941d266b9372f6..223925c2ebb9332cf4d5719f49082f2e2517b0f1 100644 (file)
@@ -131,6 +131,7 @@ panfrost_compile_blend_shader(
         struct pipe_blend_state *cso,
         enum pipe_format format)
 {
+        struct panfrost_screen *screen = pan_screen(ctx->base.screen);
         struct panfrost_blend_shader res;
 
         res.ctx = ctx;
@@ -172,7 +173,7 @@ panfrost_compile_blend_shader(
         /* Compile the built shader */
 
         midgard_program program;
-        midgard_compile_shader_nir(&ctx->compiler, shader, &program, true);
+        midgard_compile_shader_nir(&ctx->compiler, shader, &program, true, screen->gpu_id);
 
         /* At least two work registers are needed due to an encoding quirk */
         res.work_count = MAX2(program.work_register_count, 2);
index 8df3480697dd9f57bb2e88d94ec0ebc6e6221766..a0bc999f1ae9c114fa2bfaa03a175d23013b44c1 100644 (file)
@@ -881,7 +881,7 @@ panfrost_batch_submit_ioctl(struct panfrost_batch *batch,
                 /* Wait so we can get errors reported back */
                 drmSyncobjWait(screen->fd, &batch->out_sync->syncobj, 1,
                                INT64_MAX, 0, NULL);
-                pandecode_jc(submit.jc, FALSE);
+                pandecode_jc(submit.jc, FALSE, screen->gpu_id);
         }
 
         return 0;
index e77344f0ff005d9d12abe75f9e0d21310d22b170..498404c0d15dd14a33b2abf4f156784b4aa2bf4f 100644 (file)
@@ -292,6 +292,8 @@ typedef struct compiler_context {
 
         /* Bitmask of valid metadata */
         unsigned metadata;
+
+        unsigned gpu_id;
 } compiler_context;
 
 /* Per-block live_in/live_out */
index df75730a5f906b4dd4af0a999ad9fa375a56309b..24c78c357c370543fd105cfb24aaed8b566aef60 100644 (file)
@@ -1455,7 +1455,7 @@ print_texture_word(uint32_t *word, unsigned tabs)
 }
 
 struct midgard_disasm_stats
-disassemble_midgard(uint8_t *code, size_t size)
+disassemble_midgard(uint8_t *code, size_t size, unsigned gpu_id)
 {
         uint32_t *words = (uint32_t *) code;
         unsigned num_words = size / 4;
index fc39875007a8708bf36405db2c8760625734d73f..4d685323bae9de2afe8ecf43c9be062d88b9be0b 100644 (file)
@@ -23,4 +23,4 @@ struct midgard_disasm_stats {
 };
 
 struct midgard_disasm_stats
-disassemble_midgard(uint8_t *code, size_t size);
+disassemble_midgard(uint8_t *code, size_t size, unsigned gpu_id);
index 22c0d44c759511e7d46735228e2d11fa19265e5f..5f369f9a2ef3f7916f1281d124403053e14a2713 100644 (file)
@@ -2372,7 +2372,7 @@ midgard_get_first_tag_from_block(compiler_context *ctx, unsigned block_idx)
 }
 
 int
-midgard_compile_shader_nir(struct midgard_screen *screen, nir_shader *nir, midgard_program *program, bool is_blend)
+midgard_compile_shader_nir(struct midgard_screen *screen, nir_shader *nir, midgard_program *program, bool is_blend, unsigned gpu_id)
 {
         struct util_dynarray *compiled = &program->compiled;
 
@@ -2386,6 +2386,7 @@ midgard_compile_shader_nir(struct midgard_screen *screen, nir_shader *nir, midga
         ctx->stage = nir->info.stage;
         ctx->is_blend = is_blend;
         ctx->alpha_ref = program->alpha_ref;
+        ctx->gpu_id = gpu_id;
 
         /* Start off with a safe cutoff, allowing usage of all 16 work
          * registers. Later, we'll promote uniform reads to uniform registers
@@ -2696,7 +2697,7 @@ midgard_compile_shader_nir(struct midgard_screen *screen, nir_shader *nir, midga
         program->tls_size = ctx->tls_size;
 
         if (midgard_debug & MIDGARD_DBG_SHADERS)
-                disassemble_midgard(program->compiled.data, program->compiled.size);
+                disassemble_midgard(program->compiled.data, program->compiled.size, gpu_id);
 
         if (midgard_debug & MIDGARD_DBG_SHADERDB) {
                 unsigned nr_bundles = 0, nr_ins = 0;
index bf512a0ca5930457a8e0e1393632542ab331ec92..2e6e44913a8b0753d3238bb5fbc664b3f8cc4e23 100644 (file)
@@ -111,7 +111,7 @@ typedef struct {
 } midgard_program;
 
 int
-midgard_compile_shader_nir(struct midgard_screen *screen, nir_shader *nir, midgard_program *program, bool is_blend);
+midgard_compile_shader_nir(struct midgard_screen *screen, nir_shader *nir, midgard_program *program, bool is_blend, unsigned gpu_id);
 
 /* NIR options are shared between the standalone compiler and the online
  * compiler. Defining it here is the simplest, though maybe not the Right
index ebe1967fbf8715fcf4b3350b430a42f1b7548d32..0de1f7c7043da68cc1946399f1d5f92b75d6c3df 100644 (file)
@@ -40,8 +40,6 @@
 
 #include "pan_encoder.h"
 
-int pandecode_jc(mali_ptr jc_gpu_va, bool bifrost);
-
 static void pandecode_swizzle(unsigned swizzle, enum mali_format format);
 
 #define MEMORY_PROP(obj, p) {\
@@ -1830,7 +1828,7 @@ static unsigned shader_id = 0;
 
 static struct midgard_disasm_stats
 pandecode_shader_disassemble(mali_ptr shader_ptr, int shader_no, int type,
-                             bool is_bifrost)
+                             bool is_bifrost, unsigned gpu_id)
 {
         struct pandecode_mapped_memory *mem = pandecode_find_mapped_gpu_mem_containing(shader_ptr);
         uint8_t *PANDECODE_PTR_VAR(code, mem, shader_ptr);
@@ -1862,7 +1860,7 @@ pandecode_shader_disassemble(mali_ptr shader_ptr, int shader_no, int type,
                 stats.quadword_count = 0;
                 stats.helper_invocations = false;
         } else {
-                stats = disassemble_midgard(code, sz);
+                stats = disassemble_midgard(code, sz, gpu_id);
         }
 
         /* Print shader-db stats */
@@ -2070,10 +2068,10 @@ pandecode_shader_prop(const char *name, unsigned claim, signed truth, bool fuzzy
 
 static void
 pandecode_blend_shader_disassemble(mali_ptr shader, int job_no, int job_type,
-                                   bool is_bifrost)
+                                   bool is_bifrost, unsigned gpu_id)
 {
         struct midgard_disasm_stats stats =
-                pandecode_shader_disassemble(shader, job_no, job_type, is_bifrost);
+                pandecode_shader_disassemble(shader, job_no, job_type, is_bifrost, gpu_id);
 
         bool has_texture = (stats.texture_count > 0);
         bool has_sampler = (stats.sampler_count > 0);
@@ -2096,7 +2094,7 @@ static void
 pandecode_vertex_tiler_postfix_pre(
                 const struct mali_vertex_tiler_postfix *p,
                 int job_no, enum mali_job_type job_type,
-                char *suffix, bool is_bifrost)
+                char *suffix, bool is_bifrost, unsigned gpu_id)
 {
         struct pandecode_mapped_memory *attr_mem;
 
@@ -2143,7 +2141,7 @@ pandecode_vertex_tiler_postfix_pre(
                 };
 
                 if (s->shader & ~0xF)
-                        info = pandecode_shader_disassemble(s->shader & ~0xF, job_no, job_type, is_bifrost);
+                        info = pandecode_shader_disassemble(s->shader & ~0xF, job_no, job_type, is_bifrost, gpu_id);
 
                 pandecode_log("struct mali_shader_meta shader_meta_%"PRIx64"_%d%s = {\n", p->shader, job_no, suffix);
                 pandecode_indent++;
@@ -2272,7 +2270,7 @@ pandecode_vertex_tiler_postfix_pre(
                         union midgard_blend blend = s->blend;
                         mali_ptr shader = pandecode_midgard_blend(&blend, s->unknown2_3 & MALI_HAS_BLEND_SHADER);
                         if (shader & ~0xF)
-                                pandecode_blend_shader_disassemble(shader, job_no, job_type, false);
+                                pandecode_blend_shader_disassemble(shader, job_no, job_type, false, gpu_id);
                 }
 
                 pandecode_indent--;
@@ -2293,7 +2291,7 @@ pandecode_vertex_tiler_postfix_pre(
                                         shader = pandecode_midgard_blend_mrt(blend_base, job_no, i);
 
                                 if (shader & ~0xF)
-                                        pandecode_blend_shader_disassemble(shader, job_no, job_type, false);
+                                        pandecode_blend_shader_disassemble(shader, job_no, job_type, false, gpu_id);
 
                         }
                 }
@@ -2622,11 +2620,11 @@ pandecode_tiler_only_bfr(const struct bifrost_tiler_only *t, int job_no)
 static int
 pandecode_vertex_job_bfr(const struct mali_job_descriptor_header *h,
                                 const struct pandecode_mapped_memory *mem,
-                                mali_ptr payload, int job_no)
+                                mali_ptr payload, int job_no, unsigned gpu_id)
 {
         struct bifrost_payload_vertex *PANDECODE_PTR_VAR(v, mem, payload);
 
-        pandecode_vertex_tiler_postfix_pre(&v->postfix, job_no, h->job_type, "", true);
+        pandecode_vertex_tiler_postfix_pre(&v->postfix, job_no, h->job_type, "", true, gpu_id);
 
         pandecode_log("struct bifrost_payload_vertex payload_%d = {\n", job_no);
         pandecode_indent++;
@@ -2648,11 +2646,11 @@ pandecode_vertex_job_bfr(const struct mali_job_descriptor_header *h,
 static int
 pandecode_tiler_job_bfr(const struct mali_job_descriptor_header *h,
                                const struct pandecode_mapped_memory *mem,
-                               mali_ptr payload, int job_no)
+                               mali_ptr payload, int job_no, unsigned gpu_id)
 {
         struct bifrost_payload_tiler *PANDECODE_PTR_VAR(t, mem, payload);
 
-        pandecode_vertex_tiler_postfix_pre(&t->postfix, job_no, h->job_type, "", true);
+        pandecode_vertex_tiler_postfix_pre(&t->postfix, job_no, h->job_type, "", true, gpu_id);
         pandecode_tiler_meta(t->tiler.tiler_meta, job_no);
 
         pandecode_log("struct bifrost_payload_tiler payload_%d = {\n", job_no);
@@ -2675,11 +2673,11 @@ pandecode_tiler_job_bfr(const struct mali_job_descriptor_header *h,
 static int
 pandecode_vertex_or_tiler_job_mdg(const struct mali_job_descriptor_header *h,
                 const struct pandecode_mapped_memory *mem,
-                mali_ptr payload, int job_no)
+                mali_ptr payload, int job_no, unsigned gpu_id)
 {
         struct midgard_payload_vertex_tiler *PANDECODE_PTR_VAR(v, mem, payload);
 
-        pandecode_vertex_tiler_postfix_pre(&v->postfix, job_no, h->job_type, "", false);
+        pandecode_vertex_tiler_postfix_pre(&v->postfix, job_no, h->job_type, "", false, gpu_id);
 
         pandecode_log("struct midgard_payload_vertex_tiler payload_%d = {\n", job_no);
         pandecode_indent++;
@@ -2815,7 +2813,7 @@ pandecode_fragment_job(const struct pandecode_mapped_memory *mem,
 static int job_descriptor_number = 0;
 
 int
-pandecode_jc(mali_ptr jc_gpu_va, bool bifrost)
+pandecode_jc(mali_ptr jc_gpu_va, bool bifrost, unsigned gpu_id)
 {
         struct mali_job_descriptor_header *h;
 
@@ -2912,11 +2910,11 @@ pandecode_jc(mali_ptr jc_gpu_va, bool bifrost)
                 case JOB_TYPE_COMPUTE:
                         if (bifrost) {
                                 if (h->job_type == JOB_TYPE_TILER)
-                                        pandecode_tiler_job_bfr(h, mem, payload_ptr, job_no);
+                                        pandecode_tiler_job_bfr(h, mem, payload_ptr, job_no, gpu_id);
                                 else
-                                        pandecode_vertex_job_bfr(h, mem, payload_ptr, job_no);
+                                        pandecode_vertex_job_bfr(h, mem, payload_ptr, job_no, gpu_id);
                         } else
-                                pandecode_vertex_or_tiler_job_mdg(h, mem, payload_ptr, job_no);
+                                pandecode_vertex_or_tiler_job_mdg(h, mem, payload_ptr, job_no, gpu_id);
 
                         break;
 
index b52324c784d4c45607105e52d3ffb256ac900b8a..c68dbe6a2eac541bbbe8925e6100d8e619828bd9 100644 (file)
@@ -47,6 +47,6 @@ void pandecode_initialize(void);
 void
 pandecode_inject_mmap(uint64_t gpu_va, void *cpu, unsigned sz, const char *name);
 
-int pandecode_jc(uint64_t jc_gpu_va, bool bifrost);
+int pandecode_jc(uint64_t jc_gpu_va, bool bifrost, unsigned gpu_id);
 
 #endif /* __MMAP_TRACE_H__ */