drm/amdgpu: fix contiguous handling for IB parsing v2
authorChristian König <christian.koenig@amd.com>
Wed, 24 Jul 2024 07:24:02 +0000 (09:24 +0200)
committerAlex Deucher <alexander.deucher@amd.com>
Sat, 27 Jul 2024 21:28:47 +0000 (17:28 -0400)
Otherwise we won't get correct access to the IB.

v2: keep setting AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS to avoid problems in
    the VRAM backend.

Signed-off-by: Christian König <christian.koenig@amd.com>
Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/3501
Fixes: e362b7c8f8c7 ("drm/amdgpu: Modify the contiguous flags behaviour")
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org
Tested-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c

index cde2f4548a625864a3e16e949a1b6337840ac858..1e167d925b64b56bfc51f2d583255f00f2220fb9 100644 (file)
@@ -1782,7 +1782,7 @@ int amdgpu_cs_find_mapping(struct amdgpu_cs_parser *parser,
        struct ttm_operation_ctx ctx = { false, false };
        struct amdgpu_vm *vm = &fpriv->vm;
        struct amdgpu_bo_va_mapping *mapping;
-       int r;
+       int i, r;
 
        addr /= AMDGPU_GPU_PAGE_SIZE;
 
@@ -1797,13 +1797,13 @@ int amdgpu_cs_find_mapping(struct amdgpu_cs_parser *parser,
        if (dma_resv_locking_ctx((*bo)->tbo.base.resv) != &parser->exec.ticket)
                return -EINVAL;
 
-       if (!((*bo)->flags & AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS)) {
-               (*bo)->flags |= AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS;
-               amdgpu_bo_placement_from_domain(*bo, (*bo)->allowed_domains);
-               r = ttm_bo_validate(&(*bo)->tbo, &(*bo)->placement, &ctx);
-               if (r)
-                       return r;
-       }
+       (*bo)->flags |= AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS;
+       amdgpu_bo_placement_from_domain(*bo, (*bo)->allowed_domains);
+       for (i = 0; i < (*bo)->placement.num_placement; i++)
+               (*bo)->placements[i].flags |= TTM_PL_FLAG_CONTIGUOUS;
+       r = ttm_bo_validate(&(*bo)->tbo, &(*bo)->placement, &ctx);
+       if (r)
+               return r;
 
        return amdgpu_ttm_alloc_gart(&(*bo)->tbo);
 }