All of lore.kernel.org
 help / color / mirror / Atom feed
From: Edward O'Callaghan <funfunctor-dczkZgxz+BNUPWh3PAxdjQ@public.gmane.org>
To: Chunming Zhou <David1.Zhou-5C7GfCeVMHo@public.gmane.org>,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: Re: [PATCH 08/18] drm/amdgpu: update pd shadow bo
Date: Fri, 12 Aug 2016 19:50:07 +1000	[thread overview]
Message-ID: <2b268e2c-0448-993c-c9ae-83374f91aaca@folklore1984.net> (raw)
In-Reply-To: <1470983947-32579-9-git-send-email-David1.Zhou-5C7GfCeVMHo@public.gmane.org>


[-- Attachment #1.1.1: Type: text/plain, Size: 4974 bytes --]



On 08/12/2016 04:38 PM, Chunming Zhou wrote:
> Change-Id: I8d0c625c9f1c9a16b8e2e915831590be5a9a5242
> Signed-off-by: Chunming Zhou <David1.Zhou-5C7GfCeVMHo@public.gmane.org>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu.h    |  1 +
>  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 73 +++++++++++++++++++++++-----------
>  2 files changed, 50 insertions(+), 24 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> index 7eb854a..73af7ba 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> @@ -884,6 +884,7 @@ struct amdgpu_ring {
>  struct amdgpu_vm_pt {
>  	struct amdgpu_bo_list_entry	entry;
>  	uint64_t			addr;
> +	uint64_t			shadow_addr;
>  };
>  
>  struct amdgpu_vm {
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> index f1a1add..bd69cf83 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> @@ -597,23 +597,13 @@ uint64_t amdgpu_vm_map_gart(const dma_addr_t *pages_addr, uint64_t addr)
>  	return result;
>  }
>  
> -/**
> - * amdgpu_vm_update_pdes - make sure that page directory is valid
> - *
> - * @adev: amdgpu_device pointer
> - * @vm: requested vm
> - * @start: start of GPU address range
> - * @end: end of GPU address range
> - *
> - * Allocates new page tables if necessary
> - * and updates the page directory.
> - * Returns 0 for success, error for failure.
> - */
> -int amdgpu_vm_update_page_directory(struct amdgpu_device *adev,
> -				    struct amdgpu_vm *vm)
> +int amdgpu_vm_update_page_directory_or_shadow(struct amdgpu_device *adev,
> +					      struct amdgpu_vm *vm,
> +					      bool shadow)
>  {
>  	struct amdgpu_ring *ring;
> -	struct amdgpu_bo *pd = vm->page_directory;
> +	struct amdgpu_bo *pd = shadow ? vm->page_directory->shadow :
> +		vm->page_directory;
>  	uint64_t pd_addr = amdgpu_bo_gpu_offset(pd);
>  	uint32_t incr = AMDGPU_VM_PTE_COUNT * 8;
>  	uint64_t last_pde = ~0, last_pt = ~0;
> @@ -647,10 +637,17 @@ int amdgpu_vm_update_page_directory(struct amdgpu_device *adev,
>  		if (bo == NULL)
>  			continue;
>  
> -		pt = amdgpu_bo_gpu_offset(bo);
Hmm, no need to remove this line as it is common to both branches.

> -		if (vm->page_tables[pt_idx].addr == pt)
> -			continue;
> -		vm->page_tables[pt_idx].addr = pt;
> +		if (!shadow) {
> +			pt = amdgpu_bo_gpu_offset(bo);
ditto

> +			if (vm->page_tables[pt_idx].addr == pt)
> +				continue;
> +			vm->page_tables[pt_idx].addr = pt;
> +		} else {
> +			pt = amdgpu_bo_gpu_offset(bo);
ditto

> +			if (vm->page_tables[pt_idx].shadow_addr == pt)
> +				continue;
> +			vm->page_tables[pt_idx].shadow_addr = pt;
> +		}
>  
>  		pde = pd_addr + pt_idx * 8;
>  		if (((last_pde + 8 * count) != pde) ||
> @@ -678,17 +675,21 @@ int amdgpu_vm_update_page_directory(struct amdgpu_device *adev,
>  
>  	if (vm_update_params.ib->length_dw != 0) {
>  		amdgpu_ring_pad_ib(ring, vm_update_params.ib);
> -		amdgpu_sync_resv(adev, &job->sync, pd->tbo.resv,
> -				 AMDGPU_FENCE_OWNER_VM);
> +		if (!shadow)
> +			amdgpu_sync_resv(adev, &job->sync, pd->tbo.resv,
> +					 AMDGPU_FENCE_OWNER_VM);
>  		WARN_ON(vm_update_params.ib->length_dw > ndw);
> -		r = amdgpu_job_submit(job, ring, &vm->entity,
> +		r = amdgpu_job_submit(job, ring,
> +				      shadow ? &vm->shadow_entity : &vm->entity,
>  				      AMDGPU_FENCE_OWNER_VM, &fence);
>  		if (r)
>  			goto error_free;
>  
>  		amdgpu_bo_fence(pd, fence, true);
> -		fence_put(vm->page_directory_fence);
> -		vm->page_directory_fence = fence_get(fence);
> +		if (!shadow) {
> +			fence_put(vm->page_directory_fence);
> +			vm->page_directory_fence = fence_get(fence);
> +		}
>  		fence_put(fence);
>  
>  	} else {
> @@ -702,6 +703,29 @@ error_free:
>  	return r;
>  }
>  
> +/**
> + * amdgpu_vm_update_pdes - make sure that page directory is valid
> + *
> + * @adev: amdgpu_device pointer
> + * @vm: requested vm
> + * @start: start of GPU address range
> + * @end: end of GPU address range
> + *
> + * Allocates new page tables if necessary
> + * and updates the page directory.
> + * Returns 0 for success, error for failure.
> + */
> +int amdgpu_vm_update_page_directory(struct amdgpu_device *adev,
> +				    struct amdgpu_vm *vm)
> +{
> +	int r;
> +
> +	r = amdgpu_vm_update_page_directory_or_shadow(adev, vm, true);
> +	if (r)
> +		return r;
> +	return amdgpu_vm_update_page_directory_or_shadow(adev, vm, false);
> +}
> +
>  int amdgpu_vm_recover_page_table_from_shadow(struct amdgpu_device *adev,
>  					     struct amdgpu_vm *vm)
>  {
> @@ -1410,6 +1434,7 @@ int amdgpu_vm_bo_map(struct amdgpu_device *adev,
>  		entry->tv.shared = true;
>  		entry->user_pages = NULL;
>  		vm->page_tables[pt_idx].addr = 0;
> +		vm->page_tables[pt_idx].shadow_addr = 0;
>  	}
>  
>  	return 0;
> 


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

[-- Attachment #2: Type: text/plain, Size: 154 bytes --]

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

  parent reply	other threads:[~2016-08-12  9:50 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-12  6:38 [PATCH 00/18] shadow page table support V3 Chunming Zhou
     [not found] ` <1470983947-32579-1-git-send-email-David1.Zhou-5C7GfCeVMHo@public.gmane.org>
2016-08-12  6:38   ` [PATCH 01/18] drm/amdgpu: add shadow bo support V2 Chunming Zhou
2016-08-12  6:38   ` [PATCH 02/18] drm/amdgpu: validate shadow as well when validating bo Chunming Zhou
2016-08-12  6:38   ` [PATCH 03/18] drm/amdgpu: allocate shadow for pd/pt bo V2 Chunming Zhou
2016-08-12  6:38   ` [PATCH 04/18] drm/amdgpu: add shadow flag V2 Chunming Zhou
2016-08-12  6:38   ` [PATCH 05/18] drm/amdgpu: sync bo and shadow Chunming Zhou
2016-08-12  6:38   ` [PATCH 06/18] drm/amdgpu: implement vm recovery function from shadow Chunming Zhou
2016-08-12  6:38   ` [PATCH 07/18] drm/amdgpu: add shadow_entity for shadow page table updates Chunming Zhou
2016-08-12  6:38   ` [PATCH 08/18] drm/amdgpu: update pd shadow bo Chunming Zhou
     [not found]     ` <1470983947-32579-9-git-send-email-David1.Zhou-5C7GfCeVMHo@public.gmane.org>
2016-08-12  9:50       ` Edward O'Callaghan [this message]
2016-08-12  6:38   ` [PATCH 09/18] drm/amdgpu: update pt shadow Chunming Zhou
2016-08-12  6:38   ` [PATCH 10/18] drm/amd: add last fence in sched entity Chunming Zhou
2016-08-12  6:39   ` [PATCH 11/18] drm/amdgpu: link all vm clients Chunming Zhou
2016-08-12  6:39   ` [PATCH 12/18] drm/amdgpu: add vm_list_lock Chunming Zhou
2016-08-12  6:39   ` [PATCH 13/18] drm/amd: add block entity function Chunming Zhou
2016-08-12  6:39   ` [PATCH 14/18] drm/amdgpu: add shadow fence owner Chunming Zhou
2016-08-12  6:39   ` [PATCH 15/18] drm/amd: block entity Chunming Zhou
     [not found]     ` <1470983947-32579-16-git-send-email-David1.Zhou-5C7GfCeVMHo@public.gmane.org>
2016-08-12  9:42       ` Edward O'Callaghan
     [not found]         ` <f8dfeb55-132f-1ddf-2e2f-02776aa5d3e0-dczkZgxz+BNUPWh3PAxdjQ@public.gmane.org>
2016-08-12  9:43           ` zhoucm1
2016-08-12  6:39   ` [PATCH 16/18] drm/amdgpu: recover page tables after gpu reset Chunming Zhou
2016-08-12  6:39   ` [PATCH 17/18] drm/amdgpu: add need backup function Chunming Zhou
2016-08-12  6:39   ` [PATCH 18/18] drm/amdgpu: add backup condition for vm Chunming Zhou
2016-08-12  8:00   ` [PATCH 00/18] shadow page table support V3 Christian König

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=2b268e2c-0448-993c-c9ae-83374f91aaca@folklore1984.net \
    --to=funfunctor-dczkzgxz+bnupwh3paxdjq@public.gmane.org \
    --cc=David1.Zhou-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 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.