All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Chen, Xiaogang" <xiaogang.chen@amd.com>
To: Philip Yang <Philip.Yang@amd.com>, amd-gfx@lists.freedesktop.org
Cc: Felix.Kuehling@amd.com, christian.koenig@amd.com
Subject: Re: [PATCH 3/3] drm/amdkfd: destroy_pdds release pdd->drm_file at end
Date: Thu, 15 May 2025 09:29:31 -0500	[thread overview]
Message-ID: <4a02537f-1ea3-471f-ae10-c85471a65402@amd.com> (raw)
In-Reply-To: <20250514171004.4259-4-Philip.Yang@amd.com>

[-- Attachment #1: Type: text/plain, Size: 1570 bytes --]

Does this patch fix a bug or just make code look more reasonable? 
kfd_process_destroy_pdds releases pdd related buffers, not related to 
operations on vm. So vm tear down dose not affect this function.

Regards

Xiaogang

On 5/14/2025 12:10 PM, Philip Yang wrote:
> Release pdd->drm_file may free the vm if this is the last reference,
> move it to the last step after memory is unmapped.
>
> Signed-off-by: Philip Yang<Philip.Yang@amd.com>
> ---
>   drivers/gpu/drm/amd/amdkfd/kfd_process.c | 10 +++++++---
>   1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
> index e868cc8da46f..b009c852180d 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
> @@ -1063,9 +1063,6 @@ static void kfd_process_destroy_pdds(struct kfd_process *p)
>   		kfd_process_device_destroy_cwsr_dgpu(pdd);
>   		kfd_process_device_destroy_ib_mem(pdd);
>   
> -		if (pdd->drm_file)
> -			fput(pdd->drm_file);
> -
>   		if (pdd->qpd.cwsr_kaddr && !pdd->qpd.cwsr_base)
>   			free_pages((unsigned long)pdd->qpd.cwsr_kaddr,
>   				get_order(KFD_CWSR_TBA_TMA_SIZE));
> @@ -1088,6 +1085,13 @@ static void kfd_process_destroy_pdds(struct kfd_process *p)
>   			pdd->runtime_inuse = false;
>   		}
>   
> +		/*
> +		 * This may release the vm if application already close the drm node,
> +		 * do it as last step after memory unmapped.
> +		 */
> +		if (pdd->drm_file)
> +			fput(pdd->drm_file);
> +
>   		kfree(pdd);
>   		p->pdds[i] = NULL;
>   	}

[-- Attachment #2: Type: text/html, Size: 2110 bytes --]

  reply	other threads:[~2025-05-15 14:29 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-14 17:10 [PATCH 0/3] Remove process exit error message Philip Yang
2025-05-14 17:10 ` [PATCH 1/3] drm/amdgpu: seq64 memory unmap uses uninterruptible lock Philip Yang
2025-05-21  7:06   ` Christian König
2025-05-14 17:10 ` [PATCH 2/3] drm/amdgpu: amdgpu_vm_fini hold vm lock to access vm->va Philip Yang
2025-05-15 12:18   ` Christian König
2025-05-15 14:40   ` Chen, Xiaogang
2025-05-15 19:47     ` Philip Yang
2025-05-14 17:10 ` [PATCH 3/3] drm/amdkfd: destroy_pdds release pdd->drm_file at end Philip Yang
2025-05-15 14:29   ` Chen, Xiaogang [this message]
2025-05-15 20:45     ` Philip Yang
2025-05-15 21:31       ` Chen, Xiaogang
2025-05-16 13:07         ` Philip Yang
2025-05-16 15:19           ` Chen, Xiaogang

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=4a02537f-1ea3-471f-ae10-c85471a65402@amd.com \
    --to=xiaogang.chen@amd.com \
    --cc=Felix.Kuehling@amd.com \
    --cc=Philip.Yang@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=christian.koenig@amd.com \
    /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.