1. 22 Feb, 2022 1 commit
    • Arunpravin's avatar
      drm: improve drm_buddy_alloc function · afea229f
      Arunpravin authored
      - Make drm_buddy_alloc a single function to handle
        range allocation and non-range allocation demands
      
      - Implemented a new function alloc_range() which allocates
        the requested power-of-two block comply with range limitations
      
      - Moved order computation and memory alignment logic from
        i915 driver to drm buddy
      
      v2:
        merged below changes to keep the build unbroken
         - drm_buddy_alloc_range() becomes obsolete and may be removed
         - enable ttm range allocation (fpfn / lpfn) support in i915 driver
         - apply enhanced drm_buddy_alloc() function to i915 driver
      
      v3(Matthew Auld):
        - Fix alignment issues and remove unnecessary list_empty check
        - add more validation checks for input arguments
        - make alloc_range() block allocations as bottom-up
        - optimize order computation logic
        - replace uint64_t with u64, which is preferred in the kernel
      
      v4(Matthew Auld):
        - keep drm_buddy_alloc_range() function implementation for generic
          actual range allocations
        - keep alloc_range() implementation for end bias allocations
      
      v5(Matthew Auld):
        - modify drm_buddy_alloc() passing argument place->lpfn to lpfn
          as place->lpfn will currently always be zero for i915
      
      v6(Matthew Auld):
        - fixup potential uaf - If we are unlucky and can't allocate
          enough memory when splitting blocks, where we temporarily
          end up with the given block and its buddy on the respective
          free list, then we need to ensure we delete both blocks,
          and no just the buddy, before potentially freeing them
      
        - fix warnings reported by kernel test robot <lkp@intel.com>
      
      v7(Matthew Auld):
        - revert fixup potential uaf
        - keep __alloc_range() add node to the list logic same as
          drm_buddy_alloc_blocks() by having a temporary list variable
        - at drm_buddy_alloc_blocks() keep i915 range_overflows macro
          and add a new check for end variable
      
      v8:
        - fix warnings reported by kernel test robot <lkp@intel.com>
      
      v9(Matthew Auld):
        - remove DRM_BUDDY_RANGE_ALLOCATION flag
        - remove unnecessary function description
      
      v10:
         - keep DRM_BUDDY_RANGE_ALLOCATION flag as removing the flag
           and replacing with (end < size) logic fails amdgpu driver load
      Signed-off-by: default avatarArunpravin <Arunpravin.PaneerSelvam@amd.com>
      Reviewed-by: default avatarMatthew Auld <matthew.auld@intel.com>
      Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20220221164552.2434-1-Arunpravin.PaneerSelvam@amd.com
      afea229f
  2. 21 Feb, 2022 1 commit
    • Ville Syrjälä's avatar
      drm/vc4: Use drm_mode_copy() · d8a8cf82
      Ville Syrjälä authored
      struct drm_display_mode embeds a list head, so overwriting
      the full struct with another one will corrupt the list
      (if the destination mode is on a list). Use drm_mode_copy()
      instead which explicitly preserves the list head of
      the destination mode.
      
      Even if we know the destination mode is not on any list
      using drm_mode_copy() seems decent as it sets a good
      example. Bad examples of not using it might eventually
      get copied into code where preserving the list head
      actually matters.
      
      Obviously one case not covered here is when the mode
      itself is embedded in a larger structure and the whole
      structure is copied. But if we are careful when copying
      into modes embedded in structures I think we can be a
      little more reassured that bogus list heads haven't been
      propagated in.
      
      @is_mode_copy@
      @@
      drm_mode_copy(...)
      {
      ...
      }
      
      @depends on !is_mode_copy@
      struct drm_display_mode *mode;
      expression E, S;
      @@
      (
      - *mode = E
      + drm_mode_copy(mode, &E)
      |
      - memcpy(mode, E, S)
      + drm_mode_copy(mode, E)
      )
      
      @depends on !is_mode_copy@
      struct drm_display_mode mode;
      expression E;
      @@
      (
      - mode = E
      + drm_mode_copy(&mode, &E)
      |
      - memcpy(&mode, E, S)
      + drm_mode_copy(&mode, E)
      )
      
      @@
      struct drm_display_mode *mode;
      @@
      - &*mode
      + mode
      
      Cc: Emma Anholt <emma@anholt.net>
      Cc: Maxime Ripard <mripard@kernel.org>
      Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
      Signed-off-by: default avatarMaxime Ripard <maxime@cerno.tech>
      Link: https://patchwork.freedesktop.org/patch/msgid/20220218100403.7028-18-ville.syrjala@linux.intel.com
      d8a8cf82
  3. 20 Feb, 2022 3 commits
  4. 16 Feb, 2022 12 commits
  5. 15 Feb, 2022 4 commits
  6. 14 Feb, 2022 16 commits
  7. 12 Feb, 2022 2 commits
  8. 11 Feb, 2022 1 commit