aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/vc4/vc4_bufmgr.c
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2014-11-19 17:39:04 -0800
committerEric Anholt <[email protected]>2014-11-20 13:07:07 -0800
commit21577571b37e68edc0422fbf80932588a4614abc (patch)
tree031a8f9d5adbb2c2bab7d0fd65137e1d7396cd36 /src/gallium/drivers/vc4/vc4_bufmgr.c
parent390799c496d363e7476afb0dbb8f28cbc6e20807 (diff)
vc4: Update for new kernel ABI with async execution and waits.
Our submits now return immediately and you have to manually wait for things to complete if you want to (like a normal driver).
Diffstat (limited to 'src/gallium/drivers/vc4/vc4_bufmgr.c')
-rw-r--r--src/gallium/drivers/vc4/vc4_bufmgr.c65
1 files changed, 64 insertions, 1 deletions
diff --git a/src/gallium/drivers/vc4/vc4_bufmgr.c b/src/gallium/drivers/vc4/vc4_bufmgr.c
index 33592e84527..3b73ac80bf6 100644
--- a/src/gallium/drivers/vc4/vc4_bufmgr.c
+++ b/src/gallium/drivers/vc4/vc4_bufmgr.c
@@ -152,8 +152,57 @@ vc4_bo_flink(struct vc4_bo *bo, uint32_t *name)
return true;
}
+bool
+vc4_wait_seqno(struct vc4_screen *screen, uint64_t seqno, uint64_t timeout_ns)
+{
+#ifndef USE_VC4_SIMULATOR
+ struct drm_vc4_wait_seqno wait;
+ memset(&wait, 0, sizeof(wait));
+ wait.seqno = seqno;
+ wait.timeout_ns = timeout_ns;
+
+ int ret = drmIoctl(screen->fd, DRM_IOCTL_VC4_WAIT_SEQNO, &wait);
+ if (ret == -ETIME) {
+ return false;
+ } else if (ret != 0) {
+ fprintf(stderr, "wait failed\n");
+ abort();
+ } else {
+ screen->finished_seqno = wait.seqno;
+ return true;
+ }
+#else
+ return true;
+#endif
+}
+
+bool
+vc4_bo_wait(struct vc4_bo *bo, uint64_t timeout_ns)
+{
+#ifndef USE_VC4_SIMULATOR
+ 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 = drmIoctl(screen->fd, DRM_IOCTL_VC4_WAIT_BO, &wait);
+ if (ret == -ETIME) {
+ return false;
+ } else if (ret != 0) {
+ fprintf(stderr, "wait failed\n");
+ abort();
+ } else {
+ return true;
+ }
+#else
+ return true;
+#endif
+}
+
void *
-vc4_bo_map(struct vc4_bo *bo)
+vc4_bo_map_unsynchronized(struct vc4_bo *bo)
{
int ret;
@@ -179,3 +228,17 @@ vc4_bo_map(struct vc4_bo *bo)
return bo->map;
}
+
+void *
+vc4_bo_map(struct vc4_bo *bo)
+{
+ void *map = vc4_bo_map_unsynchronized(bo);
+
+ bool ok = vc4_bo_wait(bo, PIPE_TIMEOUT_INFINITE);
+ if (!ok) {
+ fprintf(stderr, "BO wait for map failed\n");
+ abort();
+ }
+
+ return map;
+}