From patchwork Thu Feb 21 18:41:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 10825441 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 CC421139A for ; Fri, 22 Feb 2019 08:21:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BBC28311FE for ; Fri, 22 Feb 2019 08:21:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AD79431AED; Fri, 22 Feb 2019 08:21:21 +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 463A1311FE for ; Fri, 22 Feb 2019 08:21:21 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5B76189301; Fri, 22 Feb 2019 08:20:54 +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 4F39E8906D for ; Thu, 21 Feb 2019 18:42:34 +0000 (UTC) Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1gwtIn-0000fW-TW; Thu, 21 Feb 2019 18:42:33 +0000 From: Matthew Wilcox To: dri-devel@lists.freedesktop.org Subject: [PATCH 18/34] drm/i915: Convert handles_vma to XArray Date: Thu, 21 Feb 2019 10:41:56 -0800 Message-Id: <20190221184226.2149-37-willy@infradead.org> X-Mailer: git-send-email 2.14.5 In-Reply-To: <20190221184226.2149-1-willy@infradead.org> References: <20190221184226.2149-1-willy@infradead.org> 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=References:In-Reply-To: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:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=VFr0SPzG3t9/UZiNtoQm+54BQodXeIZV+WW7ZFTbpdU=; b=jRdufdMk6Zvv6mbzJZpSdQi1b 99jkXXn52yp8AGCyFxAV7e3pVPJFRyErRM5Ua5Io9TewNjkzF5v3s5gggiICv8s6tQb29Xc6jWJsg PVYpovgx+ltaYK++FTP6yN72SyWyGjPgNFOieGgpCAV8PsC4szO81x4EV2E1Kk+ohkLIb+wVXaO9R 69gI0IVCAJOrWXjAqhvB0MUWU47uZe+KPWVGswRS35cGicDUKJYYmjccVbJZ6hmhy+TLXNGUvHYKn CdR4RdNCHAAl36jYZUG22LjRa6EGqe4upuibsb4mPlAkpm7yso3Sny5UUvOK2U0qtDPeNHplruF4j vQFzmt3xw==; 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 Straightforward conversion. Signed-off-by: Matthew Wilcox --- drivers/gpu/drm/i915/i915_gem.c | 2 +- drivers/gpu/drm/i915/i915_gem_context.c | 12 +++++------- drivers/gpu/drm/i915/i915_gem_context.h | 4 ++-- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 6 +++--- drivers/gpu/drm/i915/selftests/mock_context.c | 2 +- 5 files changed, 12 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 216f52b744a6..0cdccc886587 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -3663,7 +3663,7 @@ void i915_gem_close_object(struct drm_gem_object *gem, struct drm_file *file) if (ctx->file_priv != fpriv) continue; - vma = radix_tree_delete(&ctx->handles_vma, lut->handle); + vma = xa_erase(&ctx->handles_vma, lut->handle); GEM_BUG_ON(vma->obj != obj); /* We allow the process to have multiple handles to the same diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c index 371c07087095..9db04b2e65cf 100644 --- a/drivers/gpu/drm/i915/i915_gem_context.c +++ b/drivers/gpu/drm/i915/i915_gem_context.c @@ -96,9 +96,9 @@ static void lut_close(struct i915_gem_context *ctx) { + XA_STATE(xas, &ctx->handles_vma, 0); struct i915_lut_handle *lut, *ln; - struct radix_tree_iter iter; - void __rcu **slot; + struct i915_vma *vma; list_for_each_entry_safe(lut, ln, &ctx->handles_list, ctx_link) { list_del(&lut->obj_link); @@ -106,10 +106,8 @@ static void lut_close(struct i915_gem_context *ctx) } rcu_read_lock(); - radix_tree_for_each_slot(slot, &ctx->handles_vma, &iter, 0) { - struct i915_vma *vma = rcu_dereference_raw(*slot); - - radix_tree_iter_delete(&ctx->handles_vma, &iter, slot); + xas_for_each(&xas, vma, ULONG_MAX) { + xas_store(&xas, NULL); __i915_gem_object_release_unless_active(vma->obj); } rcu_read_unlock(); @@ -345,7 +343,7 @@ __create_hw_context(struct drm_i915_private *dev_priv, ce->gem_context = ctx; } - INIT_RADIX_TREE(&ctx->handles_vma, GFP_KERNEL); + xa_init(&ctx->handles_vma); INIT_LIST_HEAD(&ctx->handles_list); INIT_LIST_HEAD(&ctx->hw_id_link); diff --git a/drivers/gpu/drm/i915/i915_gem_context.h b/drivers/gpu/drm/i915/i915_gem_context.h index f6d870b1f73e..ec22de370a22 100644 --- a/drivers/gpu/drm/i915/i915_gem_context.h +++ b/drivers/gpu/drm/i915/i915_gem_context.h @@ -194,11 +194,11 @@ struct i915_gem_context { /** remap_slice: Bitmask of cache lines that need remapping */ u8 remap_slice; - /** handles_vma: rbtree to look up our context specific obj/vma for + /** handles_vma: lookup our context specific obj/vma for * the user handle. (user handles are per fd, but the binding is * per vm, which may be one per context or shared with the global GTT) */ - struct radix_tree_root handles_vma; + struct xarray handles_vma; /** handles_list: reverse list of all the rbtree entries in use for * this context, which allows us to free all the allocations on diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c index 485b259127c3..8f136da3f73a 100644 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c @@ -756,7 +756,7 @@ static int eb_select_context(struct i915_execbuffer *eb) static int eb_lookup_vmas(struct i915_execbuffer *eb) { - struct radix_tree_root *handles_vma = &eb->ctx->handles_vma; + struct xarray *handles_vma = &eb->ctx->handles_vma; struct drm_i915_gem_object *obj; unsigned int i, batch; int err; @@ -777,7 +777,7 @@ static int eb_lookup_vmas(struct i915_execbuffer *eb) struct i915_lut_handle *lut; struct i915_vma *vma; - vma = radix_tree_lookup(handles_vma, handle); + vma = xa_load(handles_vma, handle); if (likely(vma)) goto add_vma; @@ -799,7 +799,7 @@ static int eb_lookup_vmas(struct i915_execbuffer *eb) goto err_obj; } - err = radix_tree_insert(handles_vma, handle, vma); + err = xa_err(xa_store(handles_vma, handle, vma, GFP_KERNEL)); if (unlikely(err)) { kmem_cache_free(eb->i915->luts, lut); goto err_obj; diff --git a/drivers/gpu/drm/i915/selftests/mock_context.c b/drivers/gpu/drm/i915/selftests/mock_context.c index d937bdff26f9..ab42ab625f25 100644 --- a/drivers/gpu/drm/i915/selftests/mock_context.c +++ b/drivers/gpu/drm/i915/selftests/mock_context.c @@ -41,7 +41,7 @@ mock_context(struct drm_i915_private *i915, INIT_LIST_HEAD(&ctx->link); ctx->i915 = i915; - INIT_RADIX_TREE(&ctx->handles_vma, GFP_KERNEL); + xa_init(&ctx->handles_vma); INIT_LIST_HEAD(&ctx->handles_list); INIT_LIST_HEAD(&ctx->hw_id_link);