<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from rtf -->
<style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<font face="Calibri" size="2"><span style="font-size:11pt;">
<div>aubinator.c: In function ‘parse_commands’:</div>
<div>aubinator.c:768:19: warning: suggest parentheses around comparison in operand of ‘&’ [-Wparentheses]</div>
<div>          if (p[0] & (1 << 22) == 0)</div>
<a name="_MailEndCompose"></a>
<div> </div>
<div>-----Original Message-----<br>

From: mesa-dev [<a href="mailto:mesa-dev-bounces@lists.freedesktop.org">mailto:mesa-dev-bounces@lists.freedesktop.org</a>] On Behalf Of Jason Ekstrand<br>

Sent: Thursday, September 08, 2016 9:12 PM<br>

To: mesa-dev@lists.freedesktop.org<br>

Cc: Ekstrand, Jason <jason.ekstrand@intel.com><br>

Subject: [Mesa-dev] [PATCH] intel/aubinator: Properly handle batch buffer chaining</div>
<div> </div>
<div>The original aubinator that Kristian wrote had a bug in the handling of MI_BATCH_BUFFER_START that propagated into the version in upstream mesa.</div>
<div>Say you have two batch buffers A and B where A calls MI_BATCH_BUFFER_START to jump to B.  Now suppose that A and B are placed consecutively in the address space with A before B.  What can happen is that aubinator will process A, and start processing B
when it should.  When it gets done with B, it returns and continues to process A.  Because A doesn't have any more data after the MI_BATCH_BUFFER_START, it will just process a bunch of NOPs until it gets to the next buffer in memory which is B again.  In this
scenario B gets processed twice which can be very confusing.  If you place things in memory just right, you can also end up with infinite loops which are all sorts of fun.</div>
<div> </div>
<div>The root problem here is that it continues to process commands even after an MI_BATCH_BUFFER_START.  By simply checking the 2nd level we can detect whether or not the command buffer we are jumping to will return here and stop processing commands if it
won't.</div>
<div> </div>
<div>Signed-off-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>></div>
<div>---</div>
<div> src/intel/tools/aubinator.c | 7 +++++++</div>
<div> 1 file changed, 7 insertions(+)</div>
<div> </div>
<div>diff --git a/src/intel/tools/aubinator.c b/src/intel/tools/aubinator.c index fe1f369..73a7f21 100644</div>
<div>--- a/src/intel/tools/aubinator.c</div>
<div>+++ b/src/intel/tools/aubinator.c</div>
<div>@@ -766,6 +766,13 @@ parse_commands(struct gen_spec *spec, uint32_t *cmds, int size, int engine)</div>
<div>             start = p[1];</div>
<div> </div>
<div>          parse_commands(spec, gtt + start, 1 << 20, engine);</div>
<div>+</div>
<div>+         /* MI_BATCH_BUFFER_START with "2nd Level Batch Buffer" unset acts</div>
<div>+          * like a goto.  No commands after such a MI_BATCH_BUFFER_START will</div>
<div>+          * get processed so we should bail as well.</div>
<div>+          */</div>
<div>+         if (p[0] & (1 << 22) == 0)</div>
<div> </div>
<div><font color="#7030A0">[SG]: The above line might need extra pair of parenthesis around comparison to get rid of the compile time warning I was seeing as below. Otherwise, Patch looks good to me.</font></div>
<div><font color="#7030A0">aubinator.c: In function ‘parse_commands’:</font></div>
<div><font color="#7030A0">aubinator.c:768:19: warning: suggest parentheses around comparison in operand of ‘&’ [-Wparentheses]</font></div>
<div><font color="#7030A0">          if (p[0] & (1 << 22) == 0)</font></div>
<div> </div>
<div>+            break;</div>
<div>       } else if ((p[0] & 0xffff0000) == AUB_MI_BATCH_BUFFER_END) {</div>
<div>          break;</div>
<div>       }</div>
<div>--</div>
<div>2.5.0.400.gff86faf</div>
<div> </div>
<div>_______________________________________________</div>
<div>mesa-dev mailing list</div>
<div><a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a></div>
<div><a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a></div>
<div> </div>
</span></font>
</body>
</html>