[PATCH v2 2/6] drm/ttm: Implement intersect/compatible functions
Arunpravin Paneer Selvam
arunpravin.paneerselvam at amd.com
Tue Aug 9 08:26:36 UTC 2022
On 8/8/2022 5:00 PM, Christian König wrote:
>
>
> Am 25.07.22 um 13:42 schrieb Arunpravin Paneer Selvam:
>> Implemented a new intersect and compatible callback functions
>> to ttm range manager fetching start offset from drm mm range
>> allocator.
>>
>> Signed-off-by: Christian König <christian.koenig at amd.com>
>> Signed-off-by: Arunpravin Paneer Selvam
>> <Arunpravin.PaneerSelvam at amd.com>
>> ---
>> drivers/gpu/drm/ttm/ttm_range_manager.c | 33 +++++++++++++++++++++++++
>> 1 file changed, 33 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/ttm/ttm_range_manager.c
>> b/drivers/gpu/drm/ttm/ttm_range_manager.c
>> index d91666721dc6..12b8d9b36fe6 100644
>> --- a/drivers/gpu/drm/ttm/ttm_range_manager.c
>> +++ b/drivers/gpu/drm/ttm/ttm_range_manager.c
>> @@ -113,6 +113,37 @@ static void ttm_range_man_free(struct
>> ttm_resource_manager *man,
>> kfree(node);
>> }
>> +static bool ttm_range_man_intersect(struct ttm_resource_manager *man,
>> + struct ttm_resource *res,
>> + const struct ttm_place *place,
>> + size_t size)
>> +{
>> + struct drm_mm_node *node =
>> &to_ttm_range_mgr_node(res)->mm_nodes[0];
>> + u32 num_pages = PFN_UP(size);
>> +
>> + /* Don't evict BOs outside of the requested placement range */
>> + if (place->fpfn >= (node->start + num_pages) ||
>> + (place->lpfn && place->lpfn <= node->start))
>> + return false;
>> +
>> + return true;
>> +}
>> +
>> +static bool ttm_range_man_compatible(struct ttm_resource_manager *man,
>> + struct ttm_resource *res,
>> + const struct ttm_place *place,
>> + size_t size)
>> +{
>> + struct drm_mm_node *node =
>> &to_ttm_range_mgr_node(res)->mm_nodes[0];
>> + u32 num_pages = PFN_UP(size);
>> +
>> + if (node->start < place->fpfn ||
>
> This should probably be "<=".
We are checking the false condition here, if node->start == place->fpfn,
then the node->start
value is compatible with place->fpfn, therefore, we don't return false.
Thanks,
Arun
>
> Regards,
> Christian.
>
>> + (place->lpfn && (node->start + num_pages) > place->lpfn))
>> + return false;
>> +
>> + return true;
>> +}
>> +
>> static void ttm_range_man_debug(struct ttm_resource_manager *man,
>> struct drm_printer *printer)
>> {
>> @@ -126,6 +157,8 @@ static void ttm_range_man_debug(struct
>> ttm_resource_manager *man,
>> static const struct ttm_resource_manager_func
>> ttm_range_manager_func = {
>> .alloc = ttm_range_man_alloc,
>> .free = ttm_range_man_free,
>> + .intersect = ttm_range_man_intersect,
>> + .compatible = ttm_range_man_compatible,
>> .debug = ttm_range_man_debug
>> };
>
More information about the dri-devel
mailing list