[v2,04/37] panfrost: Add polygon_list to the batch BO set at allocation time

Submitted by Boris Brezillon on Sept. 16, 2019, 9:36 a.m.

Details

Message ID 20190916093715.32203-5-boris.brezillon@collabora.com
State Accepted
Commit 4eac1b20080dce362ded2cfafde668156480a9a9
Headers show
Series "panfrost: Support batch pipelining" ( rev: 1 ) in Mesa

Not browsing as part of any series.

Commit Message

Boris Brezillon Sept. 16, 2019, 9:36 a.m.
That's what we do for other per-batch BOs, and we'll soon add an helper
to automate this create_bo()+add_bo()+bo_unreference() sequence, so
let's prepare the code to ease this transition.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
---
 src/gallium/drivers/panfrost/pan_drm.c |  1 -
 src/gallium/drivers/panfrost/pan_job.c | 10 +++++++---
 2 files changed, 7 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/gallium/drivers/panfrost/pan_drm.c b/src/gallium/drivers/panfrost/pan_drm.c
index ada6221850c0..b77af714d117 100644
--- a/src/gallium/drivers/panfrost/pan_drm.c
+++ b/src/gallium/drivers/panfrost/pan_drm.c
@@ -278,7 +278,6 @@  panfrost_drm_submit_vs_fs_batch(struct panfrost_batch *batch, bool has_draws)
 
         panfrost_batch_add_bo(batch, ctx->scratchpad);
         panfrost_batch_add_bo(batch, ctx->tiler_heap);
-        panfrost_batch_add_bo(batch, batch->polygon_list);
 
         if (batch->first_job.gpu) {
                 ret = panfrost_drm_submit_batch(batch, batch->first_job.gpu, 0);
diff --git a/src/gallium/drivers/panfrost/pan_job.c b/src/gallium/drivers/panfrost/pan_job.c
index 03119e643846..e06440010aeb 100644
--- a/src/gallium/drivers/panfrost/pan_job.c
+++ b/src/gallium/drivers/panfrost/pan_job.c
@@ -67,9 +67,6 @@  panfrost_free_batch(struct panfrost_batch *batch)
                 panfrost_bo_unreference(ctx->base.screen, bo);
         }
 
-        /* Unreference the polygon list */
-        panfrost_bo_unreference(ctx->base.screen, batch->polygon_list);
-
         _mesa_hash_table_remove_key(ctx->batches, &batch->key);
 
         if (ctx->batch == batch)
@@ -158,6 +155,13 @@  panfrost_batch_get_polygon_list(struct panfrost_batch *batch, unsigned size)
 
                 batch->polygon_list = panfrost_drm_create_bo(screen,
                                 size, PAN_ALLOCATE_INVISIBLE);
+                panfrost_batch_add_bo(batch, batch->polygon_list);
+
+                /* A BO reference has been retained by panfrost_batch_add_bo(),
+                 * so we need to unreference it here if we want the BO to be
+                 * automatically released when the batch is destroyed.
+                 */
+                panfrost_bo_unreference(&screen->base, batch->polygon_list);
         }
 
         return batch->polygon_list->gpu;

Comments

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>

> That's what we do for other per-batch BOs, and we'll soon add an helper
> to automate this create_bo()+add_bo()+bo_unreference() sequence, so
> let's prepare the code to ease this transition.
> 
> Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
> ---
>  src/gallium/drivers/panfrost/pan_drm.c |  1 -
>  src/gallium/drivers/panfrost/pan_job.c | 10 +++++++---
>  2 files changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/src/gallium/drivers/panfrost/pan_drm.c b/src/gallium/drivers/panfrost/pan_drm.c
> index ada6221850c0..b77af714d117 100644
> --- a/src/gallium/drivers/panfrost/pan_drm.c
> +++ b/src/gallium/drivers/panfrost/pan_drm.c
> @@ -278,7 +278,6 @@ panfrost_drm_submit_vs_fs_batch(struct panfrost_batch *batch, bool has_draws)
>  
>          panfrost_batch_add_bo(batch, ctx->scratchpad);
>          panfrost_batch_add_bo(batch, ctx->tiler_heap);
> -        panfrost_batch_add_bo(batch, batch->polygon_list);
>  
>          if (batch->first_job.gpu) {
>                  ret = panfrost_drm_submit_batch(batch, batch->first_job.gpu, 0);
> diff --git a/src/gallium/drivers/panfrost/pan_job.c b/src/gallium/drivers/panfrost/pan_job.c
> index 03119e643846..e06440010aeb 100644
> --- a/src/gallium/drivers/panfrost/pan_job.c
> +++ b/src/gallium/drivers/panfrost/pan_job.c
> @@ -67,9 +67,6 @@ panfrost_free_batch(struct panfrost_batch *batch)
>                  panfrost_bo_unreference(ctx->base.screen, bo);
>          }
>  
> -        /* Unreference the polygon list */
> -        panfrost_bo_unreference(ctx->base.screen, batch->polygon_list);
> -
>          _mesa_hash_table_remove_key(ctx->batches, &batch->key);
>  
>          if (ctx->batch == batch)
> @@ -158,6 +155,13 @@ panfrost_batch_get_polygon_list(struct panfrost_batch *batch, unsigned size)
>  
>                  batch->polygon_list = panfrost_drm_create_bo(screen,
>                                  size, PAN_ALLOCATE_INVISIBLE);
> +                panfrost_batch_add_bo(batch, batch->polygon_list);
> +
> +                /* A BO reference has been retained by panfrost_batch_add_bo(),
> +                 * so we need to unreference it here if we want the BO to be
> +                 * automatically released when the batch is destroyed.
> +                 */
> +                panfrost_bo_unreference(&screen->base, batch->polygon_list);
>          }
>  
>          return batch->polygon_list->gpu;
> -- 
> 2.21.0