1. 25 Feb, 2022 7 commits
  2. 24 Feb, 2022 2 commits
  3. 23 Feb, 2022 9 commits
  4. 22 Feb, 2022 3 commits
    • Arunpravin's avatar
      drm: implement a method to free unused pages · 95ee2a8b
      Arunpravin authored
      On contiguous allocation, we round up the size
      to the *next* power of 2, implement a function
      to free the unused pages after the newly allocate block.
      
      v2(Matthew Auld):
        - replace function name 'drm_buddy_free_unused_pages' with
          drm_buddy_block_trim
        - replace input argument name 'actual_size' with 'new_size'
        - add more validation checks for input arguments
        - add overlaps check to avoid needless searching and splitting
        - merged the below patch to see the feature in action
           - add free unused pages support to i915 driver
        - lock drm_buddy_block_trim() function as it calls mark_free/mark_split
          are all globally visible
      
      v3(Matthew Auld):
        - remove trim method error handling as we address the failure case
          at drm_buddy_block_trim() function
      
      v4:
        - in case of trim, at __alloc_range() split_block failure path
          marks the block as free and removes it from the original list,
          potentially also freeing it, to overcome this problem, we turn
          the drm_buddy_block_trim() input node into a temporary node to
          prevent recursively freeing itself, but still retain the
          un-splitting/freeing of the other nodes(Matthew Auld)
      
        - modify the drm_buddy_block_trim() function return type
      
      v5(Matthew Auld):
        - revert drm_buddy_block_trim() function return type changes in v4
        - modify drm_buddy_block_trim() passing argument n_pages to original_size
          as n_pages has already been rounded up to the next power-of-two and
          passing n_pages results noop
      
      v6:
        - fix warnings reported by kernel test robot <lkp@intel.com>
      
      v7:
        - modify drm_buddy_block_trim() function doc description
        - at drm_buddy_block_trim() handle non-allocated block as
          a serious programmer error
        - fix a typo
      Signed-off-by: default avatarArunpravin <Arunpravin.PaneerSelvam@amd.com>
      Reviewed-by: default avatarMatthew Auld <matthew.auld@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20220221164552.2434-3-Arunpravin.PaneerSelvam@amd.comSigned-off-by: default avatarChristian König <christian.koenig@amd.com>
      95ee2a8b
    • Arunpravin's avatar
      drm: implement top-down allocation method · 476e4063
      Arunpravin authored
      Implemented a function which walk through the order list,
      compares the offset and returns the maximum offset block,
      this method is unpredictable in obtaining the high range
      address blocks which depends on allocation and deallocation.
      for instance, if driver requests address at a low specific
      range, allocator traverses from the root block and splits
      the larger blocks until it reaches the specific block and
      in the process of splitting, lower orders in the freelist
      are occupied with low range address blocks and for the
      subsequent TOPDOWN memory request we may return the low
      range blocks.To overcome this issue, we may go with the
      below approach.
      
      The other approach, sorting each order list entries in
      ascending order and compares the last entry of each
      order list in the freelist and return the max block.
      This creates sorting overhead on every drm_buddy_free()
      request and split up of larger blocks for a single page
      request.
      
      v2:
        - Fix alignment issues(Matthew Auld)
        - Remove unnecessary list_empty check(Matthew Auld)
        - merged the below patch to see the feature in action
           - add top-down alloc support to i915 driver
      Signed-off-by: default avatarArunpravin <Arunpravin.PaneerSelvam@amd.com>
      Reviewed-by: default avatarMatthew Auld <matthew.auld@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20220221164552.2434-2-Arunpravin.PaneerSelvam@amd.comSigned-off-by: default avatarChristian König <christian.koenig@amd.com>
      476e4063
    • 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
  5. 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
  6. 20 Feb, 2022 3 commits
  7. 16 Feb, 2022 12 commits
  8. 15 Feb, 2022 3 commits
    • Douglas Anderson's avatar
      drm/panel-edp: Allow querying the detected panel via debugfs · 6ed19359
      Douglas Anderson authored
      Recently we added generic "edp-panel"s probed by EDID. To support
      panels in this way we look at the panel ID in the EDID and look up the
      panel in a table that has power sequence timings. If we find a panel
      that's not in the table we will still attempt to use it but we'll use
      conservative timings. While it's likely that these conservative
      timings will work for most nearly all panels, the performance of
      turning the panel off and on suffers.
      
      We'd like to be able to reliably detect the case that we're using the
      hardcoded timings without relying on parsing dmesg. This allows us to
      implement tests that ensure that no devices get shipped that are
      relying on the conservative timings.
      
      Let's add a new debugfs entry to panel devices. It will have one of:
      * UNKNOWN - We tried to detect a panel but it wasn't in our table.
      * HARDCODED - We're not using generic "edp-panel" probed by EDID.
      * A panel name - This is the name of the panel from our table.
      Signed-off-by: default avatarDouglas Anderson <dianders@chromium.org>
      Reviewed-by: default avatarJavier Martinez Canillas <javierm@redhat.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20220204161245.v2.3.I209d72bcc571e1d7d6b793db71bf15c9c0fc9292@changeid
      6ed19359
    • Douglas Anderson's avatar
      drm: Plumb debugfs_init through to panels · 2509969a
      Douglas Anderson authored
      We'd like panels to be able to add things to debugfs underneath the
      connector's directory. Let's plumb it through. A panel will be able to
      put things in a "panel" directory under the connector's
      directory. Note that debugfs is not ABI and so it's always possible
      that the location that the panel gets for its debugfs could change in
      the future.
      
      NOTE: this currently only works if you're using a modern
      architecture. Specifically the plumbing relies on _both_
      drm_bridge_connector and drm_panel_bridge. If you're not using one or
      both of these things then things won't be plumbed through.
      
      As a side effect of this change, drm_bridges can also get callbacks to
      put stuff underneath the connector's debugfs directory. At the moment
      all bridges in the chain have their debugfs_init() called with the
      connector's root directory.
      Signed-off-by: default avatarDouglas Anderson <dianders@chromium.org>
      Reviewed-by: default avatarJavier Martinez Canillas <javierm@redhat.com>
      Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20220204161245.v2.2.Ib0bd5346135cbb0b63006b69b61d4c8af6484740@changeid
      2509969a
    • Douglas Anderson's avatar
      drm/bridge: ti-sn65dsi86: Use drm_bridge_connector · e283820c
      Douglas Anderson authored
      The ti-sn65dsi86 driver shouldn't hand-roll its own bridge
      connector. It should use the normal drm_bridge_connector. Let's switch
      to do that, removing all of the custom code.
      
      NOTE: this still _doesn't_ implement DRM_BRIDGE_ATTACH_NO_CONNECTOR
      support for ti-sn65dsi86 and that would still be a useful thing to do
      in the future. It was attempted in the past [1] but put on the back
      burner. However, unless we instantly change ti-sn65dsi86 fully from
      not supporting DRM_BRIDGE_ATTACH_NO_CONNECTOR at all to _only_
      supporting DRM_BRIDGE_ATTACH_NO_CONNECTOR then we'll still need a bit
      of time when we support both. This is a better way to support the old
      way where the driver hand rolls things itself.
      
      A new notes about the implementation here:
      * When using the drm_bridge_connector the connector should be created
        after all the bridges, so we change the ordering a bit.
      * I'm reasonably certain that we don't need to do anything to "free"
        the new drm_bridge_connector. If drm_bridge_connector_init() returns
        success then we know drm_connector_init() was called with the
        `drm_bridge_connector_funcs`. The `drm_bridge_connector_funcs` has a
        .destroy() that does all the cleanup. drm_connector_init() calls
        __drm_mode_object_add() with a drm_connector_free() that will call
        the .destroy().
      * I'm also reasonably certain that I don't need to "undo" the
        drm_bridge_attach() if drm_bridge_connector_init() fails. The
        "detach" function is private and other similar code doesn't try to
        undo the drm_bridge_attach() in error cases. There's also a comment
        indicating the lack of balance at the top of drm_bridge_attach().
      
      [1] https://lore.kernel.org/r/20210920225801.227211-4-robdclark@gmail.comSigned-off-by: default avatarDouglas Anderson <dianders@chromium.org>
      Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20220204161245.v2.1.I3ab26b7f197cc56c874246a43e57913e9c2c1028@changeid
      e283820c