[PATCH 01/10] drm/ttm: allocate resource object instead of embedding it v2

Christian König ckoenig.leichtzumerken at gmail.com
Fri Jun 4 11:54:57 UTC 2021



Am 03.06.21 um 10:45 schrieb Matthew Auld:
> On 02/06/2021 11:09, Christian König wrote:
>> [SNIP]
>> -/**
>> - * ttm_bo_mem_placement - check if placement is compatible
>> - * @bo: BO to find memory for
>> - * @place: where to search
>> - * @mem: the memory object to fill in
>> - *
>> - * Check if placement is compatible and fill in mem structure.
>> - * Returns -EBUSY if placement won't work or negative error code.
>> - * 0 when placement can be used.
>> - */
>> -static int ttm_bo_mem_placement(struct ttm_buffer_object *bo,
>> -                const struct ttm_place *place,
>> -                struct ttm_resource *mem)
>> -{
>> -    struct ttm_device *bdev = bo->bdev;
>> -    struct ttm_resource_manager *man;
>> -
>> -    man = ttm_manager_type(bdev, place->mem_type);
>> -    if (!man || !ttm_resource_manager_used(man))
>> -        return -EBUSY;
>> -
>> -    mem->mem_type = place->mem_type;
>> -    mem->placement = place->flags;
>> -
>> -    spin_lock(&bo->bdev->lru_lock);
>> -    ttm_bo_move_to_lru_tail(bo, mem, NULL);
>> -    spin_unlock(&bo->bdev->lru_lock);
>
> Why do we drop the move_to_lru_tail here?

Ah, good point.

The move_to_lru_tail() was here to make sure we see the BO in the new 
LRU instead of the old one before actually doing the move.

Since we haven't allocated the mem structure at this point that is no 
longer possible, but I think it is ok to do this for now.

One motivation of doing this is to move the LRU handling into the 
resource backend, so that tricks like those are not needed any more.

Regards,
Christian.


More information about the dri-devel mailing list