diff mbox series

[v2] drm/amdkfd: fixes for HMM mem allocation

Message ID 20240107130700.1165029-1-dhirschfeld@habana.ai (mailing list archive)
State New, archived
Headers show
Series [v2] drm/amdkfd: fixes for HMM mem allocation | expand

Commit Message

Dafna Hirschfeld Jan. 7, 2024, 1:07 p.m. UTC
Fix err return value and reset pgmap->type after checking it.

Fixes: c83dee9b6394 ("drm/amdkfd: add SPM support for SVM")
Reviewed-by: Felix Kuehling <felix.kuehling@amd.com>
Signed-off-by: Dafna Hirschfeld <dhirschfeld@habana.ai>
---
v2: remove unrelated DOC fix and add 'Fixes' tag.

 drivers/gpu/drm/amd/amdkfd/kfd_migrate.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Felix Kuehling Jan. 8, 2024, 5:51 p.m. UTC | #1
On 2024-01-07 08:07, Dafna Hirschfeld wrote:
> Fix err return value and reset pgmap->type after checking it.
>
> Fixes: c83dee9b6394 ("drm/amdkfd: add SPM support for SVM")
> Reviewed-by: Felix Kuehling <felix.kuehling@amd.com>
> Signed-off-by: Dafna Hirschfeld <dhirschfeld@habana.ai>
> ---
> v2: remove unrelated DOC fix and add 'Fixes' tag.

Thank you. I'm going to apply this patch to amd-staging-drm-next.

Regards,
   Felix


>
>   drivers/gpu/drm/amd/amdkfd/kfd_migrate.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
> index 6c25dab051d5..b8680e0753ca 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
> @@ -1021,7 +1021,7 @@ int kgd2kfd_init_zone_device(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;
> @@ -1037,10 +1037,10 @@ int kgd2kfd_init_zone_device(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);
>   	}
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
index 6c25dab051d5..b8680e0753ca 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
@@ -1021,7 +1021,7 @@  int kgd2kfd_init_zone_device(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;
@@ -1037,10 +1037,10 @@  int kgd2kfd_init_zone_device(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);
 	}