<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Jan 12, 2018 at 1:28 AM, Chris Wilson <span dir="ltr"><<a href="mailto:chris@chris-wilson.co.uk" target="_blank">chris@chris-wilson.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Quoting Jason Ekstrand (2018-01-12 01:40:52)<br>
<span class="">> This helper should be used carefully as setting tiling is a racy<br>
> operation since it potentially interacts with other processes. Still,<br>
> it is a useful thing to be able to do.<br>
><br>
> Cc: <a href="mailto:mesa-stable@lists.freedesktop.org">mesa-stable@lists.freedesktop.<wbr>org</a><br>
> ---<br>
> src/mesa/drivers/dri/i965/brw_<wbr>bufmgr.c | 27 +++++++++++++++++++++++++++<br>
> src/mesa/drivers/dri/i965/brw_<wbr>bufmgr.h | 10 ++++++++++<br>
> 2 files changed, 37 insertions(+)<br>
><br>
> diff --git a/src/mesa/drivers/dri/i965/<wbr>brw_bufmgr.c b/src/mesa/drivers/dri/i965/<wbr>brw_bufmgr.c<br>
> index 469895e..dbd13dd 100644<br>
> --- a/src/mesa/drivers/dri/i965/<wbr>brw_bufmgr.c<br>
> +++ b/src/mesa/drivers/dri/i965/<wbr>brw_bufmgr.c<br>
> @@ -1133,6 +1133,33 @@ brw_bo_get_tiling(struct brw_bo *bo, uint32_t *tiling_mode,<br>
> return 0;<br>
> }<br>
><br>
> +int<br>
> +brw_bo_set_tiling(struct brw_bo *bo, uint32_t tiling_mode,<br>
> + uint32_t stride)<br>
> +{<br>
> + struct brw_bufmgr *bufmgr = bo->bufmgr;<br>
> +<br>
> + mtx_lock(&bufmgr->lock);<br>
<br>
</span>This mutex protects the buffer cache, which should not be containing<br>
this bo. Changing the tiling of a shared active bo also should not<br>
happen because the other parties will have already derived state from<br>
the older tiling. So I don't see the purpose of this mutex here.<span class="HOEnZb"><font color="#888888"><br>
</font></span></blockquote></div></div><div class="gmail_extra"><br></div><div class="gmail_extra">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.</div><div class="gmail_extra"><br></div><div class="gmail_extra">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.<br></div></div>