From patchwork Thu Feb 21 18:42:22 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: 10825481 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 900ED1390 for ; Fri, 22 Feb 2019 08:21:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8050131B35 for ; Fri, 22 Feb 2019 08:21:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7529B31B39; Fri, 22 Feb 2019 08:21:56 +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 26AD731B35 for ; Fri, 22 Feb 2019 08:21:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3C33489428; Fri, 22 Feb 2019 08:21:25 +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 C12348916A for ; Thu, 21 Feb 2019 18:42:38 +0000 (UTC) Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1gwtIs-0000jR-Bq; Thu, 21 Feb 2019 18:42:38 +0000 From: Matthew Wilcox To: dri-devel@lists.freedesktop.org Subject: [PATCH 32/34] drm/via: Convert object_idr to XArray Date: Thu, 21 Feb 2019 10:42:22 -0800 Message-Id: <20190221184226.2149-63-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=YGBEn8zwNDH22I27p2EsD5gWED6QZHjQqT5ZpsPrD3A=; b=AW/CcZepeTCR7J0VdSaiDo4sc 68pRiX0QwfFMDMkUHcfuf9hpguIBZezbxFpoiJp8GevSAP8nS7auUjXZIPtHfQ5X/DjWYl5yh2p16 j4GC+E9irQ/Id6rgbfBwRnnOHaix/BiZD43wf17XHrEkw70n+QONMPX42VbsUd0Co+Aszy3ClIf4K gfVgKGaQCIbEKkx3i/9rW32Z2ifwsvieuAFK4MLQk9o0UoifdQNs7eDVaJhccR7ufO869dRUl9Ceg +RAMyWllOndWi1w5ZP2m6eByQz31wg1a37owbAUyh5xmhNoyHaHVrfH0ZSBbhBCpK4rdgk9Luswk3 qnn5PatIA==; 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/via/via_drv.h | 2 +- drivers/gpu/drm/via/via_map.c | 4 +--- drivers/gpu/drm/via/via_mm.c | 11 +++++------ 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h index 6d1ae834484c..df0f451908e2 100644 --- a/drivers/gpu/drm/via/via_drv.h +++ b/drivers/gpu/drm/via/via_drv.h @@ -95,7 +95,7 @@ typedef struct drm_via_private { int agp_initialized; struct drm_mm agp_mm; /** Mapping of userspace keys to mm objects */ - struct idr object_idr; + struct xarray objects; unsigned long vram_offset; unsigned long agp_offset; drm_via_blitq_t blit_queues[VIA_NUM_BLIT_ENGINES]; diff --git a/drivers/gpu/drm/via/via_map.c b/drivers/gpu/drm/via/via_map.c index 2ad865870372..c47630105f5b 100644 --- a/drivers/gpu/drm/via/via_map.c +++ b/drivers/gpu/drm/via/via_map.c @@ -100,7 +100,7 @@ int via_driver_load(struct drm_device *dev, unsigned long chipset) if (dev_priv == NULL) return -ENOMEM; - idr_init(&dev_priv->object_idr); + xa_init_flags(&dev_priv->objects, XA_FLAGS_ALLOC1); dev->dev_private = (void *)dev_priv; dev_priv->chipset = chipset; @@ -120,7 +120,5 @@ void via_driver_unload(struct drm_device *dev) { drm_via_private_t *dev_priv = dev->dev_private; - idr_destroy(&dev_priv->object_idr); - kfree(dev_priv); } diff --git a/drivers/gpu/drm/via/via_mm.c b/drivers/gpu/drm/via/via_mm.c index 4217d66a5cc6..aaa90a096e52 100644 --- a/drivers/gpu/drm/via/via_mm.c +++ b/drivers/gpu/drm/via/via_mm.c @@ -148,10 +148,10 @@ int via_mem_alloc(struct drm_device *dev, void *data, if (retval) goto fail_alloc; - retval = idr_alloc(&dev_priv->object_idr, item, 1, 0, GFP_KERNEL); + retval = xa_alloc(&dev_priv->objects, &user_key, item, + xa_limit_31b, GFP_KERNEL); if (retval < 0) - goto fail_idr; - user_key = retval; + goto fail_xa; list_add(&item->owner_list, &file_priv->obj_list); mutex_unlock(&dev->struct_mutex); @@ -163,7 +163,7 @@ int via_mem_alloc(struct drm_device *dev, void *data, return 0; -fail_idr: +fail_xa: drm_mm_remove_node(&item->mm_node); fail_alloc: kfree(item); @@ -184,13 +184,12 @@ int via_mem_free(struct drm_device *dev, void *data, struct drm_file *file_priv) struct via_memblock *obj; mutex_lock(&dev->struct_mutex); - obj = idr_find(&dev_priv->object_idr, mem->index); + obj = xa_erase(&dev_priv->objects, mem->index); if (obj == NULL) { mutex_unlock(&dev->struct_mutex); return -EINVAL; } - idr_remove(&dev_priv->object_idr, mem->index); list_del(&obj->owner_list); drm_mm_remove_node(&obj->mm_node); kfree(obj);