Commit c0f76fc8 authored by Philip Yang's avatar Philip Yang Committed by Alex Deucher

drm/amdkfd: fix double free device pgmap resource

Use devm_memunmap_pages instead of memunmap_pages to release pgmap
and remove pgmap from device action, to avoid double free pgmap when
unloading driver module.

Release device memory region if failed to create device memory pages
structure.
Signed-off-by: default avatarPhilip Yang <Philip.Yang@amd.com>
Reviewed-by: default avatarFelix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent dd57e65f
...@@ -912,6 +912,8 @@ int svm_migrate_init(struct amdgpu_device *adev) ...@@ -912,6 +912,8 @@ int svm_migrate_init(struct amdgpu_device *adev)
r = devm_memremap_pages(adev->dev, pgmap); r = devm_memremap_pages(adev->dev, pgmap);
if (IS_ERR(r)) { if (IS_ERR(r)) {
pr_err("failed to register HMM device memory\n"); pr_err("failed to register HMM device memory\n");
devm_release_mem_region(adev->dev, res->start,
res->end - res->start + 1);
return PTR_ERR(r); return PTR_ERR(r);
} }
...@@ -927,5 +929,9 @@ int svm_migrate_init(struct amdgpu_device *adev) ...@@ -927,5 +929,9 @@ int svm_migrate_init(struct amdgpu_device *adev)
void svm_migrate_fini(struct amdgpu_device *adev) void svm_migrate_fini(struct amdgpu_device *adev)
{ {
memunmap_pages(&adev->kfd.dev->pgmap); struct dev_pagemap *pgmap = &adev->kfd.dev->pgmap;
devm_memunmap_pages(adev->dev, pgmap);
devm_release_mem_region(adev->dev, pgmap->range.start,
pgmap->range.end - pgmap->range.start + 1);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment