<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Sep 17, 2014 at 1:49 PM, Paulo Zanoni <span dir="ltr"><<a href="mailto:przanoni@gmail.com" target="_blank">przanoni@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">2014-09-05 17:57 GMT-03:00 Rodrigo Vivi <<a href="mailto:rodrigo.vivi@intel.com">rodrigo.vivi@intel.com</a>>:<br>
<div><div class="h5">> The sw cache clean on gen8 is a tempoorary workaround because we cannot<br>
> set cache clean on blt ring with risk of hungs. So we are doing the cache clean on sw.<br>
> However we are doing much more than needed. Not only when using blt ring.<br>
> So, with this extra w/a we minimize the ammount of cache cleans and call it only<br>
> on same cases that it was being called on gen7.<br>
><br>
> fbc.need_sw_cache_clean works in the opposite information direction<br>
> of ring->fbc_dirty telling software on frontbuffer tracking to perform<br>
> the cache clean on sw side.<br>
><br>
> Cc: Paulo Zanoni <<a href="mailto:paulo.r.zanoni@intel.com">paulo.r.zanoni@intel.com</a>><br>
> Signed-off-by: Rodrigo Vivi <<a href="mailto:rodrigo.vivi@intel.com">rodrigo.vivi@intel.com</a>><br>
> ---<br>
> drivers/gpu/drm/i915/i915_drv.h | 8 ++++++++<br>
> drivers/gpu/drm/i915/intel_display.c | 4 +++-<br>
> drivers/gpu/drm/i915/intel_ringbuffer.c | 9 +++++++--<br>
> 3 files changed, 18 insertions(+), 3 deletions(-)<br>
><br>
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h<br>
> index 5706b8a..5acda40 100644<br>
> --- a/drivers/gpu/drm/i915/i915_drv.h<br>
> +++ b/drivers/gpu/drm/i915/i915_drv.h<br>
> @@ -657,6 +657,14 @@ struct i915_fbc {<br>
><br>
> bool false_color;<br>
><br>
> + /* On gen8 some rings cannont perform fbc clean operation so for now<br>
> + * we are doing this on SW with mmio.<br>
> + * This variable works in the opposite information direction<br>
> + * of ring->fbc_dirty telling software on frontbuffer tracking<br>
> + * to perform the cache clean on sw side.<br>
> + */<br>
> + bool need_sw_cache_clean;<br>
<br>
<br>
</div></div>Ok, this is my first time trying to look at the buffer tracking code,<br>
so I have some noob questions.<br>
<br>
It seems need_sw_cache_clean is set every time we call<br>
gen6_ring_flush(), just like gen7_ring_fbc_flush(). But the thing<br>
about gen7_ring_fbc_flush() is that it becomes a noop when fbc_dirty<br>
is false. So maybe on this code we're doing the sw cache clean every<br>
time we do a BLT operation, even if this operation is not on the front<br>
buffer? That would be an unnecessary overkill, right? Continuing the<br>
same though, why can't we just reuse the ring->fbc_dirty variable<br>
instead of using this new need_sw_cache_clean? Maybe we should only do<br>
the sw cache clean when both fbc_dirty *and* need_sw_cache are true?<br></blockquote><div><br></div><div>need_sw_cache_clean is exactly the opposite information flow of fbc_dirty. fbc_dirty was actually the first name that came to my mind but I noticed we already had this name.</div><div><br></div><div>Well, the fbc cache need to be clean when it is dirty ;) That means on ring flush (other than render one) and when frontbuffer was touched.</div><div><br></div><div>When frontbuffer was touched and there is render flush we Nuke FBC and when frontbuffer was touched and other ring than render is flushed we clean the cache. (that is the hw logic that is implemented there). The fbc_dirty is to tell frontfbuffer was touched and cache clean lri can be executed on ring.</div><div>need_sw_cache_clean is exactly the opposite when rings was flushed it tells next frontbuffer touch to clean the cache.</div><div><br></div><div>I know the order of the things are different. The hw one is frontbuffer than ring flush with lri for cache clean while this one is ring flush than next frontbuffer do the mmio to clean the cache. So I imagine that might have cases where the cache needs to be cleaned and no frontbuffer occurs and fbc keeps disabled not compressed anything.... But this is exactly how the hw was without the sw cache clean. And my tests here shows that with this even not on the propper order fbc just keep working and compressing propperly.</div><div> </div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
More below.<br>
<span class=""><br>
<br>
> +<br>
> struct intel_fbc_work {<br>
> struct delayed_work work;<br>
> struct drm_crtc *crtc;<br>
> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c<br>
> index 965eb3c..731d925 100644<br>
> --- a/drivers/gpu/drm/i915/intel_display.c<br>
> +++ b/drivers/gpu/drm/i915/intel_display.c<br>
> @@ -9137,8 +9137,10 @@ void intel_frontbuffer_flush(struct drm_device *dev,<br>
> * needs to be reworked into a proper frontbuffer tracking scheme like<br>
> * psr employs.<br>
> */<br>
> - if (IS_BROADWELL(dev))<br>
> + if (IS_BROADWELL(dev) && dev_priv->fbc.need_sw_cache_clean) {<br>
> + dev_priv->fbc.need_sw_cache_clean = false;<br>
> gen8_fbc_sw_flush(dev, FBC_REND_CACHE_CLEAN);<br>
> + }<br>
<br>
<br>
</span>Bikeshed: since this is the only caller, I think it makes sense to put<br>
the checks inside the function instead of the caller.<br></blockquote><div><br></div><div>Agree.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class=""><br>
<br>
> }<br>
><br>
> /**<br>
> diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c<br>
> index 85fc2b1..02b43cd 100644<br>
> --- a/drivers/gpu/drm/i915/intel_ringbuffer.c<br>
> +++ b/drivers/gpu/drm/i915/intel_ringbuffer.c<br>
> @@ -2227,6 +2227,7 @@ static int gen6_ring_flush(struct intel_engine_cs *ring,<br>
<br>
<br>
</span>The thing about gen6_render_ring_flush is that it is also a function<br>
for the vebox ring. Is this a problem? What are the consequences of<br>
doing the FBC thing on it?<br></blockquote><div><br></div><div>As far as I remember we should nuke on render and clean cache on all other rings flush so no problem with that.</div><div> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class=""><br>
<br>
> u32 invalidate, u32 flush)<br>
> {<br>
> struct drm_device *dev = ring->dev;<br>
> + struct drm_i915_private *dev_priv = dev->dev_private;<br>
> uint32_t cmd;<br>
> int ret;<br>
><br>
> @@ -2257,8 +2258,12 @@ static int gen6_ring_flush(struct intel_engine_cs *ring,<br>
> }<br>
> intel_ring_advance(ring);<br>
><br>
> - if (IS_GEN7(dev) && !invalidate && flush)<br>
> - return gen7_ring_fbc_flush(ring, FBC_REND_CACHE_CLEAN);<br>
> + if (!invalidate && flush) {<br>
> + if (IS_GEN7(dev))<br>
> + return gen7_ring_fbc_flush(ring, FBC_REND_CACHE_CLEAN);<br>
> + else if (IS_GEN8(dev))<br>
> + dev_priv->fbc.need_sw_cache_clean = true;<br>
<br>
<br>
</span>Bikeshed: since I like to keep the callers clean, can't we just create<br>
a new intel_blt_fbc_flush (or intel_ring_fbc_flush(), or whatever)<br>
that will be responsible for deciding if it needs to call<br>
gen7_ring_fbc_flush or set need_sw_cache_clean to true? </blockquote><div><br></div><div>Agree this can be cleaner.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">That would<br>
make even more sense if we conclude we also need to check for<br>
fbc_dirty before setting need_sw_cache_clean to true...<br></blockquote><div><br></div><div>I don't think so. fbc_dirty is set on the frontbuffer touch, exactly when fbc_dirty is set.</div><div>This would only make a flow that necessary we touch the frontbuffer before flushing the ring... But I'm confident this is already happening and we wouldn't be saving any case.</div><div><br></div><div> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class="im HOEnZb"><br>
<br>
> + }<br>
><br>
> return 0;<br>
> }<br>
> --<br>
> 1.9.3<br>
><br>
> _______________________________________________<br>
> Intel-gfx mailing list<br>
> <a href="mailto:Intel-gfx@lists.freedesktop.org">Intel-gfx@lists.freedesktop.org</a><br>
> <a href="http://lists.freedesktop.org/mailman/listinfo/intel-gfx" target="_blank">http://lists.freedesktop.org/mailman/listinfo/intel-gfx</a><br>
<br>
<br>
<br>
</span><span class="HOEnZb"><font color="#888888">--<br>
Paulo Zanoni<br>
</font></span><div class="HOEnZb"><div class="h5">_______________________________________________<br>
Intel-gfx mailing list<br>
<a href="mailto:Intel-gfx@lists.freedesktop.org">Intel-gfx@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/intel-gfx" target="_blank">http://lists.freedesktop.org/mailman/listinfo/intel-gfx</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div>Rodrigo Vivi</div><div>Blog: <a href="http://blog.vivi.eng.br" target="_blank">http://blog.vivi.eng.br</a></div><div> </div>
</div></div>