diff options
author | Christian König <christian.koenig@amd.com> | 2018-09-10 14:02:46 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2018-09-13 16:14:12 -0400 |
commit | 646b90259842faa8341b076a3488a227927d84a2 (patch) | |
tree | 8c2de4481394f7e1c602e9d57ff35121adaec578 /drivers/gpu | |
parent | e83dfe4d869358549bb259ab581ae4f0450c6580 (diff) |
drm/amdgpu: use a single linked list for amdgpu_vm_bo_base
Instead of the double linked list. Gets the size of amdgpu_vm_pt down to
64 bytes again.
We could even reduce it down to 32 bytes, but that would require some
rather extreme hacks.
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
Acked-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 4 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 38 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 2 |
4 files changed, 29 insertions, 17 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index de990bdcdd6c..e6909252aefa 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | |||
@@ -448,7 +448,7 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev, | |||
448 | return -ENOMEM; | 448 | return -ENOMEM; |
449 | drm_gem_private_object_init(adev->ddev, &bo->gem_base, size); | 449 | drm_gem_private_object_init(adev->ddev, &bo->gem_base, size); |
450 | INIT_LIST_HEAD(&bo->shadow_list); | 450 | INIT_LIST_HEAD(&bo->shadow_list); |
451 | INIT_LIST_HEAD(&bo->va); | 451 | bo->vm_bo = NULL; |
452 | bo->preferred_domains = bp->preferred_domain ? bp->preferred_domain : | 452 | bo->preferred_domains = bp->preferred_domain ? bp->preferred_domain : |
453 | bp->domain; | 453 | bp->domain; |
454 | bo->allowed_domains = bo->preferred_domains; | 454 | bo->allowed_domains = bo->preferred_domains; |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h index 907fdf46d895..64337ff2ad63 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | |||
@@ -89,8 +89,8 @@ struct amdgpu_bo { | |||
89 | void *metadata; | 89 | void *metadata; |
90 | u32 metadata_size; | 90 | u32 metadata_size; |
91 | unsigned prime_shared_count; | 91 | unsigned prime_shared_count; |
92 | /* list of all virtual address to which this bo is associated to */ | 92 | /* per VM structure for page tables and with virtual addresses */ |
93 | struct list_head va; | 93 | struct amdgpu_vm_bo_base *vm_bo; |
94 | /* Constant after initialization */ | 94 | /* Constant after initialization */ |
95 | struct drm_gem_object gem_base; | 95 | struct drm_gem_object gem_base; |
96 | struct amdgpu_bo *parent; | 96 | struct amdgpu_bo *parent; |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index 234764ac58cf..a7f9aaa47c49 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | |||
@@ -309,12 +309,13 @@ static void amdgpu_vm_bo_base_init(struct amdgpu_vm_bo_base *base, | |||
309 | { | 309 | { |
310 | base->vm = vm; | 310 | base->vm = vm; |
311 | base->bo = bo; | 311 | base->bo = bo; |
312 | INIT_LIST_HEAD(&base->bo_list); | 312 | base->next = NULL; |
313 | INIT_LIST_HEAD(&base->vm_status); | 313 | INIT_LIST_HEAD(&base->vm_status); |
314 | 314 | ||
315 | if (!bo) | 315 | if (!bo) |
316 | return; | 316 | return; |
317 | list_add_tail(&base->bo_list, &bo->va); | 317 | base->next = bo->vm_bo; |
318 | bo->vm_bo = base; | ||
318 | 319 | ||
319 | if (bo->tbo.resv != vm->root.base.bo->tbo.resv) | 320 | if (bo->tbo.resv != vm->root.base.bo->tbo.resv) |
320 | return; | 321 | return; |
@@ -352,7 +353,7 @@ static struct amdgpu_vm_pt *amdgpu_vm_pt_parent(struct amdgpu_vm_pt *pt) | |||
352 | if (!parent) | 353 | if (!parent) |
353 | return NULL; | 354 | return NULL; |
354 | 355 | ||
355 | return list_first_entry(&parent->va, struct amdgpu_vm_pt, base.bo_list); | 356 | return container_of(parent->vm_bo, struct amdgpu_vm_pt, base); |
356 | } | 357 | } |
357 | 358 | ||
358 | /** | 359 | /** |
@@ -954,7 +955,7 @@ static void amdgpu_vm_free_pts(struct amdgpu_device *adev, | |||
954 | for_each_amdgpu_vm_pt_dfs_safe(adev, vm, cursor, entry) { | 955 | for_each_amdgpu_vm_pt_dfs_safe(adev, vm, cursor, entry) { |
955 | 956 | ||
956 | if (entry->base.bo) { | 957 | if (entry->base.bo) { |
957 | list_del(&entry->base.bo_list); | 958 | entry->base.bo->vm_bo = NULL; |
958 | list_del(&entry->base.vm_status); | 959 | list_del(&entry->base.vm_status); |
959 | amdgpu_bo_unref(&entry->base.bo->shadow); | 960 | amdgpu_bo_unref(&entry->base.bo->shadow); |
960 | amdgpu_bo_unref(&entry->base.bo); | 961 | amdgpu_bo_unref(&entry->base.bo); |
@@ -1162,12 +1163,13 @@ int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job, bool need_ | |||
1162 | struct amdgpu_bo_va *amdgpu_vm_bo_find(struct amdgpu_vm *vm, | 1163 | struct amdgpu_bo_va *amdgpu_vm_bo_find(struct amdgpu_vm *vm, |
1163 | struct amdgpu_bo *bo) | 1164 | struct amdgpu_bo *bo) |
1164 | { | 1165 | { |
1165 | struct amdgpu_bo_va *bo_va; | 1166 | struct amdgpu_vm_bo_base *base; |
1166 | 1167 | ||
1167 | list_for_each_entry(bo_va, &bo->va, base.bo_list) { | 1168 | for (base = bo->vm_bo; base; base = base->next) { |
1168 | if (bo_va->base.vm == vm) { | 1169 | if (base->vm != vm) |
1169 | return bo_va; | 1170 | continue; |
1170 | } | 1171 | |
1172 | return container_of(base, struct amdgpu_bo_va, base); | ||
1171 | } | 1173 | } |
1172 | return NULL; | 1174 | return NULL; |
1173 | } | 1175 | } |
@@ -2728,11 +2730,21 @@ void amdgpu_vm_bo_rmv(struct amdgpu_device *adev, | |||
2728 | struct amdgpu_bo_va_mapping *mapping, *next; | 2730 | struct amdgpu_bo_va_mapping *mapping, *next; |
2729 | struct amdgpu_bo *bo = bo_va->base.bo; | 2731 | struct amdgpu_bo *bo = bo_va->base.bo; |
2730 | struct amdgpu_vm *vm = bo_va->base.vm; | 2732 | struct amdgpu_vm *vm = bo_va->base.vm; |
2733 | struct amdgpu_vm_bo_base **base; | ||
2731 | 2734 | ||
2732 | if (bo && bo->tbo.resv == vm->root.base.bo->tbo.resv) | 2735 | if (bo) { |
2733 | vm->bulk_moveable = false; | 2736 | if (bo->tbo.resv == vm->root.base.bo->tbo.resv) |
2737 | vm->bulk_moveable = false; | ||
2734 | 2738 | ||
2735 | list_del(&bo_va->base.bo_list); | 2739 | for (base = &bo_va->base.bo->vm_bo; *base; |
2740 | base = &(*base)->next) { | ||
2741 | if (*base != &bo_va->base) | ||
2742 | continue; | ||
2743 | |||
2744 | *base = bo_va->base.next; | ||
2745 | break; | ||
2746 | } | ||
2747 | } | ||
2736 | 2748 | ||
2737 | spin_lock(&vm->invalidated_lock); | 2749 | spin_lock(&vm->invalidated_lock); |
2738 | list_del(&bo_va->base.vm_status); | 2750 | list_del(&bo_va->base.vm_status); |
@@ -2774,7 +2786,7 @@ void amdgpu_vm_bo_invalidate(struct amdgpu_device *adev, | |||
2774 | if (bo->parent && bo->parent->shadow == bo) | 2786 | if (bo->parent && bo->parent->shadow == bo) |
2775 | bo = bo->parent; | 2787 | bo = bo->parent; |
2776 | 2788 | ||
2777 | list_for_each_entry(bo_base, &bo->va, bo_list) { | 2789 | for (bo_base = bo->vm_bo; bo_base; bo_base = bo_base->next) { |
2778 | struct amdgpu_vm *vm = bo_base->vm; | 2790 | struct amdgpu_vm *vm = bo_base->vm; |
2779 | 2791 | ||
2780 | if (evicted && bo->tbo.resv == vm->root.base.bo->tbo.resv) { | 2792 | if (evicted && bo->tbo.resv == vm->root.base.bo->tbo.resv) { |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h index 12d21eec4568..2a8898d19c8b 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | |||
@@ -129,7 +129,7 @@ struct amdgpu_vm_bo_base { | |||
129 | struct amdgpu_bo *bo; | 129 | struct amdgpu_bo *bo; |
130 | 130 | ||
131 | /* protected by bo being reserved */ | 131 | /* protected by bo being reserved */ |
132 | struct list_head bo_list; | 132 | struct amdgpu_vm_bo_base *next; |
133 | 133 | ||
134 | /* protected by spinlock */ | 134 | /* protected by spinlock */ |
135 | struct list_head vm_status; | 135 | struct list_head vm_status; |