Skip to content

Commit

Permalink
drm/amdkfd: fixes for HMM mem allocation
Browse files Browse the repository at this point in the history
[ Upstream commit 02eed83 ]

Fix err return value and reset pgmap->type after checking it.

Fixes: c83dee9 ("drm/amdkfd: add SPM support for SVM")
Reviewed-by: Felix Kuehling <[email protected]>
Signed-off-by: Dafna Hirschfeld <[email protected]>
Signed-off-by: Felix Kuehling <[email protected]>
Signed-off-by: Alex Deucher <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
  • Loading branch information
dhirschfeld1 authored and gregkh committed Jan 25, 2024
1 parent 81b86a1 commit 359fadf
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1019,7 +1019,7 @@ int svm_migrate_init(struct amdgpu_device *adev)
} else {
res = devm_request_free_mem_region(adev->dev, &iomem_resource, size);
if (IS_ERR(res))
return -ENOMEM;
return PTR_ERR(res);
pgmap->range.start = res->start;
pgmap->range.end = res->end;
pgmap->type = MEMORY_DEVICE_PRIVATE;
Expand All @@ -1035,10 +1035,10 @@ int svm_migrate_init(struct amdgpu_device *adev)
r = devm_memremap_pages(adev->dev, pgmap);
if (IS_ERR(r)) {
pr_err("failed to register HMM device memory\n");
/* Disable SVM support capability */
pgmap->type = 0;
if (pgmap->type == MEMORY_DEVICE_PRIVATE)
devm_release_mem_region(adev->dev, res->start, resource_size(res));
/* Disable SVM support capability */
pgmap->type = 0;
return PTR_ERR(r);
}

Expand Down

0 comments on commit 359fadf

Please sign in to comment.