<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    Hi Christian,<br>
    <br>
    I verified the patch.<br>
    <br>
    Reviewed-by:
    Arunpravin Paneer Selvam <<a href="mailto:Arunpravin.PaneerSelvam@amd.com" class="moz-txt-link-freetext">Arunpravin.PaneerSelvam@amd.com</a>><br>
    <br>
    Regards,<br>
    Arun<br>
    <br>
    <div class="moz-cite-prefix">On 7/14/2022 6:53 PM, Christian König
      wrote:<br>
    </div>
    <blockquote type="cite" cite="mid:20220714132315.587217-1-christian.koenig@amd.com">
      <pre class="moz-quote-pre" wrap="">This re-applys commit 5e3f1e7729ec7a99e145e9d8ed58963d86cdfb98.

The original problem this was reverted for was found and the correct fix
will be merged to drm-misc-next-fixes.

Signed-off-by: Christian König <a class="moz-txt-link-rfc2396E" href="mailto:christian.koenig@amd.com"><christian.koenig@amd.com></a>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 22 +++++++++++++-------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
index 49e4092f447f..51d9d3a4456c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
@@ -496,16 +496,22 @@ static int amdgpu_vram_mgr_new(struct ttm_resource_manager *man,
                        list_splice_tail(trim_list, &vres->blocks);
        }
 
-       list_for_each_entry(block, &vres->blocks, link)
-               vis_usage += amdgpu_vram_mgr_vis_size(adev, block);
+       vres->base.start = 0;
+       list_for_each_entry(block, &vres->blocks, link) {
+               unsigned long start;
 
-       block = amdgpu_vram_mgr_first_block(&vres->blocks);
-       if (!block) {
-               r = -EINVAL;
-               goto error_fini;
-       }
+               start = amdgpu_vram_mgr_block_start(block) +
+                       amdgpu_vram_mgr_block_size(block);
+               start >>= PAGE_SHIFT;
 
-       vres->base.start = amdgpu_vram_mgr_block_start(block) >> PAGE_SHIFT;
+               if (start > vres->base.num_pages)
+                       start -= vres->base.num_pages;
+               else
+                       start = 0;
+               vres->base.start = max(vres->base.start, start);
+
+               vis_usage += amdgpu_vram_mgr_vis_size(adev, block);
+       }
 
        if (amdgpu_is_vram_mgr_blocks_contiguous(&vres->blocks))
                vres->base.placement |= TTM_PL_FLAG_CONTIGUOUS;
</pre>
    </blockquote>
    <br>
  </body>
</html>