panfrost: Add PAN_MESA_DEBUG=sync
authorTomeu Vizoso <tomeu.vizoso@collabora.com>
Mon, 9 Dec 2019 07:39:59 +0000 (08:39 +0100)
committerTomeu Vizoso <tomeu.vizoso@collabora.com>
Wed, 11 Dec 2019 07:01:20 +0000 (08:01 +0100)
Sometimes it's useful to get information about GPU faults in the
console, so it's synchronized with other messages.

This commit will cause Mesa to wait for completion and check if there
are any faults raised by the GPU.

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
src/gallium/drivers/panfrost/pan_context.h
src/gallium/drivers/panfrost/pan_fragment.c
src/gallium/drivers/panfrost/pan_job.c
src/gallium/drivers/panfrost/pan_screen.c
src/gallium/drivers/panfrost/pan_util.h
src/panfrost/pandecode/decode.c
src/panfrost/pandecode/public.h

index 79755eaf97c8e2ac11fff9a59cce76fd7e2a6536..f1db89dab125e59aa2f73153fe01110b4e8589f2 100644 (file)
@@ -311,7 +311,8 @@ struct mali_single_framebuffer
 panfrost_emit_sfbd(struct panfrost_batch *batch, unsigned vertex_count);
 
 mali_ptr
-panfrost_fragment_job(struct panfrost_batch *batch, bool has_draws);
+panfrost_fragment_job(struct panfrost_batch *batch, bool has_draws,
+                      struct mali_job_descriptor_header **header_cpu);
 
 void
 panfrost_shader_compile(
index b6bbce391c4bbe54d4b8d1b185194533fc9f19e7..c03df51fafa61000d1ee63aef9a0a70ca4b65fe0 100644 (file)
@@ -49,7 +49,8 @@ panfrost_initialize_surface(
  * presentations, this is supposed to correspond to eglSwapBuffers) */
 
 mali_ptr
-panfrost_fragment_job(struct panfrost_batch *batch, bool has_draws)
+panfrost_fragment_job(struct panfrost_batch *batch, bool has_draws,
+                      struct mali_job_descriptor_header **header_cpu)
 {
         struct panfrost_screen *screen = pan_screen(batch->ctx->base.screen);
 
@@ -108,5 +109,6 @@ panfrost_fragment_job(struct panfrost_batch *batch, bool has_draws)
         struct panfrost_transfer transfer = panfrost_allocate_transient(batch, sizeof(header) + sizeof(payload));
         memcpy(transfer.cpu, &header, sizeof(header));
         memcpy(transfer.cpu + sizeof(header), &payload, sizeof(payload));
+        *header_cpu = (struct mali_job_descriptor_header *)transfer.cpu;
         return transfer.gpu;
 }
index e2e54aff21670d6cac336b4641bbe82d6ab64731..3116d29463246b73a562568519a9767612f5e1df 100644 (file)
@@ -807,7 +807,8 @@ panfrost_batch_draw_wallpaper(struct panfrost_batch *batch)
 static int
 panfrost_batch_submit_ioctl(struct panfrost_batch *batch,
                             mali_ptr first_job_desc,
-                            uint32_t reqs)
+                            uint32_t reqs,
+                            struct mali_job_descriptor_header *header)
 {
         struct panfrost_context *ctx = batch->ctx;
         struct pipe_context *gallium = (struct pipe_context *) ctx;
@@ -877,6 +878,26 @@ panfrost_batch_submit_ioctl(struct panfrost_batch *batch,
                 return errno;
         }
 
+        if (pan_debug & PAN_DBG_SYNC) {
+                u32 status;
+
+                /* Wait so we can get errors reported back */
+                drmSyncobjWait(screen->fd, &batch->out_sync->syncobj, 1,
+                               INT64_MAX, 0, NULL);
+
+                status = header->exception_status;
+
+                if (status && status != 0x1) {
+                        fprintf(stderr, "Job %" PRIx64 " failed: source ID: 0x%x access: %s exception: 0x%x (exception_status 0x%x) fault_pointer 0x%" PRIx64 " \n",
+                               first_job_desc,
+                               (status >> 16) & 0xFFFF,
+                               pandecode_exception_access((status >> 8) & 0x3),
+                               status  & 0xFF,
+                               status,
+                               header->fault_pointer);
+                }
+        }
+
         /* Trace the job if we're doing that */
         if (pan_debug & PAN_DBG_TRACE) {
                 /* Wait so we can get errors reported back */
@@ -892,17 +913,19 @@ static int
 panfrost_batch_submit_jobs(struct panfrost_batch *batch)
 {
         bool has_draws = batch->first_job.gpu;
+        struct mali_job_descriptor_header *header;
         int ret = 0;
 
         if (has_draws) {
-                ret = panfrost_batch_submit_ioctl(batch, batch->first_job.gpu, 0);
+                header = (struct mali_job_descriptor_header *)batch->first_job.cpu;
+                ret = panfrost_batch_submit_ioctl(batch, batch->first_job.gpu, 0, header);
                 assert(!ret);
         }
 
         if (batch->first_tiler.gpu || batch->clear) {
-                mali_ptr fragjob = panfrost_fragment_job(batch, has_draws);
+                mali_ptr fragjob = panfrost_fragment_job(batch, has_draws, &header);
 
-                ret = panfrost_batch_submit_ioctl(batch, fragjob, PANFROST_JD_REQ_FS);
+                ret = panfrost_batch_submit_ioctl(batch, fragjob, PANFROST_JD_REQ_FS, header);
                 assert(!ret);
         }
 
index 3aa5f05cd5ec0ccd03ae57b7fa69791acfc9b09c..c9bf9bcc7eb616682ab3aadf581c1b30b4e4191d 100644 (file)
@@ -59,6 +59,7 @@ static const struct debug_named_value debug_options[] = {
         {"trace",     PAN_DBG_TRACE,    "Trace the command stream"},
         {"deqp",      PAN_DBG_DEQP,     "Hacks for dEQP"},
         {"afbc",      PAN_DBG_AFBC,     "Enable non-conformant AFBC impl"},
+        {"sync",      PAN_DBG_SYNC,     "Wait for each job's completion and check for any GPU fault"},
         DEBUG_NAMED_VALUE_END
 };
 
index 24c71d59ba04e38f47e5f9aeede34c0cbf9248a6..b51b88d2e1a2b3bf8702b7152a1abb607905d893 100644 (file)
@@ -32,6 +32,7 @@
 #define PAN_DBG_TRACE           0x0002
 #define PAN_DBG_DEQP            0x0004
 #define PAN_DBG_AFBC            0x0008
+#define PAN_DBG_SYNC            0x0010
 
 extern int pan_debug;
 
index d112f104b430de35d3bc64e2229e5404d5ef85da..c266f82fae8c733fefc229d58281b743b9e68013 100644 (file)
@@ -490,7 +490,7 @@ pandecode_block_format(enum mali_block_format fmt)
 #undef DEFINE_CASE
 
 #define DEFINE_CASE(name) case MALI_EXCEPTION_ACCESS_## name: return ""#name
-static char *
+char *
 pandecode_exception_access(enum mali_exception_access access)
 {
         switch (access) {
index c68dbe6a2eac541bbbe8925e6100d8e619828bd9..89e6c3e02d4373699b90c7918c2706a8fe33e148 100644 (file)
@@ -49,4 +49,8 @@ pandecode_inject_mmap(uint64_t gpu_va, void *cpu, unsigned sz, const char *name)
 
 int pandecode_jc(uint64_t jc_gpu_va, bool bifrost, unsigned gpu_id);
 
+char *
+pandecode_exception_access(enum mali_exception_access access);
+
+
 #endif /* __MMAP_TRACE_H__ */