Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 1f327df

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 <felix.kuehling@amd.com> Reviewed-by: Lang Yu <Lang.Yu@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent dd2b75f commit 1f327df

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;
@@ -890,7 +890,7 @@ static int kfd_mem_attach(struct amdgpu_device *adev, struct kgd_mem *mem,
890890
* if peer device has large BAR. In contrast, access over xGMI is
891891
* allowed for both small and large BAR configurations of peer device
892892
*/
893-
if ((adev != bo_adev && !(adev->gmc.is_app_apu || adev->flags & AMD_IS_APU)) &&
893+
if ((adev != bo_adev && !(adev->flags & AMD_IS_APU)) &&
894894
((mem->domain == AMDGPU_GEM_DOMAIN_VRAM) ||
895895
(mem->alloc_flags & KFD_IOC_ALLOC_MEM_FLAGS_DOORBELL) ||
896896
(mem->alloc_flags & KFD_IOC_ALLOC_MEM_FLAGS_MMIO_REMAP))) {
@@ -1658,7 +1658,7 @@ size_t amdgpu_amdkfd_get_available_memory(struct amdgpu_device *adev,
16581658
- atomic64_read(&adev->vram_pin_size)
16591659
- reserved_for_pt;
16601660

1661-
if (adev->gmc.is_app_apu || adev->flags & AMD_IS_APU) {
1661+
if (adev->flags & AMD_IS_APU) {
16621662
system_mem_available = no_system_mem_limit ?
16631663
kfd_mem_limit.max_system_mem_limit :
16641664
kfd_mem_limit.max_system_mem_limit -
@@ -1706,7 +1706,7 @@ int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu(
17061706
if (flags & KFD_IOC_ALLOC_MEM_FLAGS_VRAM) {
17071707
domain = alloc_domain = AMDGPU_GEM_DOMAIN_VRAM;
17081708

1709-
if (adev->gmc.is_app_apu || adev->flags & AMD_IS_APU) {
1709+
if (adev->flags & AMD_IS_APU) {
17101710
domain = AMDGPU_GEM_DOMAIN_GTT;
17111711
alloc_domain = AMDGPU_GEM_DOMAIN_GTT;
17121712
alloc_flags = 0;
@@ -1953,7 +1953,7 @@ int amdgpu_amdkfd_gpuvm_free_memory_of_gpu(
19531953
if (size) {
19541954
if (!is_imported &&
19551955
(mem->bo->preferred_domains == AMDGPU_GEM_DOMAIN_VRAM ||
1956-
((adev->gmc.is_app_apu || adev->flags & AMD_IS_APU) &&
1956+
((adev->flags & AMD_IS_APU) &&
19571957
mem->bo->preferred_domains == AMDGPU_GEM_DOMAIN_GTT)))
19581958
*size = bo_size;
19591959
else
@@ -2376,7 +2376,7 @@ static int import_obj_create(struct amdgpu_device *adev,
23762376
(*mem)->bo = bo;
23772377
(*mem)->va = va;
23782378
(*mem)->domain = (bo->preferred_domains & AMDGPU_GEM_DOMAIN_VRAM) &&
2379-
!(adev->gmc.is_app_apu || adev->flags & AMD_IS_APU) ?
2379+
!(adev->flags & AMD_IS_APU) ?
23802380
AMDGPU_GEM_DOMAIN_VRAM : AMDGPU_GEM_DOMAIN_GTT;
23812381

23822382
(*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
@@ -2619,8 +2619,7 @@ svm_range_best_restore_location(struct svm_range *prange,
26192619
return -1;
26202620
}
26212621

2622-
if (node->adev->gmc.is_app_apu ||
2623-
node->adev->flags & AMD_IS_APU)
2622+
if (node->adev->flags & AMD_IS_APU)
26242623
return 0;
26252624

26262625
if (prange->preferred_loc == gpuid ||
@@ -3338,8 +3337,7 @@ svm_range_best_prefetch_location(struct svm_range *prange)
33383337
goto out;
33393338
}
33403339

3341-
if (bo_node->adev->gmc.is_app_apu ||
3342-
bo_node->adev->flags & AMD_IS_APU) {
3340+
if (bo_node->adev->flags & AMD_IS_APU) {
33433341
best_loc = 0;
33443342
goto out;
33453343
}

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)