diff mbox series

drm/amdkfd: fixes for HMM mem allocation

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

Commit Message

Dafna Hirschfeld Dec. 31, 2023, 2:37 p.m. UTC
Few fixes to amdkfd and the doc of
devm_request_free_mem_region.

Signed-off-by: Dafna Hirschfeld <dhirschfeld@habana.ai>
---
 drivers/gpu/drm/amd/amdkfd/kfd_migrate.c | 6 +++---
 kernel/resource.c                        | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

Comments

Felix Kuehling Jan. 2, 2024, 6:26 p.m. UTC | #1
On 2023-12-31 09:37, Dafna Hirschfeld wrote:
> Few fixes to amdkfd and the doc of
> devm_request_free_mem_region.
>
> Signed-off-by: Dafna Hirschfeld <dhirschfeld@habana.ai>
> ---
>   drivers/gpu/drm/amd/amdkfd/kfd_migrate.c | 6 +++---
>   kernel/resource.c                        | 2 +-
>   2 files changed, 4 insertions(+), 4 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;

Ooff, thanks for catching that. For the KFD driver changes you can add

Fixes: c83dee9b6394 ("drm/amdkfd: add SPM support for SVM")
Reviewed-by: Felix Kuehling <felix.kuehling@amd.com>


>   		return PTR_ERR(r);
>   	}
>   
> diff --git a/kernel/resource.c b/kernel/resource.c
> index 866ef3663a0b..fe890b874606 100644
> --- a/kernel/resource.c
> +++ b/kernel/resource.c
> @@ -1905,8 +1905,8 @@ get_free_mem_region(struct device *dev, struct resource *base,
>    * devm_request_free_mem_region - find free region for device private memory
>    *
>    * @dev: device struct to bind the resource to
> - * @size: size in bytes of the device memory to add
>    * @base: resource tree to look in
> + * @size: size in bytes of the device memory to add
>    *
>    * This function tries to find an empty range of physical address big enough to
>    * contain the new resource, so that it can later be hotplugged as ZONE_DEVICE
Alex Deucher Jan. 3, 2024, 2:23 p.m. UTC | #2
On Sun, Dec 31, 2023 at 9:39 AM Dafna Hirschfeld <dhirschfeld@habana.ai> wrote:
>
> Few fixes to amdkfd and the doc of
> devm_request_free_mem_region.
>
> Signed-off-by: Dafna Hirschfeld <dhirschfeld@habana.ai>
> ---
>  drivers/gpu/drm/amd/amdkfd/kfd_migrate.c | 6 +++---
>  kernel/resource.c                        | 2 +-
>  2 files changed, 4 insertions(+), 4 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 --git a/kernel/resource.c b/kernel/resource.c
> index 866ef3663a0b..fe890b874606 100644
> --- a/kernel/resource.c
> +++ b/kernel/resource.c
> @@ -1905,8 +1905,8 @@ get_free_mem_region(struct device *dev, struct resource *base,
>   * devm_request_free_mem_region - find free region for device private memory
>   *
>   * @dev: device struct to bind the resource to
> - * @size: size in bytes of the device memory to add
>   * @base: resource tree to look in
> + * @size: size in bytes of the device memory to add

This change should be a separate patch?  It looks unrelated.

Alex

>   *
>   * This function tries to find an empty range of physical address big enough to
>   * contain the new resource, so that it can later be hotplugged as ZONE_DEVICE
> --
> 2.34.1
>
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);
 	}
 
diff --git a/kernel/resource.c b/kernel/resource.c
index 866ef3663a0b..fe890b874606 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -1905,8 +1905,8 @@  get_free_mem_region(struct device *dev, struct resource *base,
  * devm_request_free_mem_region - find free region for device private memory
  *
  * @dev: device struct to bind the resource to
- * @size: size in bytes of the device memory to add
  * @base: resource tree to look in
+ * @size: size in bytes of the device memory to add
  *
  * This function tries to find an empty range of physical address big enough to
  * contain the new resource, so that it can later be hotplugged as ZONE_DEVICE