Convert DRM to XArray

Submitted by Matthew Wilcox on Feb. 21, 2019, 6:41 p.m.

Details

Reviewer None
Submitted Feb. 21, 2019, 6:41 p.m.
Last Updated Feb. 22, 2019, 8:22 a.m.
Revision 1

Cover Letter(s)

Revision 1
      I intend to remove the IDR and the radix tree interfaces from Linux.
Converting each user from either the IDR or radix tree interface varies
from the trivial 1:1 replacement to a complete rewrite of the locking.
Despite the best efforts of our automated testers (who have caught many
of my mistakes), I cannot claim that my conversions of code are free
from bugs.

Please check these patches over carefully and test them; there may be
off-by-one errors, locking mistakes, or various other failures on my part.
The patches are based on the latest XArray API which can be found here:
http://git.infradead.org/users/willy/linux-dax.git/shortlog/refs/heads/xarray
which I intend to submit during the upcoming merge window.

Substantive interface changes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 - The IDR and radix tree required callers to handle their own locking.
   The XArray embeds a spinlock which is taken for modifications to
   the data structure; plain lookups occur under the RCU read lock or
   under the spinlock.
 - You can take the spinlock yourself (xa_lock() and friends) to protect
   related data.
 - idr_alloc() returned -ENOSPC, radix_tree_insert() returned -EEXIST.
   xa_insert() and xa_alloc() return -EBUSY.
 - The search keys which the radix tree calls "tags", the XArray calls
   "marks".
 - There is no preloading in the XArray API.  If your locking is
   exceptionally complicated, you may need to use xa_reserve(), but
   there are only 6 callers of xa_reserve(), so it's quite uncommon.
 - The radix tree provided GFP flags as part of the tree definition;
   the XArray (like the IDR) passes GFP flags at the point of allocation.
 - radix_tree_insert() of a NULL pointer was not well-specified.  The
   XArray treats it as reserving the entry (it reads back as NULL but
   a subsequent xa_insert() to that slot will fail).
 - xa_alloc_cyclic() returns 1 if the allocation wraps, unlike
   idr_alloc_cyclic() which provides no indication.
 - There is no equivalent to idr_for_each(); the xa_for_each() iterator
   is similar to idr_for_each_entry().
 - idr_replace() has no exact equivalent.  Some users relied on its exact
   semantics of only storing if the entry was non-NULL, but all users of
   idr_replace() were able to use xa_store().
 - The family of radix tree gang lookup functions have been replaced with
   xa_extract().

Matthew Wilcox (34):
  drm: Convert drm_minors_idr to XArray
  drm: Convert aux_idr to XArray
  drm: Convert object_name_idr to XArray
  drm: Convert object_idr to XArray
  drm: Convert syncobj_idr to XArray
  drm: Convert magic_map to XArray
  drm: Convert lessee_idr to XArray
  drm: Remove linked lists for lessees
  drm: Convert ctx_idr to XArray
  drm: Convert tile_idr to XArray
  drm: Convert crtc_idr to XArray
  drm/agp: Convert bo_list_handles to XArray
  drm/amdgpu: Convert ctx_handles to XArray
  drm/amdgpu: Convert pasid_idr to XArray
  drm/amdkfd: Convert event_idr to XArray
  drm/amdkfd: Convert alloc_idr to XArray
  drm/etnaviv: Convert fence_idr to XArray
  drm/i915: Convert handles_vma to XArray
  drm/i915: Convert spt_tree to XArray
  drm/i915: Convert page_track_tree to XArray
  drm/i915: Convert get_page to XArray
  drm/i915: Convert object_idr to IDA
  drm/i915: Convert context_idr to XArray
  drm/i915: Convert metrics_idr to XArray
  drm/i915: Convert vgpus_idr to XArray
  drm/qxl: Convert release_idr to XArray
  drm/qxl: Convert surf_id_idr to XArray
  drm/tegra: Convert contexts IDR to XArray
  drm/vc4: Convert perfmon IDR to XArray
  drm/sis: Convert object_idr to XArray
  drm/vgem: Convert fence_idr to XArray
  drm/via: Convert object_idr to XArray
  drm/vmwgfx: Convert base IDR to XArray
  drm/vmwgfx: Convert res_idr to XArray

 Documentation/gpu/todo.rst                    |   3 -
 drivers/gpu/drm/amd/amdgpu/amdgpu.h           |   5 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c   |  22 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c       |  42 ++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h       |   2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c       |  23 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c       |  10 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c     |   4 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c        |  66 ++----
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h        |   3 +-
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c         |  12 +-
 drivers/gpu/drm/amd/amdkfd/kfd_events.c       |  71 +++----
 drivers/gpu/drm/amd/amdkfd/kfd_priv.h         |   4 +-
 drivers/gpu/drm/amd/amdkfd/kfd_process.c      |  32 ++-
 drivers/gpu/drm/drm_auth.c                    |  27 +--
 drivers/gpu/drm/drm_connector.c               |  27 +--
 drivers/gpu/drm/drm_context.c                 |  42 ++--
 drivers/gpu/drm/drm_debugfs.c                 |  19 +-
 drivers/gpu/drm/drm_dp_aux_dev.c              |  41 ++--
 drivers/gpu/drm/drm_drv.c                     |  49 ++---
 drivers/gpu/drm/drm_gem.c                     |  78 +++----
 drivers/gpu/drm/drm_lease.c                   | 201 ++++++++----------
 drivers/gpu/drm/drm_mode_config.c             |   6 +-
 drivers/gpu/drm/drm_mode_object.c             |  47 ++--
 drivers/gpu/drm/drm_syncobj.c                 |  64 ++----
 drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c  |  16 +-
 drivers/gpu/drm/etnaviv/etnaviv_gpu.c         |   5 +-
 drivers/gpu/drm/etnaviv/etnaviv_gpu.h         |   3 +-
 drivers/gpu/drm/etnaviv/etnaviv_sched.c       |   8 +-
 drivers/gpu/drm/i915/gvt/display.c            |   5 +-
 drivers/gpu/drm/i915/gvt/dmabuf.c             |   7 +-
 drivers/gpu/drm/i915/gvt/gtt.c                |  18 +-
 drivers/gpu/drm/i915/gvt/gtt.h                |   2 +-
 drivers/gpu/drm/i915/gvt/gvt.c                |   4 +-
 drivers/gpu/drm/i915/gvt/gvt.h                |   9 +-
 drivers/gpu/drm/i915/gvt/kvmgt.c              |   2 +-
 drivers/gpu/drm/i915/gvt/page_track.c         |   6 +-
 drivers/gpu/drm/i915/gvt/sched_policy.c       |   2 +-
 drivers/gpu/drm/i915/gvt/vgpu.c               |  24 +--
 drivers/gpu/drm/i915/i915_debugfs.c           |  48 +++--
 drivers/gpu/drm/i915/i915_drv.h               |   9 +-
 drivers/gpu/drm/i915/i915_gem.c               |  40 ++--
 drivers/gpu/drm/i915/i915_gem_context.c       |  43 ++--
 drivers/gpu/drm/i915/i915_gem_context.h       |   6 +-
 drivers/gpu/drm/i915/i915_gem_execbuffer.c    |   6 +-
 drivers/gpu/drm/i915/i915_gem_object.h        |   6 +-
 drivers/gpu/drm/i915/i915_perf.c              |  39 ++--
 .../gpu/drm/i915/selftests/i915_gem_context.c |   7 +-
 drivers/gpu/drm/i915/selftests/mock_context.c |   2 +-
 drivers/gpu/drm/msm/msm_gem_submit.c          |  12 +-
 drivers/gpu/drm/qxl/qxl_cmd.c                 |  60 ++----
 drivers/gpu/drm/qxl/qxl_drv.h                 |   6 +-
 drivers/gpu/drm/qxl/qxl_kms.c                 |   8 +-
 drivers/gpu/drm/qxl/qxl_release.c             |  54 ++---
 drivers/gpu/drm/sis/sis_drv.c                 |   4 +-
 drivers/gpu/drm/sis/sis_drv.h                 |   2 +-
 drivers/gpu/drm/sis/sis_mm.c                  |  17 +-
 drivers/gpu/drm/tegra/drm.c                   |  35 ++-
 drivers/gpu/drm/v3d/v3d_gem.c                 |  17 +-
 drivers/gpu/drm/vc4/vc4_drv.h                 |   2 +-
 drivers/gpu/drm/vc4/vc4_gem.c                 |   6 +-
 drivers/gpu/drm/vc4/vc4_perfmon.c             |  33 ++-
 drivers/gpu/drm/vgem/vgem_drv.h               |   3 +-
 drivers/gpu/drm/vgem/vgem_fence.c             |  43 ++--
 drivers/gpu/drm/via/via_drv.h                 |   2 +-
 drivers/gpu/drm/via/via_map.c                 |   4 +-
 drivers/gpu/drm/via/via_mm.c                  |  11 +-
 drivers/gpu/drm/vmwgfx/ttm_object.c           |  29 +--
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c           |   9 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h           |   3 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_resource.c      |  31 +--
 include/drm/drm_auth.h                        |  11 +-
 include/drm/drm_device.h                      |   4 +-
 include/drm/drm_file.h                        |  15 +-
 include/drm/drm_mode_config.h                 |  18 +-
 75 files changed, 673 insertions(+), 983 deletions(-)
    

Revisions

Patches download mbox

# Name Submitter State A F R T
[01/34] drm: Convert drm_minors_idr to XArray Matthew Wilcox New
[02/34] drm: Convert aux_idr to XArray Matthew Wilcox New
[03/34] drm: Convert object_name_idr to XArray Matthew Wilcox New
[04/34] drm: Convert object_idr to XArray Matthew Wilcox New
[05/34] drm: Convert syncobj_idr to XArray Matthew Wilcox New
[06/34] drm: Convert magic_map to XArray Matthew Wilcox New
[07/34] drm: Convert lessee_idr to XArray Matthew Wilcox New
[08/34] drm: Remove linked lists for lessees Matthew Wilcox New
[09/34] drm: Convert ctx_idr to XArray Matthew Wilcox New
[10/34] drm: Convert tile_idr to XArray Matthew Wilcox New
[11/34] drm: Convert crtc_idr to XArray Matthew Wilcox New
[12/34] drm/agp: Convert bo_list_handles to XArray Matthew Wilcox New
[13/34] drm/amdgpu: Convert ctx_handles to XArray Matthew Wilcox New
[14/34] drm/amdgpu: Convert pasid_idr to XArray Matthew Wilcox New
[15/34] drm/amdkfd: Convert event_idr to XArray Matthew Wilcox New
[16/34] drm/amdkfd: Convert alloc_idr to XArray Matthew Wilcox New
[17/34] drm/etnaviv: Convert fence_idr to XArray Matthew Wilcox New
[18/34] drm/i915: Convert handles_vma to XArray Matthew Wilcox New
[19/34] drm/i915: Convert spt_tree to XArray Matthew Wilcox New
[20/34] drm/i915: Convert page_track_tree to XArray Matthew Wilcox New
[21/34] drm/i915: Convert get_page to XArray Matthew Wilcox New
[22/34] drm/i915: Convert object_idr to IDA Matthew Wilcox New
[23/34] drm/i915: Convert context_idr to XArray Matthew Wilcox New
[24/34] drm/i915: Convert metrics_idr to XArray Matthew Wilcox New
[25/34] drm/i915: Convert vgpus_idr to XArray Matthew Wilcox New
[26/34] drm/qxl: Convert release_idr to XArray Matthew Wilcox New
[27/34] drm/qxl: Convert surf_id_idr to XArray Matthew Wilcox New
[28/34] drm/tegra: Convert contexts IDR to XArray Matthew Wilcox New
[29/34] drm/vc4: Convert perfmon IDR to XArray Matthew Wilcox New
[30/34] drm/sis: Convert object_idr to XArray Matthew Wilcox New
[31/34] drm/vgem: Convert fence_idr to XArray Matthew Wilcox New
[32/34] drm/via: Convert object_idr to XArray Matthew Wilcox New
[33/34] drm/vmwgfx: Convert base IDR to XArray Matthew Wilcox New
[34/34] drm/vmwgfx: Convert res_idr to XArray Matthew Wilcox New