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

Felix Kuehling felix.kuehling at amd.com
Tue Jan 2 18:26:44 UTC 2024


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 at 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 at 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


More information about the dri-devel mailing list