From patchwork Thu Feb 21 18:41:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 10825457 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8F40A139A for ; Fri, 22 Feb 2019 08:21:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7C00B31B29 for ; Fri, 22 Feb 2019 08:21:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 70CAF31AF8; Fri, 22 Feb 2019 08:21:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D3C6D31AFD for ; Fri, 22 Feb 2019 08:21:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 88AB88933C; Fri, 22 Feb 2019 08:20:57 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by gabe.freedesktop.org (Postfix) with ESMTPS id 69F4A88F9A for ; Thu, 21 Feb 2019 18:42:28 +0000 (UTC) Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1gwtIh-0000a4-T2; Thu, 21 Feb 2019 18:42:27 +0000 From: Matthew Wilcox To: dri-devel@lists.freedesktop.org Subject: [PATCH 00/34] Convert DRM to XArray Date: Thu, 21 Feb 2019 10:41:20 -0800 Message-Id: <20190221184226.2149-1-willy@infradead.org> X-Mailer: git-send-email 2.14.5 X-Mailman-Approved-At: Fri, 22 Feb 2019 08:20:52 +0000 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=HGWT4Qe/dqwmhKygiHwuK8AstJX10mD1mKyXHXwnr6Q=; b=RHbS3KuEOz2LpXVU0qgf8ymCY klAYCn7cd/i7+BtCxT9D8FVko8uR6+Hml5LVEG5kXa4jlGjLeFhJJ9D/sIA9+AIgz+6+e78gUzgUs 5niswuJsD27VFZXrMQ4E+8RBvbrc3Hiqu5qChgyWzz0gL+kknqIos9dZPzkOWPe9qTsMgK0a2W7rv 32CzgK1maYRObA57iw+Y7g07cJ/IfdFrXNsNsOfX4+zP7GyCgQFpIhgoGEQUAynqioQWJ38kF1lnR P04JHiJy2omGhrUTmnt1RK3HpZGiryCB2XB3cLo6YnHhtUTnIxs516VrDupBQ3gLWvjlPBxNnLTZJ uTOujSW8g==; X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Matthew Wilcox MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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(-)