[PATCH 1/3] drm/amdgpu: fix gtt mgr available statistics

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am 19.04.2017 um 05:50 schrieb Chunming Zhou:
> gtt_mgr_alloc is called by many places in local driver, while
> gtt_mgr_new is called by get_node in ttm.

NAK, that can lead to over allocating the address space and we can't 
handle that during suspend/resume.

Regards,
Christian.

>
> Change-Id: Ia5a18a3b531a01ad7d47f40e08f778e7b94c048a
> Signed-off-by: Chunming Zhou <David1.Zhou at amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 11 +++++------
>   1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
> index 69ab2ee..8a950a5 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
> @@ -124,6 +124,8 @@ int amdgpu_gtt_mgr_alloc(struct ttm_mem_type_manager *man,
>   	r = drm_mm_insert_node_in_range_generic(&mgr->mm, node, mem->num_pages,
>   						mem->page_alignment, 0,
>   						fpfn, lpfn, sflags, aflags);
> +	if (!r)
> +		mgr->available -= mem->num_pages;
>   	spin_unlock(&mgr->lock);
>   
>   	if (!r) {
> @@ -160,7 +162,6 @@ static int amdgpu_gtt_mgr_new(struct ttm_mem_type_manager *man,
>   		spin_unlock(&mgr->lock);
>   		return 0;
>   	}
> -	mgr->available -= mem->num_pages;
>   	spin_unlock(&mgr->lock);
>   
>   	node = kzalloc(sizeof(*node), GFP_KERNEL);
> @@ -187,9 +188,6 @@ static int amdgpu_gtt_mgr_new(struct ttm_mem_type_manager *man,
>   
>   	return 0;
>   err_out:
> -	spin_lock(&mgr->lock);
> -	mgr->available += mem->num_pages;
> -	spin_unlock(&mgr->lock);
>   
>   	return r;
>   }
> @@ -214,9 +212,10 @@ static void amdgpu_gtt_mgr_del(struct ttm_mem_type_manager *man,
>   		return;
>   
>   	spin_lock(&mgr->lock);
> -	if (node->start != AMDGPU_BO_INVALID_OFFSET)
> +	if (node->start != AMDGPU_BO_INVALID_OFFSET) {
>   		drm_mm_remove_node(node);
> -	mgr->available += mem->num_pages;
> +		mgr->available += mem->num_pages;
> +	}
>   	spin_unlock(&mgr->lock);
>   
>   	kfree(node);




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux