From patchwork Thu Feb 21 18:41:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 10825447 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 286841390 for ; Fri, 22 Feb 2019 08:21:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1915E31B2A for ; Fri, 22 Feb 2019 08:21:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0D0A631B16; Fri, 22 Feb 2019 08:21:27 +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 9D3CE31B24 for ; Fri, 22 Feb 2019 08:21:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B882F89337; Fri, 22 Feb 2019 08:20:55 +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 93D3988F9A for ; Thu, 21 Feb 2019 18:42:30 +0000 (UTC) Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1gwtIk-0000bs-44; Thu, 21 Feb 2019 18:42:30 +0000 From: Matthew Wilcox To: dri-devel@lists.freedesktop.org Subject: [PATCH 07/34] drm: Convert lessee_idr to XArray Date: Thu, 21 Feb 2019 10:41:33 -0800 Message-Id: <20190221184226.2149-14-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=cp2HRc3lQRUOfLIWl2m5f4v+efAx0hHbTTHhtTt0uTk=; b=DlaYyfzQLKX7Z+A8Bhe1d5nfu rxg4MrYG4Vk+0qrJAAfXWKmmmccWDdLPA0iK2muGxwX45lLfx7jeeadxiCgdRscz9l3U3q7obPbR2 ip1yLWdtVRghzfXrDiYeErKDDZAzroN0IhtDzQ7DY8N+exbP40ex5RRWxjrwDZM8iHtvwuVI7Em99 4p5pkrjvS54qtVN2NT23vcJFWCePICaPXLiGODPTIokwmksH9DgNdiNYbr/xFHkN/VKejTfnL62t+ S5bcQRS2sTQpB4GLtvL3up4FxBmObz01u36b14BRjABMpRJJWqJ2kmb4VUg025u70UeZmBx4UZEFA e8HUaZFVg==; 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 Signed-off-by: Matthew Wilcox --- drivers/gpu/drm/drm_auth.c | 3 +-- drivers/gpu/drm/drm_lease.c | 15 ++++++--------- include/drm/drm_auth.h | 2 +- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/drm_auth.c b/drivers/gpu/drm/drm_auth.c index 268189e9e2e0..28767f55b30b 100644 --- a/drivers/gpu/drm/drm_auth.c +++ b/drivers/gpu/drm/drm_auth.c @@ -113,7 +113,7 @@ struct drm_master *drm_master_create(struct drm_device *dev) INIT_LIST_HEAD(&master->lessees); INIT_LIST_HEAD(&master->lessee_list); idr_init(&master->leases); - idr_init(&master->lessee_idr); + xa_init_flags(&master->lessee_xa, XA_FLAGS_ALLOC1); return master; } @@ -348,7 +348,6 @@ static void drm_master_destroy(struct kref *kref) drm_legacy_master_rmmaps(dev, master); idr_destroy(&master->leases); - idr_destroy(&master->lessee_idr); kfree(master->unique); kfree(master); diff --git a/drivers/gpu/drm/drm_lease.c b/drivers/gpu/drm/drm_lease.c index 99cba8ea5d82..c02587443b61 100644 --- a/drivers/gpu/drm/drm_lease.c +++ b/drivers/gpu/drm/drm_lease.c @@ -54,7 +54,7 @@ static struct drm_master* _drm_find_lessee(struct drm_master *master, int lessee_id) { lockdep_assert_held(&master->dev->mode_config.idr_mutex); - return idr_find(&drm_lease_owner(master)->lessee_idr, lessee_id); + return xa_load(&drm_lease_owner(master)->lessee_xa, lessee_id); } /** @@ -203,7 +203,6 @@ static struct drm_master *drm_lease_create(struct drm_master *lessor, struct idr int error; struct drm_master *lessee; int object; - int id; void *entry; DRM_DEBUG_LEASE("lessor %d\n", lessor->lessee_id); @@ -232,13 +231,11 @@ static struct drm_master *drm_lease_create(struct drm_master *lessor, struct idr } /* Insert the new lessee into the tree */ - id = idr_alloc(&(drm_lease_owner(lessor)->lessee_idr), lessee, 1, 0, GFP_KERNEL); - if (id < 0) { - error = id; + error = xa_alloc(&drm_lease_owner(lessor)->lessee_xa, + &lessee->lessee_id, lessee, xa_limit_32b, GFP_KERNEL); + if (error < 0) goto out_lessee; - } - lessee->lessee_id = id; lessee->lessor = drm_master_get(lessor); list_add_tail(&lessee->lessee_list, &lessor->lessees); @@ -279,10 +276,10 @@ void drm_lease_destroy(struct drm_master *master) */ WARN_ON(!list_empty(&master->lessees)); - /* Remove this master from the lessee idr in the owner */ + /* Remove this master from the lessee array in the owner */ if (master->lessee_id != 0) { DRM_DEBUG_LEASE("remove master %d from device list of lessees\n", master->lessee_id); - idr_remove(&(drm_lease_owner(master)->lessee_idr), master->lessee_id); + xa_erase(&drm_lease_owner(master)->lessee_xa, master->lessee_id); } /* Remove this master from any lessee list it may be on */ diff --git a/include/drm/drm_auth.h b/include/drm/drm_auth.h index c719fe375967..f1e092406caa 100644 --- a/include/drm/drm_auth.h +++ b/include/drm/drm_auth.h @@ -93,7 +93,7 @@ struct drm_master { struct list_head lessee_list; struct list_head lessees; struct idr leases; - struct idr lessee_idr; + struct xarray lessee_xa; }; struct drm_master *drm_master_get(struct drm_master *master);