diff mbox series

[6/8] drm/i915: add free_unused_pages support to i915

Message ID 20211025130033.1547667-4-Arunpravin.PaneerSelvam@amd.com (mailing list archive)
State New, archived
Headers show
Series [v2,1/8] drm: move the buddy allocator from i915 into common drm | expand

Commit Message

Paneer Selvam, Arunpravin Oct. 25, 2021, 1 p.m. UTC
add drm_buddy_free_unused_pages() support on
contiguous allocation

Signed-off-by: Arunpravin <Arunpravin.PaneerSelvam@amd.com>
---
 drivers/gpu/drm/i915/i915_ttm_buddy_manager.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Matthew Auld Nov. 3, 2021, 7:18 p.m. UTC | #1
On 25/10/2021 14:00, Arunpravin wrote:
> add drm_buddy_free_unused_pages() support on
> contiguous allocation
> 
> Signed-off-by: Arunpravin <Arunpravin.PaneerSelvam@amd.com>
> ---
>   drivers/gpu/drm/i915/i915_ttm_buddy_manager.c | 8 ++++++++
>   1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/gpu/drm/i915/i915_ttm_buddy_manager.c b/drivers/gpu/drm/i915/i915_ttm_buddy_manager.c
> index 963468228392..162947af8e04 100644
> --- a/drivers/gpu/drm/i915/i915_ttm_buddy_manager.c
> +++ b/drivers/gpu/drm/i915/i915_ttm_buddy_manager.c
> @@ -98,6 +98,14 @@ static int i915_ttm_buddy_man_alloc(struct ttm_resource_manager *man,
>   	if (unlikely(err))
>   		goto err_free_blocks;
>   
> +	if (place->flags & TTM_PL_FLAG_CONTIGUOUS) {
> +		err = drm_buddy_free_unused_pages(mm, (uint64_t)n_pages << PAGE_SHIFT,
> +						       &bman_res->blocks);
> +
> +		if (unlikely(err))
> +			goto err_free_blocks;

That needs some locking, mark_free/mark_split are all globally visible. 
Some concurrent user might steal the block, or worse.

> +	}
> +
>   	*res = &bman_res->base;
>   	return 0;
>   
>
Paneer Selvam, Arunpravin Nov. 8, 2021, 10:04 p.m. UTC | #2
On 04/11/21 12:48 am, Matthew Auld wrote:
> On 25/10/2021 14:00, Arunpravin wrote:
>> add drm_buddy_free_unused_pages() support on
>> contiguous allocation
>>
>> Signed-off-by: Arunpravin <Arunpravin.PaneerSelvam@amd.com>
>> ---
>>   drivers/gpu/drm/i915/i915_ttm_buddy_manager.c | 8 ++++++++
>>   1 file changed, 8 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/i915/i915_ttm_buddy_manager.c b/drivers/gpu/drm/i915/i915_ttm_buddy_manager.c
>> index 963468228392..162947af8e04 100644
>> --- a/drivers/gpu/drm/i915/i915_ttm_buddy_manager.c
>> +++ b/drivers/gpu/drm/i915/i915_ttm_buddy_manager.c
>> @@ -98,6 +98,14 @@ static int i915_ttm_buddy_man_alloc(struct ttm_resource_manager *man,
>>   	if (unlikely(err))
>>   		goto err_free_blocks;
>>   
>> +	if (place->flags & TTM_PL_FLAG_CONTIGUOUS) {
>> +		err = drm_buddy_free_unused_pages(mm, (uint64_t)n_pages << PAGE_SHIFT,
>> +						       &bman_res->blocks);
>> +
>> +		if (unlikely(err))
>> +			goto err_free_blocks;
> 
> That needs some locking, mark_free/mark_split are all globally visible. 
> Some concurrent user might steal the block, or worse.
[Arun] I will lock using mutex
> 
>> +	}
>> +
>>   	*res = &bman_res->base;
>>   	return 0;
>>   
>>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/i915_ttm_buddy_manager.c b/drivers/gpu/drm/i915/i915_ttm_buddy_manager.c
index 963468228392..162947af8e04 100644
--- a/drivers/gpu/drm/i915/i915_ttm_buddy_manager.c
+++ b/drivers/gpu/drm/i915/i915_ttm_buddy_manager.c
@@ -98,6 +98,14 @@  static int i915_ttm_buddy_man_alloc(struct ttm_resource_manager *man,
 	if (unlikely(err))
 		goto err_free_blocks;
 
+	if (place->flags & TTM_PL_FLAG_CONTIGUOUS) {
+		err = drm_buddy_free_unused_pages(mm, (uint64_t)n_pages << PAGE_SHIFT,
+						       &bman_res->blocks);
+
+		if (unlikely(err))
+			goto err_free_blocks;
+	}
+
 	*res = &bman_res->base;
 	return 0;