AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "StDenis, Tom" <Tom.StDenis-5C7GfCeVMHo@public.gmane.org>
To: "Koenig,
	Christian" <Christian.Koenig-5C7GfCeVMHo@public.gmane.org>,
	"amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org"
	<amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org>
Subject: Re: [PATCH] drm/amd/amdgpu: Bail out of BO node creation if not enough VRAM
Date: Tue, 11 Jun 2019 16:51:42 +0000	[thread overview]
Message-ID: <0d91df20-2bad-d629-ba21-a3d454d35e97@amd.com> (raw)
In-Reply-To: <91bb2355-949f-43a3-67e6-fb752de86b5c-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>


On 2019-06-11 9:34 a.m., Christian König wrote:
> Am 10.06.19 um 16:32 schrieb StDenis, Tom:
>> Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
>> ---
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 17 ++++++++++++-----
>>   1 file changed, 12 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c 
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
>> index 8aea2f21b202..70b4a5a97ed2 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
>> @@ -276,7 +276,7 @@ static int amdgpu_vram_mgr_new(struct 
>> ttm_mem_type_manager *man,
>>       struct drm_mm_node *nodes;
>>       enum drm_mm_insert_mode mode;
>>       unsigned long lpfn, num_nodes, pages_per_node, pages_left;
>> -    uint64_t usage = 0, vis_usage = 0;
>> +    uint64_t vis_usage = 0;
>>       unsigned i;
>>       int r;
>>   @@ -284,6 +284,13 @@ 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) {
>> +        atomic64_sub(mem->num_pages << PAGE_SHIFT, &mgr->usage);
>> +        return -ENOSPC;
>> +    }
>
> That's not 100% correct IIRC. See TTM expects a return value of 0, but 
> mem->node to be NULL when allocation fails.


Yup, the node creation returns -ENOSPC which this function then 
translates to 0.  I'll submit a v2 in a minute once I pass a piglit test :-)


Tom

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

      parent reply	other threads:[~2019-06-11 16:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-10 14:32 [PATCH] drm/amd/amdgpu: Bail out of BO node creation if not enough VRAM StDenis, Tom
     [not found] ` <20190610143157.26752-1-tom.stdenis-5C7GfCeVMHo@public.gmane.org>
2019-06-11 13:34   ` Christian König
     [not found]     ` <91bb2355-949f-43a3-67e6-fb752de86b5c-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2019-06-11 16:51       ` StDenis, Tom [this message]

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=0d91df20-2bad-d629-ba21-a3d454d35e97@amd.com \
    --to=tom.stdenis-5c7gfcevmho@public.gmane.org \
    --cc=Christian.Koenig-5C7GfCeVMHo@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    /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