[PATCH] drm/amdgpu: New method to check block continuous

Christian König ckoenig.leichtzumerken at gmail.com
Mon Nov 28 17:11:32 UTC 2022


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



More information about the amd-gfx mailing list