Skip to content

Commit 1fc160c

Browse files
alexsierragalexdeucher
authored andcommitted
drm/amdgpu: get owner ref in validate and map
Get the proper owner reference for amdgpu_hmm_range_get_pages function. This is useful for partial migrations. To avoid migrating back to system memory, VRAM pages, that are accessible by all devices in the same memory domain. Ex. multiple devices in the same hive. Signed-off-by: Alex Sierra <alex.sierra@amd.com> Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent a010d98 commit 1fc160c

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

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

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1337,6 +1337,17 @@ static void svm_range_unreserve_bos(struct svm_validate_context *ctx)
13371337
ttm_eu_backoff_reservation(&ctx->ticket, &ctx->validate_list);
13381338
}
13391339

1340+
static void *kfd_svm_page_owner(struct kfd_process *p, int32_t gpuidx)
1341+
{
1342+
struct kfd_process_device *pdd;
1343+
struct amdgpu_device *adev;
1344+
1345+
pdd = kfd_process_device_from_gpuidx(p, gpuidx);
1346+
adev = (struct amdgpu_device *)pdd->dev->kgd;
1347+
1348+
return SVM_ADEV_PGMAP_OWNER(adev);
1349+
}
1350+
13401351
/*
13411352
* Validation+GPU mapping with concurrent invalidation (MMU notifiers)
13421353
*
@@ -1367,6 +1378,9 @@ static int svm_range_validate_and_map(struct mm_struct *mm,
13671378
{
13681379
struct svm_validate_context ctx;
13691380
struct hmm_range *hmm_range;
1381+
struct kfd_process *p;
1382+
void *owner;
1383+
int32_t idx;
13701384
int r = 0;
13711385

13721386
ctx.process = container_of(prange->svms, struct kfd_process, svms);
@@ -1413,10 +1427,19 @@ static int svm_range_validate_and_map(struct mm_struct *mm,
14131427
svm_range_reserve_bos(&ctx);
14141428

14151429
if (!prange->actual_loc) {
1430+
p = container_of(prange->svms, struct kfd_process, svms);
1431+
owner = kfd_svm_page_owner(p, find_first_bit(ctx.bitmap,
1432+
MAX_GPU_INSTANCE));
1433+
for_each_set_bit(idx, ctx.bitmap, MAX_GPU_INSTANCE) {
1434+
if (kfd_svm_page_owner(p, idx) != owner) {
1435+
owner = NULL;
1436+
break;
1437+
}
1438+
}
14161439
r = amdgpu_hmm_range_get_pages(&prange->notifier, mm, NULL,
14171440
prange->start << PAGE_SHIFT,
14181441
prange->npages, &hmm_range,
1419-
false, true, NULL);
1442+
false, true, owner);
14201443
if (r) {
14211444
pr_debug("failed %d to get svm range pages\n", r);
14221445
goto unreserve_out;

0 commit comments

Comments
 (0)