diff options
author | Arunpravin Paneer Selvam <Arunpravin.PaneerSelvam@amd.com> | 2023-09-09 09:09:00 -0700 |
---|---|---|
committer | Christian König <christian.koenig@amd.com> | 2023-09-11 20:18:00 +0200 |
commit | 0a1844bf0b532d84324453374ad6845f64066c28 (patch) | |
tree | de60b3dac8a0c7e7450c20439231aa7de0555985 /include/drm/drm_buddy.h | |
parent | 6ae9f693ed4ff54f4bb0bd41e20da10733c49c0c (diff) | |
download | linux-stable-0a1844bf0b532d84324453374ad6845f64066c28.tar.gz linux-stable-0a1844bf0b532d84324453374ad6845f64066c28.tar.bz2 linux-stable-0a1844bf0b532d84324453374ad6845f64066c28.zip |
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>
Diffstat (limited to 'include/drm/drm_buddy.h')
-rw-r--r-- | include/drm/drm_buddy.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/include/drm/drm_buddy.h b/include/drm/drm_buddy.h index 572077ff8ae7..a5b39fc01003 100644 --- a/include/drm/drm_buddy.h +++ b/include/drm/drm_buddy.h @@ -22,8 +22,9 @@ start__ >= max__ || size__ > max__ - start__; \ }) -#define DRM_BUDDY_RANGE_ALLOCATION (1 << 0) -#define DRM_BUDDY_TOPDOWN_ALLOCATION (1 << 1) +#define DRM_BUDDY_RANGE_ALLOCATION BIT(0) +#define DRM_BUDDY_TOPDOWN_ALLOCATION BIT(1) +#define DRM_BUDDY_CONTIGUOUS_ALLOCATION BIT(2) struct drm_buddy_block { #define DRM_BUDDY_HEADER_OFFSET GENMASK_ULL(63, 12) @@ -155,5 +156,4 @@ void drm_buddy_print(struct drm_buddy *mm, struct drm_printer *p); void drm_buddy_block_print(struct drm_buddy *mm, struct drm_buddy_block *block, struct drm_printer *p); - #endif |