All of lore.kernel.org
 help / color / mirror / Atom feed
From: Felix Kuehling <felix.kuehling@amd.com>
To: Philip Yang <Philip.Yang@amd.com>, amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH] drm/amdkfd: fix svm_migrate_fini warning
Date: Mon, 20 Sep 2021 22:20:25 -0400	[thread overview]
Message-ID: <64c57694-ac14-5fa8-2424-b325b6e1229c@amd.com> (raw)
In-Reply-To: <20210920215532.26132-1-Philip.Yang@amd.com>


Am 2021-09-20 um 5:55 p.m. schrieb Philip Yang:
> Don't use devm_request_free_mem_region to alloc VRAM region for pgmap,
devm_... refers to a device manager that automatically releases
device-specific resources when a driver disconnects from a device. So
maybe that just means, our devm_memunmap_pages and
devm_release_mem_region calls in svm_migrate_fini are redundant, and the
best solution is to remove those calls.

See Documentation/driver-api/driver-model/devres.rst

Regards,
  Felix


> because driver__detach releases all device resource region, then calls
> amdgpu_device_fini_sw, which calls devm_memunmap_pages generating below
> warning trace:
>
> WARNING: CPU: 1 PID: 3646 at drivers/base/devres.c:795
> devm_release_action+0x51/0x60
> Call Trace:
>     ? memunmap_pages+0x360/0x360
>     svm_migrate_fini+0x2d/0x60 [amdgpu]
>     kgd2kfd_device_exit+0x23/0xa0 [amdgpu]
>     amdgpu_amdkfd_device_fini_sw+0x1d/0x30 [amdgpu]
>     amdgpu_device_fini_sw+0x45/0x290 [amdgpu]
>     amdgpu_driver_release_kms+0x12/0x30 [amdgpu]
>     drm_dev_release+0x20/0x40 [drm]
>     release_nodes+0x196/0x1e0
>     device_release_driver_internal+0x104/0x1d0
>     driver_detach+0x47/0x90
>     bus_remove_driver+0x7a/0xd0
>     pci_unregister_driver+0x3d/0x90
>     amdgpu_exit+0x11/0x20 [amdgpu]
> Trying to free nonexistent resource <000007fc00000000-000007fdffffffff>
>
> Signed-off-by: Philip Yang <Philip.Yang@amd.com>
> ---
>  drivers/gpu/drm/amd/amdkfd/kfd_migrate.c | 13 ++++++-------
>  1 file changed, 6 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
> index 21f745e0b86c..aa96767920a9 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
> @@ -880,7 +880,7 @@ int svm_migrate_init(struct amdgpu_device *adev)
>  	 * should remove reserved size
>  	 */
>  	size = ALIGN(adev->gmc.real_vram_size, 2ULL << 20);
> -	res = devm_request_free_mem_region(adev->dev, &iomem_resource, size);
> +	res = request_free_mem_region(&iomem_resource, size, "amdgpu_vram");
>  	if (IS_ERR(res))
>  		return -ENOMEM;
>  
> @@ -891,14 +891,13 @@ int svm_migrate_init(struct amdgpu_device *adev)
>  	pgmap->ops = &svm_migrate_pgmap_ops;
>  	pgmap->owner = SVM_ADEV_PGMAP_OWNER(adev);
>  	pgmap->flags = MIGRATE_VMA_SELECT_DEVICE_PRIVATE;
> -	r = devm_memremap_pages(adev->dev, pgmap);
> +	r = memremap_pages(pgmap, dev_to_node(adev->dev));
>  	if (IS_ERR(r)) {
>  		pr_err("failed to register HMM device memory\n");
>  
>  		/* Disable SVM support capability */
>  		pgmap->type = 0;
> -		devm_release_mem_region(adev->dev, res->start,
> -					res->end - res->start + 1);
> +		release_mem_region(res->start, res->end - res->start + 1);
>  		return PTR_ERR(r);
>  	}
>  
> @@ -919,7 +918,7 @@ void svm_migrate_fini(struct amdgpu_device *adev)
>  	if (!KFD_IS_SVM_API_SUPPORTED(adev->kfd.dev))
>  		return;
>  
> -	devm_memunmap_pages(adev->dev, pgmap);
> -	devm_release_mem_region(adev->dev, pgmap->range.start,
> -				pgmap->range.end - pgmap->range.start + 1);
> +	memunmap_pages(pgmap);
> +	release_mem_region(pgmap->range.start,
> +			   pgmap->range.end - pgmap->range.start + 1);
>  }

  reply	other threads:[~2021-09-21  2:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-20 21:55 [PATCH] drm/amdkfd: fix svm_migrate_fini warning Philip Yang
2021-09-21  2:20 ` Felix Kuehling [this message]
2021-09-21 14:06   ` Andrey Grodzovsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=64c57694-ac14-5fa8-2424-b325b6e1229c@amd.com \
    --to=felix.kuehling@amd.com \
    --cc=Philip.Yang@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.