[5/8] drm/amdgpu: don't use ttm_bo_move_ttm in amdgpu_ttm_bind

Submitted by Christian König on Oct. 26, 2017, 4:06 p.m.

Details

Message ID 1509033983-2977-5-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 Oct. 26, 2017, 4:06 p.m.
From: Christian König <christian.koenig@amd.com>

Just unbind and rebind to force updates of the GART space.

This prevents forcing the BO to be idle.

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

Patch hide | download patch | download mbox

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 3045701..b40d2f3 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -917,14 +917,26 @@  int amdgpu_ttm_bind(struct ttm_buffer_object *bo, struct ttm_mem_reg *bo_mem)
 	if (unlikely(r))
 		return r;
 
-	r = ttm_bo_move_ttm(bo, true, false, &tmp);
-	if (unlikely(r))
+	if (ttm->state == tt_bound) {
+		r = ttm->func->unbind(ttm);
+		if (unlikely(r))
+			return r;
+
+		ttm->state = tt_unbound;
+	}
+
+	r = ttm_tt_bind(ttm, &tmp);
+	if (unlikely(r)) {
 		ttm_bo_mem_put(bo, &tmp);
-	else
-		bo->offset = (bo->mem.start << PAGE_SHIFT) +
-			bo->bdev->man[bo->mem.mem_type].gpu_offset;
+		return r;
+	}
 
-	return r;
+	ttm_bo_mem_put(bo, bo_mem);
+	bo->mem = tmp;
+	bo->offset = (bo->mem.start << PAGE_SHIFT) +
+		bo->bdev->man[bo->mem.mem_type].gpu_offset;
+
+	return 0;
 }
 
 int amdgpu_ttm_recover_gart(struct amdgpu_device *adev)

Comments

> -----Original Message-----

> From: amd-gfx [mailto:amd-gfx-bounces@lists.freedesktop.org] On Behalf

> Of Christian König

> Sent: Thursday, October 26, 2017 12:06 PM

> To: amd-gfx@lists.freedesktop.org

> Subject: [PATCH 5/8] drm/amdgpu: don't use ttm_bo_move_ttm in

> amdgpu_ttm_bind

> 

> From: Christian König <christian.koenig@amd.com>

> 

> Just unbind and rebind to force updates of the GART space.

> 

> This prevents forcing the BO to be idle.


Is there a chance something could change like the caching on a  rebind that we need to account for?

Alex

> 

> Signed-off-by: Christian König <christian.koenig@amd.com>

> ---

>  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 24 ++++++++++++++++++-

> -----

>  1 file changed, 18 insertions(+), 6 deletions(-)

> 

> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c

> b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c

> index 3045701..b40d2f3 100644

> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c

> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c

> @@ -917,14 +917,26 @@ int amdgpu_ttm_bind(struct ttm_buffer_object

> *bo, struct ttm_mem_reg *bo_mem)

>  	if (unlikely(r))

>  		return r;

> 

> -	r = ttm_bo_move_ttm(bo, true, false, &tmp);

> -	if (unlikely(r))

> +	if (ttm->state == tt_bound) {

> +		r = ttm->func->unbind(ttm);

> +		if (unlikely(r))

> +			return r;

> +

> +		ttm->state = tt_unbound;

> +	}

> +

> +	r = ttm_tt_bind(ttm, &tmp);

> +	if (unlikely(r)) {

>  		ttm_bo_mem_put(bo, &tmp);

> -	else

> -		bo->offset = (bo->mem.start << PAGE_SHIFT) +

> -			bo->bdev->man[bo->mem.mem_type].gpu_offset;

> +		return r;

> +	}

> 

> -	return r;

> +	ttm_bo_mem_put(bo, bo_mem);

> +	bo->mem = tmp;

> +	bo->offset = (bo->mem.start << PAGE_SHIFT) +

> +		bo->bdev->man[bo->mem.mem_type].gpu_offset;

> +

> +	return 0;

>  }

> 

>  int amdgpu_ttm_recover_gart(struct amdgpu_device *adev)

> --

> 2.7.4

> 

> _______________________________________________

> amd-gfx mailing list

> amd-gfx@lists.freedesktop.org

> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Am 26.10.2017 um 20:11 schrieb Deucher, Alexander:
>> -----Original Message-----
>> From: amd-gfx [mailto:amd-gfx-bounces@lists.freedesktop.org] On Behalf
>> Of Christian König
>> Sent: Thursday, October 26, 2017 12:06 PM
>> To: amd-gfx@lists.freedesktop.org
>> Subject: [PATCH 5/8] drm/amdgpu: don't use ttm_bo_move_ttm in
>> amdgpu_ttm_bind
>>
>> From: Christian König <christian.koenig@amd.com>
>>
>> Just unbind and rebind to force updates of the GART space.
>>
>> This prevents forcing the BO to be idle.
> Is there a chance something could change like the caching on a  rebind that we need to account for?

Not that I could think of.

The new placement should have identical attributes to the old one, just 
with GART space allocated.

Christian.

>
> Alex
>
>> Signed-off-by: Christian König <christian.koenig@amd.com>
>> ---
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 24 ++++++++++++++++++-
>> -----
>>   1 file changed, 18 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
>> index 3045701..b40d2f3 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
>> @@ -917,14 +917,26 @@ int amdgpu_ttm_bind(struct ttm_buffer_object
>> *bo, struct ttm_mem_reg *bo_mem)
>>   	if (unlikely(r))
>>   		return r;
>>
>> -	r = ttm_bo_move_ttm(bo, true, false, &tmp);
>> -	if (unlikely(r))
>> +	if (ttm->state == tt_bound) {
>> +		r = ttm->func->unbind(ttm);
>> +		if (unlikely(r))
>> +			return r;
>> +
>> +		ttm->state = tt_unbound;
>> +	}
>> +
>> +	r = ttm_tt_bind(ttm, &tmp);
>> +	if (unlikely(r)) {
>>   		ttm_bo_mem_put(bo, &tmp);
>> -	else
>> -		bo->offset = (bo->mem.start << PAGE_SHIFT) +
>> -			bo->bdev->man[bo->mem.mem_type].gpu_offset;
>> +		return r;
>> +	}
>>
>> -	return r;
>> +	ttm_bo_mem_put(bo, bo_mem);
>> +	bo->mem = tmp;
>> +	bo->offset = (bo->mem.start << PAGE_SHIFT) +
>> +		bo->bdev->man[bo->mem.mem_type].gpu_offset;
>> +
>> +	return 0;
>>   }
>>
>>   int amdgpu_ttm_recover_gart(struct amdgpu_device *adev)
>> --
>> 2.7.4
>>
>> _______________________________________________
>> amd-gfx mailing list
>> amd-gfx@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
> -----Original Message-----

> From: Christian König [mailto:ckoenig.leichtzumerken@gmail.com]

> Sent: Thursday, October 26, 2017 2:39 PM

> To: Deucher, Alexander; 'Christian König'; amd-gfx@lists.freedesktop.org

> Subject: Re: [PATCH 5/8] drm/amdgpu: don't use ttm_bo_move_ttm in

> amdgpu_ttm_bind

> 

> Am 26.10.2017 um 20:11 schrieb Deucher, Alexander:

> >> -----Original Message-----

> >> From: amd-gfx [mailto:amd-gfx-bounces@lists.freedesktop.org] On

> Behalf

> >> Of Christian König

> >> Sent: Thursday, October 26, 2017 12:06 PM

> >> To: amd-gfx@lists.freedesktop.org

> >> Subject: [PATCH 5/8] drm/amdgpu: don't use ttm_bo_move_ttm in

> >> amdgpu_ttm_bind

> >>

> >> From: Christian König <christian.koenig@amd.com>

> >>

> >> Just unbind and rebind to force updates of the GART space.

> >>

> >> This prevents forcing the BO to be idle.

> > Is there a chance something could change like the caching on a  rebind that

> we need to account for?

> 

> Not that I could think of.

> 

> The new placement should have identical attributes to the old one, just

> with GART space allocated.


In that case,

Acked-by: Alex Deucher <alexander.deucher@amd.com>


> 

> Christian.

> 

> >

> > Alex

> >

> >> Signed-off-by: Christian König <christian.koenig@amd.com>

> >> ---

> >>   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 24

> ++++++++++++++++++-

> >> -----

> >>   1 file changed, 18 insertions(+), 6 deletions(-)

> >>

> >> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c

> >> b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c

> >> index 3045701..b40d2f3 100644

> >> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c

> >> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c

> >> @@ -917,14 +917,26 @@ int amdgpu_ttm_bind(struct ttm_buffer_object

> >> *bo, struct ttm_mem_reg *bo_mem)

> >>   	if (unlikely(r))

> >>   		return r;

> >>

> >> -	r = ttm_bo_move_ttm(bo, true, false, &tmp);

> >> -	if (unlikely(r))

> >> +	if (ttm->state == tt_bound) {

> >> +		r = ttm->func->unbind(ttm);

> >> +		if (unlikely(r))

> >> +			return r;

> >> +

> >> +		ttm->state = tt_unbound;

> >> +	}

> >> +

> >> +	r = ttm_tt_bind(ttm, &tmp);

> >> +	if (unlikely(r)) {

> >>   		ttm_bo_mem_put(bo, &tmp);

> >> -	else

> >> -		bo->offset = (bo->mem.start << PAGE_SHIFT) +

> >> -			bo->bdev->man[bo->mem.mem_type].gpu_offset;

> >> +		return r;

> >> +	}

> >>

> >> -	return r;

> >> +	ttm_bo_mem_put(bo, bo_mem);

> >> +	bo->mem = tmp;

> >> +	bo->offset = (bo->mem.start << PAGE_SHIFT) +

> >> +		bo->bdev->man[bo->mem.mem_type].gpu_offset;

> >> +

> >> +	return 0;

> >>   }

> >>

> >>   int amdgpu_ttm_recover_gart(struct amdgpu_device *adev)

> >> --

> >> 2.7.4

> >>

> >> _______________________________________________

> >> amd-gfx mailing list

> >> amd-gfx@lists.freedesktop.org

> >> https://lists.freedesktop.org/mailman/listinfo/amd-gfx

> > _______________________________________________

> > amd-gfx mailing list

> > amd-gfx@lists.freedesktop.org

> > https://lists.freedesktop.org/mailman/listinfo/amd-gfx

>