AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Auld <matthew.auld@intel.com>
To: "Lin.Cao" <lincao12@amd.com>,
	dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org,
	alexander.deucher@amd.com, christian.koenig@amd.com,
	Arunpravin.PaneerSelvam@amd.com
Cc: Horace.Chen@amd.com
Subject: Re: [PATCH] drm/buddy: fix issue that force_merge cannot free all roots
Date: Wed, 14 Aug 2024 15:31:41 +0100	[thread overview]
Message-ID: <0ceebb29-9242-4d8a-afcc-111b5f96c154@intel.com> (raw)
In-Reply-To: <20240813094451.1478481-1-lincao12@amd.com>

On 13/08/2024 10:44, Lin.Cao wrote:
> If buddy manager have more than one roots and each root have sub-block
> need to be free. When drm_buddy_fini called, the first loop of
> force_merge will merge and free all of the sub block of first root,
> which offset is 0x0 and size is biggest(more than have of the mm size).
> In subsequent force_merge rounds, if we use 0 as start and use remaining
> mm size as end, the block of other roots will be skipped in
> __force_merge function. It will cause the other roots can not be freed.
> 
> Solution: use roots' offset as the start could fix this issue.

Were you able to take a look at the test side for this? See previous 
reply: 
https://lore.kernel.org/dri-devel/3fdd9175-832a-4113-8aaa-6039925c5a4d@intel.com/

Patch itself is good, but would be good to understand why the test for 
this is not failing, and try to improve that also.

> 
> Signed-off-by: Lin.Cao <lincao12@amd.com>
> ---
>   drivers/gpu/drm/drm_buddy.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_buddy.c b/drivers/gpu/drm/drm_buddy.c
> index 94f8c34fc293..b3f0dd652088 100644
> --- a/drivers/gpu/drm/drm_buddy.c
> +++ b/drivers/gpu/drm/drm_buddy.c
> @@ -324,7 +324,7 @@ EXPORT_SYMBOL(drm_buddy_init);
>    */
>   void drm_buddy_fini(struct drm_buddy *mm)
>   {
> -	u64 root_size, size;
> +	u64 root_size, size, start;
>   	unsigned int order;
>   	int i;
>   
> @@ -332,7 +332,8 @@ void drm_buddy_fini(struct drm_buddy *mm)
>   
>   	for (i = 0; i < mm->n_roots; ++i) {
>   		order = ilog2(size) - ilog2(mm->chunk_size);
> -		__force_merge(mm, 0, size, order);
> +		start = drm_buddy_block_offset(mm->roots[i]);
> +		__force_merge(mm, start, start + size, order);
>   
>   		WARN_ON(!drm_buddy_block_is_free(mm->roots[i]));
>   		drm_block_free(mm, mm->roots[i]);

  reply	other threads:[~2024-08-14 14:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-13  9:44 [PATCH] drm/buddy: fix issue that force_merge cannot free all roots Lin.Cao
2024-08-14 14:31 ` Matthew Auld [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-08-08  6:38 Lin.Cao
2024-08-09 10:09 ` Matthew Auld

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=0ceebb29-9242-4d8a-afcc-111b5f96c154@intel.com \
    --to=matthew.auld@intel.com \
    --cc=Arunpravin.PaneerSelvam@amd.com \
    --cc=Horace.Chen@amd.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=lincao12@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox