[4/8] panfrost: Pass the fence down when flushing

Submitted by Tomeu Vizoso on March 4, 2019, 4:11 p.m.

Details

Message ID 20190304161144.52910-5-tomeu.vizoso@collabora.com
State New
Headers show
Series "Series without cover letter" ( rev: 1 ) in Mesa

Not browsing as part of any series.

Commit Message

Tomeu Vizoso March 4, 2019, 4:11 p.m.
Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
---
 src/gallium/drivers/panfrost/pan_context.c | 11 +++++++----
 src/gallium/drivers/panfrost/pan_context.h |  7 +++++++
 src/gallium/drivers/panfrost/pan_screen.c  | 11 ++++++-----
 src/gallium/drivers/panfrost/pan_screen.h  | 11 ++++++++++-
 4 files changed, 30 insertions(+), 10 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c
index cfcd4b13f592..b419f25224f2 100644
--- a/src/gallium/drivers/panfrost/pan_context.c
+++ b/src/gallium/drivers/panfrost/pan_context.c
@@ -1529,7 +1529,8 @@  panfrost_link_jobs(struct panfrost_context *ctx)
 /* The entire frame is in memory -- send it off to the kernel! */
 
 static void
-panfrost_submit_frame(struct panfrost_context *ctx, bool flush_immediate)
+panfrost_submit_frame(struct panfrost_context *ctx, bool flush_immediate,
+		      struct pipe_fence_handle **fence)
 {
         struct pipe_context *gallium = (struct pipe_context *) ctx;
         struct panfrost_screen *screen = pan_screen(gallium->screen);
@@ -1556,14 +1557,14 @@  panfrost_submit_frame(struct panfrost_context *ctx, bool flush_immediate)
         /* If visual, we can stall a frame */
 
         if (!flush_immediate)
-                screen->driver->force_flush_fragment(ctx);
+                screen->driver->force_flush_fragment(ctx, fence);
 
         screen->last_fragment_id = fragment_id;
         screen->last_fragment_flushed = false;
 
         /* If readback, flush now (hurts the pipelined performance) */
         if (flush_immediate)
-                screen->driver->force_flush_fragment(ctx);
+                screen->driver->force_flush_fragment(ctx, fence);
 
         if (screen->driver->dump_counters && pan_counters_base) {
                 screen->driver->dump_counters(screen);
@@ -1594,7 +1595,7 @@  panfrost_flush(
         bool flush_immediate = flags & PIPE_FLUSH_END_OF_FRAME;
 
         /* Submit the frame itself */
-        panfrost_submit_frame(ctx, flush_immediate);
+        panfrost_submit_frame(ctx, flush_immediate, fence);
 
         /* Prepare for the next frame */
         panfrost_invalidate_frame(ctx);
@@ -2791,6 +2792,8 @@  panfrost_create_context(struct pipe_screen *screen, void *priv, unsigned flags)
 
         panfrost_resource_context_init(gallium);
 
+        pscreen->driver->init_context(ctx);
+
         panfrost_setup_hardware(ctx);
 
         /* XXX: leaks */
diff --git a/src/gallium/drivers/panfrost/pan_context.h b/src/gallium/drivers/panfrost/pan_context.h
index a809f207d46b..adc53a3bfae4 100644
--- a/src/gallium/drivers/panfrost/pan_context.h
+++ b/src/gallium/drivers/panfrost/pan_context.h
@@ -74,6 +74,11 @@  struct panfrost_query {
         struct panfrost_transfer transfer;
 };
 
+struct panfrost_fence {
+        struct pipe_reference reference;
+        int fd;
+};
+
 #define PANFROST_MAX_TRANSIENT_ENTRIES 64
 
 struct panfrost_transient_pool {
@@ -211,6 +216,8 @@  struct panfrost_context {
 
         /* True for t6XX, false for t8xx. */
         bool is_t6xx;
+
+	__u32 out_sync;
 };
 
 /* Corresponds to the CSO */
diff --git a/src/gallium/drivers/panfrost/pan_screen.c b/src/gallium/drivers/panfrost/pan_screen.c
index f77bb11ffda4..3d13c3e924d2 100644
--- a/src/gallium/drivers/panfrost/pan_screen.c
+++ b/src/gallium/drivers/panfrost/pan_screen.c
@@ -503,21 +503,22 @@  panfrost_get_timestamp(struct pipe_screen *_screen)
 }
 
 static void
-panfrost_fence_reference(struct pipe_screen *screen,
+panfrost_fence_reference(struct pipe_screen *pscreen,
                          struct pipe_fence_handle **ptr,
                          struct pipe_fence_handle *fence)
 {
-        *ptr = fence;
+        struct panfrost_screen *screen = pan_screen(pscreen);
+        screen->driver->fence_reference(pscreen, ptr, fence);
 }
 
 static boolean
-panfrost_fence_finish(struct pipe_screen *screen,
+panfrost_fence_finish(struct pipe_screen *pscreen,
                       struct pipe_context *ctx,
                       struct pipe_fence_handle *fence,
                       uint64_t timeout)
 {
-        assert(fence);
-        return TRUE;
+        struct panfrost_screen *screen = pan_screen(pscreen);
+        return screen->driver->fence_finish(pscreen, ctx, fence, timeout);
 }
 
 static const void *
diff --git a/src/gallium/drivers/panfrost/pan_screen.h b/src/gallium/drivers/panfrost/pan_screen.h
index 576dca11dc7b..f109df857c7b 100644
--- a/src/gallium/drivers/panfrost/pan_screen.h
+++ b/src/gallium/drivers/panfrost/pan_screen.h
@@ -51,7 +51,8 @@  struct panfrost_driver {
 	struct panfrost_bo * (*import_bo) (struct panfrost_screen *screen, struct winsys_handle *whandle);
 
 	int (*submit_vs_fs_job) (struct panfrost_context *ctx, bool has_draws, bool is_scanout);
-	void (*force_flush_fragment) (struct panfrost_context *ctx);
+	void (*force_flush_fragment) (struct panfrost_context *ctx,
+				      struct pipe_fence_handle **fence);
 	void (*allocate_slab) (struct panfrost_screen *screen,
 		               struct panfrost_memory *mem,
 		               size_t pages,
@@ -66,6 +67,14 @@  struct panfrost_driver {
         void (*enable_counters) (struct panfrost_screen *screen);
         void (*dump_counters) (struct panfrost_screen *screen);
 	unsigned (*query_gpu_version) (struct panfrost_screen *screen);
+	int (*init_context) (struct panfrost_context *ctx);
+	void (*fence_reference) (struct pipe_screen *screen,
+                         struct pipe_fence_handle **ptr,
+                         struct pipe_fence_handle *fence);
+	boolean (*fence_finish) (struct pipe_screen *screen,
+                      struct pipe_context *ctx,
+                      struct pipe_fence_handle *fence,
+                      uint64_t timeout);
 };
 
 struct panfrost_screen {

Comments

> +	__u32 out_sync;

Why __u32 instead of u32 or uint32_t? I don't think we use the prefixed
types anywhere else.

> +	int (*init_context) (struct panfrost_context *ctx);
> +	void (*fence_reference) (struct pipe_screen *screen,
> +                         struct pipe_fence_handle **ptr,
> +                         struct pipe_fence_handle *fence);
> +	boolean (*fence_finish) (struct pipe_screen *screen,
> +                      struct pipe_context *ctx,
> +                      struct pipe_fence_handle *fence,
> +                      uint64_t timeout);

How should these be implemented on the non-DRM backend? If I just stub
out the corresponding routines, should everything work alright? (If
that's the case, then I'll do that; nothing you need to worry about. But
I'm not up to date on how fencing works on mainline.)