<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-2022-jp">
<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,Arial,Helvetica,sans-serif;" dir="ltr">
<p>Hi David,</p>
<p><br>
</p>
<p>Thanks for the comments. However, please have look at <span style="font-family: Calibri, Arial, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">
amdgpu_bo_reserve</span> definition.</p>
<p><span>static inline int amdgpu_bo_reserve(struct amdgpu_bo *bo, bool no_intr)</span><br>
</p>
<p><span><br>
</span></p>
<p><span>When we call this function like the following:</span></p>
<p><span><span style="font-family: Calibri, Arial, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 13.3333px;">         r = amdgpu_bo_reserve(adev->vram_scratch.robj,
 false);</span><br style="font-family: Calibri, Arial, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 13.3333px;">
</span><span style="font-size: 12pt;">The false means <span>interruptible</span>.</span><span><br>
</span></p>
<p><span style="font-size: 12pt;"><br>
</span></p>
<p><span style="font-size: 12pt;">On the other hand,  when <span style="font-family: Calibri, Arial, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 13.3333px;">amdgpu_bo_reserve
 function return error, why do we unref BO without kunmap and unpin the BO? This is wrong implementation when <span style="font-family: Calibri, Arial, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 13.3333px;">amdgpu_bo_reserve
 return any error.</span></span></span></p>
<p><br>
</p>
Thanks,
<div>Alex Bin Xie<br>
<br>
<div style="color: rgb(0, 0, 0);">
<div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Zhou, David(ChunMing)<br>
<b>Sent:</b> Friday, April 14, 2017 12:00 AM<br>
<b>To:</b> Xie, AlexBin; amd-gfx@lists.freedesktop.org<br>
<b>Subject:</b> Re: [PATCH] dmr/amdgpu: Fix wrongly unref of BO</font>
<div> </div>
</div>
</div>
<font size="2"><span style="font-size:10pt;">
<div class="PlainText"><br>
<br>
On 2017年04月14日 05:34, Alex Xie wrote:<br>
> According to comment of amdgpu_bo_reserve, amdgpu_bo_reserve<br>
> can return with -ERESTARTSYS. When this function was interrupted<br>
> by a signal, BO should not be unref. Otherwise the BO might be<br>
> released while is kmapped and pinned, or BO MIGHT be deref<br>
> multiple times, etc.<br>
         r = amdgpu_bo_reserve(adev->vram_scratch.robj, false);<br>
we have specified interruptible to false, so -ERESTARTSYS isn't possible <br>
here.<br>
<br>
Thanks,<br>
David Zhou<br>
><br>
> Change-Id: If76071a768950a0d3ad9d5da7fcae04881807621<br>
> Signed-off-by: Alex Xie <AlexBin.Xie@amd.com><br>
> ---<br>
>   drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 +-<br>
>   1 file changed, 1 insertion(+), 1 deletion(-)<br>
><br>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c<br>
> index 53996e3..1dcc2d1 100644<br>
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c<br>
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c<br>
> @@ -355,8 +355,8 @@ static void amdgpu_vram_scratch_fini(struct amdgpu_device *adev)<br>
>                amdgpu_bo_kunmap(adev->vram_scratch.robj);<br>
>                amdgpu_bo_unpin(adev->vram_scratch.robj);<br>
>                amdgpu_bo_unreserve(adev->vram_scratch.robj);<br>
> +             amdgpu_bo_unref(&adev->vram_scratch.robj);<br>
>        }<br>
> -     amdgpu_bo_unref(&adev->vram_scratch.robj);<br>
>   }<br>
>   <br>
>   /**<br>
<br>
</div>
</span></font></div>
</div>
</div>
</body>
</html>