<div dir="ltr"><div><div>Tested-by: Andriy.Khulap <<a href="mailto:andriy.khulap@globallogic.com" target="_blank">andriy.khulap@globallogic.com</a><wbr>><br><br>Fixes Bug 104301 (<a href="https://bugs.freedesktop.org/show_bug.cgi?id=104301" target="_blank">https://bugs.freedesktop.org/<wbr>show_bug.cgi?id=104301</a>) on<br>Intel(R) HD Graphics 530 (Skylake GT2) (0x191b)<br></div>Ubuntu 16.04 Kernel 4.4.0<br></div>Mesa 17.4.0-devel (git-4f1e500)<br>mpv 0.14.0-git-e1993d5<br></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><b>Andriy Khulap | Software Engineer</b><div>Mobile: +38-067-607-27-80 Skype: a.khulap</div><div><a href="http://www.globallogic.com" target="_blank">www.globallogic.com</a><br><font size="-1"><a href="http://www.globallogic.com/email_disclaimer.txt" target="_blank"><span style="font-size:11px;font-family:Arial;color:#1155cc;background-color:transparent;font-weight:normal;font-style:normal;font-variant:normal;text-decoration:underline;vertical-align:baseline">http://www.globallogic.com/email_disclaimer.txt</span></a></font><br></div></div></div></div></div></div>
<br><div class="gmail_quote">On Thu, Jan 11, 2018 at 11:53 AM, Thomas Hellstrom <span dir="ltr"><<a href="mailto:thellstrom@vmware.com" target="_blank">thellstrom@vmware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Upon reception of an event that lowered the number of active back buffers,<br>
the code would immediately try to free all back buffers with an id equal to or<br>
higher than the new number of active back buffers.<br>
<br>
However, that could lead to an active or to-be-active back buffer being freed,<br>
since the old number of back buffers was used when obtaining an idle back<br>
buffer for use.<br>
<br>
This lead to crashes when lowering the number of active back buffers by<br>
transitioning from page-flipping to non-page-flipping presents.<br>
<br>
Fix this by computing the number of active back buffers only when trying to<br>
obtain a new back buffer.<br>
<br>
Fixes: 15e208c4cc ("loader/dri3: Don't accidently free buffer holding new back content")<br>
Bugzilla: <a href="https://bugs.freedesktop.org/show_bug.cgi?id=104214" rel="noreferrer" target="_blank">https://bugs.freedesktop.org/<wbr>show_bug.cgi?id=104214</a><br>
Cc: "17.3" <<a href="mailto:mesa-stable@lists.freedesktop.org">mesa-stable@lists.<wbr>freedesktop.org</a>><br>
Signed-off-by: Thomas Hellstrom <<a href="mailto:thellstrom@vmware.com">thellstrom@vmware.com</a>><br>
---<br>
src/loader/loader_dri3_helper.<wbr>c | 6 +++---<br>
1 file changed, 3 insertions(+), 3 deletions(-)<br>
<br>
diff --git a/src/loader/loader_dri3_<wbr>helper.c b/src/loader/loader_dri3_<wbr>helper.c<br>
index cc890bc..c01b0ac 100644<br>
--- a/src/loader/loader_dri3_<wbr>helper.c<br>
+++ b/src/loader/loader_dri3_<wbr>helper.c<br>
@@ -205,7 +205,6 @@ void<br>
loader_dri3_set_swap_interval(<wbr>struct loader_dri3_drawable *draw, int interval)<br>
{<br>
draw->swap_interval = interval;<br>
- dri3_update_num_back(draw);<br>
}<br>
<br>
/** dri3_free_render_buffer<br>
@@ -377,7 +376,6 @@ dri3_handle_present_event(<wbr>struct loader_dri3_drawable *draw,<br>
draw->flipping = false;<br>
break;<br>
}<br>
- dri3_update_num_back(draw);<br>
<br>
if (draw->vtable->show_fps)<br>
draw->vtable->show_fps(draw, ce->ust);<br>
@@ -402,7 +400,8 @@ dri3_handle_present_event(<wbr>struct loader_dri3_drawable *draw,<br>
buf->busy = 0;<br>
<br>
if (buf && draw->num_back <= b && b < LOADER_DRI3_MAX_BACK &&<br>
- draw->cur_blit_source != b) {<br>
+ draw->cur_blit_source != b &&<br>
+ buf->busy == 0) {<br>
dri3_free_render_buffer(draw, buf);<br>
draw->buffers[b] = NULL;<br>
}<br>
@@ -537,6 +536,7 @@ dri3_find_back(struct loader_dri3_drawable *draw)<br>
/* Check whether we need to reuse the current back buffer as new back.<br>
* In that case, wait until it's not busy anymore.<br>
*/<br>
+ dri3_update_num_back(draw);<br>
num_to_consider = draw->num_back;<br>
if (!loader_dri3_have_image_blit(<wbr>draw) && draw->cur_blit_source != -1) {<br>
num_to_consider = 1;<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.7.4<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div>