From patchwork Thu Feb 21 18:41:40 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: 10825443 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 44FFE139A for ; Fri, 22 Feb 2019 08:21:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 36BEF31B0B for ; Fri, 22 Feb 2019 08:21:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2B1E131B01; Fri, 22 Feb 2019 08:21:23 +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 C6D4131AF8 for ; Fri, 22 Feb 2019 08:21:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8A0E589333; 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 BCECC88F9A for ; Thu, 21 Feb 2019 18:42:31 +0000 (UTC) Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1gwtIl-0000dF-Aw; Thu, 21 Feb 2019 18:42:31 +0000 From: Matthew Wilcox To: dri-devel@lists.freedesktop.org Subject: [PATCH 10/34] drm: Convert tile_idr to XArray Date: Thu, 21 Feb 2019 10:41:40 -0800 Message-Id: <20190221184226.2149-21-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=MPO7TThXQaFN2WP/FlB8d/oTTPGTtN2z3lmnfrivX00=; b=ITM5H25QaoJMpjr6YhmxxZM2a iRIdF45scLUUyX1Z06BiHA/yOG07wuqkV/N+Dqtn05ttYkJnODl0TchuAKhjkMwp3Glr4IeAYUSaf 0rL5mHoehxMI3YD2KtV1DhNHQKCgH77TtFNDjaPIe8FAkk5AB7wXh4e1T6nfwiUcKESHvjvXrCPD+ ckEdkc3c8d4QNjGMiSYf7iDEb3qvX5UGGdawTSLjRMkBRxfNWeq9FH7IbyZn5+maXUH5TksDIrXg1 i/5JaK+ONjTPtiK4bjyKda5H9JNxLuLNnV0hv/W5B7CdLrFcDlLNWNarK5wFoxCQmktCIx4MbDq5v jmTRtZvlQ==; 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_connector.c | 27 +++++++++++---------------- drivers/gpu/drm/drm_mode_config.c | 3 +-- include/drm/drm_mode_config.h | 12 ++++++------ 3 files changed, 18 insertions(+), 24 deletions(-) diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c index da8ae80c2750..682eb79b721a 100644 --- a/drivers/gpu/drm/drm_connector.c +++ b/drivers/gpu/drm/drm_connector.c @@ -2019,9 +2019,7 @@ static void drm_tile_group_free(struct kref *kref) { struct drm_tile_group *tg = container_of(kref, struct drm_tile_group, refcount); struct drm_device *dev = tg->dev; - mutex_lock(&dev->mode_config.idr_mutex); - idr_remove(&dev->mode_config.tile_idr, tg->id); - mutex_unlock(&dev->mode_config.idr_mutex); + xa_erase(&dev->mode_config.tiles, tg->id); kfree(tg); } @@ -2053,18 +2051,18 @@ struct drm_tile_group *drm_mode_get_tile_group(struct drm_device *dev, char topology[8]) { struct drm_tile_group *tg; - int id; - mutex_lock(&dev->mode_config.idr_mutex); - idr_for_each_entry(&dev->mode_config.tile_idr, tg, id) { + unsigned long id; + + xa_lock(&dev->mode_config.tiles); + xa_for_each(&dev->mode_config.tiles, id, tg) { if (!memcmp(tg->group_data, topology, 8)) { if (!kref_get_unless_zero(&tg->refcount)) tg = NULL; - mutex_unlock(&dev->mode_config.idr_mutex); - return tg; + break; } } - mutex_unlock(&dev->mode_config.idr_mutex); - return NULL; + xa_unlock(&dev->mode_config.tiles); + return tg; } EXPORT_SYMBOL(drm_mode_get_tile_group); @@ -2093,16 +2091,13 @@ struct drm_tile_group *drm_mode_create_tile_group(struct drm_device *dev, memcpy(tg->group_data, topology, 8); tg->dev = dev; - mutex_lock(&dev->mode_config.idr_mutex); - ret = idr_alloc(&dev->mode_config.tile_idr, tg, 1, 0, GFP_KERNEL); - if (ret >= 0) { - tg->id = ret; - } else { + ret = xa_alloc(&dev->mode_config.tiles, &tg->id, tg, xa_limit_32b, + GFP_KERNEL); + if (ret < 0) { kfree(tg); tg = ERR_PTR(ret); } - mutex_unlock(&dev->mode_config.idr_mutex); return tg; } EXPORT_SYMBOL(drm_mode_create_tile_group); diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c index 703bfce975bb..609b30d7dcb1 100644 --- a/drivers/gpu/drm/drm_mode_config.c +++ b/drivers/gpu/drm/drm_mode_config.c @@ -394,7 +394,7 @@ void drm_mode_config_init(struct drm_device *dev) INIT_LIST_HEAD(&dev->mode_config.property_blob_list); INIT_LIST_HEAD(&dev->mode_config.plane_list); idr_init(&dev->mode_config.crtc_idr); - idr_init(&dev->mode_config.tile_idr); + xa_init_flags(&dev->mode_config.tiles, XA_FLAGS_ALLOC1); ida_init(&dev->mode_config.connector_ida); spin_lock_init(&dev->mode_config.connector_list_lock); @@ -495,7 +495,6 @@ void drm_mode_config_cleanup(struct drm_device *dev) } ida_destroy(&dev->mode_config.connector_ida); - idr_destroy(&dev->mode_config.tile_idr); idr_destroy(&dev->mode_config.crtc_idr); drm_modeset_lock_fini(&dev->mode_config.connection_mutex); } diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h index 572274ccbec7..fea334d99201 100644 --- a/include/drm/drm_mode_config.h +++ b/include/drm/drm_mode_config.h @@ -391,8 +391,8 @@ struct drm_mode_config { /** * @idr_mutex: * - * Mutex for KMS ID allocation and management. Protects both @crtc_idr - * and @tile_idr. + * Mutex for KMS ID allocation and management. Protects the + * objects in @objects. */ struct mutex idr_mutex; @@ -405,12 +405,12 @@ struct drm_mode_config { struct idr crtc_idr; /** - * @tile_idr: + * @tiles: * - * Use this idr for allocating new IDs for tiled sinks like use in some - * high-res DP MST screens. + * Use this for allocating new IDs for tiled sinks like those + * used in some high-res DP MST screens. */ - struct idr tile_idr; + struct xarray tiles; /** @fb_lock: Mutex to protect fb the global @fb_list and @num_fb. */ struct mutex fb_lock;