[PATCH 5/6] drm/ttm: replace dma_resv object on deleted BOs v2
Christian König
ckoenig.leichtzumerken at gmail.com
Tue Feb 11 15:15:17 UTC 2020
Am 11.02.20 um 15:14 schrieb Daniel Vetter:
> On Mon, Feb 10, 2020 at 04:09:06PM +0100, Christian König wrote:
>> When non-imported BOs are resurrected for delayed delete we replace
>> the dma_resv object to allow for easy reclaiming of the resources.
>>
>> v2: move that to ttm_bo_individualize_resv
>>
>> Signed-off-by: Christian König <christian.koenig at amd.com>
>> ---
>> drivers/gpu/drm/ttm/ttm_bo.c | 10 +++++++++-
>> 1 file changed, 9 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
>> index d0624685f5d2..4d161038de98 100644
>> --- a/drivers/gpu/drm/ttm/ttm_bo.c
>> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
>> @@ -393,6 +393,14 @@ static int ttm_bo_individualize_resv(struct ttm_buffer_object *bo)
>>
>> r = dma_resv_copy_fences(&bo->base._resv, bo->base.resv);
>> dma_resv_unlock(&bo->base._resv);
>> + if (r)
>> + return r;
>> +
>> + if (bo->type != ttm_bo_type_sg) {
>> + spin_lock(&ttm_bo_glob.lru_lock);
>> + bo->base.resv = &bo->base._resv;
> Having the dma_resv pointer be protected by the lru_lock for ttm internal
> stuff, but invariant everywhere else is really confusing. Not sure that's
> a great idea, I've just chased some ttm code around freaking out about
> that.
The key point is that the reference counter is zero in this moment.
Taking the LRU spinlock was just a precaution and might actually be not
even necessary here.
I will double check,
Christian.
> -Daniel
>
>> + spin_unlock(&ttm_bo_glob.lru_lock);
>> + }
>>
>> return r;
>> }
>> @@ -720,7 +728,7 @@ static bool ttm_bo_evict_swapout_allowable(struct ttm_buffer_object *bo,
>>
>> if (bo->base.resv == ctx->resv) {
>> dma_resv_assert_held(bo->base.resv);
>> - if (ctx->flags & TTM_OPT_FLAG_ALLOW_RES_EVICT || bo->deleted)
>> + if (ctx->flags & TTM_OPT_FLAG_ALLOW_RES_EVICT)
>> ret = true;
>> *locked = false;
>> if (busy)
>> --
>> 2.17.1
>>
>> _______________________________________________
>> dri-devel mailing list
>> dri-devel at lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/dri-devel
More information about the dri-devel
mailing list