[PATCH 13/59] drm/ttm: split the mm manager init code (v2)
Christian König
christian.koenig at amd.com
Tue Aug 4 13:08:11 UTC 2020
Am 04.08.20 um 13:07 schrieb Christian König:
> Am 04.08.20 um 04:55 schrieb Dave Airlie:
>> From: Dave Airlie <airlied at redhat.com>
>>
>> This will allow the driver to control the ordering here better.
>>
>> Eventually the old path will be removed.
>>
>> v2: add docs for new APIs.
>> rename new path to ttm_mem_type_manager_init/set_used(for now)
>>
>> Signed-off-by: Dave Airlie <airlied at redhat.com>
>
> Reviewed-by: Christian König <christian.koenig at amd.com>
BTW: I've just noticed that you (most likely) accidentally added a tab
after every use of ttm_mem_type_manager_set_used() in the follow up patches.
Not sure where this is coming from, but it annoys checkpatch quite a bit :)
Christian.
>
>> ---
>> drivers/gpu/drm/ttm/ttm_bo.c | 34 +++++++++++++++++++--------------
>> include/drm/ttm/ttm_bo_api.h | 15 +++++++++++++++
>> include/drm/ttm/ttm_bo_driver.h | 15 +++++++++++++++
>> 3 files changed, 50 insertions(+), 14 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
>> index 2ac70ec1f37d..300bcc10696a 100644
>> --- a/drivers/gpu/drm/ttm/ttm_bo.c
>> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
>> @@ -1509,35 +1509,41 @@ int ttm_bo_evict_mm(struct ttm_bo_device
>> *bdev, unsigned mem_type)
>> }
>> EXPORT_SYMBOL(ttm_bo_evict_mm);
>> -int ttm_bo_init_mm(struct ttm_bo_device *bdev, unsigned type,
>> - unsigned long p_size)
>> +void ttm_mem_type_manager_init(struct ttm_bo_device *bdev,
>> + struct ttm_mem_type_manager *man,
>> + unsigned long p_size)
>> {
>> - int ret;
>> - struct ttm_mem_type_manager *man;
>> unsigned i;
>> - BUG_ON(type >= TTM_NUM_MEM_TYPES);
>> - man = &bdev->man[type];
>> BUG_ON(man->has_type);
>> man->use_io_reserve_lru = false;
>> mutex_init(&man->io_reserve_mutex);
>> spin_lock_init(&man->move_lock);
>> INIT_LIST_HEAD(&man->io_reserve_lru);
>> man->bdev = bdev;
>> -
>> - if (type != TTM_PL_SYSTEM) {
>> - ret = (*man->func->init)(man, p_size);
>> - if (ret)
>> - return ret;
>> - }
>> - man->has_type = true;
>> - man->use_type = true;
>> man->size = p_size;
>> for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i)
>> INIT_LIST_HEAD(&man->lru[i]);
>> man->move = NULL;
>> +}
>> +EXPORT_SYMBOL(ttm_mem_type_manager_init);
>> +int ttm_bo_init_mm(struct ttm_bo_device *bdev, unsigned type,
>> + unsigned long p_size)
>> +{
>> + int ret;
>> + struct ttm_mem_type_manager *man;
>> +
>> + BUG_ON(type >= TTM_NUM_MEM_TYPES);
>> + ttm_mem_type_manager_init(bdev, &bdev->man[type], p_size);
>> +
>> + if (type != TTM_PL_SYSTEM) {
>> + ret = (*man->func->init)(man, p_size);
>> + if (ret)
>> + return ret;
>> + }
>> + ttm_mem_type_manager_set_used(man, true);
>> return 0;
>> }
>> EXPORT_SYMBOL(ttm_bo_init_mm);
>> diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h
>> index a9e13b252820..89053e761a69 100644
>> --- a/include/drm/ttm/ttm_bo_api.h
>> +++ b/include/drm/ttm/ttm_bo_api.h
>> @@ -54,6 +54,8 @@ struct ttm_place;
>> struct ttm_lru_bulk_move;
>> +struct ttm_mem_type_manager;
>> +
>> /**
>> * struct ttm_bus_placement
>> *
>> @@ -531,6 +533,19 @@ int ttm_bo_create(struct ttm_bo_device *bdev,
>> unsigned long size,
>> uint32_t page_alignment, bool interruptible,
>> struct ttm_buffer_object **p_bo);
>> +/**
>> + * ttm_mem_type_manager_init
>> + *
>> + * @bdev: Pointer to a ttm_bo_device struct.
>> + * @man: memory manager object to init
>> + * @p_size: size managed area in pages.
>> + *
>> + * Initialise core parts of a a manager object.
>> + */
>> +void ttm_mem_type_manager_init(struct ttm_bo_device *bdev,
>> + struct ttm_mem_type_manager *man,
>> + unsigned long p_size);
>> +
>> /**
>> * ttm_bo_init_mm
>> *
>> diff --git a/include/drm/ttm/ttm_bo_driver.h
>> b/include/drm/ttm/ttm_bo_driver.h
>> index 73f5d9c766cc..6b49c0356343 100644
>> --- a/include/drm/ttm/ttm_bo_driver.h
>> +++ b/include/drm/ttm/ttm_bo_driver.h
>> @@ -678,6 +678,21 @@ static inline void ttm_bo_unreserve(struct
>> ttm_buffer_object *bo)
>> dma_resv_unlock(bo->base.resv);
>> }
>> +/**
>> + * ttm_mem_type_manager_set_used
>> + *
>> + * @man: A memory manager object.
>> + * @used: usage state to set.
>> + *
>> + * Set the manager in use flag. If disabled the manager is no longer
>> + * used for object placement.
>> + */
>> +static inline void ttm_mem_type_manager_set_used(struct
>> ttm_mem_type_manager *man, bool used)
>> +{
>> + man->has_type = true;
>> + man->use_type = used;
>> +}
>> +
>> /*
>> * ttm_bo_util.c
>> */
>
More information about the dri-devel
mailing list