From 2f1947b39ca5426f1bb501d22cf3dcae9ae411ea Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Sat, 17 Oct 2020 10:51:24 +0200 Subject: [PATCH] panfrost: Fix tiler job injection When injecting a tiler job, we shouln't make it depend on the last tiler job, but instead make the first tiler job depend on it. Signed-off-by: Boris Brezillon Reviewed-by: Alyssa Rosenzweig Part-of: --- src/panfrost/lib/pan_scoreboard.c | 29 ++++++++++++++++++++++++----- src/panfrost/lib/pan_scoreboard.h | 6 ++++++ 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/panfrost/lib/pan_scoreboard.c b/src/panfrost/lib/pan_scoreboard.c index b0e2cb3fdd3..bbe12c2c312 100644 --- a/src/panfrost/lib/pan_scoreboard.c +++ b/src/panfrost/lib/pan_scoreboard.c @@ -115,6 +115,7 @@ panfrost_add_job( const struct panfrost_transfer *job, bool inject) { + bool is_bifrost = !!(pool->dev->quirks & IS_BIFROST); unsigned global_dep = 0; if (type == MALI_JOB_TYPE_TILER) { @@ -122,12 +123,13 @@ panfrost_add_job( * job must depend on the write value job, whose index we * reserve now */ - if (scoreboard->tiler_dep) - global_dep = scoreboard->tiler_dep; - else if (!(pool->dev->quirks & IS_BIFROST)) { + if (is_bifrost && !scoreboard->write_value_index) scoreboard->write_value_index = ++scoreboard->job_index; + + if (scoreboard->tiler_dep && !inject) + global_dep = scoreboard->tiler_dep; + else if (is_bifrost) global_dep = scoreboard->write_value_index; - } } /* Assign the index */ @@ -145,13 +147,30 @@ panfrost_add_job( } if (inject) { + if (type == MALI_JOB_TYPE_TILER) { + if (scoreboard->first_tiler) { + /* Manual update of the dep2 field. This is bad, + * don't copy this pattern. + */ + scoreboard->first_tiler->opaque[5] = + scoreboard->first_tiler_dep1 | (index << 16); + } + + scoreboard->first_tiler = (void *)job->cpu; + scoreboard->first_tiler_dep1 = local_dep; + } scoreboard->first_job = job->gpu; return index; } /* Form a chain */ - if (type == MALI_JOB_TYPE_TILER) + if (type == MALI_JOB_TYPE_TILER) { + if (!scoreboard->first_tiler) { + scoreboard->first_tiler = (void *)job->cpu; + scoreboard->first_tiler_dep1 = local_dep; + } scoreboard->tiler_dep = index; + } if (scoreboard->prev_job) { /* Manual update of the next pointer. This is bad, don't copy diff --git a/src/panfrost/lib/pan_scoreboard.h b/src/panfrost/lib/pan_scoreboard.h index 17fbc32549d..27710aa4771 100644 --- a/src/panfrost/lib/pan_scoreboard.h +++ b/src/panfrost/lib/pan_scoreboard.h @@ -40,6 +40,12 @@ struct pan_scoreboard { /* A CPU-side pointer to the previous job for next_job linking */ struct mali_job_header_packed *prev_job; + /* A CPU-side pointer to the first tiler job for dep updates when + * injecting a reload tiler job. + */ + struct mali_job_header_packed *first_tiler; + uint32_t first_tiler_dep1; + /* The dependency for tiler jobs (i.e. the index of the last emitted * tiler job, or zero if none have been emitted) */ unsigned tiler_dep;