<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html;
      charset=windows-1252">
  </head>
  <body>
    I take that as an reviewed-by :)<br>
    <br>
    Thanks,<br>
    Christian.<br>
    <br>
    <div class="moz-cite-prefix">Am 07.06.21 um 16:14 schrieb Pan,
      Xinhui:<br>
    </div>
    <blockquote type="cite"
cite="mid:DM4PR12MB5165EDA10869E4A37D94CED387389@DM4PR12MB5165.namprd12.prod.outlook.com">
      <meta http-equiv="Content-Type" content="text/html;
        charset=windows-1252">
      <p
        style="font-family:Arial;font-size:10pt;color:#0000FF;margin:15pt;"
        align="Left">
        [AMD Official Use Only]<br>
      </p>
      <br>
      <div>
        <div dir="auto" style="direction: ltr; margin: 0px; padding:
          0px; font-family: sans-serif; font-size: 11pt; color: black;
          text-align: left;">
          Looks good to me.</div>
        <hr style="display:inline-block;width:98%" tabindex="-1">
        <div id="divRplyFwdMsg" dir="ltr"><font style="font-size:11pt"
            face="Calibri, sans-serif" color="#000000"><b>From:</b>
            Christian König <a class="moz-txt-link-rfc2396E" href="mailto:ckoenig.leichtzumerken@gmail.com"><ckoenig.leichtzumerken@gmail.com></a><br>
            <b>Sent:</b> Monday, June 7, 2021 8:52:21 PM<br>
            <b>To:</b> <a class="moz-txt-link-abbreviated" href="mailto:dri-devel@lists.freedesktop.org">dri-devel@lists.freedesktop.org</a>
            <a class="moz-txt-link-rfc2396E" href="mailto:dri-devel@lists.freedesktop.org"><dri-devel@lists.freedesktop.org></a>; Pan, Xinhui
            <a class="moz-txt-link-rfc2396E" href="mailto:Xinhui.Pan@amd.com"><Xinhui.Pan@amd.com></a>; Das, Nirmoy
            <a class="moz-txt-link-rfc2396E" href="mailto:Nirmoy.Das@amd.com"><Nirmoy.Das@amd.com></a>; Huang, Ray
            <a class="moz-txt-link-rfc2396E" href="mailto:Ray.Huang@amd.com"><Ray.Huang@amd.com></a><br>
            <b>Cc:</b> Thomas Hellström
            <a class="moz-txt-link-rfc2396E" href="mailto:thomas.hellstrom@linux.intel.com"><thomas.hellstrom@linux.intel.com></a><br>
            <b>Subject:</b> Re: [PATCH] drm/ttm: fix deref of bo->ttm
            without holding the lock v2</font>
          <div> </div>
        </div>
        <div class="BodyFragment"><font size="2"><span
              style="font-size:11pt;">
              <div class="PlainText"><br>
                <br>
                Am 28.05.21 um 15:06 schrieb Thomas Hellström:<br>
                ><br>
                > On 5/28/21 3:00 PM, Christian König wrote:<br>
                >> We need to grab the resv lock first before
                doing that check.<br>
                >><br>
                >> v2 (chk): simplify the change for -fixes<br>
                >><br>
                >> Signed-off-by: Christian König
                <a class="moz-txt-link-rfc2396E" href="mailto:christian.koenig@amd.com"><christian.koenig@amd.com></a><br>
                >> Signed-off-by: Thomas Hellström
                <a class="moz-txt-link-rfc2396E" href="mailto:thomas.hellstrom@linux.intel.com"><thomas.hellstrom@linux.intel.com></a><br>
                ><br>
                > Hmm, OK, but this doesn't fix the
                swapped-bo-not-on-lru and <br>
                > unpopulating from swap_notify issues. Are you
                planning a follow up <br>
                > patch for those?<br>
                <br>
                As discussed in a separate thread this needs to be
                applied as needed <br>
                when the DG1 branch is merged.<br>
                <br>
                Xinhui, Nirmoy, Rui can anybody give be an rb/ab so that
                I can push this?<br>
                <br>
                Thanks,<br>
                Christian.<br>
                <br>
                ><br>
                > Thanks,<br>
                ><br>
                > Thomas<br>
                ><br>
                >> ---<br>
                >>   drivers/gpu/drm/ttm/ttm_bo.c     | 5 ++++-<br>
                >>   drivers/gpu/drm/ttm/ttm_device.c | 8 +-------<br>
                >>   2 files changed, 5 insertions(+), 8
                deletions(-)<br>
                >><br>
                >> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c
                b/drivers/gpu/drm/ttm/ttm_bo.c<br>
                >> index cfd0b9292397..ebcffe794adb 100644<br>
                >> --- a/drivers/gpu/drm/ttm/ttm_bo.c<br>
                >> +++ b/drivers/gpu/drm/ttm/ttm_bo.c<br>
                >> @@ -1172,7 +1172,10 @@ int
                ttm_bo_swapout(struct ttm_buffer_object <br>
                >> *bo, struct ttm_operation_ctx *ctx,<br>
                >>       if (!ttm_bo_evict_swapout_allowable(bo,
                ctx, &locked, NULL))<br>
                >>           return -EBUSY;<br>
                >>   -    if (!ttm_bo_get_unless_zero(bo)) {<br>
                >> +    if (!bo->ttm ||
                !ttm_tt_is_populated(bo->ttm) ||<br>
                >> +        bo->ttm->page_flags &
                TTM_PAGE_FLAG_SG ||<br>
                >> +        bo->ttm->page_flags &
                TTM_PAGE_FLAG_SWAPPED ||<br>
                >> +        !ttm_bo_get_unless_zero(bo)) {<br>
                >>           if (locked)<br>
                >>              
                dma_resv_unlock(bo->base.resv);<br>
                >>           return -EBUSY;<br>
                >> diff --git a/drivers/gpu/drm/ttm/ttm_device.c <br>
                >> b/drivers/gpu/drm/ttm/ttm_device.c<br>
                >> index a1dcf7d55c90..3d9c62b93e29 100644<br>
                >> --- a/drivers/gpu/drm/ttm/ttm_device.c<br>
                >> +++ b/drivers/gpu/drm/ttm/ttm_device.c<br>
                >> @@ -143,14 +143,8 @@ int
                ttm_device_swapout(struct ttm_device *bdev, <br>
                >> struct ttm_operation_ctx *ctx,<br>
                >>             for (j = 0; j <
                TTM_MAX_BO_PRIORITY; ++j) {<br>
                >>               list_for_each_entry(bo,
                &man->lru[j], lru) {<br>
                >> -                uint32_t num_pages;<br>
                >> +                uint32_t num_pages =
                PFN_UP(bo->base.size);<br>
                >>   -                if (!bo->ttm ||
                !ttm_tt_is_populated(bo->ttm) ||<br>
                >> -                    bo->ttm->page_flags
                & TTM_PAGE_FLAG_SG ||<br>
                >> -                    bo->ttm->page_flags
                & TTM_PAGE_FLAG_SWAPPED)<br>
                >> -                    continue;<br>
                >> -<br>
                >> -                num_pages =
                bo->ttm->num_pages;<br>
                >>                   ret = ttm_bo_swapout(bo, ctx,
                gfp_flags);<br>
                >>                   /* ttm_bo_swapout has dropped
                the lru_lock */<br>
                >>                   if (!ret)<br>
                <br>
              </div>
            </span></font></div>
      </div>
    </blockquote>
    <br>
  </body>
</html>