• Arunpravin Paneer Selvam's avatar
    drm/buddy: Implement tracking clear page feature · 96950929
    Arunpravin Paneer Selvam authored
    - Add tracking clear page feature.
    
    - Driver should enable the DRM_BUDDY_CLEARED flag if it
      successfully clears the blocks in the free path. On the otherhand,
      DRM buddy marks each block as cleared.
    
    - Track the available cleared pages size
    
    - If driver requests cleared memory we prefer cleared memory
      but fallback to uncleared if we can't find the cleared blocks.
      when driver requests uncleared memory we try to use uncleared but
      fallback to cleared memory if necessary.
    
    - When a block gets freed we clear it and mark the freed block as cleared,
      when there are buddies which are cleared as well we can merge them.
      Otherwise, we prefer to keep the blocks as separated.
    
    - Add a function to support defragmentation.
    
    v1:
      - Depends on the flag check DRM_BUDDY_CLEARED, enable the block as
        cleared. Else, reset the clear flag for each block in the list(Christian)
      - For merging the 2 cleared blocks compare as below,
        drm_buddy_is_clear(block) != drm_buddy_is_clear(buddy)(Christian)
      - Defragment the memory beginning from min_order
        till the required memory space is available.
    
    v2: (Matthew)
      - Add a wrapper drm_buddy_free_list_internal for the freeing of blocks
        operation within drm buddy.
      - Write a macro block_incompatible() to allocate the required blocks.
      - Update the xe driver for the drm_buddy_free_list change in arguments.
      - add a warning if the two blocks are incompatible on
        defragmentation
      - call full defragmentation in the fini() function
      - place a condition to test if min_order is equal to 0
      - replace the list with safe_reverse() variant as we might
        remove the block from the list.
    
    v3:
      - fix Gitlab user reported lockup issue.
      - Keep DRM_BUDDY_HEADER_CLEAR define sorted(Matthew)
      - modify to pass the root order instead max_order in fini()
        function(Matthew)
      - change bool 1 to true(Matthew)
      - add check if min_block_size is power of 2(Matthew)
      - modify the min_block_size datatype to u64(Matthew)
    
    v4:
      - rename the function drm_buddy_defrag with __force_merge.
      - Include __force_merge directly in drm buddy file and remove
        the defrag use in amdgpu driver.
      - Remove list_empty() check(Matthew)
      - Remove unnecessary space, headers and placement of new variables(Matthew)
      - Add a unit test case(Matthew)
    
    v5:
      - remove force merge support to actual range allocation and not to bail
        out when contains && split(Matthew)
      - add range support to force merge function.
    
    v6:
      - modify the alloc_range() function clear page non merged blocks
        allocation(Matthew)
      - correct the list_insert function name(Matthew).
    Signed-off-by: default avatarArunpravin Paneer Selvam <Arunpravin.PaneerSelvam@amd.com>
    Signed-off-by: default avatarMatthew Auld <matthew.auld@intel.com>
    Suggested-by: default avatarChristian König <christian.koenig@amd.com>
    Suggested-by: default avatarMatthew Auld <matthew.auld@intel.com>
    Reviewed-by: default avatarMatthew Auld <matthew.auld@intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20240419063538.11957-1-Arunpravin.PaneerSelvam@amd.comSigned-off-by: default avatarChristian König <christian.koenig@amd.com>
    96950929
amdgpu_vram_mgr.c 24.4 KB