panfrost: Add PAN_MESA_DEBUG=sync

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>
This commit is contained in:
Tomeu Vizoso 2019-12-09 08:39:59 +01:00
parent 2e654db27a
commit 63ae9e61c1
7 changed files with 39 additions and 7 deletions

View 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(

View 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;
}

View 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);
}

View 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
};

View 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;

View 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) {

View 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__ */