drm/amdgpu: make sure that BOs have a backing store
authorChristian König <christian.koenig@amd.com>
Mon, 5 Jun 2023 09:11:22 +0000 (11:11 +0200)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 15 Jun 2023 15:06:59 +0000 (11:06 -0400)
It's perfectly possible that the BO is about to be destroyed and doesn't
have a backing store associated with it.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Acked-by: Guchun Chen <guchun.chen@amd.com>
Tested-by: Mikhail Gavrilov <mikhail.v.gavrilov@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c

index 54cd21c..f7905bc 100644 (file)
@@ -1282,8 +1282,12 @@ void amdgpu_bo_move_notify(struct ttm_buffer_object *bo,
 void amdgpu_bo_get_memory(struct amdgpu_bo *bo,
                          struct amdgpu_mem_stats *stats)
 {
-       unsigned int domain;
        uint64_t size = amdgpu_bo_size(bo);
+       unsigned int domain;
+
+       /* Abort if the BO doesn't currently have a backing store */
+       if (!bo->tbo.resource)
+               return;
 
        domain = amdgpu_mem_type_to_domain(bo->tbo.resource->mem_type);
        switch (domain) {