<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:DengXian;
panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:"Microsoft YaHei";
panose-1:2 11 5 3 2 2 4 2 2 4;}
@font-face
{font-family:"Microsoft YaHei";}
@font-face
{font-family:DengXian;
panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
{mso-style-name:msonormal;
margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
span.EmailStyle20
{mso-style-type:personal-reply;
font-family:DengXian;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="ZH-CN" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.5pt;font-family:DengXian">Oh, I see
<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"> </span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#C586C0">for</span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4">
(i = </span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#B5CEA8"><o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#B5CEA8">0</span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4">; i < fobj-></span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#9CDCFE">shared_count</span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4">;
++i) {<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><o:p> </o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"> </span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#569CD6">struct</span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4">
dma_fence *old_fence;<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.5pt;font-family:DengXian"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.5pt;font-family:DengXian"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.5pt;font-family:DengXian">Since it use I < fobj->shared_count, then the wild pointer access won¡¯t hit, please ignore question 1<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.5pt;font-family:DengXian"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.5pt;font-family:DengXian">The only valuable is question 2: how we treat excl fence and shared fence?
<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.5pt;font-family:DengXian">e.g. when we add an excl fence to resv, how to deal with shared ? current logic is just put the all
<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.5pt;font-family:DengXian">do we need to wait on their signaling before putting them ?<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.5pt;font-family:DengXian"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.5pt;font-family:DengXian">thanks
<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.5pt;font-family:DengXian"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.5pt;font-family:DengXian">/Monk<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.5pt;font-family:DengXian"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.5pt;font-family:DengXian"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US">From:</span></b><span lang="EN-US"> Liu, Monk
<br>
<b>Sent:</b> 2018</span><span style="font-family:"΢ÈíÑźÚ",sans-serif">Äê</span><span lang="EN-US">3</span><span style="font-family:"΢ÈíÑźÚ",sans-serif">ÔÂ</span><span lang="EN-US">6</span><span style="font-family:"΢ÈíÑźÚ",sans-serif">ÈÕ</span><span lang="EN-US"> 17:57<br>
<b>To:</b> dri-devel@lists.freedesktop.org; Chris Wilson <chris@chris-wilson.co.uk>; Koenig, Christian <Christian.Koenig@amd.com><br>
<b>Subject:</b> Re: reservation questions <o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<div id="divtagdefaultwrapper">
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black"><br>
</span><span lang="EN-US" style="font-size:12.0pt;color:red">sorry, I have some mistake in previous thread, correct it as followings.</span><span lang="EN-US" style="font-size:12.0pt;color:black"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black">1) considering below sequence:<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black">call reservation_object_add_shared_fence,<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black">now assume old->shared_count is now 3<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black">call reservation_object_add_shared_fence,<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black">now assume old->shared_count is now 4,<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black">call reservation_object_reserve_shared,<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black">now obj->staged is new allocated, and its shared_max = 8, but not<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black">used by far.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black">call reservation_object_add_excl_fence,<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black">it set obj->fence->shared_count to 0, <b>and put all shared fence from obj->fence without waiting signaling.</b><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black">(this action looks inappropriate, I think at least before put all those shared fences<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black">we should dma_wait_fence() on them to make sure they are signaled)<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black">call reservation_object_reserve_shared,<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:12.0pt;color:black">this time obj->staged isn't NULL, and it is freed</span></b><span lang="EN-US" style="font-size:12.0pt;color:black"> (nothing bad now<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black">since obj->fence points to other place),<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black">and obj->staged set to NULL,<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:#006FC9">call reservation_object_add_shared_fence,</span><span lang="EN-US" style="font-size:12.0pt;color:black"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:#006FC9">this time should going through
<b>reservation_object_add_shared_inplace</b>,</span><span lang="EN-US" style="font-size:12.0pt;color:black"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:#006FC9">since old->shared_count is 1 now, during <b>reservation_object_add_shared_inplace</b>()</span><span lang="EN-US" style="font-size:12.0pt;color:black"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:#006FC9">it would go through the shared list, but the fence in shared list is now wild pointer:</span><span lang="EN-US" style="font-size:12.0pt;color:black"><o:p></o:p></span></p>
</div>
<div>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"> </span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#C586C0">for</span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4">
(i = </span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#B5CEA8"><o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#B5CEA8">0</span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4">; i < fobj-></span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#9CDCFE">shared_count</span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4">;
++i) {<o:p></o:p></span></p>
</div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"> </span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#569CD6">struct</span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4">
dma_fence *old_fence;<o:p></o:p></span></p>
</div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><o:p> </o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><br>
<br>
<o:p></o:p></span></p>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><b><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"> old_fence =
</span></b><b><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#DCDCAA">rcu_dereference_protected</span></b><b><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4">(fobj-></span></b><b><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#9CDCFE">shared</span></b><b><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4">[i],</span></b><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><o:p></o:p></span></p>
</div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><b><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"> </span></b><b><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#DCDCAA">reservation_object_held</span></b><b><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4">(obj));</span></b><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><o:p></o:p></span></p>
</div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><o:p> </o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><br>
<br>
<o:p></o:p></span></p>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"> </span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#C586C0">if</span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4">
(old_fence-></span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#9CDCFE">context</span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"> == fence-></span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#9CDCFE">context</span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4">
&&<o:p></o:p></span></p>
</div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"> </span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#DCDCAA">dma_fence_is_later</span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4">(fence,
old_fence)) {<o:p></o:p></span></p>
</div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"> </span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#608B4E">/*
memory barrier is added by write_seqcount_begin */</span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><o:p></o:p></span></p>
</div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"> </span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#DCDCAA">RCU_INIT_POINTER</span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4">(fobj-></span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#9CDCFE">shared</span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4">[i],
fence);<o:p></o:p></span></p>
</div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"> </span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#DCDCAA">write_seqcount_end</span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4">(&obj-></span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#9CDCFE">seq</span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4">);<o:p></o:p></span></p>
</div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"> </span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#DCDCAA">preempt_enable</span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4">();<o:p></o:p></span></p>
</div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><o:p> </o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><br>
<br>
<o:p></o:p></span></p>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"> </span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#DCDCAA">dma_fence_put</span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4">(old_fence);<o:p></o:p></span></p>
</div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"> </span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#C586C0">return</span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4">;<o:p></o:p></span></p>
</div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"> }<o:p></o:p></span></p>
</div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><o:p> </o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><br>
<br>
<o:p></o:p></span></p>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"> </span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#C586C0">if</span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4">
(!signaled && </span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#DCDCAA"><o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#DCDCAA">dma_fence_is_signaled</span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4">(old_fence))
{<o:p></o:p></span></p>
</div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"> signaled = old_fence;<o:p></o:p></span></p>
</div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"> signaled_idx = i;<o:p></o:p></span></p>
</div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"> }<o:p></o:p></span></p>
</div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"> }<o:p></o:p></span></p>
</div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><o:p> </o:p></span></p>
</div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black">see that old_fence is get from fobj, and fobj is from </span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:black">reservation_object_get_list(obj)</span><span lang="EN-US" style="font-size:12.0pt;color:black"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:black">in outside, which is obj->fence, and in add_excl_fence, all dma_fence in</span><span lang="EN-US" style="font-size:12.0pt;color:black"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:black">obj->fence is already put.</span><span lang="EN-US" style="font-size:12.0pt;color:black"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black">/Monk<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
</div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
</div>
<div class="MsoNormal" align="center" style="text-align:center"><span lang="EN-US">
<hr size="3" width="98%" align="center">
</span></div>
<div id="divRplyFwdMsg">
<p class="MsoNormal"><b><span lang="EN-US" style="color:black">From:</span></b><span lang="EN-US" style="color:black"> Liu, Monk<br>
<b>Sent:</b> Tuesday, March 6, 2018 5:45:19 PM<br>
<b>To:</b> <a href="mailto:dri-devel@lists.freedesktop.org">dri-devel@lists.freedesktop.org</a>; Chris Wilson; Koenig, Christian<br>
<b>Subject:</b> reservation questions </span><span lang="EN-US"><o:p></o:p></span></p>
<div>
<p class="MsoNormal"><span lang="EN-US"> <o:p></o:p></span></p>
</div>
</div>
<div>
<div id="x_divtagdefaultwrapper">
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black">Hi Christian & Chris<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black">two question regarding resv:<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black">1) considering below sequence:<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black">call reservation_object_add_shared_fence,<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black">now assume old->shared_count is now 3<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black">call reservation_object_add_shared_fence,<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black">now assume old->shared_count is now 4,<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black">call reservation_object_reserve_shared,<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black">now obj->staged is new allocated, and its shared_max = 8, but not<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black">used by far.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black">call reservation_object_add_excl_fence,<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black">it set obj->fence->shared_count to 0,
<b>and put all shared fence from obj->fence without waiting signaling.</b><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black">(this action looks inappropriate, I think at least before put all those shared fences<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black">we should dma_wait_fence() on them to make sure they are signaled)<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black">call reservation_object_reserve_shared,<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:12.0pt;color:black">this time obj->staged isn't NULL, and it is freed</span></b><span lang="EN-US" style="font-size:12.0pt;color:black"> (nothing bad now<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black">since obj->fence points to other place),<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black">and obj->staged set to NULL,<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black">call reservation_object_add_shared_fence,<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black">this time should going through reservation_object_add_shared_inplace,<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:12.0pt;color:black">But BUG_ON(old->shared_count >= old->shared_max) will hit !</span></b><span lang="EN-US" style="font-size:12.0pt;color:black"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black">This looks a design flaw in reservation object, shouldn't we fix it ?<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black">2) in add_excl_fence(), it simply set old->shared_count to 0, and put all shared fences of old<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black">is that correct? if excl fence is really exclusively used, why we still consider both shared fence and<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black">excl fence on wait_timeout_rcu() routine, see blew description of this routine<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
</div>
<div>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><o:p> </o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><br>
<br>
<o:p></o:p></span></p>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#608B4E">/**</span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><o:p></o:p></span></p>
</div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#608B4E">* reservation_object_wait_timeout_rcu - Wait on reservation's objects</span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><o:p></o:p></span></p>
</div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#608B4E">* shared and/or exclusive fences.</span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><o:p></o:p></span></p>
</div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#608B4E">* @obj: the reservation object</span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><o:p></o:p></span></p>
</div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#608B4E">* @wait_all: if true, wait on all fences, else wait on just exclusive fence</span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><o:p></o:p></span></p>
</div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#608B4E">* @intr: if true, do interruptible wait</span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><o:p></o:p></span></p>
</div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#608B4E">* @timeout: timeout value in jiffies or zero to return immediately</span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><o:p></o:p></span></p>
</div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#608B4E">*</span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><o:p></o:p></span></p>
</div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#608B4E">* RETURNS</span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><o:p></o:p></span></p>
</div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#608B4E">* Returns -ERESTARTSYS if interrupted, 0 if the wait timed out, or</span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><o:p></o:p></span></p>
</div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#608B4E">* greater than zer on success.</span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><o:p></o:p></span></p>
</div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#608B4E">*/</span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><o:p></o:p></span></p>
</div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#569CD6">long</span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4">
</span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#DCDCAA">reservation_object_wait_timeout_rcu</span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4">(</span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#569CD6">struct</span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4">
reservation_object *obj,<o:p></o:p></span></p>
</div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4">
</span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#569CD6">bool</span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"> wait_all,
</span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#569CD6"><o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#569CD6">bool</span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"> intr,<o:p></o:p></span></p>
</div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4">
</span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#569CD6">unsigned</span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4">
</span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#569CD6"><o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#569CD6">long</span><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"> timeout)<o:p></o:p></span></p>
</div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-size:10.5pt;font-family:"Courier New";color:#D4D4D4"><o:p> </o:p></span></p>
</div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black"> <o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black">thanks<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black">/Monk<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
</div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
</div>
</div>
</div>
</body>
</html>