On Fri, Jan 12, 2018 at 1:28 AM, Chris Wilson <ch...@chris-wilson.co.uk>
wrote:

> Quoting Jason Ekstrand (2018-01-12 01:40:52)
> > This helper should be used carefully as setting tiling is a racy
> > operation since it potentially interacts with other processes.  Still,
> > it is a useful thing to be able to do.
> >
> > Cc: mesa-sta...@lists.freedesktop.org
> > ---
> >  src/mesa/drivers/dri/i965/brw_bufmgr.c | 27 +++++++++++++++++++++++++++
> >  src/mesa/drivers/dri/i965/brw_bufmgr.h | 10 ++++++++++
> >  2 files changed, 37 insertions(+)
> >
> > diff --git a/src/mesa/drivers/dri/i965/brw_bufmgr.c
> b/src/mesa/drivers/dri/i965/brw_bufmgr.c
> > index 469895e..dbd13dd 100644
> > --- a/src/mesa/drivers/dri/i965/brw_bufmgr.c
> > +++ b/src/mesa/drivers/dri/i965/brw_bufmgr.c
> > @@ -1133,6 +1133,33 @@ brw_bo_get_tiling(struct brw_bo *bo, uint32_t
> *tiling_mode,
> >     return 0;
> >  }
> >
> > +int
> > +brw_bo_set_tiling(struct brw_bo *bo, uint32_t tiling_mode,
> > +                  uint32_t stride)
> > +{
> > +   struct brw_bufmgr *bufmgr = bo->bufmgr;
> > +
> > +   mtx_lock(&bufmgr->lock);
>
> This mutex protects the buffer cache, which should not be containing
> this bo. Changing the tiling of a shared active bo also should not
> happen because the other parties will have already derived state from
> the older tiling. So I don't see the purpose of this mutex here.
>

It can, in theory, if we have simultaneous imports on two different
contexts.  That's a bit of a crazy case, I'll agree, but it can happen and
I don't want there to be any chance of corruption of the internal state of
the BO.  Setting tiling from two different contexts simultaneously is racy,
I'll grant, but there are many other reasons why BO tilings are racy and/or
problematic so I don't really want to get hung up on it.

Also, FYI, I expect this patch (and 4/4) to live in 17.3 only and in master
for about a week or two before Scott gets rid of GTT maps and we stop
setting tiling on any BOs except legacy (non-modifiers) window-system ones.
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to