All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Zhang, Jerry (Junwei)" <Jerry.Zhang-5C7GfCeVMHo@public.gmane.org>
To: "Christian König"
	<ckoenig.leichtzumerken-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: Re: [PATCH 10/11] drm/amdgpu: add helper for VM PD/PT allocation parameters
Date: Thu, 23 Aug 2018 11:19:09 +0800	[thread overview]
Message-ID: <5B7E27AD.4040407@amd.com> (raw)
In-Reply-To: <20180822150517.2330-10-christian.koenig-5C7GfCeVMHo@public.gmane.org>

On 08/22/2018 11:05 PM, Christian König wrote:
> Add a helper function to figure them out only once.
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Junwei Zhang <Jerry.Zhang@amd.com>

> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 61 ++++++++++++--------------
>   1 file changed, 28 insertions(+), 33 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> index 87e3d44b0a3f..928fdae0dab4 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> @@ -446,6 +446,31 @@ static int amdgpu_vm_clear_bo(struct amdgpu_device *adev,
>   	return r;
>   }
>
> +/**
> + * amdgpu_vm_bo_param - fill in parameters for PD/PT allocation
> + *
> + * @adev: amdgpu_device pointer
> + * @vm: requesting vm
> + * @bp: resulting BO allocation parameters
> + */
> +static void amdgpu_vm_bo_param(struct amdgpu_device *adev, struct amdgpu_vm *vm,
> +			       int level, struct amdgpu_bo_param *bp)
> +{
> +	memset(&bp, 0, sizeof(bp));
> +
> +	bp->size = amdgpu_vm_bo_size(adev, level);
> +	bp->byte_align = AMDGPU_GPU_PAGE_SIZE;
> +	bp->domain = AMDGPU_GEM_DOMAIN_VRAM;
> +	bp->flags = AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS;
> +	if (vm->use_cpu_for_update)
> +		bp->flags |= AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED;
> +	else
> +		bp->flags |= AMDGPU_GEM_CREATE_SHADOW;
> +	bp->type = ttm_bo_type_kernel;
> +	if (vm->root.base.bo)
> +		bp->resv = vm->root.base.bo->tbo.resv;
> +}
> +
>   /**
>    * amdgpu_vm_alloc_levels - allocate the PD/PT levels
>    *
> @@ -469,8 +494,8 @@ static int amdgpu_vm_alloc_levels(struct amdgpu_device *adev,
>   				  unsigned level, bool ats)
>   {
>   	unsigned shift = amdgpu_vm_level_shift(adev, level);
> +	struct amdgpu_bo_param bp;
>   	unsigned pt_idx, from, to;
> -	u64 flags;
>   	int r;
>
>   	if (!parent->entries) {
> @@ -494,29 +519,14 @@ static int amdgpu_vm_alloc_levels(struct amdgpu_device *adev,
>   	saddr = saddr & ((1 << shift) - 1);
>   	eaddr = eaddr & ((1 << shift) - 1);
>
> -	flags = AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS;
> -	if (vm->use_cpu_for_update)
> -		flags |= AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED;
> -	else
> -		flags |= (AMDGPU_GEM_CREATE_NO_CPU_ACCESS |
> -				AMDGPU_GEM_CREATE_SHADOW);
> +	amdgpu_vm_bo_param(adev, vm, level, &bp);
>
>   	/* walk over the address space and allocate the page tables */
>   	for (pt_idx = from; pt_idx <= to; ++pt_idx) {
> -		struct reservation_object *resv = vm->root.base.bo->tbo.resv;
>   		struct amdgpu_vm_pt *entry = &parent->entries[pt_idx];
>   		struct amdgpu_bo *pt;
>
>   		if (!entry->base.bo) {
> -			struct amdgpu_bo_param bp;
> -
> -			memset(&bp, 0, sizeof(bp));
> -			bp.size = amdgpu_vm_bo_size(adev, level);
> -			bp.byte_align = AMDGPU_GPU_PAGE_SIZE;
> -			bp.domain = AMDGPU_GEM_DOMAIN_VRAM;
> -			bp.flags = flags;
> -			bp.type = ttm_bo_type_kernel;
> -			bp.resv = resv;
>   			r = amdgpu_bo_create(adev, &bp, &pt);
>   			if (r)
>   				return r;
> @@ -2564,8 +2574,6 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,
>   {
>   	struct amdgpu_bo_param bp;
>   	struct amdgpu_bo *root;
> -	unsigned long size;
> -	uint64_t flags;
>   	int r, i;
>
>   	vm->va = RB_ROOT_CACHED;
> @@ -2602,20 +2610,7 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,
>   		  "CPU update of VM recommended only for large BAR system\n");
>   	vm->last_update = NULL;
>
> -	flags = AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS;
> -	if (vm->use_cpu_for_update)
> -		flags |= AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED;
> -	else
> -		flags |= AMDGPU_GEM_CREATE_SHADOW;
> -
> -	size = amdgpu_vm_bo_size(adev, adev->vm_manager.root_level);
> -	memset(&bp, 0, sizeof(bp));
> -	bp.size = size;
> -	bp.byte_align = AMDGPU_GPU_PAGE_SIZE;
> -	bp.domain = AMDGPU_GEM_DOMAIN_VRAM;
> -	bp.flags = flags;
> -	bp.type = ttm_bo_type_kernel;
> -	bp.resv = NULL;
> +	amdgpu_vm_bo_param(adev, vm, adev->vm_manager.root_level, &bp);
>   	r = amdgpu_bo_create(adev, &bp, &root);
>   	if (r)
>   		goto error_free_sched_entity;
>
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  parent reply	other threads:[~2018-08-23  3:19 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-22 15:05 [PATCH 01/11] drm/amdgpu: remove extra root PD alignment Christian König
     [not found] ` <20180822150517.2330-1-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2018-08-22 15:05   ` [PATCH 02/11] drm/amdgpu: validate the VM root PD from the VM code Christian König
     [not found]     ` <20180822150517.2330-2-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2018-08-23  2:46       ` Zhang, Jerry (Junwei)
2018-08-23  7:28       ` Huang Rui
2018-08-23 12:01         ` Christian König
2018-08-22 15:05   ` [PATCH 03/11] drm/amdgpu: cleanup VM handling in the CS a bit Christian König
     [not found]     ` <20180822150517.2330-3-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2018-08-22 19:49       ` Alex Deucher
2018-08-23  7:54       ` Huang Rui
2018-08-22 15:05   ` [PATCH 04/11] drm/amdgpu: move setting the GART addr into TTM Christian König
     [not found]     ` <20180822150517.2330-4-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2018-08-22 19:50       ` Alex Deucher
2018-08-23 11:23       ` Huang Rui
2018-08-22 15:05   ` [PATCH 05/11] drm/amdgpu: rename gart.robj into gart.bo Christian König
     [not found]     ` <20180822150517.2330-5-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2018-08-22 19:50       ` Alex Deucher
2018-08-23 11:27       ` Huang Rui
2018-08-22 15:05   ` [PATCH 06/11] drm/amdgpu: remove gart.table_addr Christian König
2018-08-22 15:05   ` [PATCH 07/11] drm/amdgpu: add GMC9 support for PDs/PTs in system memory Christian König
     [not found]     ` <20180822150517.2330-7-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2018-08-23  2:50       ` Zhang, Jerry (Junwei)
     [not found]         ` <5B7E2109.3020406-5C7GfCeVMHo@public.gmane.org>
2018-08-23 11:39           ` Huang Rui
2018-08-23 11:40       ` Huang Rui
2018-08-22 15:05   ` [PATCH 08/11] drm/amdgpu: add amdgpu_gmc_pd_addr helper Christian König
     [not found]     ` <20180822150517.2330-8-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2018-08-22 22:09       ` Felix Kuehling
2018-08-23  3:07       ` Zhang, Jerry (Junwei)
     [not found]         ` <5B7E2507.5050205-5C7GfCeVMHo@public.gmane.org>
2018-08-23 12:18           ` Christian König
2018-08-23 11:42       ` Huang Rui
2018-08-22 15:05   ` [PATCH 09/11] drm/amdgpu: add amdgpu_gmc_get_pde_for_bo helper Christian König
     [not found]     ` <20180822150517.2330-9-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2018-08-23 12:45       ` Huang Rui
2018-08-22 15:05   ` [PATCH 10/11] drm/amdgpu: add helper for VM PD/PT allocation parameters Christian König
     [not found]     ` <20180822150517.2330-10-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2018-08-22 19:55       ` Alex Deucher
2018-08-23  3:19       ` Zhang, Jerry (Junwei) [this message]
2018-08-23 12:46       ` Huang Rui
2018-08-22 15:05   ` [PATCH 11/11] drm/amdgpu: enable GTT PD/PT for raven Christian König
     [not found]     ` <20180822150517.2330-11-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2018-08-22 15:44       ` Andrey Grodzovsky
     [not found]         ` <f5c10bb6-4d93-5102-2c3b-ae0e161b70e1-5C7GfCeVMHo@public.gmane.org>
2018-08-23 12:54           ` Huang Rui
2018-08-23 13:02             ` Christian König
2018-08-23  5:28       ` Zhang, Jerry (Junwei)
2018-08-22 19:46   ` [PATCH 01/11] drm/amdgpu: remove extra root PD alignment Alex Deucher
     [not found]     ` <CADnq5_OscxLwhzUnR9pcQ9cRVLPK1YyqEp6kCGOdVWahWPKEUg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-08-23  2:36       ` Zhang, Jerry (Junwei)
2018-08-23  6:52       ` Christian König
2018-08-23  7:21   ` Huang Rui

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=5B7E27AD.4040407@amd.com \
    --to=jerry.zhang-5c7gfcevmho@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=ckoenig.leichtzumerken-Re5JQEeQqe8AvxtiuMwx3w@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.