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 |
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; > >
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 --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;
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(+)