AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Kuehling, Felix" <Felix.Kuehling-5C7GfCeVMHo@public.gmane.org>
To: "Christian König"
	<ckoenig.leichtzumerken-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	"amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org"
	<amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org>
Subject: Re: [PATCH 2/7] drm/amdgpu: rework shadow handling during PD clear
Date: Wed, 20 Feb 2019 00:07:08 +0000	[thread overview]
Message-ID: <3293bfe5-dae6-ebe2-e47e-db3d3d954c9e@amd.com> (raw)
In-Reply-To: <20190219134103.1531-2-christian.koenig-5C7GfCeVMHo@public.gmane.org>

Comments inline.

On 2019-02-19 8:40 a.m., Christian König wrote:
> This way we only deal with the real BO in here.
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 64 ++++++++++++++++----------
>   1 file changed, 39 insertions(+), 25 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> index 12d51d96491e..3c7b98a758c9 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> @@ -788,38 +788,58 @@ static int amdgpu_vm_clear_bo(struct amdgpu_device *adev,
>   
>   	r = ttm_bo_validate(&bo->tbo, &bo->placement, &ctx);
>   	if (r)
> -		goto error;
> +		return r;
>   
>   	r = amdgpu_ttm_alloc_gart(&bo->tbo);
>   	if (r)
>   		return r;
>   
> +	if (bo->shadow) {
> +		r = ttm_bo_validate(&bo->shadow->tbo, &bo->shadow->placement,
> +				    &ctx);
> +		if (r)
> +			return r;
> +
> +		r = amdgpu_ttm_alloc_gart(&bo->shadow->tbo);
> +		if (r)
> +			return r;
> +
> +	}
> +
>   	r = amdgpu_job_alloc_with_ib(adev, 64, &job);

I guess that's still big enough to fit 4 instead of 2 SDMA commands (10 
dwords each).


>   	if (r)
> -		goto error;
> +		return r;
>   
> -	addr = amdgpu_bo_gpu_offset(bo);
> -	if (ats_entries) {
> -		uint64_t ats_value;
> +	while (1) {
> +		addr = amdgpu_bo_gpu_offset(bo);
> +		if (ats_entries) {
> +			uint64_t ats_value;
>   
> -		ats_value = AMDGPU_PTE_DEFAULT_ATC;
> -		if (level != AMDGPU_VM_PTB)
> -			ats_value |= AMDGPU_PDE_PTE;
> +			ats_value = AMDGPU_PTE_DEFAULT_ATC;
> +			if (level != AMDGPU_VM_PTB)
> +				ats_value |= AMDGPU_PDE_PTE;
>   
> -		amdgpu_vm_set_pte_pde(adev, &job->ibs[0], addr, 0,
> -				      ats_entries, 0, ats_value);
> -		addr += ats_entries * 8;
> -	}
> +			amdgpu_vm_set_pte_pde(adev, &job->ibs[0], addr, 0,
> +					      ats_entries, 0, ats_value);
> +			addr += ats_entries * 8;
> +		}
>   
> -	if (entries) {
> -		uint64_t value = 0;
> +		if (entries) {
> +			uint64_t value = 0;
>   
> -		/* Workaround for fault priority problem on GMC9 */
> -		if (level == AMDGPU_VM_PTB && adev->asic_type >= CHIP_VEGA10)
> -			value = AMDGPU_PTE_EXECUTABLE;
> +			/* Workaround for fault priority problem on GMC9 */
> +			if (level == AMDGPU_VM_PTB &&
> +			    adev->asic_type >= CHIP_VEGA10)
> +				value = AMDGPU_PTE_EXECUTABLE;
> +
> +			amdgpu_vm_set_pte_pde(adev, &job->ibs[0], addr, 0,
> +					      entries, 0, value);
> +		}
>   
> -		amdgpu_vm_set_pte_pde(adev, &job->ibs[0], addr, 0,
> -				      entries, 0, value);
> +		if (bo->shadow)
> +			bo = bo->shadow;
> +		else
> +			break;
>   	}

Instead of a while(1) endless loop, this could be written as a do ... 
while loop with a sane termination condition like this:

	do {
		...
		bo = bo->shadow;
	} while (bo);

Assuming that you don't need "bo" after this. You do below, but I think 
that's a mistake anyway. See the next comment.

>   
>   	amdgpu_ring_pad_ib(ring, &job->ibs[0]);
> @@ -838,16 +858,10 @@ static int amdgpu_vm_clear_bo(struct amdgpu_device *adev,
>   	amdgpu_bo_fence(bo, fence, true);

Here you'll only fence the shadow BO.

Regards,
   Felix


>   	dma_fence_put(fence);
>   
> -	if (bo->shadow)
> -		return amdgpu_vm_clear_bo(adev, vm, bo->shadow,
> -					  level, pte_support_ats);
> -
>   	return 0;
>   
>   error_free:
>   	amdgpu_job_free(job);
> -
> -error:
>   	return r;
>   }
>   
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  parent reply	other threads:[~2019-02-20  0:07 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-19 13:40 [PATCH 1/7] drm/amdgpu: clear PDs/PTs only after initializing them Christian König
     [not found] ` <20190219134103.1531-1-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2019-02-19 13:40   ` [PATCH 2/7] drm/amdgpu: rework shadow handling during PD clear Christian König
     [not found]     ` <20190219134103.1531-2-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2019-02-20  0:07       ` Kuehling, Felix [this message]
2019-02-22 15:51       ` Zeng, Oak
     [not found]         ` <BL0PR12MB258008B300413D2A0052EE5F807F0-b4cIHhjg/p/XzH18dTCKOgdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2019-02-22 16:34           ` Grodzovsky, Andrey
2019-02-19 13:40   ` [PATCH 3/7] drm/amdgpu: let amdgpu_vm_clear_bo figure out ats status Christian König
     [not found]     ` <20190219134103.1531-3-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2019-02-20  0:42       ` Kuehling, Felix
2019-02-19 13:41   ` [PATCH 4/7] drm/amdgpu: allocate VM PDs/PTs on demand Christian König
2019-02-19 13:41   ` [PATCH 5/7] drm/amdgpu: free " Christian König
2019-02-19 13:41   ` [PATCH 6/7] drm/amdgpu: drop the huge page flag Christian König
2019-02-19 13:41   ` [PATCH 7/7] drm/amdgpu: allow huge invalid mappings on GMC8 Christian König
2019-02-20  0:43   ` [PATCH 1/7] drm/amdgpu: clear PDs/PTs only after initializing them 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=3293bfe5-dae6-ebe2-e47e-db3d3d954c9e@amd.com \
    --to=felix.kuehling-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox