All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: Nirmoy Das <nirmoy.das@amd.com>, amd-gfx@lists.freedesktop.org
Cc: alexander.deucher@amd.com
Subject: Re: [PATCH 3/7] drm/amdgpu: use amdgpu_bo_vm for vm code
Date: Wed, 26 May 2021 14:39:43 +0200	[thread overview]
Message-ID: <3d857c73-6f96-ef12-5a16-3282624153bc@amd.com> (raw)
In-Reply-To: <20210526101027.14936-3-nirmoy.das@amd.com>

Am 26.05.21 um 12:10 schrieb Nirmoy Das:
> Use amdgpu_bo_vm subclass for creating BOs related to PD/PT.

I think it would be better if you just squash patch #3, #4 and #5 together.

Apart from that looks good to me, but still need to double check patch #7.

Christian.

>
> Signed-off-by: Nirmoy Das <nirmoy.das@amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 43 ++++++++++++++------------
>   1 file changed, 24 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> index f474f15ba344..2c97d67d9cfc 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> @@ -868,9 +868,10 @@ static int amdgpu_vm_clear_bo(struct amdgpu_device *adev,
>   static int amdgpu_vm_pt_create(struct amdgpu_device *adev,
>   			       struct amdgpu_vm *vm,
>   			       int level, bool immediate,
> -			       struct amdgpu_bo **bo)
> +			       struct amdgpu_bo_vm **vmbo)
>   {
>   	struct amdgpu_bo_param bp;
> +	struct amdgpu_bo *bo;
>   	int r;
>   
>   	memset(&bp, 0, sizeof(bp));
> @@ -881,7 +882,7 @@ static int amdgpu_vm_pt_create(struct amdgpu_device *adev,
>   	bp.domain = amdgpu_bo_get_preferred_pin_domain(adev, bp.domain);
>   	bp.flags = AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS |
>   		AMDGPU_GEM_CREATE_CPU_GTT_USWC;
> -	bp.bo_ptr_size = sizeof(struct amdgpu_bo);
> +	bp.bo_ptr_size = sizeof(struct amdgpu_bo_vm);
>   	if (vm->use_cpu_for_update)
>   		bp.flags |= AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED;
>   
> @@ -890,23 +891,24 @@ static int amdgpu_vm_pt_create(struct amdgpu_device *adev,
>   	if (vm->root.base.bo)
>   		bp.resv = vm->root.base.bo->tbo.base.resv;
>   
> -	r = amdgpu_bo_create(adev, &bp, bo);
> +	r = amdgpu_bo_create_vm(adev, &bp, vmbo);
>   	if (r)
>   		return r;
>   
> +	bo = &(*vmbo)->bo;
>   	if (vm->is_compute_context && (adev->flags & AMD_IS_APU))
>   		return 0;
>   
>   	if (!bp.resv)
> -		WARN_ON(dma_resv_lock((*bo)->tbo.base.resv,
> +		WARN_ON(dma_resv_lock(bo->tbo.base.resv,
>   				      NULL));
> -	r = amdgpu_bo_create_shadow(adev, bp.size, *bo);
> +	r = amdgpu_bo_create_shadow(adev, bp.size, bo);
>   
>   	if (!bp.resv)
> -		dma_resv_unlock((*bo)->tbo.base.resv);
> +		dma_resv_unlock(bo->tbo.base.resv);
>   
>   	if (r) {
> -		amdgpu_bo_unref(bo);
> +		amdgpu_bo_unref(&bo);
>   		return r;
>   	}
>   
> @@ -933,7 +935,8 @@ static int amdgpu_vm_alloc_pts(struct amdgpu_device *adev,
>   			       bool immediate)
>   {
>   	struct amdgpu_vm_pt *entry = cursor->entry;
> -	struct amdgpu_bo *pt;
> +	struct amdgpu_bo *pt_bo;
> +	struct amdgpu_bo_vm *pt;
>   	int r;
>   
>   	if (cursor->level < AMDGPU_VM_PTB && !entry->entries) {
> @@ -957,18 +960,19 @@ static int amdgpu_vm_alloc_pts(struct amdgpu_device *adev,
>   	/* Keep a reference to the root directory to avoid
>   	 * freeing them up in the wrong order.
>   	 */
> -	pt->parent = amdgpu_bo_ref(cursor->parent->base.bo);
> -	amdgpu_vm_bo_base_init(&entry->base, vm, pt);
> +	pt_bo = &pt->bo;
> +	pt_bo->parent = amdgpu_bo_ref(cursor->parent->base.bo);
> +	amdgpu_vm_bo_base_init(&entry->base, vm, pt_bo);
>   
> -	r = amdgpu_vm_clear_bo(adev, vm, pt, immediate);
> +	r = amdgpu_vm_clear_bo(adev, vm, pt_bo, immediate);
>   	if (r)
>   		goto error_free_pt;
>   
>   	return 0;
>   
>   error_free_pt:
> -	amdgpu_bo_unref(&pt->shadow);
> -	amdgpu_bo_unref(&pt);
> +	amdgpu_bo_unref(&pt_bo->shadow);
> +	amdgpu_bo_unref(&pt_bo);
>   	return r;
>   }
>   
> @@ -2843,7 +2847,8 @@ long amdgpu_vm_wait_idle(struct amdgpu_vm *vm, long timeout)
>    */
>   int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm, u32 pasid)
>   {
> -	struct amdgpu_bo *root;
> +	struct amdgpu_bo *root_bo;
> +	struct amdgpu_bo_vm *root;
>   	int r, i;
>   
>   	vm->va = RB_ROOT_CACHED;
> @@ -2897,18 +2902,18 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm, u32 pasid)
>   				false, &root);
>   	if (r)
>   		goto error_free_delayed;
> -
> -	r = amdgpu_bo_reserve(root, true);
> +	root_bo = &root->bo;
> +	r = amdgpu_bo_reserve(root_bo, true);
>   	if (r)
>   		goto error_free_root;
>   
> -	r = dma_resv_reserve_shared(root->tbo.base.resv, 1);
> +	r = dma_resv_reserve_shared(root_bo->tbo.base.resv, 1);
>   	if (r)
>   		goto error_unreserve;
>   
> -	amdgpu_vm_bo_base_init(&vm->root.base, vm, root);
> +	amdgpu_vm_bo_base_init(&vm->root.base, vm, root_bo);
>   
> -	r = amdgpu_vm_clear_bo(adev, vm, root, false);
> +	r = amdgpu_vm_clear_bo(adev, vm, root_bo, false);
>   	if (r)
>   		goto error_unreserve;
>   

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

  reply	other threads:[~2021-05-26 12:39 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-26 10:10 [PATCH 1/7] drm/amdgpu: add amdgpu_bo_vm bo type Nirmoy Das
2021-05-26 10:10 ` [PATCH 2/7] drm/amdgpu: move shadow bo validation to VM code Nirmoy Das
2021-05-26 12:02   ` Christian König
2021-05-26 12:38     ` Das, Nirmoy
2021-05-26 10:10 ` [PATCH 3/7] drm/amdgpu: use amdgpu_bo_vm for vm code Nirmoy Das
2021-05-26 12:39   ` Christian König [this message]
2021-05-26 10:10 ` [PATCH 4/7] drm/amdgpu: create shadow bo directly Nirmoy Das
2021-05-26 10:10 ` [PATCH 5/7] drm/amdgpu: switch to amdgpu_bo_vm for shadow pointer Nirmoy Das
2021-05-26 10:10 ` [PATCH 6/7] drm/amdgpu: remove unused code Nirmoy Das
2021-05-26 11:34   ` Das, Nirmoy
2021-05-26 10:10 ` [PATCH v2 7/7] drm/amdgpu: do not allocate entries separately Nirmoy Das
2021-05-26 12:01 ` [PATCH 1/7] drm/amdgpu: add amdgpu_bo_vm bo type Christian König
  -- strict thread matches above, loose matches on Subject: below --
2021-05-21 12:45 Nirmoy Das
2021-05-21 12:45 ` [PATCH 3/7] drm/amdgpu: use amdgpu_bo_vm for vm code Nirmoy Das

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=3d857c73-6f96-ef12-5a16-3282624153bc@amd.com \
    --to=christian.koenig@amd.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=nirmoy.das@amd.com \
    /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.