v3d: add a V3D_DEBUG option to force synchronous execution of jobs

This is useful to debug sync issues and can also can be used to
instrument tooling for dumping job execution times in the future.

Reviewed-by: Jose Maria Casanova Crespo <jmcasanova@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32111>
This commit is contained in:
Iago Toral Quiroga 2024-10-30 08:44:04 +01:00 committed by Marge Bot
parent e5d64ca69c
commit 87acd4cde5
5 changed files with 15 additions and 1 deletions

View File

@ -105,6 +105,8 @@ static const struct debug_named_value debug_control[] = {
/* disable_tfu is v3dv only because v3d has some uses of the TFU without alternative codepaths */
{ "disable_tfu", V3D_DEBUG_DISABLE_TFU,
"Disable TFU (v3dv only)" },
{ "sync", V3D_DEBUG_SYNC,
"Sync wait for each job to complete after submission." },
DEBUG_NAMED_VALUE_END
};

View File

@ -69,6 +69,7 @@ extern uint32_t v3d_mesa_debug;
#define V3D_DEBUG_NO_MERGE_JOBS (1 << 24)
#define V3D_DEBUG_OPT_COMPILE_TIME (1 << 25)
#define V3D_DEBUG_DISABLE_TFU (1 << 26)
#define V3D_DEBUG_SYNC (1 << 27)
#define V3D_DEBUG_SHADERS (V3D_DEBUG_TGSI | V3D_DEBUG_NIR | \
V3D_DEBUG_VIR | V3D_DEBUG_QPU | \

View File

@ -592,7 +592,6 @@ v3d_job_submit(struct v3d_context *v3d, struct v3d_job *job)
if (!V3D_DBG(NORAST)) {
int ret;
ret = v3d_ioctl(v3d->fd, DRM_IOCTL_V3D_SUBMIT_CL, &job->submit);
static bool warned = false;
if (ret && !warned) {
@ -602,6 +601,10 @@ v3d_job_submit(struct v3d_context *v3d, struct v3d_job *job)
} else if (!ret) {
if (v3d->active_perfmon)
v3d->active_perfmon->job_submitted = true;
if (V3D_DBG(SYNC)) {
drmSyncobjWait(v3d->fd, &v3d->out_sync, 1, INT64_MAX,
DRM_SYNCOBJ_WAIT_FLAGS_WAIT_ALL, NULL);
}
}
/* If we are submitting a job in the middle of transform

View File

@ -1601,6 +1601,10 @@ v3d_launch_grid(struct pipe_context *pctx, const struct pipe_grid_info *info)
} else if (!ret) {
if (v3d->active_perfmon)
v3d->active_perfmon->job_submitted = true;
if (V3D_DBG(SYNC)) {
drmSyncobjWait(v3d->fd, &v3d->out_sync, 1, INT64_MAX,
DRM_SYNCOBJ_WAIT_FLAGS_WAIT_ALL, NULL);
}
}
}

View File

@ -197,6 +197,10 @@ v3dX(tfu)(struct pipe_context *pctx,
fprintf(stderr, "Failed to submit TFU job: %d\n", ret);
return false;
}
if (V3D_DBG(SYNC)) {
drmSyncobjWait(v3d->fd, &v3d->out_sync, 1, INT64_MAX,
DRM_SYNCOBJ_WAIT_FLAGS_WAIT_ALL, NULL);
}
dst->writes++;