Skip to content

Commit e18aaea

Browse files
Nirmoy Dasalexdeucher
authored andcommitted
drm/amdgpu: move shadow_list to amdgpu_bo_vm
Move shadow_list to struct amdgpu_bo_vm as shadow BOs are part of PT/PD BOs. Signed-off-by: Nirmoy Das <nirmoy.das@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent 23e24fb commit e18aaea

4 files changed

Lines changed: 14 additions & 13 deletions

File tree

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4124,6 +4124,7 @@ static int amdgpu_device_recover_vram(struct amdgpu_device *adev)
41244124
{
41254125
struct dma_fence *fence = NULL, *next = NULL;
41264126
struct amdgpu_bo *shadow;
4127+
struct amdgpu_bo_vm *vmbo;
41274128
long r = 1, tmo;
41284129

41294130
if (amdgpu_sriov_runtime(adev))
@@ -4133,8 +4134,8 @@ static int amdgpu_device_recover_vram(struct amdgpu_device *adev)
41334134

41344135
dev_info(adev->dev, "recover vram bo from shadow start\n");
41354136
mutex_lock(&adev->shadow_list_lock);
4136-
list_for_each_entry(shadow, &adev->shadow_list, shadow_list) {
4137-
4137+
list_for_each_entry(vmbo, &adev->shadow_list, shadow_list) {
4138+
shadow = &vmbo->bo;
41384139
/* No need to recover an evicted BO */
41394140
if (shadow->tbo.resource->mem_type != TTM_PL_TT ||
41404141
shadow->tbo.resource->start == AMDGPU_BO_INVALID_OFFSET ||

drivers/gpu/drm/amd/amdgpu/amdgpu_object.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,13 @@ static void amdgpu_bo_vm_destroy(struct ttm_buffer_object *tbo)
7979
{
8080
struct amdgpu_device *adev = amdgpu_ttm_adev(tbo->bdev);
8181
struct amdgpu_bo *bo = ttm_to_amdgpu_bo(tbo);
82+
struct amdgpu_bo_vm *vmbo;
8283

84+
vmbo = to_amdgpu_bo_vm(bo);
8385
/* in case amdgpu_device_recover_vram got NULL of bo->parent */
84-
if (!list_empty(&bo->shadow_list)) {
86+
if (!list_empty(&vmbo->shadow_list)) {
8587
mutex_lock(&adev->shadow_list_lock);
86-
list_del_init(&bo->shadow_list);
88+
list_del_init(&vmbo->shadow_list);
8789
mutex_unlock(&adev->shadow_list_lock);
8890
}
8991

@@ -559,7 +561,6 @@ int amdgpu_bo_create(struct amdgpu_device *adev,
559561
if (bo == NULL)
560562
return -ENOMEM;
561563
drm_gem_private_object_init(adev_to_drm(adev), &bo->tbo.base, size);
562-
INIT_LIST_HEAD(&bo->shadow_list);
563564
bo->vm_bo = NULL;
564565
bo->preferred_domains = bp->preferred_domain ? bp->preferred_domain :
565566
bp->domain;
@@ -689,6 +690,7 @@ int amdgpu_bo_create_vm(struct amdgpu_device *adev,
689690
return r;
690691

691692
*vmbo_ptr = to_amdgpu_bo_vm(bo_ptr);
693+
INIT_LIST_HEAD(&(*vmbo_ptr)->shadow_list);
692694
return r;
693695
}
694696

@@ -733,12 +735,12 @@ int amdgpu_bo_validate(struct amdgpu_bo *bo)
733735
*
734736
* Insert a BO to the shadow list.
735737
*/
736-
void amdgpu_bo_add_to_shadow_list(struct amdgpu_bo *bo)
738+
void amdgpu_bo_add_to_shadow_list(struct amdgpu_bo_vm *vmbo)
737739
{
738-
struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
740+
struct amdgpu_device *adev = amdgpu_ttm_adev(vmbo->bo.tbo.bdev);
739741

740742
mutex_lock(&adev->shadow_list_lock);
741-
list_add_tail(&bo->shadow_list, &adev->shadow_list);
743+
list_add_tail(&vmbo->shadow_list, &adev->shadow_list);
742744
mutex_unlock(&adev->shadow_list_lock);
743745
}
744746

drivers/gpu/drm/amd/amdgpu/amdgpu_object.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,6 @@ struct amdgpu_bo {
109109
#ifdef CONFIG_MMU_NOTIFIER
110110
struct mmu_interval_notifier notifier;
111111
#endif
112-
113-
struct list_head shadow_list;
114-
115112
struct kgd_mem *kfd_bo;
116113
};
117114

@@ -127,6 +124,7 @@ struct amdgpu_bo_user {
127124
struct amdgpu_bo_vm {
128125
struct amdgpu_bo bo;
129126
struct amdgpu_bo *shadow;
127+
struct list_head shadow_list;
130128
struct amdgpu_vm_bo_base entries[];
131129
};
132130

@@ -333,7 +331,7 @@ u64 amdgpu_bo_gpu_offset_no_check(struct amdgpu_bo *bo);
333331
int amdgpu_bo_validate(struct amdgpu_bo *bo);
334332
void amdgpu_bo_get_memory(struct amdgpu_bo *bo, uint64_t *vram_mem,
335333
uint64_t *gtt_mem, uint64_t *cpu_mem);
336-
void amdgpu_bo_add_to_shadow_list(struct amdgpu_bo *bo);
334+
void amdgpu_bo_add_to_shadow_list(struct amdgpu_bo_vm *vmbo);
337335
int amdgpu_bo_restore_shadow(struct amdgpu_bo *shadow,
338336
struct dma_fence **fence);
339337
uint32_t amdgpu_bo_get_preferred_pin_domain(struct amdgpu_device *adev,

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,7 @@ static int amdgpu_vm_pt_create(struct amdgpu_device *adev,
938938
}
939939

940940
(*vmbo)->shadow->parent = amdgpu_bo_ref(bo);
941-
amdgpu_bo_add_to_shadow_list((*vmbo)->shadow);
941+
amdgpu_bo_add_to_shadow_list(*vmbo);
942942

943943
return 0;
944944
}

0 commit comments

Comments
 (0)