AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <ckoenig.leichtzumerken-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: "Zhou,
	David(ChunMing)" <David1.Zhou-5C7GfCeVMHo@public.gmane.org>,
	"amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org"
	<amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org>
Subject: Re: [PATCH 2/3] drm/amdgpu: reserve at least 4MB of VRAM for page tables
Date: Tue, 3 Sep 2019 10:47:11 +0200	[thread overview]
Message-ID: <eb92584c-6409-8c10-bb9f-a44f62168588@gmail.com> (raw)
In-Reply-To: <MN2PR12MB29104DDA4EBB320F67988981B4B90-rweVpJHSKTr1t3MqfsnKMAdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>

Oh, good point! That is probably good idea.

Christian.

Am 03.09.19 um 08:52 schrieb Zhou, David(ChunMing):
> Do you need update the vram size reported to UMD ?
>
> -David
>
> -----Original Message-----
> From: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> On Behalf Of Christian König
> Sent: Monday, September 2, 2019 6:52 PM
> To: amd-gfx@lists.freedesktop.org
> Subject: [PATCH 2/3] drm/amdgpu: reserve at least 4MB of VRAM for page tables
>
> This hopefully helps reduce the contention for page tables.
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h       | 3 +++
>   drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 9 +++++++--
>   2 files changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
> index 2eda3a8c330d..3352a87b822e 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
> @@ -99,6 +99,9 @@ struct amdgpu_bo_list_entry;
>   #define AMDGPU_VM_FAULT_STOP_FIRST	1
>   #define AMDGPU_VM_FAULT_STOP_ALWAYS	2
>   
> +/* Reserve 4MB VRAM for page tables */
> +#define AMDGPU_VM_RESERVED_VRAM		(4ULL << 20)
> +
>   /* max number of VMHUB */
>   #define AMDGPU_MAX_VMHUBS			3
>   #define AMDGPU_GFXHUB_0				0
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> index 1150e34bc28f..59440f71d304 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> @@ -24,6 +24,7 @@
>   
>   #include <drm/drmP.h>
>   #include "amdgpu.h"
> +#include "amdgpu_vm.h"
>   
>   struct amdgpu_vram_mgr {
>   	struct drm_mm mm;
> @@ -276,7 +277,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 vis_usage = 0, mem_bytes;
> +	uint64_t vis_usage = 0, mem_bytes, max_bytes;
>   	unsigned i;
>   	int r;
>   
> @@ -284,9 +285,13 @@ static int amdgpu_vram_mgr_new(struct ttm_mem_type_manager *man,
>   	if (!lpfn)
>   		lpfn = man->size;
>   
> +	max_bytes = adev->gmc.mc_vram_size;
> +	if (tbo->type != ttm_bo_type_kernel)
> +		max_bytes -= AMDGPU_VM_RESERVED_VRAM;
> +
>   	/* bail out quickly if there's likely not enough VRAM for this BO */
>   	mem_bytes = (u64)mem->num_pages << PAGE_SHIFT;
> -	if (atomic64_add_return(mem_bytes, &mgr->usage) > adev->gmc.mc_vram_size) {
> +	if (atomic64_add_return(mem_bytes, &mgr->usage) > max_bytes) {
>   		atomic64_sub(mem_bytes, &mgr->usage);
>   		mem->mm_node = NULL;
>   		return 0;

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

  parent reply	other threads:[~2019-09-03  8:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-02 10:52 [PATCH 1/3] drm/amdgpu: use moving fence instead of exclusive for VM updates Christian König
     [not found] ` <20190902105219.2813-1-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2019-09-02 10:52   ` [PATCH 2/3] drm/amdgpu: reserve at least 4MB of VRAM for page tables Christian König
     [not found]     ` <20190902105219.2813-2-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2019-09-03  6:52       ` Zhou, David(ChunMing)
     [not found]         ` <MN2PR12MB29104DDA4EBB320F67988981B4B90-rweVpJHSKTr1t3MqfsnKMAdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2019-09-03  8:47           ` Christian König [this message]
2019-09-02 10:52   ` [PATCH 3/3] drm/amdgpu: remove amdgpu_cs_try_evict Christian König
     [not found]     ` <20190902105219.2813-3-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2019-09-02 14:07       ` Kenny Ho
     [not found]         ` <CAOWid-dhHxhuPRmz26POaFKnAo3LfvayGnEqA-wLCRn3kNsKsw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2019-09-02 14:30           ` Christian König
     [not found]             ` <4e8e46ea-4492-480e-bcd3-58cc563e4520-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2019-09-02 14:47               ` Kenny Ho
     [not found]                 ` <CAOWid-cCsb3OifZhuKA3-uPxj=S9TS96HBYb5b-xM-7+yzNRXA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2019-09-02 14:56                   ` Christian König
2019-09-03 20:37   ` [PATCH 1/3] drm/amdgpu: use moving fence instead of exclusive for VM updates Kuehling, Felix

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=eb92584c-6409-8c10-bb9f-a44f62168588@gmail.com \
    --to=ckoenig.leichtzumerken-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=David1.Zhou-5C7GfCeVMHo@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=christian.koenig-5C7GfCeVMHo@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