<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <br>
    <br>
    <div class="moz-cite-prefix">On 2017年04月17日 22:54, Xie, AlexBin
      wrote:<br>
    </div>
    <blockquote
cite="mid:MWHPR1201MB0045DE55E81D0FF5CE76671FF2060@MWHPR1201MB0045.namprd12.prod.outlook.com"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
      <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>
      </div>
    </blockquote>
    Ah, this is a wired wrapper for ttm_bo_reserve.<br>
    <br>
    <blockquote
cite="mid:MWHPR1201MB0045DE55E81D0FF5CE76671FF2060@MWHPR1201MB0045.namprd12.prod.outlook.com"
      type="cite">
      <div id="divtagdefaultwrapper"
style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif;"
        dir="ltr">
        <p>
        </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>
      </div>
    </blockquote>
    Yeah, I see your mean, it's in driver un-loading, How about changing
    to no interruptible? Your patch will make a memleak if bo_reserve
    fails, but it seems not matter. I have no strong preference.<br>
    <br>
    Regards,<br>
    David Zhou<br>
    <blockquote
cite="mid:MWHPR1201MB0045DE55E81D0FF5CE76671FF2060@MWHPR1201MB0045.namprd12.prod.outlook.com"
      type="cite">
      <div id="divtagdefaultwrapper"
style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif;"
        dir="ltr">
        <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
                  style="font-size:11pt" face="Calibri, sans-serif"
                  color="#000000"><b>From:</b> Zhou, David(ChunMing)<br>
                  <b>Sent:</b> Friday, April 14, 2017 12:00 AM<br>
                  <b>To:</b> Xie, AlexBin; <a class="moz-txt-link-abbreviated" href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a><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
                  <a class="moz-txt-link-rfc2396E" href="mailto:AlexBin.Xie@amd.com"><AlexBin.Xie@amd.com></a><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>
    </blockquote>
    <br>
  </body>
</html>