[PATCH] drm/amd/amdgpu: Bail out of BO node creation if not enough VRAM (v2)
Michel Dänzer
michel at daenzer.net
Wed Jun 12 07:26:00 UTC 2019
On 2019-06-11 6:54 p.m., StDenis, Tom wrote:
> (v2): Return 0 and set mem->mm_node to NULL.
>
> Signed-off-by: Tom St Denis <tom.stdenis at amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 18 +++++++++++++-----
> 1 file changed, 13 insertions(+), 5 deletions(-)
>
> [...]
>
> @@ -284,6 +284,14 @@ static int amdgpu_vram_mgr_new(struct ttm_mem_type_manager *man,
> if (!lpfn)
> lpfn = man->size;
>
> + /* bail out quickly if there's likely not enough VRAM for this BO */
> + atomic64_add(mem->num_pages << PAGE_SHIFT, &mgr->usage);
> + if (atomic64_read(&mgr->usage) > adev->gmc.mc_vram_size) {
Should probably use atomic64_add_return instead of atomic64_add +
atomic64_read.
Also, AFAICT this doesn't allow any VRAM overcommit, which seems a bit
conservative?
--
Earthling Michel Dänzer | https://www.amd.com
Libre software enthusiast | Mesa and X developer
More information about the amd-gfx
mailing list