[3/3] drm/amdgpu: only bind VM shadows after validation

Submitted by Christian König on July 13, 2017, 1:25 p.m.

Details

Message ID 1499952313-2398-3-git-send-email-deathsimple@vodafone.de
State New
Headers show
Series "Series without cover letter" ( rev: 1 ) in AMD X.Org drivers

Not browsing as part of any series.

Commit Message

Christian König July 13, 2017, 1:25 p.m.
From: Christian König <christian.koenig@amd.com>

No need to do this on every CS.

Signed-off-by: Christian König <christian.koenig@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index ea419ec..e1641f1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -171,6 +171,18 @@  static int amdgpu_vm_validate_level(struct amdgpu_vm_pt *parent,
 			return r;
 	}
 
+	if (parent->bo->shadow) {
+		struct amdgpu_bo *shadow = parent->bo->shadow;
+
+		r = amdgpu_ttm_bind(&shadow->tbo, &shadow->tbo.mem);
+		if (r)
+			return r;
+
+		spin_lock(&glob->lru_lock);
+		ttm_bo_move_to_lru_tail(&shadow->tbo);
+		spin_unlock(&glob->lru_lock);
+	}
+
 	spin_lock(&glob->lru_lock);
 	ttm_bo_move_to_lru_tail(&parent->bo->tbo);
 	spin_unlock(&glob->lru_lock);
@@ -1031,11 +1043,6 @@  static int amdgpu_vm_update_level(struct amdgpu_device *adev,
 
 		params.func = amdgpu_vm_cpu_set_ptes;
 	} else {
-		if (shadow) {
-			r = amdgpu_ttm_bind(&shadow->tbo, &shadow->tbo.mem);
-			if (r)
-				return r;
-		}
 		ring = container_of(vm->entity.sched, struct amdgpu_ring,
 				    sched);
 

Comments

On 17-07-13 09:25 AM, Christian König wrote:
> From: Christian König <christian.koenig@amd.com>
>
> No need to do this on every CS.
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 17 ++++++++++++-----
>  1 file changed, 12 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> index ea419ec..e1641f1 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> @@ -171,6 +171,18 @@ static int amdgpu_vm_validate_level(struct amdgpu_vm_pt *parent,
>  			return r;
>  	}
>  
> +	if (parent->bo->shadow) {
> +		struct amdgpu_bo *shadow = parent->bo->shadow;
> +
> +		r = amdgpu_ttm_bind(&shadow->tbo, &shadow->tbo.mem);
> +		if (r)
> +			return r;
> +
> +		spin_lock(&glob->lru_lock);
> +		ttm_bo_move_to_lru_tail(&shadow->tbo);
> +		spin_unlock(&glob->lru_lock);
> +	}
> +
>  	spin_lock(&glob->lru_lock);
>  	ttm_bo_move_to_lru_tail(&parent->bo->tbo);
>  	spin_unlock(&glob->lru_lock);
> @@ -1031,11 +1043,6 @@ static int amdgpu_vm_update_level(struct amdgpu_device *adev,
>  
>  		params.func = amdgpu_vm_cpu_set_ptes;
>  	} else {
> -		if (shadow) {
> -			r = amdgpu_ttm_bind(&shadow->tbo, &shadow->tbo.mem);
> -			if (r)
> -				return r;
> -		}

There is another bind of shadow BOs further down in the loop that does
the update.

Regards,
  Felix

>  		ring = container_of(vm->entity.sched, struct amdgpu_ring,
>  				    sched);
>