[Mesa-dev] [PATCH v2 1/2] panfrost: Jobs must be per context, not per screen

2019-08-30 Thread Rohan Garg
Jobs _must_ only be shared across the same context, having
the last_job tracked in a screen causes use-after-free issues
and memory corruptions.

Signed-off-by: Rohan Garg 
---
 src/gallium/drivers/panfrost/pan_context.c | 10 +-
 src/gallium/drivers/panfrost/pan_context.h |  6 ++
 src/gallium/drivers/panfrost/pan_drm.c |  6 +++---
 src/gallium/drivers/panfrost/pan_screen.c  |  3 ---
 src/gallium/drivers/panfrost/pan_screen.h  |  6 --
 5 files changed, 14 insertions(+), 17 deletions(-)

diff --git a/src/gallium/drivers/panfrost/pan_context.c 
b/src/gallium/drivers/panfrost/pan_context.c
index fa9c92af9f6..94ee9b5bdb2 100644
--- a/src/gallium/drivers/panfrost/pan_context.c
+++ b/src/gallium/drivers/panfrost/pan_context.c
@@ -1329,9 +1329,6 @@ panfrost_submit_frame(struct panfrost_context *ctx, bool 
flush_immediate,
   struct pipe_fence_handle **fence,
   struct panfrost_job *job)
 {
-struct pipe_context *gallium = (struct pipe_context *) ctx;
-struct panfrost_screen *screen = pan_screen(gallium->screen);
-
 panfrost_job_submit(ctx, job);
 
 /* If visual, we can stall a frame */
@@ -1339,8 +1336,8 @@ panfrost_submit_frame(struct panfrost_context *ctx, bool 
flush_immediate,
 if (!flush_immediate)
 panfrost_drm_force_flush_fragment(ctx, fence);
 
-screen->last_fragment_flushed = false;
-screen->last_job = job;
+ctx->last_fragment_flushed = false;
+ctx->last_job = job;
 
 /* If readback, flush now (hurts the pipelined performance) */
 if (flush_immediate)
@@ -2856,6 +2853,9 @@ panfrost_create_context(struct pipe_screen *screen, void 
*priv, unsigned flags)
 assert(ctx->blitter);
 assert(ctx->blitter_wallpaper);
 
+ctx->last_fragment_flushed = true;
+ctx->last_job = NULL;
+
 /* Prepare for render! */
 
 panfrost_job_init(ctx);
diff --git a/src/gallium/drivers/panfrost/pan_context.h 
b/src/gallium/drivers/panfrost/pan_context.h
index 4c1580b3393..9f96e983a86 100644
--- a/src/gallium/drivers/panfrost/pan_context.h
+++ b/src/gallium/drivers/panfrost/pan_context.h
@@ -203,6 +203,12 @@ struct panfrost_context {
 bool is_t6xx;
 
 uint32_t out_sync;
+
+/* While we're busy building up the job for frame N, the GPU is
+ * still busy executing frame N-1. So hold a reference to
+ * yesterjob */
+int last_fragment_flushed;
+struct panfrost_job *last_job;
 };
 
 /* Corresponds to the CSO */
diff --git a/src/gallium/drivers/panfrost/pan_drm.c 
b/src/gallium/drivers/panfrost/pan_drm.c
index c3693bff56a..f89bc1d26eb 100644
--- a/src/gallium/drivers/panfrost/pan_drm.c
+++ b/src/gallium/drivers/panfrost/pan_drm.c
@@ -349,12 +349,12 @@ panfrost_drm_force_flush_fragment(struct panfrost_context 
*ctx,
 struct pipe_context *gallium = (struct pipe_context *) ctx;
 struct panfrost_screen *screen = pan_screen(gallium->screen);
 
-if (!screen->last_fragment_flushed) {
+if (!ctx->last_fragment_flushed) {
 drmSyncobjWait(screen->fd, >out_sync, 1, INT64_MAX, 0, 
NULL);
-screen->last_fragment_flushed = true;
+ctx->last_fragment_flushed = true;
 
 /* The job finished up, so we're safe to clean it up now */
-panfrost_free_job(ctx, screen->last_job);
+panfrost_free_job(ctx, ctx->last_job);
 }
 
 if (fence) {
diff --git a/src/gallium/drivers/panfrost/pan_screen.c 
b/src/gallium/drivers/panfrost/pan_screen.c
index 36c91a1572e..5c288f52bbd 100644
--- a/src/gallium/drivers/panfrost/pan_screen.c
+++ b/src/gallium/drivers/panfrost/pan_screen.c
@@ -665,9 +665,6 @@ panfrost_create_screen(int fd, struct renderonly *ro)
 screen->base.fence_finish = panfrost_fence_finish;
 screen->base.set_damage_region = panfrost_resource_set_damage_region;
 
-screen->last_fragment_flushed = true;
-screen->last_job = NULL;
-
 panfrost_resource_screen_init(screen);
 
 return >base;
diff --git a/src/gallium/drivers/panfrost/pan_screen.h 
b/src/gallium/drivers/panfrost/pan_screen.h
index 35fb8de2628..7991b395f54 100644
--- a/src/gallium/drivers/panfrost/pan_screen.h
+++ b/src/gallium/drivers/panfrost/pan_screen.h
@@ -118,12 +118,6 @@ struct panfrost_screen {
  * Each bucket is a linked list of free panfrost_bo objects. */
 
 struct list_head bo_cache[NR_BO_CACHE_BUCKETS];
-
-/* While we're busy building up the job for frame N, the GPU is
- * still busy executing frame N-1. So hold a reference to
- * yesterjob */
-int last_fragment_flushed;
-struct panfrost_job *last_job;
 };
 
 static inline struct panfrost_screen *
-- 
2.17.1

___
mesa-dev mailing list

[Mesa-dev] [PATCH v2 2/2] panfrost: protect access to shared bo cache and transient pool

2019-08-30 Thread Rohan Garg
Both the BO cache and the transient pool are shared across
context's. Protect access to these with mutexes.

Signed-off-by: Rohan Garg 
---
 src/gallium/drivers/panfrost/pan_allocate.c |  2 ++
 src/gallium/drivers/panfrost/pan_bo_cache.c | 16 +++-
 src/gallium/drivers/panfrost/pan_job.c  |  2 ++
 src/gallium/drivers/panfrost/pan_screen.c   |  2 ++
 src/gallium/drivers/panfrost/pan_screen.h   |  4 
 5 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/src/gallium/drivers/panfrost/pan_allocate.c 
b/src/gallium/drivers/panfrost/pan_allocate.c
index f549c864c70..fb8b18fe718 100644
--- a/src/gallium/drivers/panfrost/pan_allocate.c
+++ b/src/gallium/drivers/panfrost/pan_allocate.c
@@ -74,6 +74,7 @@ panfrost_allocate_transient(struct panfrost_context *ctx, 
size_t sz)
 unsigned offset = 0;
 bool update_offset = false;
 
+pthread_mutex_lock(>transient_lock);
 bool has_current = batch->transient_indices.size;
 bool fits_in_current = (batch->transient_offset + sz) < 
TRANSIENT_SLAB_SIZE;
 
@@ -131,6 +132,7 @@ panfrost_allocate_transient(struct panfrost_context *ctx, 
size_t sz)
 
 if (update_offset)
 batch->transient_offset = offset + sz;
+pthread_mutex_unlock(>transient_lock);
 
 return ret;
 
diff --git a/src/gallium/drivers/panfrost/pan_bo_cache.c 
b/src/gallium/drivers/panfrost/pan_bo_cache.c
index 9dd6b694b72..f2f49437a89 100644
--- a/src/gallium/drivers/panfrost/pan_bo_cache.c
+++ b/src/gallium/drivers/panfrost/pan_bo_cache.c
@@ -24,6 +24,7 @@
  *   Alyssa Rosenzweig 
  */
 #include 
+#include 
 #include "drm-uapi/panfrost_drm.h"
 
 #include "pan_screen.h"
@@ -84,7 +85,9 @@ panfrost_bo_cache_fetch(
 struct panfrost_screen *screen,
 size_t size, uint32_t flags)
 {
+pthread_mutex_lock(>bo_cache_lock);
 struct list_head *bucket = pan_bucket(screen, size);
+struct panfrost_bo *bo = NULL;
 
 /* Iterate the bucket looking for something suitable */
 list_for_each_entry_safe(struct panfrost_bo, entry, bucket, link) {
@@ -106,12 +109,13 @@ panfrost_bo_cache_fetch(
 continue;
 }
 /* Let's go! */
-return entry;
+bo = entry;
+break;
 }
 }
+pthread_mutex_unlock(>bo_cache_lock);
 
-/* We didn't find anything */
-return NULL;
+return bo;
 }
 
 /* Tries to add a BO to the cache. Returns if it was
@@ -122,6 +126,7 @@ panfrost_bo_cache_put(
 struct panfrost_screen *screen,
 struct panfrost_bo *bo)
 {
+pthread_mutex_lock(>bo_cache_lock);
 struct list_head *bucket = pan_bucket(screen, bo->size);
 struct drm_panfrost_madvise madv;
 
@@ -133,6 +138,7 @@ panfrost_bo_cache_put(
 
 /* Add us to the bucket */
 list_addtail(>link, bucket);
+pthread_mutex_unlock(>bo_cache_lock);
 
 return true;
 }
@@ -147,6 +153,7 @@ void
 panfrost_bo_cache_evict_all(
 struct panfrost_screen *screen)
 {
+pthread_mutex_lock(>bo_cache_lock);
 for (unsigned i = 0; i < ARRAY_SIZE(screen->bo_cache); ++i) {
 struct list_head *bucket = >bo_cache[i];
 
@@ -155,7 +162,6 @@ panfrost_bo_cache_evict_all(
 panfrost_drm_release_bo(screen, entry, false);
 }
 }
-
-return;
+pthread_mutex_unlock(>bo_cache_lock);
 }
 
diff --git a/src/gallium/drivers/panfrost/pan_job.c 
b/src/gallium/drivers/panfrost/pan_job.c
index 4d8ec2eadc9..4d2908a58b7 100644
--- a/src/gallium/drivers/panfrost/pan_job.c
+++ b/src/gallium/drivers/panfrost/pan_job.c
@@ -67,10 +67,12 @@ panfrost_free_job(struct panfrost_context *ctx, struct 
panfrost_job *job)
 /* Free up the transient BOs we're sitting on */
 struct panfrost_screen *screen = pan_screen(ctx->base.screen);
 
+pthread_mutex_lock(>transient_lock);
 util_dynarray_foreach(>transient_indices, unsigned, index) {
 /* Mark it free */
 BITSET_SET(screen->free_transient, *index);
 }
+pthread_mutex_unlock(>transient_lock);
 
 /* Unreference the polygon list */
 panfrost_bo_unreference(ctx->base.screen, job->polygon_list);
diff --git a/src/gallium/drivers/panfrost/pan_screen.c 
b/src/gallium/drivers/panfrost/pan_screen.c
index 5c288f52bbd..5ceceac33ae 100644
--- a/src/gallium/drivers/panfrost/pan_screen.c
+++ b/src/gallium/drivers/panfrost/pan_screen.c
@@ -639,8 +639,10 @@ panfrost_create_screen(int fd, struct renderonly *ro)
 return NULL;
 }
 
+   pthread_mutex_init(>transient_lock, NULL);
 util_dynarray_init(>transient_bo, screen);
 
+  

Re: [Mesa-dev] [PATCH] panfrost: Remove unused variable from panfrost_drm_submit_vs_fs_job

2019-08-29 Thread Rohan Garg
On jueves, 29 de agosto de 2019 15:07:08 (CEST) Boris Brezillon wrote:
> On Thu, 29 Aug 2019 14:53:10 +0200
> 
> Rohan Garg  wrote:
> > is_scanout is not used anywhere and can be inferred within
> > panfrost_drm_submit_vs_fs_job if required.
> 
> Signed-off-by tag is missing. Looks good otherwise.
> 

Signed-off-by: Rohan Garg 

signature.asc
Description: This is a digitally signed message part.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

[Mesa-dev] [PATCH] panfrost: Remove unused variable from panfrost_drm_submit_vs_fs_job

2019-08-29 Thread Rohan Garg
is_scanout is not used anywhere and can be inferred within
panfrost_drm_submit_vs_fs_job if required.
---
 src/gallium/drivers/panfrost/pan_drm.c| 2 +-
 src/gallium/drivers/panfrost/pan_job.c| 3 +--
 src/gallium/drivers/panfrost/pan_screen.h | 3 +--
 3 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/gallium/drivers/panfrost/pan_drm.c 
b/src/gallium/drivers/panfrost/pan_drm.c
index c3693bff56a..8e05fc936b2 100644
--- a/src/gallium/drivers/panfrost/pan_drm.c
+++ b/src/gallium/drivers/panfrost/pan_drm.c
@@ -292,7 +292,7 @@ panfrost_drm_submit_job(struct panfrost_context *ctx, u64 
job_desc, int reqs)
 }
 
 int
-panfrost_drm_submit_vs_fs_job(struct panfrost_context *ctx, bool has_draws, 
bool is_scanout)
+panfrost_drm_submit_vs_fs_job(struct panfrost_context *ctx, bool has_draws)
 {
 int ret = 0;
 
diff --git a/src/gallium/drivers/panfrost/pan_job.c 
b/src/gallium/drivers/panfrost/pan_job.c
index 4d8ec2eadc9..f5bbd04b913 100644
--- a/src/gallium/drivers/panfrost/pan_job.c
+++ b/src/gallium/drivers/panfrost/pan_job.c
@@ -208,9 +208,8 @@ panfrost_job_submit(struct panfrost_context *ctx, struct 
panfrost_job *job)
 panfrost_scoreboard_link_batch(job);
 
 bool has_draws = job->last_job.gpu;
-bool is_scanout = panfrost_is_scanout(ctx);
 
-ret = panfrost_drm_submit_vs_fs_job(ctx, has_draws, is_scanout);
+ret = panfrost_drm_submit_vs_fs_job(ctx, has_draws);
 
 if (ret)
 fprintf(stderr, "panfrost_job_submit failed: %d\n", ret);
diff --git a/src/gallium/drivers/panfrost/pan_screen.h 
b/src/gallium/drivers/panfrost/pan_screen.h
index 35fb8de2628..02e8a96fabe 100644
--- a/src/gallium/drivers/panfrost/pan_screen.h
+++ b/src/gallium/drivers/panfrost/pan_screen.h
@@ -165,8 +165,7 @@ panfrost_drm_import_bo(struct panfrost_screen *screen, int 
fd);
 int
 panfrost_drm_export_bo(struct panfrost_screen *screen, const struct 
panfrost_bo *bo);
 int
-panfrost_drm_submit_vs_fs_job(struct panfrost_context *ctx, bool has_draws,
-  bool is_scanout);
+panfrost_drm_submit_vs_fs_job(struct panfrost_context *ctx, bool has_draws);
 void
 panfrost_drm_force_flush_fragment(struct panfrost_context *ctx,
   struct pipe_fence_handle **fence);
-- 
2.17.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

[Mesa-dev] [PATCH] panfrost: Jobs must be per context, not per screen

2019-08-29 Thread Rohan Garg
Jobs _must_ only be shared across the same context, having
the last_job tracked in a screen causes use-after-free issues
and memory corruptions.

Signed-off-by: Rohan Garg 
---
 src/gallium/drivers/panfrost/pan_allocate.c |  2 ++
 src/gallium/drivers/panfrost/pan_bo_cache.c | 16 +++-
 src/gallium/drivers/panfrost/pan_context.c  | 10 +-
 src/gallium/drivers/panfrost/pan_context.h  |  6 ++
 src/gallium/drivers/panfrost/pan_drm.c  |  6 +++---
 src/gallium/drivers/panfrost/pan_job.c  |  2 ++
 src/gallium/drivers/panfrost/pan_screen.c   |  5 ++---
 src/gallium/drivers/panfrost/pan_screen.h   | 10 --
 8 files changed, 35 insertions(+), 22 deletions(-)

diff --git a/src/gallium/drivers/panfrost/pan_allocate.c 
b/src/gallium/drivers/panfrost/pan_allocate.c
index f549c864c70..fb8b18fe718 100644
--- a/src/gallium/drivers/panfrost/pan_allocate.c
+++ b/src/gallium/drivers/panfrost/pan_allocate.c
@@ -74,6 +74,7 @@ panfrost_allocate_transient(struct panfrost_context *ctx, 
size_t sz)
 unsigned offset = 0;
 bool update_offset = false;
 
+pthread_mutex_lock(>transient_lock);
 bool has_current = batch->transient_indices.size;
 bool fits_in_current = (batch->transient_offset + sz) < 
TRANSIENT_SLAB_SIZE;
 
@@ -131,6 +132,7 @@ panfrost_allocate_transient(struct panfrost_context *ctx, 
size_t sz)
 
 if (update_offset)
 batch->transient_offset = offset + sz;
+pthread_mutex_unlock(>transient_lock);
 
 return ret;
 
diff --git a/src/gallium/drivers/panfrost/pan_bo_cache.c 
b/src/gallium/drivers/panfrost/pan_bo_cache.c
index 9dd6b694b72..f2f49437a89 100644
--- a/src/gallium/drivers/panfrost/pan_bo_cache.c
+++ b/src/gallium/drivers/panfrost/pan_bo_cache.c
@@ -24,6 +24,7 @@
  *   Alyssa Rosenzweig 
  */
 #include 
+#include 
 #include "drm-uapi/panfrost_drm.h"
 
 #include "pan_screen.h"
@@ -84,7 +85,9 @@ panfrost_bo_cache_fetch(
 struct panfrost_screen *screen,
 size_t size, uint32_t flags)
 {
+pthread_mutex_lock(>bo_cache_lock);
 struct list_head *bucket = pan_bucket(screen, size);
+struct panfrost_bo *bo = NULL;
 
 /* Iterate the bucket looking for something suitable */
 list_for_each_entry_safe(struct panfrost_bo, entry, bucket, link) {
@@ -106,12 +109,13 @@ panfrost_bo_cache_fetch(
 continue;
 }
 /* Let's go! */
-return entry;
+bo = entry;
+break;
 }
 }
+pthread_mutex_unlock(>bo_cache_lock);
 
-/* We didn't find anything */
-return NULL;
+return bo;
 }
 
 /* Tries to add a BO to the cache. Returns if it was
@@ -122,6 +126,7 @@ panfrost_bo_cache_put(
 struct panfrost_screen *screen,
 struct panfrost_bo *bo)
 {
+pthread_mutex_lock(>bo_cache_lock);
 struct list_head *bucket = pan_bucket(screen, bo->size);
 struct drm_panfrost_madvise madv;
 
@@ -133,6 +138,7 @@ panfrost_bo_cache_put(
 
 /* Add us to the bucket */
 list_addtail(>link, bucket);
+pthread_mutex_unlock(>bo_cache_lock);
 
 return true;
 }
@@ -147,6 +153,7 @@ void
 panfrost_bo_cache_evict_all(
 struct panfrost_screen *screen)
 {
+pthread_mutex_lock(>bo_cache_lock);
 for (unsigned i = 0; i < ARRAY_SIZE(screen->bo_cache); ++i) {
 struct list_head *bucket = >bo_cache[i];
 
@@ -155,7 +162,6 @@ panfrost_bo_cache_evict_all(
 panfrost_drm_release_bo(screen, entry, false);
 }
 }
-
-return;
+pthread_mutex_unlock(>bo_cache_lock);
 }
 
diff --git a/src/gallium/drivers/panfrost/pan_context.c 
b/src/gallium/drivers/panfrost/pan_context.c
index fa9c92af9f6..94ee9b5bdb2 100644
--- a/src/gallium/drivers/panfrost/pan_context.c
+++ b/src/gallium/drivers/panfrost/pan_context.c
@@ -1329,9 +1329,6 @@ panfrost_submit_frame(struct panfrost_context *ctx, bool 
flush_immediate,
   struct pipe_fence_handle **fence,
   struct panfrost_job *job)
 {
-struct pipe_context *gallium = (struct pipe_context *) ctx;
-struct panfrost_screen *screen = pan_screen(gallium->screen);
-
 panfrost_job_submit(ctx, job);
 
 /* If visual, we can stall a frame */
@@ -1339,8 +1336,8 @@ panfrost_submit_frame(struct panfrost_context *ctx, bool 
flush_immediate,
 if (!flush_immediate)
 panfrost_drm_force_flush_fragment(ctx, fence);
 
-screen->last_fragment_flushed = false;
-screen->last_job = job;
+ctx->last_fragment_flushed = false;
+ctx->last_job = job;
 
 /* If readback, flush now (hurts the pipelined perfo

[Mesa-dev] [PATCH v2] panfrost: Take into account a index_bias for glDrawElementsBaseVertex calls

2019-08-05 Thread Rohan Garg
Bifrost does not accept a index_bias and relies instead on a bias correction
offset ( offset_bias_correction ) in order to calculate the unbiased vertex
index.

We need to make sure we adjust offset_start and vertex_count in order to
take into account the index_bias as required by a glDrawElementsBaseVertex
call and then supply a additional offset_bias_correction to the hardware.

Changes for v2:
  * Renamed the draw_start and negative_start variables to something
more appropriate.

Signed-off-by: Rohan Garg 
---
 src/gallium/drivers/panfrost/pan_context.c | 17 -
 src/panfrost/include/panfrost-job.h| 19 ---
 src/panfrost/pandecode/decode.c|  8 
 3 files changed, 28 insertions(+), 16 deletions(-)

diff --git a/src/gallium/drivers/panfrost/pan_context.c 
b/src/gallium/drivers/panfrost/pan_context.c
index 929ffd16605..a2274bf206a 100644
--- a/src/gallium/drivers/panfrost/pan_context.c
+++ b/src/gallium/drivers/panfrost/pan_context.c
@@ -694,7 +694,7 @@ panfrost_stage_attributes(struct panfrost_context *ctx)
  * QED.
  */
 
-unsigned start = ctx->payload_vertex.draw_start;
+unsigned start = ctx->payload_vertex.offset_start;
 
 for (unsigned i = 0; i < so->num_elements; ++i) {
 unsigned vbi = so->pipe[i].vertex_buffer_index;
@@ -1633,8 +1633,8 @@ panfrost_draw_vbo(
 if (panfrost_scissor_culls_everything(ctx))
 return;
 
-ctx->payload_vertex.draw_start = info->start;
-ctx->payload_tiler.draw_start = info->start;
+ctx->payload_vertex.offset_start = info->start;
+ctx->payload_tiler.offset_start = info->start;
 
 int mode = info->mode;
 
@@ -1671,7 +1671,7 @@ panfrost_draw_vbo(
 
 ctx->payload_tiler.prefix.draw_mode = g2m_draw_mode(mode);
 
-ctx->vertex_count = info->count;
+ctx->vertex_count = info->count + info->index_bias;
 ctx->instance_count = info->instance_count;
 
 /* For non-indexed draws, they're the same */
@@ -1720,14 +1720,13 @@ panfrost_draw_vbo(
 
 /* Use the corresponding values */
 vertex_count = max_index - min_index + 1;
-ctx->payload_vertex.draw_start = min_index;
-ctx->payload_tiler.draw_start = min_index;
+ctx->payload_vertex.offset_start = min_index + 
info->index_bias;
+ctx->payload_tiler.offset_start = min_index + info->index_bias;
 
-ctx->payload_tiler.prefix.negative_start = -min_index;
+ctx->payload_tiler.prefix.offset_bias_correction = -min_index;
 ctx->payload_tiler.prefix.index_count = 
MALI_POSITIVE(info->count);
 
 //assert(!info->restart_index); /* TODO: Research */
-assert(!info->index_bias);
 
 draw_flags |= panfrost_translate_index_size(info->index_size);
 ctx->payload_tiler.prefix.indices = 
panfrost_get_index_buffer_mapped(ctx, info);
@@ -1735,7 +1734,7 @@ panfrost_draw_vbo(
 /* Index count == vertex count, if no indexing is applied, as
  * if it is internally indexed in the expected order */
 
-ctx->payload_tiler.prefix.negative_start = 0;
+ctx->payload_tiler.prefix.offset_bias_correction = 0;
 ctx->payload_tiler.prefix.index_count = 
MALI_POSITIVE(ctx->vertex_count);
 
 /* Reverse index state */
diff --git a/src/panfrost/include/panfrost-job.h 
b/src/panfrost/include/panfrost-job.h
index 297d0806adc..35577366bc3 100644
--- a/src/panfrost/include/panfrost-job.h
+++ b/src/panfrost/include/panfrost-job.h
@@ -917,8 +917,21 @@ struct mali_vertex_tiler_prefix {
 u32 workgroups_x_shift_3 : 6;
 
 
-/* Negative of draw_start for TILER jobs from what I've seen */
-int32_t negative_start;
+/* Negative of min_index. This is done in order to identify each vertex
+   in vertex shader runs.
+
+   The hardware adds negative_start in each run, so that absent an
+   index bias, the first vertex processed is genuinely the first
+   vertex (0). But with an index bias, the first vertex process
+   is numbered the same as the bias.
+
+   To represent this more conviniently:
+   current_vertex_index = min_index + index_bias + negative_start
+
+   This is done since the hardware doesn't accept a index_bias
+   and this allows it to recover the unbiased index.
+ */
+int32_t offset_bias_correction;
 u32 zero1;
 
 /* Like many other strictly nonzero quantities, index_count is
@@ -1062,7 +1075,7 @@ struct midgard_payload_vertex_tiler {
 u8 zero4;
 
 /* Offset for first vertex in buffer */
-u32 draw_start;

[Mesa-dev] [PATCH] panfrost: Take into account a index_bias for glDrawElementsBaseVertex calls

2019-07-18 Thread Rohan Garg
Make sure we adjust draw_start and vertex_count in order to
take into account a index_bias as required by a glDrawElementsBaseVertex
call

Signed-off-by: Rohan Garg 
---
 src/gallium/drivers/panfrost/pan_context.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/panfrost/pan_context.c 
b/src/gallium/drivers/panfrost/pan_context.c
index 4bbf5230c6c..6484401e472 100644
--- a/src/gallium/drivers/panfrost/pan_context.c
+++ b/src/gallium/drivers/panfrost/pan_context.c
@@ -1637,7 +1637,7 @@ panfrost_draw_vbo(
 
 ctx->payload_tiler.prefix.draw_mode = g2m_draw_mode(mode);
 
-ctx->vertex_count = info->count;
+ctx->vertex_count = info->count + info->index_bias;
 ctx->instance_count = info->instance_count;
 
 /* For non-indexed draws, they're the same */
@@ -1686,14 +1686,13 @@ panfrost_draw_vbo(
 
 /* Use the corresponding values */
 vertex_count = max_index - min_index + 1;
-ctx->payload_vertex.draw_start = min_index;
-ctx->payload_tiler.draw_start = min_index;
+ctx->payload_vertex.draw_start = min_index + info->index_bias;
+ctx->payload_tiler.draw_start = min_index + info->index_bias;
 
 ctx->payload_tiler.prefix.negative_start = -min_index;
 ctx->payload_tiler.prefix.index_count = 
MALI_POSITIVE(info->count);
 
 //assert(!info->restart_index); /* TODO: Research */
-assert(!info->index_bias);
 
 draw_flags |= panfrost_translate_index_size(info->index_size);
 ctx->payload_tiler.prefix.indices = 
panfrost_get_index_buffer_mapped(ctx, info);
-- 
2.17.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

[Mesa-dev] [PATCH] panfrost: Maintain a whitelist of supported GPU's

2019-06-24 Thread Rohan Garg
Maintain a list of panfrost supported GPU's and exit early when
running on a unsupported GPU.

Signed-off-by: Rohan Garg 
---
 src/gallium/drivers/panfrost/pan_screen.c | 15 +++
 src/gallium/drivers/panfrost/pan_screen.h |  6 ++
 2 files changed, 21 insertions(+)

diff --git a/src/gallium/drivers/panfrost/pan_screen.c 
b/src/gallium/drivers/panfrost/pan_screen.c
index dccb0143a53..a0c940d4c30 100644
--- a/src/gallium/drivers/panfrost/pan_screen.c
+++ b/src/gallium/drivers/panfrost/pan_screen.c
@@ -563,6 +563,8 @@ panfrost_screen_get_compiler_options(struct pipe_screen 
*pscreen,
 struct pipe_screen *
 panfrost_create_screen(int fd, struct renderonly *ro)
 {
+unsigned gpu_id;
+bool supported_gpu = false;
 struct panfrost_screen *screen = rzalloc(NULL, struct panfrost_screen);
 
pan_debug = debug_get_option_pan_debug();
@@ -581,6 +583,19 @@ panfrost_create_screen(int fd, struct renderonly *ro)
 
 screen->fd = fd;
 
+gpu_id = panfrost_drm_query_gpu_version(screen);
+
+for (int i = 0; i < ARRAY_SIZE(panfrost_supported_gpus); i++) {
+if (panfrost_supported_gpus[i] == gpu_id)
+supported_gpu = true;
+}
+
+if (!supported_gpu) {
+fprintf(stderr, "Unsupported GPU\n");
+free(screen);
+return NULL;
+}
+
 if (pan_debug & PAN_DBG_TRACE)
 pandecode_initialize();
 
diff --git a/src/gallium/drivers/panfrost/pan_screen.h 
b/src/gallium/drivers/panfrost/pan_screen.h
index 4907bd4395f..8c8915d0ad5 100644
--- a/src/gallium/drivers/panfrost/pan_screen.h
+++ b/src/gallium/drivers/panfrost/pan_screen.h
@@ -46,6 +46,12 @@ struct panfrost_screen;
 #define PAN_ALLOCATE_INVISIBLE (1 << 2)
 #define PAN_ALLOCATE_COHERENT_LOCAL (1 << 3)
 
+static const panfrost_supported_gpus[] = {
+0x0750,
+0x0820,
+0x0860
+};
+
 struct panfrost_screen {
 struct pipe_screen base;
 int fd;
-- 
2.17.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Re: [Mesa-dev] [PATCH 1/3] panfrost: Print a backtrace if there is one

2019-06-24 Thread Rohan Garg
> I think assertions should be limited to the most basic of sanity checks,
> and the other asserts replaced by proper error handling.

So, should I leave it as is and let us hit assertions that we fix?

Cheers
Rohan Garg

signature.asc
Description: This is a digitally signed message part.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Re: [Mesa-dev] [PATCH] panfrost: Implement command stream scoreboarding

2019-06-21 Thread Rohan Garg
 payload = {
> +.out = polygon_list,
> +.unknown = 0x3,
> +};
> +
> +struct panfrost_transfer transfer =
> panfrost_allocate_transient(ctx, sizeof(job) + sizeof(payload)); +   
> memcpy(transfer.cpu, , sizeof(job));
> +memcpy(transfer.cpu + sizeof(job), , sizeof(payload));
> +
> +return transfer;
> +}
> +
> +/* If there are any tiler jobs, there needs to be a corresponding set value
> job + * linked to the first vertex job feeding into tiling. */
> +
> +static void
> +panfrost_scoreboard_set_value(struct panfrost_job *batch)
> +{
> +/* Check if we even need tiling */
> +if (!batch->last_tiler.gpu)
> +return;
> +
> +/* Okay, we do. Let's generate it */
> +
> +struct panfrost_context *ctx = batch->ctx;
> +mali_ptr polygon_list = ctx->tiler_polygon_list.gpu;
> +
> +struct panfrost_transfer job =
> +panfrost_set_value_job(ctx, polygon_list);
> +
> +/* Queue it */
> +panfrost_scoreboard_queue_compute_job(batch, job);
> +
> +/* Tiler jobs need us */
> +panfrost_add_dependency(batch->first_tiler, job);
> +}
> +
> +/* Once all jobs have been added to a batch and we're ready to submit, we
> need + * to order them to set each of the next_job fields, obeying the
> golden rule: + * "A job's dependencies must appear earlier in the job chain
> than itself". + * Fortunately, computing this job chain is a well-studied
> graph theory problem + * known as "topological sorting", which has linear
> time algorithms. We let + * each job represent a node, each dependency a
> directed edge, and the entire + * set of jobs to be a dependency graph.
> This graph is inherently acyclic, as + * otherwise there are unresolveable
> dependencies.
> + *
> + * We implement Kahn's algorithm here to compute the next_job chain:
> + * https://en.wikipedia.org/wiki/Topological_sorting#Kahn's_algorithm
> + *
> + * A few implementation notes: we represent S explicitly with a bitset, L
> + * implicitly in the next_job fields. The indices of the bitset are
> off-by-one: + * nodes are numbered [0, node_count - 1], whereas in reality
> job_index in the + * hardware and dependencies are [1, node_count].
> + *
> + * We represent edge removal implicitly with another pair of bitsets,
> rather + * than explicitly removing the edges, since we need to keep the
> dependencies + * there for the hardware.
> + */
> +
> +#define DESCRIPTOR_FOR_NODE(count) \
> +*(util_dynarray_element(>headers, \
> +struct mali_job_descriptor_header*, count))
> +
> +#define GPU_ADDRESS_FOR_NODE(count) \
> +*(util_dynarray_element(>gpu_headers, \
> +mali_ptr, count))
> +
> +void
> +panfrost_scoreboard_link_batch(struct panfrost_job *batch)
> +{
> +/* Finalize the batch */
> +panfrost_scoreboard_set_value(batch);
> +
> +/* Let no_incoming represent the set S described. */
> +
> +unsigned node_count = batch->job_index;
> +
> +size_t sz = BITSET_WORDS(node_count) * sizeof(BITSET_WORD);
> +BITSET_WORD *no_incoming = calloc(sz, 1);
> +
> +/* Sets for edges being removed in dep 1 or 2 respectively */
> +
> +BITSET_WORD *edge_removal_1 = calloc(sz, 1);
> +BITSET_WORD *edge_removal_2 = calloc(sz, 1);
> +
> +/* We compute no_incoming by traversing the batch. */
> +
> +for (unsigned i = 0; i < node_count; ++i) {
> +struct mali_job_descriptor_header *node =
> DESCRIPTOR_FOR_NODE(i); +
> +unsigned dep_1 = node->job_dependency_index_1;
> +unsigned dep_2 = node->job_dependency_index_2;
> +
> +if (!(dep_1 || dep_2))
> +BITSET_SET(no_incoming, i);
> +}
> +
> +/* No next_job fields are set at the beginning, so L is implciitly
> the + * empty set. As next_job fields are filled, L is implicitly
> set. Tail + * is the tail of L, however. */
> +
> +struct mali_job_descriptor_header *tail = NULL;
> +
> +/* We iterate, popping off elements of S. A simple foreach won't
> do, + * since we mutate S as we go (even adding elements) */
> +
> +unsigned arr_size = BITSET_WORDS(node_count);
> +
> +for (unsigned node_n_1 = __bitset_ffs(no_incoming, arr_size);
> +(node_n_1 != 0);
> +node_n_1 = __bitset_ffs(no_incoming, arr_size)) {
> +
> +unsigned node_n = node_n_1 - 1;
> +
> +/* We've got a node n, pop it off */
> +BITSET_CLEAR(no_incoming, node_n);
> +
> +/* Add it to the list */
> +struct mali_job_descriptor_header *n =
> +DESCRIPTOR_FOR_NODE(node_n);
> +
> +mali_ptr addr = GPU_ADDRESS_FOR_NODE(node_n);
> +
> +if (tail) {
> +/* Link us to the last node */
> +panfrost_set_job_next(tail, addr);
> +} else {
> +/* We are the first/last node */
> +batch->first_job.cpu = (uint8_t *) n;
> +batch->first_job.gpu = addr;
> +}
> +
> +tail = n;
> +
> +/* Scan dependencies */
> +for (unsigned node_m = 0; node_m < node_count; ++node_m) {
> +struct mali_job_descriptor_header *m =
> +DESCRIPTOR_FOR_NODE(node_m);
> +
> +/* Get the deps, accounting for removal */
> +unsigned dep_1 = m->job_dependency_index_1;
> +unsigned dep_2 = m->job_dependency_index_2;
> +
> +if (BITSET_TEST(edge_removal_1, node_m))
> +dep_1 = 0;
> +
> +if (BITSET_TEST(edge_removal_2, node_m))
> +dep_2 = 0;
> +
> +/* Pretend to remove edges */
> +if (dep_1 == node_n_1) {
> +BITSET_SET(edge_removal_1, node_m);
> +dep_1 = 0;
> +} else if (dep_2 == node_n_1) {
> +BITSET_SET(edge_removal_2, node_m);
> +dep_2 = 0;
> +} else {
> +/* This node has no relevant dependencies
> */ +continue;
> +}
> +
> +/* Are there edges left? If not, add us to S */
> +bool has_edges = dep_1 || dep_2;
> +
> +if (!has_edges)
> +BITSET_SET(no_incoming, node_m);
> +}
> +}
> +
> +}

Awesome stuff \o/

R-b :)

Cheers
Rohan Garg


signature.asc
Description: This is a digitally signed message part.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

[Mesa-dev] [PATCH 1/1] panfrost: Use mir_foreach_instr_in_block_safe

2019-06-21 Thread Rohan Garg
Use the _safe version as asserted by gallium

Signed-off-by: Rohan Garg 
---
 src/gallium/drivers/panfrost/midgard/midgard_schedule.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/drivers/panfrost/midgard/midgard_schedule.c 
b/src/gallium/drivers/panfrost/midgard/midgard_schedule.c
index 0bf3502f41c..1aef19c824c 100644
--- a/src/gallium/drivers/panfrost/midgard/midgard_schedule.c
+++ b/src/gallium/drivers/panfrost/midgard/midgard_schedule.c
@@ -406,7 +406,7 @@ schedule_block(compiler_context *ctx, midgard_block *block)
 
 block->quadword_count = 0;
 
-mir_foreach_instr_in_block(block, ins) {
+mir_foreach_instr_in_block_safe(block, ins) {
 int skip;
 midgard_bundle bundle = schedule_bundle(ctx, block, ins, 
);
 util_dynarray_append(>bundles, midgard_bundle, bundle);
-- 
2.17.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Re: [Mesa-dev] [PATCH 2/3] panfrost: Make the gitlab-ci.yml file more robust

2019-06-21 Thread Rohan Garg
On Friday, 21 June 2019 07:40:02 CEST Tomeu Vizoso wrote:
> On 6/20/19 6:33 PM, Rohan Garg wrote:
> >> Not sure I understand how this works. Isn't this going to cause
> >> unnecessary container builds?
> >> 
> >> And, why cannot developers just add whatever they want to DEBIAN_TAG
> >> to that end?
> > 
> > This will spin a container for each branch, yes, though I think that is
> > how it should be.
> 
> Well, things are like this right now precisely because people wanted to
> avoid what you are proposing. I would be quite sad if every time I push a
> new branch I had to wait for the container to be rebuilt. Also note that
> this is how other projects based on wayland/ci-templates work, including
> the rest of mesa.
> 
> > The patch allows for someone working in a branch to
> > ( if the need be ) customize their containers for their branch.
> 
> As I said, you can easily do that atm by just updating DEBIAN_TAG.
> 
> > To that extent, I've simply enabled the CI to auto generate a DEBIAN_TAG
> > which depends on the branch name so that a developer doesn't have to
> > change
> > the DEBIAN_TAG themselves.
> 
> But, why is that such a problem?
> 

Fair enough, I'll rework the patch to drop the modified DEBIAN_TAG then.

Cheers
Rohan Garg

signature.asc
Description: This is a digitally signed message part.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Re: [Mesa-dev] [PATCH 1/3] panfrost: Print a backtrace if there is one

2019-06-21 Thread Rohan Garg
Hey
> Good stuff, but isn't this change making us hit assertions?

Hm, I thought it only enabled debugging symbols. Do you have a recommendation 
on how to enable debug symbols but not enabling assertions?

Cheers
Rohan Garg


___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Re: [Mesa-dev] [PATCH 2/3] panfrost: Make the gitlab-ci.yml file more robust

2019-06-20 Thread Rohan Garg

Not sure I understand how this works. Isn't this going to cause
unnecessary container builds?

And, why cannot developers just add whatever they want to DEBIAN_TAG
to that end?



This will spin a container for each branch, yes, though I think that is
how it should be. The patch allows for someone working in a branch to
( if the need be ) customize their containers for their branch.

To that extent, I've simply enabled the CI to auto generate a DEBIAN_TAG
which depends on the branch name so that a developer doesn't have to change
the DEBIAN_TAG themselves.

Cheers
Rohan Garg
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Re: [Mesa-dev] [PATCH] panfrost: Set job requirements during draw

2019-06-20 Thread Rohan Garg
On Thursday, 20 June 2019 16:06:57 CEST you wrote:
> Right now we are doing it at a moment when we don't have all the
> information we need.
> 
> Signed-off-by: Tomeu Vizoso 
> Suggested-by: Alyssa Rosenzweig 
> Cc: Rohan Garg 
> Fixes: bfca21b622df ("panfrost: Figure out job requirements in pan_job.c")
> ---
>  src/gallium/drivers/panfrost/pan_context.c | 2 ++
>  src/gallium/drivers/panfrost/pan_job.c | 1 -
>  2 files changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/src/gallium/drivers/panfrost/pan_context.c 
> b/src/gallium/drivers/panfrost/pan_context.c
> index 470a259419b6..d33c9331e67d 100644
> --- a/src/gallium/drivers/panfrost/pan_context.c
> +++ b/src/gallium/drivers/panfrost/pan_context.c
> @@ -1056,6 +1056,8 @@ panfrost_emit_for_draw(struct panfrost_context *ctx, 
> bool with_vertex_data)
>  SET_BIT(ctx->fragment_shader_core.unknown2_4, MALI_NO_MSAA, 
> !msaa);
>  }
>  
> + panfrost_job_set_requirements(ctx, job);
> +
>  if (ctx->occlusion_query) {
>  ctx->payload_tiler.gl_enables |= MALI_OCCLUSION_QUERY | 
> MALI_OCCLUSION_PRECISE;
>  ctx->payload_tiler.postfix.occlusion_counter = 
> ctx->occlusion_query->transfer.gpu;
> diff --git a/src/gallium/drivers/panfrost/pan_job.c 
> b/src/gallium/drivers/panfrost/pan_job.c
> index 717676021b44..9c5d385e2ef2 100644
> --- a/src/gallium/drivers/panfrost/pan_job.c
> +++ b/src/gallium/drivers/panfrost/pan_job.c
> @@ -90,7 +90,6 @@ panfrost_get_job(struct panfrost_context *ctx,
>  
>  memcpy(>key, , sizeof(key));
>  _mesa_hash_table_insert(ctx->jobs, >key, job);
> -panfrost_job_set_requirements(ctx, job);
>  
>  return job;
>  }
> 

Ack :)

Cheers
Rohan Garg
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

[Mesa-dev] [PATCH 3/3] panfrost: The working dir is deleted right before

2019-06-20 Thread Rohan Garg
Change to /artifacts in order to potentially fix
debootstrap failiures.
---
 src/gallium/drivers/panfrost/ci/debian-install.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/gallium/drivers/panfrost/ci/debian-install.sh 
b/src/gallium/drivers/panfrost/ci/debian-install.sh
index 8a8b4ec9a47..dca6d49197c 100644
--- a/src/gallium/drivers/panfrost/ci/debian-install.sh
+++ b/src/gallium/drivers/panfrost/ci/debian-install.sh
@@ -118,6 +118,7 @@ rm -rf /kernel
 
 
 ### Create rootfs
+cd /artifacts
 cp ${PANFROST_CI_DIR}/create-rootfs.sh /artifacts/rootfs/.
 debootstrap --variant=minbase --arch=${DEBIAN_ARCH} testing /artifacts/rootfs/ 
http://deb.debian.org/debian
 chroot /artifacts/rootfs sh /create-rootfs.sh
-- 
2.17.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

[Mesa-dev] [PATCH 2/3] panfrost: Make the gitlab-ci.yml file more robust

2019-06-20 Thread Rohan Garg
This enables developers to add packages to the container
when working on their own branches by creating
a container tag which features the branch name.
Dropped the IMAGE_LOCAL variable since I did not see it being
used anywhere.
---
 src/gallium/drivers/panfrost/ci/gitlab-ci.yml | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/panfrost/ci/gitlab-ci.yml 
b/src/gallium/drivers/panfrost/ci/gitlab-ci.yml
index 887c93dbc8b..7be53d623d6 100644
--- a/src/gallium/drivers/panfrost/ci/gitlab-ci.yml
+++ b/src/gallium/drivers/panfrost/ci/gitlab-ci.yml
@@ -16,7 +16,8 @@
 variables:
   UPSTREAM_REPO: mesa/mesa
   DEBIAN_VERSION: testing-slim
-  DEBIAN_TAG: "2019-06-17-1"
+  REV: 2019-06-17-1
+  DEBIAN_TAG: "${CI_COMMIT_REF_SLUG}_${DEBIAN_ARCH}_${REV}"
 
 include:
   - project: 'wayland/ci-templates'
@@ -42,7 +43,6 @@ stages:
   <<: *retry
   variables:
 GIT_STRATEGY: none # no need to pull the whole tree for rebuilding the 
image
-IMAGE_LOCAL: "$CI_REGISTRY/$CI_PROJECT_PATH/${DEBIAN_ARCH}:latest"
 DEBIAN_EXEC: 'DEBIAN_ARCH=${DEBIAN_ARCH}
   GCC_ARCH=${GCC_ARCH}
   KERNEL_ARCH=${KERNEL_ARCH}
@@ -73,7 +73,7 @@ container:arm64:
 
 .build:
   stage: build
-  image: $CI_REGISTRY/$CI_PROJECT_PATH/${DEBIAN_ARCH}:latest
+  image: "$CI_REGISTRY_IMAGE/debian/$DEBIAN_VERSION:$DEBIAN_TAG"
   cache:
 paths:
   - ccache
-- 
2.17.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

[Mesa-dev] [PATCH 1/3] panfrost: Print a backtrace if there is one

2019-06-20 Thread Rohan Garg
---
 src/gallium/drivers/panfrost/ci/create-rootfs.sh | 2 +-
 src/gallium/drivers/panfrost/ci/deqp-runner.sh   | 6 ++
 src/gallium/drivers/panfrost/ci/gitlab-ci.yml| 4 ++--
 src/gallium/drivers/panfrost/ci/lava-deqp.yml.jinja2 | 3 +++
 4 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/panfrost/ci/create-rootfs.sh 
b/src/gallium/drivers/panfrost/ci/create-rootfs.sh
index 84ce8cdc882..ff0742238fe 100644
--- a/src/gallium/drivers/panfrost/ci/create-rootfs.sh
+++ b/src/gallium/drivers/panfrost/ci/create-rootfs.sh
@@ -2,7 +2,7 @@
 
 set -ex
 
-apt-get -y install --no-install-recommends initramfs-tools libpng16-16 weston 
strace libsensors5
+apt-get -y install --no-install-recommends initramfs-tools libpng16-16 weston 
strace libsensors5 gdb
 passwd root -d
 chsh -s /bin/sh
 ln -s /bin/sh /init
diff --git a/src/gallium/drivers/panfrost/ci/deqp-runner.sh 
b/src/gallium/drivers/panfrost/ci/deqp-runner.sh
index 8645f75080e..47eef89a0d0 100644
--- a/src/gallium/drivers/panfrost/ci/deqp-runner.sh
+++ b/src/gallium/drivers/panfrost/ci/deqp-runner.sh
@@ -53,3 +53,9 @@ while [ -s /tmp/case-list.txt ]; do
sed -i '1,'$BATCH_SIZE'd' /tmp/case-list.txt
fi
 done
+
+if [ -e /tmp/core ]; then
+   /usr/bin/gdb /usr/bin/weston /tmp/core \
+   -batch \
+   -ex "t a a bt"
+fi
diff --git a/src/gallium/drivers/panfrost/ci/gitlab-ci.yml 
b/src/gallium/drivers/panfrost/ci/gitlab-ci.yml
index e1035e0fdff..887c93dbc8b 100644
--- a/src/gallium/drivers/panfrost/ci/gitlab-ci.yml
+++ b/src/gallium/drivers/panfrost/ci/gitlab-ci.yml
@@ -16,7 +16,7 @@
 variables:
   UPSTREAM_REPO: mesa/mesa
   DEBIAN_VERSION: testing-slim
-  DEBIAN_TAG: "2019-06-07-1"
+  DEBIAN_TAG: "2019-06-17-1"
 
 include:
   - project: 'wayland/ci-templates'
@@ -91,7 +91,7 @@ container:arm64:
 - meson . mesa-build
 --cross-file /tmp/cross_file.txt
 --libdir /artifacts/rootfs/mesa/lib/
---buildtype release
+--buildtype debug
 -Dgallium-drivers=kmsro,panfrost
 -Ddri-drivers=
 -Dprefix=/artifacts/rootfs/mesa
diff --git a/src/gallium/drivers/panfrost/ci/lava-deqp.yml.jinja2 
b/src/gallium/drivers/panfrost/ci/lava-deqp.yml.jinja2
index f610f9c826a..8f3d516da76 100644
--- a/src/gallium/drivers/panfrost/ci/lava-deqp.yml.jinja2
+++ b/src/gallium/drivers/panfrost/ci/lava-deqp.yml.jinja2
@@ -52,6 +52,9 @@ actions:
   - mount -t devpts devpts /dev/pts
   - echo 1 > /proc/sys/kernel/printk
 #  - echo performance > 
/sys/devices/platform/ff9a.gpu/devfreq/devfreq0/governor
+  - echo /tmp/core > /proc/sys/kernel/core_pattern
+  - echo 0 > /proc/sys/kernel/core_uses_pid
+  - ulimit -c unlimited
   - sh /deqp/deqp-runner.sh
 parse:
   pattern: 'Test case 
''(?P\S*)''..\s+(?P(Pass|NotSupported|QualityWarning|CompatibilityWarning|Fail|ResourceError|Crash|Timeout|InternalError))'
-- 
2.17.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

[Mesa-dev] [PATCH 0/3] panfrost: CI improvements

2019-06-20 Thread Rohan Garg
I've made a few improvements to make the CI a bit
more robust.

Rohan Garg (3):
  panfrost: Print a backtrace if there is one
  panfrost: Make the gitlab-ci.yml file more robust
  panfrost: The working dir is deleted right before

 src/gallium/drivers/panfrost/ci/create-rootfs.sh | 2 +-
 src/gallium/drivers/panfrost/ci/debian-install.sh| 1 +
 src/gallium/drivers/panfrost/ci/deqp-runner.sh   | 6 ++
 src/gallium/drivers/panfrost/ci/gitlab-ci.yml| 8 
 src/gallium/drivers/panfrost/ci/lava-deqp.yml.jinja2 | 3 +++
 5 files changed, 15 insertions(+), 5 deletions(-)

-- 
2.17.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

[Mesa-dev] [PATCH libdrm 7/9] panfrost/midgard: Move draw_count into panfrost_job

2019-06-12 Thread Rohan Garg
Refactor code to use draw_counts from a panfrost_job
---
 src/gallium/drivers/panfrost/pan_context.c | 31 --
 src/gallium/drivers/panfrost/pan_context.h |  2 --
 src/gallium/drivers/panfrost/pan_job.c |  4 +--
 src/gallium/drivers/panfrost/pan_job.h |  2 ++
 4 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/src/gallium/drivers/panfrost/pan_context.c 
b/src/gallium/drivers/panfrost/pan_context.c
index eaceaa8725e..ced25cf4b82 100644
--- a/src/gallium/drivers/panfrost/pan_context.c
+++ b/src/gallium/drivers/panfrost/pan_context.c
@@ -580,10 +580,12 @@ panfrost_link_job_pair(struct mali_job_descriptor_header 
*first, mali_ptr next)
 struct panfrost_transfer
 panfrost_vertex_tiler_job(struct panfrost_context *ctx, bool is_tiler)
 {
+struct panfrost_job *job = panfrost_get_job_for_fbo(ctx);
+
 /* Each draw call corresponds to two jobs, and the set-value job is 
first */
-int draw_job_index = 1 + (2 * ctx->draw_count) + 1;
+int draw_job_index = 1 + (2 * job->draw_count) + 1;
 
-struct mali_job_descriptor_header job = {
+struct mali_job_descriptor_header next_job = {
 .job_type = is_tiler ? JOB_TYPE_TILER : JOB_TYPE_VERTEX,
 .job_index = draw_job_index + (is_tiler ? 1 : 0),
 #ifdef __LP64__
@@ -605,25 +607,25 @@ panfrost_vertex_tiler_job(struct panfrost_context *ctx, 
bool is_tiler)
 if (is_tiler) {
 /* Tiler jobs depend on vertex jobs */
 
-job.job_dependency_index_1 = draw_job_index;
+next_job.job_dependency_index_1 = draw_job_index;
 
 /* Tiler jobs also depend on the previous tiler job */
 
-if (ctx->draw_count) {
-job.job_dependency_index_2 = draw_job_index - 1;
+if (job->draw_count) {
+next_job.job_dependency_index_2 = draw_job_index - 1;
 /* Previous tiler job points to this tiler job */
-
panfrost_link_job_pair(ctx->u_tiler_jobs[ctx->draw_count - 1], transfer.gpu);
+
panfrost_link_job_pair(ctx->u_tiler_jobs[job->draw_count - 1], transfer.gpu);
 } else {
 /* The only vertex job so far points to first tiler 
job */
 panfrost_link_job_pair(ctx->u_vertex_jobs[0], 
transfer.gpu);
 }
 } else {
-if (ctx->draw_count) {
+if (job->draw_count) {
 /* Previous vertex job points to this vertex job */
-
panfrost_link_job_pair(ctx->u_vertex_jobs[ctx->draw_count - 1], transfer.gpu);
+
panfrost_link_job_pair(ctx->u_vertex_jobs[job->draw_count - 1], transfer.gpu);
 } else {
 /* Have the first vertex job depend on the set value 
job */
-job.job_dependency_index_1 = 
ctx->u_set_value_job->job_index;
+next_job.job_dependency_index_1 = 
ctx->u_set_value_job->job_index;
 panfrost_link_job_pair(ctx->u_set_value_job, 
transfer.gpu);
 }
 }
@@ -1245,8 +1247,9 @@ panfrost_emit_for_draw(struct panfrost_context *ctx, bool 
with_vertex_data)
 static void
 panfrost_queue_draw(struct panfrost_context *ctx)
 {
+struct panfrost_job *job = panfrost_get_job_for_fbo(ctx);
 /* TODO: Expand the array? */
-if (ctx->draw_count >= MAX_DRAW_CALLS) {
+if (job->draw_count >= MAX_DRAW_CALLS) {
 DBG("Job buffer overflow, ignoring draw\n");
 assert(0);
 }
@@ -1255,7 +1258,7 @@ panfrost_queue_draw(struct panfrost_context *ctx)
 panfrost_emit_for_draw(ctx, true);
 
 /* We need a set_value job before any other draw jobs */
-if (ctx->draw_count == 0)
+if (job->draw_count == 0)
 panfrost_set_value_job(ctx);
 
 struct panfrost_transfer vertex = panfrost_vertex_tiler_job(ctx, 
false);
@@ -1264,7 +1267,7 @@ panfrost_queue_draw(struct panfrost_context *ctx)
 struct panfrost_transfer tiler = panfrost_vertex_tiler_job(ctx, true);
 ctx->u_tiler_jobs[ctx->tiler_job_count] = (struct 
mali_job_descriptor_header *) tiler.cpu;
 
-ctx->draw_count++;
+job->draw_count++;
 }
 
 /* The entire frame is in memory -- send it off to the kernel! */
@@ -1278,7 +1281,7 @@ panfrost_submit_frame(struct panfrost_context *ctx, bool 
flush_immediate,
 struct panfrost_screen *screen = pan_screen(gallium->screen);
 
 /* Edge case if screen is cleared and nothing else */
-bool has_draws = ctx->draw_count > 0;
+bool has_draws = job->draw_count > 0;
 
 /* Workaround a bizarre lockup (a hardware errata?) */
 if (!has_draws)
@@ -1323,7 +1326,7 @@ panfrost_flush(
 struct panfrost_job *job = panfrost_get_job_for_fbo(ctx);

[Mesa-dev] [PATCH libdrm 5/9] panfrost/midgard: Remove unnecessary variables

2019-06-12 Thread Rohan Garg
These are not required anymore since mali jobs are
now linked lists i.e. u_vertex_jobs and u_tiler_jobs
---
 src/gallium/drivers/panfrost/pan_context.c   | 5 -
 src/gallium/drivers/panfrost/pan_context.h   | 2 --
 src/gallium/drivers/panfrost/pan_wallpaper.c | 1 -
 3 files changed, 8 deletions(-)

diff --git a/src/gallium/drivers/panfrost/pan_context.c 
b/src/gallium/drivers/panfrost/pan_context.c
index d372f295979..66762a010f8 100644
--- a/src/gallium/drivers/panfrost/pan_context.c
+++ b/src/gallium/drivers/panfrost/pan_context.c
@@ -622,9 +622,6 @@ panfrost_vertex_tiler_job(struct panfrost_context *ctx, 
bool is_tiler)
 if (ctx->draw_count) {
 /* Previous vertex job points to this vertex job */
 
panfrost_link_job_pair(ctx->u_vertex_jobs[ctx->draw_count - 1], transfer.gpu);
-
-/* Last vertex job points to first tiler job */
-panfrost_link_job_pair(, ctx->tiler_jobs[0]);
 } else {
 /* Have the first vertex job depend on the set value 
job */
 job.job_dependency_index_1 = 
ctx->u_set_value_job->job_index;
@@ -1264,11 +1261,9 @@ panfrost_queue_draw(struct panfrost_context *ctx)
 
 struct panfrost_transfer vertex = panfrost_vertex_tiler_job(ctx, 
false);
 ctx->u_vertex_jobs[ctx->vertex_job_count] = (struct 
mali_job_descriptor_header *) vertex.cpu;
-ctx->vertex_jobs[ctx->vertex_job_count++] = vertex.gpu;
 
 struct panfrost_transfer tiler = panfrost_vertex_tiler_job(ctx, true);
 ctx->u_tiler_jobs[ctx->tiler_job_count] = (struct 
mali_job_descriptor_header *) tiler.cpu;
-ctx->tiler_jobs[ctx->tiler_job_count++] = tiler.gpu;
 
 ctx->draw_count++;
 }
diff --git a/src/gallium/drivers/panfrost/pan_context.h 
b/src/gallium/drivers/panfrost/pan_context.h
index e3dc07059b5..27bb92b8330 100644
--- a/src/gallium/drivers/panfrost/pan_context.h
+++ b/src/gallium/drivers/panfrost/pan_context.h
@@ -156,8 +156,6 @@ struct panfrost_context {
 unsigned draw_count;
 
 mali_ptr set_value_job;
-mali_ptr vertex_jobs[MAX_DRAW_CALLS];
-mali_ptr tiler_jobs[MAX_DRAW_CALLS];
 
 struct mali_job_descriptor_header *u_set_value_job;
 struct mali_job_descriptor_header *u_vertex_jobs[MAX_DRAW_CALLS];
diff --git a/src/gallium/drivers/panfrost/pan_wallpaper.c 
b/src/gallium/drivers/panfrost/pan_wallpaper.c
index ac77ad089bc..963ab608ab7 100644
--- a/src/gallium/drivers/panfrost/pan_wallpaper.c
+++ b/src/gallium/drivers/panfrost/pan_wallpaper.c
@@ -250,7 +250,6 @@ panfrost_draw_wallpaper(struct pipe_context *pipe)
 struct panfrost_transfer tiler = panfrost_vertex_tiler_job(ctx, true, 
true);
 struct mali_job_descriptor_header *jd = (struct 
mali_job_descriptor_header *) tiler.cpu;
 ctx->u_tiler_jobs[ctx->tiler_job_count] = jd;
-ctx->tiler_jobs[ctx->tiler_job_count++] = tiler.gpu;
 ctx->draw_count++;
 
 /* Okay, so we have the tiler job emitted. Since we set elided_tiler
-- 
2.17.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

[Mesa-dev] [PATCH libdrm 6/9] panfrost/midgard: Remove duplicated header

2019-06-12 Thread Rohan Garg
---
 src/gallium/drivers/panfrost/pan_context.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/gallium/drivers/panfrost/pan_context.c 
b/src/gallium/drivers/panfrost/pan_context.c
index 66762a010f8..eaceaa8725e 100644
--- a/src/gallium/drivers/panfrost/pan_context.c
+++ b/src/gallium/drivers/panfrost/pan_context.c
@@ -30,7 +30,6 @@
 #include "pan_format.h"
 
 #include "util/macros.h"
-#include "util/u_format.h"
 #include "util/u_inlines.h"
 #include "util/u_upload_mgr.h"
 #include "util/u_memory.h"
-- 
2.17.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

[Mesa-dev] [PATCH libdrm 4/9] panfrost/midgard: Move clearing logic into pan_job

2019-06-12 Thread Rohan Garg
---
 src/gallium/drivers/panfrost/pan_context.c | 49 +-
 src/gallium/drivers/panfrost/pan_job.c | 59 ++
 src/gallium/drivers/panfrost/pan_job.h |  8 +++
 3 files changed, 68 insertions(+), 48 deletions(-)

diff --git a/src/gallium/drivers/panfrost/pan_context.c 
b/src/gallium/drivers/panfrost/pan_context.c
index 4c53b2d58f5..d372f295979 100644
--- a/src/gallium/drivers/panfrost/pan_context.c
+++ b/src/gallium/drivers/panfrost/pan_context.c
@@ -245,40 +245,6 @@ panfrost_is_scanout(struct panfrost_context *ctx)
ctx->pipe_framebuffer.cbufs[0]->texture->bind & 
PIPE_BIND_SHARED;
 }
 
-static uint32_t
-pan_pack_color(const union pipe_color_union *color, enum pipe_format format)
-{
-/* Alpha magicked to 1.0 if there is no alpha */
-
-bool has_alpha = util_format_has_alpha(format);
-float clear_alpha = has_alpha ? color->f[3] : 1.0f;
-
-/* Packed color depends on the framebuffer format */
-
-const struct util_format_description *desc =
-util_format_description(format);
-
-if (util_format_is_rgba8_variant(desc)) {
-return (float_to_ubyte(clear_alpha) << 24) |
-   (float_to_ubyte(color->f[2]) << 16) |
-   (float_to_ubyte(color->f[1]) <<  8) |
-   (float_to_ubyte(color->f[0]) <<  0);
-} else if (format == PIPE_FORMAT_B5G6R5_UNORM) {
-/* First, we convert the components to R5, G6, B5 separately */
-unsigned r5 = CLAMP(color->f[0], 0.0, 1.0) * 31.0;
-unsigned g6 = CLAMP(color->f[1], 0.0, 1.0) * 63.0;
-unsigned b5 = CLAMP(color->f[2], 0.0, 1.0) * 31.0;
-
-/* Then we pack into a sparse u32. TODO: Why these shifts? */
-return (b5 << 25) | (g6 << 14) | (r5 << 5);
-} else {
-/* Unknown format */
-assert(0);
-}
-
-return 0;
-}
-
 static void
 panfrost_clear(
 struct pipe_context *pipe,
@@ -289,20 +255,7 @@ panfrost_clear(
 struct panfrost_context *ctx = pan_context(pipe);
 struct panfrost_job *job = panfrost_get_job_for_fbo(ctx);
 
-if (buffers & PIPE_CLEAR_COLOR) {
-enum pipe_format format = 
ctx->pipe_framebuffer.cbufs[0]->format;
-job->clear_color = pan_pack_color(color, format);
-}
-
-if (buffers & PIPE_CLEAR_DEPTH) {
-job->clear_depth = depth;
-}
-
-if (buffers & PIPE_CLEAR_STENCIL) {
-job->clear_stencil = stencil;
-}
-
-job->clear |= buffers;
+panfrost_job_clear(ctx, job, buffers, color, depth, stencil);
 }
 
 static mali_ptr
diff --git a/src/gallium/drivers/panfrost/pan_job.c 
b/src/gallium/drivers/panfrost/pan_job.c
index 0083ca6499e..be2742a0dc5 100644
--- a/src/gallium/drivers/panfrost/pan_job.c
+++ b/src/gallium/drivers/panfrost/pan_job.c
@@ -26,6 +26,7 @@
 #include "pan_context.h"
 #include "util/hash_table.h"
 #include "util/ralloc.h"
+#include "util/u_format.h"
 
 struct panfrost_job *
 panfrost_create_job(struct panfrost_context *ctx)
@@ -175,6 +176,64 @@ panfrost_job_set_requirements(struct panfrost_context *ctx,
 job->requirements |= PAN_REQ_DEPTH_WRITE;
 }
 
+static uint32_t
+pan_pack_color(const union pipe_color_union *color, enum pipe_format format)
+{
+/* Alpha magicked to 1.0 if there is no alpha */
+
+bool has_alpha = util_format_has_alpha(format);
+float clear_alpha = has_alpha ? color->f[3] : 1.0f;
+
+/* Packed color depends on the framebuffer format */
+
+const struct util_format_description *desc =
+util_format_description(format);
+
+if (util_format_is_rgba8_variant(desc)) {
+return (float_to_ubyte(clear_alpha) << 24) |
+   (float_to_ubyte(color->f[2]) << 16) |
+   (float_to_ubyte(color->f[1]) <<  8) |
+   (float_to_ubyte(color->f[0]) <<  0);
+} else if (format == PIPE_FORMAT_B5G6R5_UNORM) {
+/* First, we convert the components to R5, G6, B5 separately */
+unsigned r5 = CLAMP(color->f[0], 0.0, 1.0) * 31.0;
+unsigned g6 = CLAMP(color->f[1], 0.0, 1.0) * 63.0;
+unsigned b5 = CLAMP(color->f[2], 0.0, 1.0) * 31.0;
+
+/* Then we pack into a sparse u32. TODO: Why these shifts? */
+return (b5 << 25) | (g6 << 14) | (r5 << 5);
+} else {
+/* Unknown format */
+assert(0);
+}
+
+return 0;
+}
+
+void
+panfrost_job_clear(struct panfrost_context *ctx,
+struct panfrost_job *job,
+unsigned buffers,
+const union pipe_color_union *color,
+double depth, unsigned stencil)
+
+{
+if (buffers & PIPE_CLEAR_COLOR) {
+enum 

[Mesa-dev] [PATCH libdrm 9/9] Fixes 88ae2f5870c: "panfrost/midgard: Remove unnecessary variables"

2019-06-12 Thread Rohan Garg
Make sure we link the last vertex job to the first tiler job.
---
 src/gallium/drivers/panfrost/pan_context.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/src/gallium/drivers/panfrost/pan_context.c 
b/src/gallium/drivers/panfrost/pan_context.c
index 00acb464bc6..caa914e33cb 100644
--- a/src/gallium/drivers/panfrost/pan_context.c
+++ b/src/gallium/drivers/panfrost/pan_context.c
@@ -581,6 +581,7 @@ struct panfrost_transfer
 panfrost_vertex_tiler_job(struct panfrost_context *ctx, bool is_tiler)
 {
 struct panfrost_job *job = panfrost_get_job_for_fbo(ctx);
+static mali_ptr first_tiler_job = 0;
 
 /* Each draw call corresponds to two jobs, and the set-value job is 
first */
 int draw_job_index = 1 + (2 * job->draw_count) + 1;
@@ -623,6 +624,11 @@ panfrost_vertex_tiler_job(struct panfrost_context *ctx, 
bool is_tiler)
 if (job->draw_count) {
 /* Previous vertex job points to this vertex job */
 
panfrost_link_job_pair(ctx->u_vertex_jobs[job->draw_count - 1], transfer.gpu);
+
+/* Last vertex job points to first tiler job */
+if (!first_tiler_job)
+first_tiler_job = transfer.gpu;
+panfrost_link_job_pair(_job, first_tiler_job);
 } else {
 /* Have the first vertex job depend on the set value 
job */
 next_job.job_dependency_index_1 = 
ctx->u_set_value_job->job_index;
-- 
2.17.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

[Mesa-dev] [PATCH libdrm 8/9] panfrost/midgard: Move requirement setting into panfrost_job

2019-06-12 Thread Rohan Garg
Move panfrost_job_set_requirements into panfrost_get_job_for_fbo,
requirements should be set when acquiring a job from a context.
---
 src/gallium/drivers/panfrost/pan_context.c | 2 --
 src/gallium/drivers/panfrost/pan_job.c | 1 +
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/gallium/drivers/panfrost/pan_context.c 
b/src/gallium/drivers/panfrost/pan_context.c
index ced25cf4b82..00acb464bc6 100644
--- a/src/gallium/drivers/panfrost/pan_context.c
+++ b/src/gallium/drivers/panfrost/pan_context.c
@@ -872,8 +872,6 @@ panfrost_emit_for_draw(struct panfrost_context *ctx, bool 
with_vertex_data)
 SET_BIT(ctx->fragment_shader_core.unknown2_4, MALI_NO_MSAA, 
!msaa);
 }
 
-panfrost_job_set_requirements(ctx, job);
-
 if (ctx->occlusion_query) {
 ctx->payload_tiler.gl_enables |= MALI_OCCLUSION_QUERY | 
MALI_OCCLUSION_PRECISE;
 ctx->payload_tiler.postfix.occlusion_counter = 
ctx->occlusion_query->transfer.gpu;
diff --git a/src/gallium/drivers/panfrost/pan_job.c 
b/src/gallium/drivers/panfrost/pan_job.c
index 3ae7450c189..86fb24a119b 100644
--- a/src/gallium/drivers/panfrost/pan_job.c
+++ b/src/gallium/drivers/panfrost/pan_job.c
@@ -109,6 +109,7 @@ panfrost_get_job_for_fbo(struct panfrost_context *ctx)
 struct pipe_surface **cbufs = ctx->pipe_framebuffer.cbufs;
 struct pipe_surface *zsbuf = ctx->pipe_framebuffer.zsbuf;
 struct panfrost_job *job = panfrost_get_job(ctx, cbufs, zsbuf);
+panfrost_job_set_requirements(ctx, job);
 
 return job;
 }
-- 
2.17.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

[Mesa-dev] [PATCH libdrm 1/9] panfrost/midgard: Initial implementation of panfrost_job_submit

2019-06-12 Thread Rohan Garg
Start fleshing out panfrost_job
---
 src/gallium/drivers/panfrost/pan_context.c |  3 +--
 src/gallium/drivers/panfrost/pan_job.c | 20 
 src/gallium/drivers/panfrost/pan_job.h |  2 ++
 3 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/panfrost/pan_context.c 
b/src/gallium/drivers/panfrost/pan_context.c
index 6dab13de1f2..4680dd2ff8c 100644
--- a/src/gallium/drivers/panfrost/pan_context.c
+++ b/src/gallium/drivers/panfrost/pan_context.c
@@ -1350,8 +1350,7 @@ panfrost_submit_frame(struct panfrost_context *ctx, bool 
flush_immediate,
 
 #ifndef DRY_RUN
 
-bool is_scanout = panfrost_is_scanout(ctx);
-screen->driver->submit_vs_fs_job(ctx, has_draws, is_scanout);
+panfrost_job_submit(ctx, job);
 
 /* If visual, we can stall a frame */
 
diff --git a/src/gallium/drivers/panfrost/pan_job.c 
b/src/gallium/drivers/panfrost/pan_job.c
index 6e913ac3374..1e09760871c 100644
--- a/src/gallium/drivers/panfrost/pan_job.c
+++ b/src/gallium/drivers/panfrost/pan_job.c
@@ -140,6 +140,26 @@ panfrost_flush_jobs_writing_resource(struct 
panfrost_context *panfrost,
 /* TODO stub */
 }
 
+void
+panfrost_job_submit(struct panfrost_context *ctx, struct panfrost_job *job)
+{
+struct pipe_context *gallium = (struct pipe_context *) ctx;
+struct panfrost_screen *screen = pan_screen(gallium->screen);
+int ret;
+
+bool has_draws = ctx->draw_count > 0;
+bool is_scanout = panfrost_is_scanout(ctx);
+
+if (!job)
+return;
+
+ret = screen->driver->submit_vs_fs_job(ctx, has_draws, is_scanout);
+
+if (ret)
+fprintf(stderr, "panfrost_job_submit failed: %d\n", ret);
+
+}
+
 void
 panfrost_flush_jobs_reading_resource(struct panfrost_context *panfrost,
 struct pipe_resource *prsc)
diff --git a/src/gallium/drivers/panfrost/pan_job.h 
b/src/gallium/drivers/panfrost/pan_job.h
index 1b28084c599..afc9ac4e58f 100644
--- a/src/gallium/drivers/panfrost/pan_job.h
+++ b/src/gallium/drivers/panfrost/pan_job.h
@@ -88,4 +88,6 @@ void
 panfrost_flush_jobs_reading_resource(struct panfrost_context *panfrost,
 struct pipe_resource *prsc);
 
+void
+panfrost_job_submit(struct panfrost_context *ctx, struct panfrost_job *job);
 #endif
-- 
2.17.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

[Mesa-dev] [PATCH libdrm 0/9] panfrost/midgard: Refactor pan_context

2019-06-12 Thread Rohan Garg
Refactor pan_context to separate out responsibilities between
pan_context and pan_job.

Rohan Garg (9):
  panfrost/midgard: Initial implementation of panfrost_job_submit
  panfrost/midgard: Reset job counters once the job is submitted
  panfrost/midgard: Figure out job requirements in pan_job.c
  panfrost/midgard: Move clearing logic into pan_job
  panfrost/midgard: Remove unnecessary variables
  panfrost/midgard: Remove duplicated header
  panfrost/midgard: Move draw_count into panfrost_job
  panfrost/midgard: Move requirement setting into panfrost_job
  Fixes 88ae2f5870c: "panfrost/midgard: Remove unnecessary variables"

 src/gallium/drivers/panfrost/pan_context.c   | 104 ---
 src/gallium/drivers/panfrost/pan_context.h   |   4 -
 src/gallium/drivers/panfrost/pan_job.c   |  95 +
 src/gallium/drivers/panfrost/pan_job.h   |  16 +++
 src/gallium/drivers/panfrost/pan_wallpaper.c |   1 -
 5 files changed, 134 insertions(+), 86 deletions(-)

-- 
2.17.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

[Mesa-dev] [PATCH libdrm 2/9] panfrost/midgard: Reset job counters once the job is submitted

2019-06-12 Thread Rohan Garg
Move the reset out of frame invalidation into job submission
---
 src/gallium/drivers/panfrost/pan_context.c | 5 -
 src/gallium/drivers/panfrost/pan_job.c | 4 
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/gallium/drivers/panfrost/pan_context.c 
b/src/gallium/drivers/panfrost/pan_context.c
index 4680dd2ff8c..d6a54f9a9f5 100644
--- a/src/gallium/drivers/panfrost/pan_context.c
+++ b/src/gallium/drivers/panfrost/pan_context.c
@@ -384,11 +384,6 @@ panfrost_invalidate_frame(struct panfrost_context *ctx)
 
 /* XXX */
 ctx->dirty |= PAN_DIRTY_SAMPLERS | PAN_DIRTY_TEXTURES;
-
-/* Reset job counters */
-ctx->draw_count = 0;
-ctx->vertex_job_count = 0;
-ctx->tiler_job_count = 0;
 }
 
 /* In practice, every field of these payloads should be configurable
diff --git a/src/gallium/drivers/panfrost/pan_job.c 
b/src/gallium/drivers/panfrost/pan_job.c
index 1e09760871c..333c9f1f147 100644
--- a/src/gallium/drivers/panfrost/pan_job.c
+++ b/src/gallium/drivers/panfrost/pan_job.c
@@ -158,6 +158,10 @@ panfrost_job_submit(struct panfrost_context *ctx, struct 
panfrost_job *job)
 if (ret)
 fprintf(stderr, "panfrost_job_submit failed: %d\n", ret);
 
+/* Reset job counters */
+ctx->draw_count = 0;
+ctx->vertex_job_count = 0;
+ctx->tiler_job_count = 0;
 }
 
 void
-- 
2.17.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

[Mesa-dev] [PATCH libdrm 3/9] panfrost/midgard: Figure out job requirements in pan_job.c

2019-06-12 Thread Rohan Garg
Requirements for a job should be figured out in pan_job.c
---
 src/gallium/drivers/panfrost/pan_context.c |  8 +---
 src/gallium/drivers/panfrost/pan_job.c | 11 +++
 src/gallium/drivers/panfrost/pan_job.h |  4 
 3 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/src/gallium/drivers/panfrost/pan_context.c 
b/src/gallium/drivers/panfrost/pan_context.c
index d6a54f9a9f5..4c53b2d58f5 100644
--- a/src/gallium/drivers/panfrost/pan_context.c
+++ b/src/gallium/drivers/panfrost/pan_context.c
@@ -921,13 +921,7 @@ panfrost_emit_for_draw(struct panfrost_context *ctx, bool 
with_vertex_data)
 SET_BIT(ctx->fragment_shader_core.unknown2_4, MALI_NO_MSAA, 
!msaa);
 }
 
-/* Enable job requirements at draw-time */
-
-if (msaa)
-job->requirements |= PAN_REQ_MSAA;
-
-if (ctx->depth_stencil->depth.writemask)
-job->requirements |= PAN_REQ_DEPTH_WRITE;
+panfrost_job_set_requirements(ctx, job);
 
 if (ctx->occlusion_query) {
 ctx->payload_tiler.gl_enables |= MALI_OCCLUSION_QUERY | 
MALI_OCCLUSION_PRECISE;
diff --git a/src/gallium/drivers/panfrost/pan_job.c 
b/src/gallium/drivers/panfrost/pan_job.c
index 333c9f1f147..0083ca6499e 100644
--- a/src/gallium/drivers/panfrost/pan_job.c
+++ b/src/gallium/drivers/panfrost/pan_job.c
@@ -164,6 +164,17 @@ panfrost_job_submit(struct panfrost_context *ctx, struct 
panfrost_job *job)
 ctx->tiler_job_count = 0;
 }
 
+void
+panfrost_job_set_requirements(struct panfrost_context *ctx,
+ struct panfrost_job *job)
+{
+if (ctx->rasterizer->base.multisample)
+job->requirements |= PAN_REQ_MSAA;
+
+if (ctx->depth_stencil->depth.writemask)
+job->requirements |= PAN_REQ_DEPTH_WRITE;
+}
+
 void
 panfrost_flush_jobs_reading_resource(struct panfrost_context *panfrost,
 struct pipe_resource *prsc)
diff --git a/src/gallium/drivers/panfrost/pan_job.h 
b/src/gallium/drivers/panfrost/pan_job.h
index afc9ac4e58f..cbfd6cb0c7f 100644
--- a/src/gallium/drivers/panfrost/pan_job.h
+++ b/src/gallium/drivers/panfrost/pan_job.h
@@ -90,4 +90,8 @@ panfrost_flush_jobs_reading_resource(struct panfrost_context 
*panfrost,
 
 void
 panfrost_job_submit(struct panfrost_context *ctx, struct panfrost_job *job);
+
+void
+panfrost_job_set_requirements(struct panfrost_context *ctx,
+ struct panfrost_job *job);
 #endif
-- 
2.17.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev