AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <ckoenig.leichtzumerken@gmail.com>
To: xinhui pan <xinhui.pan@amd.com>, amd-gfx@lists.freedesktop.org
Cc: alexander.deucher@amd.com
Subject: Re: [PATCH] drm/amdgpu: New method to check block continuous
Date: Mon, 28 Nov 2022 18:11:32 +0100	[thread overview]
Message-ID: <1908a95c-82ff-f68d-9463-a5d92db43191@gmail.com> (raw)
In-Reply-To: <20221127053926.119084-1-xinhui.pan@amd.com>

Am 27.11.22 um 06:39 schrieb xinhui pan:
> Blocks are not guarnteed to be in ascending order.

Well certainly a NAK. Blocks are required to be in ascending order to be 
contiguous.

Regards,
Christian.

>
> Signed-off-by: xinhui pan <xinhui.pan@amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 21 ++++++++------------
>   1 file changed, 8 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> index 27159f1d112e..17175d284869 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> @@ -59,22 +59,17 @@ amdgpu_vram_mgr_first_block(struct list_head *list)
>   static inline bool amdgpu_is_vram_mgr_blocks_contiguous(struct list_head *head)
>   {
>   	struct drm_buddy_block *block;
> -	u64 start, size;
> +	u64 start = LONG_MAX, end = 0, size = 0;
>   
> -	block = amdgpu_vram_mgr_first_block(head);
> -	if (!block)
> -		return false;
> +	list_for_each_entry(block, head, link) {
> +		u64 bstart = amdgpu_vram_mgr_block_start(block);
> +		u64 bsize = amdgpu_vram_mgr_block_size(block);
>   
> -	while (head != block->link.next) {
> -		start = amdgpu_vram_mgr_block_start(block);
> -		size = amdgpu_vram_mgr_block_size(block);
> -
> -		block = list_entry(block->link.next, struct drm_buddy_block, link);
> -		if (start + size != amdgpu_vram_mgr_block_start(block))
> -			return false;
> +		start = min(bstart, start);
> +		end = max(bstart + bsize, end);
> +		size += bsize;
>   	}
> -
> -	return true;
> +	return end == start + size;
>   }
>   
>   


  reply	other threads:[~2022-11-28 17:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-27  5:39 [PATCH] drm/amdgpu: New method to check block continuous xinhui pan
2022-11-28 17:11 ` Christian König [this message]
2022-11-29  2:11   ` 回复: " Pan, Xinhui
2022-11-29  8:55     ` Christian König

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=1908a95c-82ff-f68d-9463-a5d92db43191@gmail.com \
    --to=ckoenig.leichtzumerken@gmail.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=xinhui.pan@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