drm/buddy: Improve contiguous memory allocation
authorArunpravin Paneer Selvam <Arunpravin.PaneerSelvam@amd.com>
Sat, 9 Sep 2023 16:09:00 +0000 (09:09 -0700)
committerChristian König <christian.koenig@amd.com>
Mon, 11 Sep 2023 18:18:00 +0000 (20:18 +0200)
commit0a1844bf0b532d84324453374ad6845f64066c28
treede60b3dac8a0c7e7450c20439231aa7de0555985
parent6ae9f693ed4ff54f4bb0bd41e20da10733c49c0c
drm/buddy: Improve contiguous memory allocation

Problem statement: The current method roundup_power_of_two()
to allocate contiguous address triggers -ENOSPC in some cases
even though we have enough free spaces and so to help with
that we introduce a try harder mechanism.

In case of -ENOSPC, the new try harder mechanism rounddown the
original size to power of 2 and iterating over the round down
sized freelist blocks to allocate the required size traversing
RHS and LHS.

As part of the above new method implementation we moved
contiguous/alignment size computation part and trim function
to the drm buddy file.

v2: Modify the alloc_range() function to return total allocated size
    on -ENOSPC err and traverse RHS/LHS to allocate the required
    size (Matthew).

Signed-off-by: Arunpravin Paneer Selvam <Arunpravin.PaneerSelvam@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230909160902.15644-1-Arunpravin.PaneerSelvam@amd.com
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
Signed-off-by: Christian König <christian.koenig@amd.com>
drivers/gpu/drm/drm_buddy.c
include/drm/drm_buddy.h