vc4: Add perf debug for when we wait on BOs.

This commit is contained in:
Eric Anholt
2015-06-29 22:32:03 -07:00
parent 759ed0bd03
commit ab80519b3c
4 changed files with 74 additions and 45 deletions
+69 -41
View File
@@ -94,7 +94,7 @@ vc4_bo_from_cache(struct vc4_screen *screen, uint32_t size, const char *name)
* allocate something new instead, since we assume that the
* user will proceed to CPU map it and fill it with stuff.
*/
if (!vc4_bo_wait(bo, 0)) {
if (!vc4_bo_wait(bo, 0, NULL)) {
pipe_mutex_unlock(cache->lock);
return NULL;
}
@@ -413,63 +413,91 @@ vc4_bo_flink(struct vc4_bo *bo, uint32_t *name)
return true;
}
static int vc4_wait_seqno_ioctl(int fd, uint64_t seqno, uint64_t timeout_ns)
{
if (using_vc4_simulator)
return 0;
struct drm_vc4_wait_seqno wait = {
.seqno = seqno,
.timeout_ns = timeout_ns,
};
int ret = drmIoctl(fd, DRM_IOCTL_VC4_WAIT_SEQNO, &wait);
if (ret == -1)
return -errno;
else
return 0;
}
bool
vc4_wait_seqno(struct vc4_screen *screen, uint64_t seqno, uint64_t timeout_ns)
vc4_wait_seqno(struct vc4_screen *screen, uint64_t seqno, uint64_t timeout_ns,
const char *reason)
{
if (screen->finished_seqno >= seqno)
return true;
struct drm_vc4_wait_seqno wait;
memset(&wait, 0, sizeof(wait));
wait.seqno = seqno;
wait.timeout_ns = timeout_ns;
int ret;
if (!using_vc4_simulator)
ret = drmIoctl(screen->fd, DRM_IOCTL_VC4_WAIT_SEQNO, &wait);
else {
wait.seqno = screen->finished_seqno;
ret = 0;
if (unlikely(vc4_debug & VC4_DEBUG_PERF) && timeout_ns && reason) {
if (vc4_wait_seqno_ioctl(screen->fd, seqno, 0) == -ETIME) {
fprintf(stderr, "Blocking on seqno %lld for %s\n",
(long long)seqno, reason);
}
}
if (ret == 0) {
screen->finished_seqno = wait.seqno;
return true;
int ret = vc4_wait_seqno_ioctl(screen->fd, seqno, timeout_ns);
if (ret) {
if (ret != -ETIME) {
fprintf(stderr, "wait failed: %d\n", ret);
abort();
}
return false;
}
if (errno != ETIME) {
fprintf(stderr, "wait failed: %d\n", ret);
abort();
}
screen->finished_seqno = seqno;
return true;
}
static int vc4_wait_bo_ioctl(int fd, uint32_t handle, uint64_t timeout_ns)
{
if (using_vc4_simulator)
return 0;
struct drm_vc4_wait_bo wait = {
.handle = handle,
.timeout_ns = timeout_ns,
};
int ret = drmIoctl(fd, DRM_IOCTL_VC4_WAIT_BO, &wait);
if (ret == -1)
return -errno;
else
return 0;
return false;
}
bool
vc4_bo_wait(struct vc4_bo *bo, uint64_t timeout_ns)
vc4_bo_wait(struct vc4_bo *bo, uint64_t timeout_ns, const char *reason)
{
struct vc4_screen *screen = bo->screen;
struct drm_vc4_wait_bo wait;
memset(&wait, 0, sizeof(wait));
wait.handle = bo->handle;
wait.timeout_ns = timeout_ns;
int ret;
if (!using_vc4_simulator)
ret = drmIoctl(screen->fd, DRM_IOCTL_VC4_WAIT_BO, &wait);
else
ret = 0;
if (ret == 0)
return true;
if (errno != ETIME) {
fprintf(stderr, "wait failed: %d\n", ret);
abort();
if (unlikely(vc4_debug & VC4_DEBUG_PERF) && timeout_ns && reason) {
if (vc4_wait_bo_ioctl(screen->fd, bo->handle, 0) == -ETIME) {
fprintf(stderr, "Blocking on %s BO for %s\n",
bo->name, reason);
}
}
return false;
int ret = vc4_wait_bo_ioctl(screen->fd, bo->handle, timeout_ns);
if (ret) {
if (ret != -ETIME) {
fprintf(stderr, "wait failed: %d\n", ret);
abort();
}
return false;
}
return true;
}
void *
@@ -515,7 +543,7 @@ vc4_bo_map(struct vc4_bo *bo)
{
void *map = vc4_bo_map_unsynchronized(bo);
bool ok = vc4_bo_wait(bo, PIPE_TIMEOUT_INFINITE);
bool ok = vc4_bo_wait(bo, PIPE_TIMEOUT_INFINITE, "bo map");
if (!ok) {
fprintf(stderr, "BO wait for map failed\n");
abort();
+3 -2
View File
@@ -113,10 +113,11 @@ void *
vc4_bo_map_unsynchronized(struct vc4_bo *bo);
bool
vc4_bo_wait(struct vc4_bo *bo, uint64_t timeout_ns);
vc4_bo_wait(struct vc4_bo *bo, uint64_t timeout_ns, const char *reason);
bool
vc4_wait_seqno(struct vc4_screen *screen, uint64_t seqno, uint64_t timeout_ns);
vc4_wait_seqno(struct vc4_screen *screen, uint64_t seqno, uint64_t timeout_ns,
const char *reason);
void
vc4_bufmgr_destroy(struct pipe_screen *pscreen);
+1 -1
View File
@@ -67,7 +67,7 @@ vc4_fence_finish(struct pipe_screen *pscreen,
struct vc4_screen *screen = vc4_screen(pscreen);
struct vc4_fence *f = (struct vc4_fence *)pf;
return vc4_wait_seqno(screen, f->seqno, timeout_ns);
return vc4_wait_seqno(screen, f->seqno, timeout_ns, "fence wait");
}
struct vc4_fence *
+1 -1
View File
@@ -207,7 +207,7 @@ vc4_job_submit(struct vc4_context *vc4)
if (vc4_debug & VC4_DEBUG_ALWAYS_SYNC) {
if (!vc4_wait_seqno(vc4->screen, vc4->last_emit_seqno,
PIPE_TIMEOUT_INFINITE)) {
PIPE_TIMEOUT_INFINITE, "sync")) {
fprintf(stderr, "Wait failed.\n");
abort();
}