Skip to content

Commit 7978c4d

Browse files
committed
drm/amdkfd: simplify APU VRAM handling
With commit 89773b8 ("drm/amdkfd: Let VRAM allocations go to GTT domain on small APUs") big and small APU "VRAM" handling in KFD was unified. Since AMD_IS_APU is set for both big and small APUs, we can simplify the checks in the code. v2: clean up a few more places (Lang) Acked-by: Felix Kuehling <[email protected]> Reviewed-by: Lang Yu <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent d4ab6c4 commit 7978c4d

File tree

4 files changed

+11
-14
lines changed

4 files changed

+11
-14
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ int amdgpu_amdkfd_reserve_mem_limit(struct amdgpu_device *adev,
196196
return -EINVAL;
197197

198198
vram_size = KFD_XCP_MEMORY_SIZE(adev, xcp_id);
199-
if (adev->gmc.is_app_apu || adev->flags & AMD_IS_APU) {
199+
if (adev->flags & AMD_IS_APU) {
200200
system_mem_needed = size;
201201
ttm_mem_needed = size;
202202
}
@@ -233,7 +233,7 @@ int amdgpu_amdkfd_reserve_mem_limit(struct amdgpu_device *adev,
233233
if (adev && xcp_id >= 0) {
234234
adev->kfd.vram_used[xcp_id] += vram_needed;
235235
adev->kfd.vram_used_aligned[xcp_id] +=
236-
(adev->gmc.is_app_apu || adev->flags & AMD_IS_APU) ?
236+
(adev->flags & AMD_IS_APU) ?
237237
vram_needed :
238238
ALIGN(vram_needed, VRAM_AVAILABLITY_ALIGN);
239239
}
@@ -261,7 +261,7 @@ void amdgpu_amdkfd_unreserve_mem_limit(struct amdgpu_device *adev,
261261

262262
if (adev) {
263263
adev->kfd.vram_used[xcp_id] -= size;
264-
if (adev->gmc.is_app_apu || adev->flags & AMD_IS_APU) {
264+
if (adev->flags & AMD_IS_APU) {
265265
adev->kfd.vram_used_aligned[xcp_id] -= size;
266266
kfd_mem_limit.system_mem_used -= size;
267267
kfd_mem_limit.ttm_mem_used -= size;
@@ -894,7 +894,7 @@ static int kfd_mem_attach(struct amdgpu_device *adev, struct kgd_mem *mem,
894894
* if peer device has large BAR. In contrast, access over xGMI is
895895
* allowed for both small and large BAR configurations of peer device
896896
*/
897-
if ((adev != bo_adev && !(adev->gmc.is_app_apu || adev->flags & AMD_IS_APU)) &&
897+
if ((adev != bo_adev && !(adev->flags & AMD_IS_APU)) &&
898898
((mem->domain == AMDGPU_GEM_DOMAIN_VRAM) ||
899899
(mem->alloc_flags & KFD_IOC_ALLOC_MEM_FLAGS_DOORBELL) ||
900900
(mem->alloc_flags & KFD_IOC_ALLOC_MEM_FLAGS_MMIO_REMAP))) {
@@ -1682,7 +1682,7 @@ size_t amdgpu_amdkfd_get_available_memory(struct amdgpu_device *adev,
16821682
- atomic64_read(&adev->vram_pin_size)
16831683
- reserved_for_pt;
16841684

1685-
if (adev->gmc.is_app_apu || adev->flags & AMD_IS_APU) {
1685+
if (adev->flags & AMD_IS_APU) {
16861686
system_mem_available = no_system_mem_limit ?
16871687
kfd_mem_limit.max_system_mem_limit :
16881688
kfd_mem_limit.max_system_mem_limit -
@@ -1730,7 +1730,7 @@ int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu(
17301730
if (flags & KFD_IOC_ALLOC_MEM_FLAGS_VRAM) {
17311731
domain = alloc_domain = AMDGPU_GEM_DOMAIN_VRAM;
17321732

1733-
if (adev->gmc.is_app_apu || adev->flags & AMD_IS_APU) {
1733+
if (adev->flags & AMD_IS_APU) {
17341734
domain = AMDGPU_GEM_DOMAIN_GTT;
17351735
alloc_domain = AMDGPU_GEM_DOMAIN_GTT;
17361736
alloc_flags = 0;
@@ -1981,7 +1981,7 @@ int amdgpu_amdkfd_gpuvm_free_memory_of_gpu(
19811981
if (size) {
19821982
if (!is_imported &&
19831983
(mem->bo->preferred_domains == AMDGPU_GEM_DOMAIN_VRAM ||
1984-
((adev->gmc.is_app_apu || adev->flags & AMD_IS_APU) &&
1984+
((adev->flags & AMD_IS_APU) &&
19851985
mem->bo->preferred_domains == AMDGPU_GEM_DOMAIN_GTT)))
19861986
*size = bo_size;
19871987
else
@@ -2404,7 +2404,7 @@ static int import_obj_create(struct amdgpu_device *adev,
24042404
(*mem)->bo = bo;
24052405
(*mem)->va = va;
24062406
(*mem)->domain = (bo->preferred_domains & AMDGPU_GEM_DOMAIN_VRAM) &&
2407-
!(adev->gmc.is_app_apu || adev->flags & AMD_IS_APU) ?
2407+
!(adev->flags & AMD_IS_APU) ?
24082408
AMDGPU_GEM_DOMAIN_VRAM : AMDGPU_GEM_DOMAIN_GTT;
24092409

24102410
(*mem)->mapped_to_gpu_memory = 0;

drivers/gpu/drm/amd/amdkfd/kfd_migrate.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1023,7 +1023,7 @@ int kgd2kfd_init_zone_device(struct amdgpu_device *adev)
10231023
if (amdgpu_ip_version(adev, GC_HWIP, 0) < IP_VERSION(9, 0, 1))
10241024
return -EINVAL;
10251025

1026-
if (adev->gmc.is_app_apu || adev->flags & AMD_IS_APU)
1026+
if (adev->flags & AMD_IS_APU)
10271027
return 0;
10281028

10291029
pgmap = &kfddev->pgmap;

drivers/gpu/drm/amd/amdkfd/kfd_svm.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2634,8 +2634,7 @@ svm_range_best_restore_location(struct svm_range *prange,
26342634
return -1;
26352635
}
26362636

2637-
if (node->adev->gmc.is_app_apu ||
2638-
node->adev->flags & AMD_IS_APU)
2637+
if (node->adev->flags & AMD_IS_APU)
26392638
return 0;
26402639

26412640
if (prange->preferred_loc == gpuid ||
@@ -3353,8 +3352,7 @@ svm_range_best_prefetch_location(struct svm_range *prange)
33533352
goto out;
33543353
}
33553354

3356-
if (bo_node->adev->gmc.is_app_apu ||
3357-
bo_node->adev->flags & AMD_IS_APU) {
3355+
if (bo_node->adev->flags & AMD_IS_APU) {
33583356
best_loc = 0;
33593357
goto out;
33603358
}

drivers/gpu/drm/amd/amdkfd/kfd_svm.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ void svm_range_list_lock_and_flush_work(struct svm_range_list *svms, struct mm_s
201201
* is initialized to not 0 when page migration register device memory.
202202
*/
203203
#define KFD_IS_SVM_API_SUPPORTED(adev) ((adev)->kfd.pgmap.type != 0 ||\
204-
(adev)->gmc.is_app_apu ||\
205204
((adev)->flags & AMD_IS_APU))
206205

207206
void svm_range_bo_unref_async(struct svm_range_bo *svm_bo);

0 commit comments

Comments
 (0)