[PATCH v2 5/5] drm/amdgpu: Try evicting from CPU visible to invisible VRAM first

Christian König deathsimple at vodafone.de
Thu Jul 6 11:53:50 UTC 2017


Am 06.07.2017 um 12:51 schrieb Michel Dänzer:
> From: Michel Dänzer <michel.daenzer at amd.com>
>
> This gives BOs which haven't been accessed by the CPU since they were
> moved to visible VRAM another chance to stay in VRAM when another BO
> needs to go to visible VRAM.
>
> This should allow BOs to stay in VRAM longer in some cases.
>
> v2:
> * Only do this for BOs which don't have the
>    AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED flag set.
>
> Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>

Reviewed-by: Christian König <christian.koenig at amd.com>

> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 28 ++++++++++++++++++++++++++++
>   1 file changed, 28 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> index 58576375b91c..2a9906dd7637 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> @@ -207,7 +207,35 @@ static void amdgpu_evict_flags(struct ttm_buffer_object *bo,
>   		    adev->mman.buffer_funcs_ring &&
>   		    adev->mman.buffer_funcs_ring->ready == false) {
>   			amdgpu_ttm_placement_from_domain(abo, AMDGPU_GEM_DOMAIN_CPU);
> +		} else if (adev->mc.visible_vram_size < adev->mc.real_vram_size &&
> +			   !(abo->flags & AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED)) {
> +			unsigned fpfn = adev->mc.visible_vram_size >> PAGE_SHIFT;
> +			struct drm_mm_node *node = bo->mem.mm_node;
> +			unsigned long pages_left;
> +
> +			for (pages_left = bo->mem.num_pages;
> +			     pages_left;
> +			     pages_left -= node->size, node++) {
> +				if (node->start < fpfn)
> +					break;
> +			}
> +
> +			if (!pages_left)
> +				goto gtt;
> +
> +			/* Try evicting to the CPU inaccessible part of VRAM
> +			 * first, but only set GTT as busy placement, so this
> +			 * BO will be evicted to GTT rather than causing other
> +			 * BOs to be evicted from VRAM
> +			 */
> +			amdgpu_ttm_placement_from_domain(abo, AMDGPU_GEM_DOMAIN_VRAM |
> +							 AMDGPU_GEM_DOMAIN_GTT);
> +			abo->placements[0].fpfn = fpfn;
> +			abo->placements[0].lpfn = 0;
> +			abo->placement.busy_placement = &abo->placements[1];
> +			abo->placement.num_busy_placement = 1;
>   		} else {
> +gtt:
>   			amdgpu_ttm_placement_from_domain(abo, AMDGPU_GEM_DOMAIN_GTT);
>   			for (i = 0; i < abo->placement.num_placement; ++i) {
>   				if (!(abo->placements[i].flags &




More information about the amd-gfx mailing list