R-b
On Mon, Sep 16, 2019 at 11:37:04AM +0200, Boris Brezillon wrote: > We just replace the per-context out_sync object by a pointer to the > the fence of the last last submitted batch. Pipelining of batches will > come later. > > Signed-off-by: Boris Brezillon <boris.brezil...@collabora.com> > --- > src/gallium/drivers/panfrost/pan_context.c | 6 ------ > src/gallium/drivers/panfrost/pan_context.h | 3 ++- > src/gallium/drivers/panfrost/pan_job.c | 23 ++++++++++++++++------ > src/gallium/drivers/panfrost/pan_screen.c | 6 ++++-- > 4 files changed, 23 insertions(+), 15 deletions(-) > > diff --git a/src/gallium/drivers/panfrost/pan_context.c > b/src/gallium/drivers/panfrost/pan_context.c > index a76caecef0e3..0197f78b5506 100644 > --- a/src/gallium/drivers/panfrost/pan_context.c > +++ b/src/gallium/drivers/panfrost/pan_context.c > @@ -2712,12 +2712,6 @@ panfrost_create_context(struct pipe_screen *screen, > void *priv, unsigned flags) > panfrost_blend_context_init(gallium); > panfrost_compute_context_init(gallium); > > - ASSERTED int ret; > - > - ret = drmSyncobjCreate(pscreen->fd, DRM_SYNCOBJ_CREATE_SIGNALED, > - &ctx->out_sync); > - assert(!ret); > - > /* XXX: leaks */ > gallium->stream_uploader = u_upload_create_default(gallium); > gallium->const_uploader = gallium->stream_uploader; > diff --git a/src/gallium/drivers/panfrost/pan_context.h > b/src/gallium/drivers/panfrost/pan_context.h > index c145d589757e..ce3e0c899a4f 100644 > --- a/src/gallium/drivers/panfrost/pan_context.h > +++ b/src/gallium/drivers/panfrost/pan_context.h > @@ -191,7 +191,8 @@ struct panfrost_context { > /* True for t6XX, false for t8xx. */ > bool is_t6xx; > > - uint32_t out_sync; > + /* The out sync fence of the last submitted batch. */ > + struct panfrost_batch_fence *last_out_sync; > }; > > /* Corresponds to the CSO */ > diff --git a/src/gallium/drivers/panfrost/pan_job.c > b/src/gallium/drivers/panfrost/pan_job.c > index 8712e2ce598a..78f2b766adb1 100644 > --- a/src/gallium/drivers/panfrost/pan_job.c > +++ b/src/gallium/drivers/panfrost/pan_job.c > @@ -427,11 +427,13 @@ panfrost_batch_submit_ioctl(struct panfrost_batch > *batch, > uint32_t *bo_handles; > int ret; > > - submit.in_syncs = (u64) (uintptr_t) &ctx->out_sync; > - submit.in_sync_count = 1; > > - submit.out_sync = ctx->out_sync; > + if (ctx->last_out_sync) { > + submit.in_sync_count = 1; > + submit.in_syncs = (uintptr_t)&ctx->last_out_sync->syncobj; > + } > > + submit.out_sync = batch->out_sync->syncobj; > submit.jc = first_job_desc; > submit.requirements = reqs; > > @@ -454,6 +456,14 @@ panfrost_batch_submit_ioctl(struct panfrost_batch *batch, > submit.bo_handles = (u64) (uintptr_t) bo_handles; > ret = drmIoctl(screen->fd, DRM_IOCTL_PANFROST_SUBMIT, &submit); > free(bo_handles); > + > + /* Release the last batch fence if any, and retain the new one */ > + if (ctx->last_out_sync) > + panfrost_batch_fence_unreference(ctx->last_out_sync); > + > + panfrost_batch_fence_reference(batch->out_sync); > + ctx->last_out_sync = batch->out_sync; > + > if (ret) { > fprintf(stderr, "Error submitting: %m\n"); > return errno; > @@ -462,7 +472,8 @@ panfrost_batch_submit_ioctl(struct panfrost_batch *batch, > /* Trace the job if we're doing that */ > if (pan_debug & PAN_DBG_TRACE) { > /* Wait so we can get errors reported back */ > - drmSyncobjWait(screen->fd, &ctx->out_sync, 1, INT64_MAX, 0, > NULL); > + drmSyncobjWait(screen->fd, &batch->out_sync->syncobj, 1, > + INT64_MAX, 0, NULL); > pandecode_jc(submit.jc, FALSE); > } > > @@ -531,8 +542,8 @@ out: > * rendering is quite broken right now (to be fixed by the > panfrost_job > * refactor, just take the perf hit for correctness) > */ > - drmSyncobjWait(pan_screen(ctx->base.screen)->fd, &ctx->out_sync, 1, > - INT64_MAX, 0, NULL); > + drmSyncobjWait(pan_screen(ctx->base.screen)->fd, > + &batch->out_sync->syncobj, 1, INT64_MAX, 0, NULL); > panfrost_free_batch(batch); > } > > diff --git a/src/gallium/drivers/panfrost/pan_screen.c > b/src/gallium/drivers/panfrost/pan_screen.c > index dae8b941f1ea..22f7feb890e2 100644 > --- a/src/gallium/drivers/panfrost/pan_screen.c > +++ b/src/gallium/drivers/panfrost/pan_screen.c > @@ -590,8 +590,8 @@ panfrost_fence_finish(struct pipe_screen *pscreen, > struct panfrost_screen *screen = pan_screen(pscreen); > struct panfrost_fence *f = (struct panfrost_fence *)fence; > int ret; > - > unsigned syncobj; > + > ret = drmSyncobjCreate(screen->fd, 0, &syncobj); > if (ret) { > fprintf(stderr, "Failed to create syncobj to wait on: %m\n"); > @@ -623,12 +623,14 @@ panfrost_fence_create(struct panfrost_context *ctx) > if (!f) > return NULL; > > + assert(ctx->last_out_sync); > + > /* Snapshot the last Panfrost's rendering's out fence. We'd rather > have > * another syncobj instead of a sync file, but this is all we get. > * (HandleToFD/FDToHandle just gives you another syncobj ID for the > * same syncobj). > */ > - drmSyncobjExportSyncFile(screen->fd, ctx->out_sync, &f->fd); > + drmSyncobjExportSyncFile(screen->fd, ctx->last_out_sync->syncobj, > &f->fd); > if (f->fd == -1) { > fprintf(stderr, "export failed: %m\n"); > free(f); > -- > 2.21.0 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev