]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/amdgpu: fix start calculation in amdgpu_vram_mgr_new
authorChristian König <christian.koenig@amd.com>
Tue, 10 May 2022 10:52:05 +0000 (12:52 +0200)
committerChristian König <christian.koenig@amd.com>
Wed, 11 May 2022 08:01:55 +0000 (10:01 +0200)
We still need to calculate a virtual start address for the resource to
aid checking of it is visible or not. Only matters on small BAR systems,
but better save than sorry.

Signed-off-by: Christian König <christian.koenig@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Arunpravin Paneer Selvam <Arunpravin.PaneerSelvam@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220510113649.879821-1-christian.koenig@amd.com
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c

index 49e4092f447f3da955f3f6c8fda818a1a5a93a40..51d9d3a4456c6d7342316bccf6f9bfeda1bd9368 100644 (file)
@@ -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;