<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p style="margin-top:0;margin-bottom:0">Hi Chris<span style="font-size: 12pt;"> </span></p>
<p style="margin-top:0;margin-bottom:0"><span style="font-size: 12pt;"><br>
</span></p>
<p style="margin-top:0;margin-bottom:0">another question is why we not just call "<span style="color: rgb(220, 220, 170); background-color: rgb(30, 30, 30); font-family: "Droid Sans Mono", monospace, monospace, "Droid Sans Fallback"; font-size: 14px; white-space: pre;">reservation_object_reserve_shared"</span></p>
<p style="margin-top:0;margin-bottom:0"><span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: "Droid Sans Mono", monospace, monospace, "Droid Sans Fallback"; font-size: 14px; white-space: pre;">during below add_shared_fence function,
 so the BUG_ON() could be avoided and caller won't need</span></p>
<p style="margin-top:0;margin-bottom:0"><span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: "Droid Sans Mono", monospace, monospace, "Droid Sans Fallback"; font-size: 14px; white-space: pre;">to worry when and how much time
 it should call reserve_shared() ?</span></p>
<p style="margin-top:0;margin-bottom:0"><span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: "Droid Sans Mono", monospace, monospace, "Droid Sans Fallback"; font-size: 14px; white-space: pre;"><br>
</span></p>
<p style="margin-top:0;margin-bottom:0"><span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: "Droid Sans Mono", monospace, monospace, "Droid Sans Fallback"; font-size: 14px; white-space: pre;">thanks !</span></p>
<p style="margin-top:0;margin-bottom:0"><span style="font-size: 12pt;"><br>
</span></p>
<p style="margin-top:0;margin-bottom:0"><span style="font-size: 12pt;"></p>
<div style="color: rgb(212, 212, 212); background-color: rgb(30, 30, 30); font-family: "Droid Sans Mono", monospace, monospace, "Droid Sans Fallback"; font-size: 14px; line-height: 19px; white-space: pre;">
<div><span style="color: #569cd6;">void</span> <span style="color: #dcdcaa;">reservation_object_add_shared_fence</span>(<span style="color: #569cd6;">struct</span> reservation_object *obj,</div>
<div>                     <span style="color: #569cd6;">struct</span> dma_fence *fence)</div>
<div>{</div>
<div>    <span style="color: #569cd6;">struct</span> reservation_object_list *old, *fobj = obj-><span style="color: #9cdcfe;">staged</span>;</div>
<br>
<div>    old = <span style="color: #dcdcaa;">reservation_object_get_list</span>(obj);</div>
<div>    obj-><span style="color: #9cdcfe;">staged</span> = <span style="color: #569cd6;">
NULL</span>;</div>
<br>
<div>    <span style="color: #c586c0;">if</span> (!fobj) {</div>
<div>        <span style="color: #dcdcaa;">BUG_ON</span>(old-><span style="color: #9cdcfe;">shared_count</span> >= old-><span style="color: #9cdcfe;">shared_max</span>);</div>
<div>        <span style="color: #dcdcaa;">reservation_object_add_shared_inplace</span>(obj, old, fence);</div>
<div>    } <span style="color: #c586c0;">else</span></div>
<div>        <span style="color: #dcdcaa;">reservation_object_add_shared_replace</span>(obj, old, fobj, fence);</div>
<div>}</div>
<div><span style="color: #dcdcaa;">EXPORT_SYMBOL</span>(reservation_object_add_shared_fence);</div>
<div><br>
</div>
<div><br>
</div>
</div>
</span>
<p></p>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Chris Wilson <chris@chris-wilson.co.uk><br>
<b>Sent:</b> Tuesday, March 6, 2018 6:10:21 PM<br>
<b>To:</b> Liu, Monk; dri-devel@lists.freedesktop.org; Koenig, Christian<br>
<b>Subject:</b> Re: reservation questions</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Quoting Liu, Monk (2018-03-06 09:45:19)<br>
> call reservation_object_add_excl_fence,<br>
> it set obj->fence->shared_count to 0, and put all shared fence from obj->fence<br>
> without waiting signaling.<br>
> (this action looks inappropriate, I think at least before put all those shared<br>
> fences<br>
> we should dma_wait_fence() on them to make sure they are signaled)<br>
<br>
No. Serialisation of resv updates are handled by the caller, the fences<br>
are ordered asynchronously so the wait is implicit in the construction.<br>
(I.e. before the excl fence can be signaled, all of the earlier shared<br>
fences must be signaled. You can even say before the operation that the<br>
excl fence signals completion of can begin, all the shared fences must<br>
have been signaled. But that is all implicit so that we can do it<br>
asynchronously.)<br>
<br>
> call reservation_object_reserve_shared,<br>
> this time obj->staged isn't NULL, and it is freed (nothing bad now<br>
> since obj->fence points to other place),<br>
> and obj->staged set to NULL,<br>
> <br>
> call reservation_object_add_shared_fence,<br>
> this time should going through reservation_object_add_shared_inplace,<br>
> But BUG_ON(old->shared_count >= old->shared_max) will hit !<br>
<br>
How? You only free staged iff shared_count < shared_max.<br>
<br>
You've reminded me that we should cover all this with a bunch of<br>
selftests.<br>
-Chris<br>
</div>
</span></font></div>
</body>
</html>