[PATCH 8/8] drm/amdgpu: add drm buddy support to amdgpu
Arunpravin
arunpravin.paneerselvam at amd.com
Mon Nov 8 22:08:41 UTC 2021
On 04/11/21 2:24 pm, Christian König wrote:
> Am 04.11.21 um 09:49 schrieb Matthew Auld:
>> On 04/11/2021 07:34, Christian König wrote:
>>>
>>>
>>> Am 03.11.21 um 20:25 schrieb Matthew Auld:
>>>> On 25/10/2021 14:00, Arunpravin wrote:
>>>>> - Remove drm_mm references and replace with drm buddy functionalities
>>>>> - Add res cursor support for drm buddy
>>>>>
>>>>> Signed-off-by: Arunpravin <Arunpravin.PaneerSelvam at amd.com>
>>>>
>>>> <snip>
>>>>
>>>>> + spin_lock(&mgr->lock);
>>>>> + r = drm_buddy_alloc(mm, (uint64_t)place->fpfn << PAGE_SHIFT,
>>>>> + (uint64_t)lpfn << PAGE_SHIFT,
>>>>> + (uint64_t)n_pages << PAGE_SHIFT,
>>>>> + min_page_size, &node->blocks,
>>>>> + node->flags);
>>>>
>>>>
>>>> Is spinlock + GFP_KERNEL allowed?
>>>
>>> Nope it isn't, but does that function really calls kmalloc()?
>>
>> It calls kmem_cache_zalloc(..., GFP_KERNEL)
>
> Oh that's bad. In this case we either need a mutex here or some other
> approach to avoid the allocation.
>
> Christian.
[Arun] I will replace spinlock with mutex
>
>>
>>>
>>> Christian.
>>>
>>>>
>>>>> + spin_unlock(&mgr->lock);
>>>>> +
>>>>> + if (unlikely(r))
>>>>> + goto error_free_blocks;
>>>>> +
>>>>> pages_left -= pages;
>>>>> ++i;
>>>>> if (pages > pages_left)
>>>>> pages = pages_left;
>>>>> }
>>>>> - spin_unlock(&mgr->lock);
>>>>> +
>>>>> + /* Free unused pages for contiguous allocation */
>>>>> + if (place->flags & TTM_PL_FLAG_CONTIGUOUS) {
>>>>> + uint64_t actual_size = (uint64_t)node->base.num_pages <<
>>>>> PAGE_SHIFT;
>>>>> +
>>>>> + r = drm_buddy_free_unused_pages(mm,
>>>>> + actual_size,
>>>>> + &node->blocks);
>>>>
>>>> Needs some locking.
[Arun] ok
>>>
>
More information about the dri-devel
mailing list