From patchwork Tue Apr 16 00:35:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karol Herbst X-Patchwork-Id: 10901763 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 ADD431800 for ; Tue, 16 Apr 2019 00:35:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9670628958 for ; Tue, 16 Apr 2019 00:35:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8AE5128961; Tue, 16 Apr 2019 00:35:41 +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 322C628958 for ; Tue, 16 Apr 2019 00:35:41 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BB7B1896A3; Tue, 16 Apr 2019 00:35:36 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9C65E89688 for ; Tue, 16 Apr 2019 00:35:34 +0000 (UTC) Received: by mail-wr1-f67.google.com with SMTP id q1so24376228wrp.0 for ; Mon, 15 Apr 2019 17:35:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wGObAQcYJ+O0NlolEVMOWXW81hMWX6w2HalvCHEr3o8=; b=Lda6ANNtwLY+VgzfTVZA9DM5CRoQCTxQGu/0ZRT7JVOl+I/lFJ4wrS8lXIREdbf7/F Q52Lf09XIHtiWQTfBgCrporlB5TIlhTWgEL0lbhZaerVCp45dTsz72E7b62leQ2MqGSj gaNwP0wqtOVZ/Ell6f8XLtXE6F3tnjI1xwp1Dx2UU9Ftmqqcdkl14ZHgJm2VymmRWFwb eai4IhLVLHXQJcvfFp+LbZ2ZCRzS1JdsfcLViGnGqMRKnwFSdh2GH+9spW2VpBNqlFiv Bq6dc4fHalykEeXtdw3GlOkIjKd8U7FHo1UOwt+zMjYM6CIZ6sQmv9msnq2lyu7gyzXj fGkg== X-Gm-Message-State: APjAAAXICaXEvOG/GmDYTNFy06l3WhFhC3otXDhfHnmsbQOaNLNAkR1c suhH6pJDFIglpeKxJbCkw5l9toqcEGs= X-Google-Smtp-Source: APXvYqzDhSd9cE0j1ziXbuYV8mP1ky1Kdfn+eSCz+tVbdKGdOvmbruvEFjAP3Nd9Lj9HsUvuDSiwyw== X-Received: by 2002:a5d:4750:: with SMTP id o16mr45696602wrs.206.1555374933132; Mon, 15 Apr 2019 17:35:33 -0700 (PDT) Received: from kherbst.pingu.com ([2a02:8308:b0be:6900:a1ae:358d:6041:7470]) by smtp.gmail.com with ESMTPSA id w2sm38801268wrm.74.2019.04.15.17.35.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 15 Apr 2019 17:35:32 -0700 (PDT) From: Karol Herbst To: dri-devel@lists.freedesktop.org Subject: [PATCH 4/6] Revert "drm/ttm: use a static ttm_bo_global instance" Date: Tue, 16 Apr 2019 02:35:21 +0200 Message-Id: <20190416003523.5069-5-kherbst@redhat.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190416003523.5069-1-kherbst@redhat.com> References: <20190416003523.5069-1-kherbst@redhat.com> MIME-Version: 1.0 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: Alex Deucher , Karol Herbst Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP This reverts commit 62b53b37e4b1500d4eb4624a44ad861cf8d3cd18. Signed-off-by: Karol Herbst --- drivers/gpu/drm/ttm/ttm_bo.c | 31 ++++++++----------------------- include/drm/ttm/ttm_bo_driver.h | 15 +++++++-------- 2 files changed, 15 insertions(+), 31 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 6941562ef2fa..c0efe4c89baf 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -49,9 +49,6 @@ static void ttm_bo_global_kobj_release(struct kobject *kobj); * ttm_global_mutex - protecting the global BO state */ DEFINE_MUTEX(ttm_global_mutex); -struct ttm_bo_global ttm_bo_glob = { - .use_count = 0 -}; static struct attribute ttm_bo_count = { .name = "bo_count", @@ -1531,35 +1528,22 @@ static void ttm_bo_global_kobj_release(struct kobject *kobj) kfree(glob); } -void ttm_bo_global_release(void) +void ttm_bo_global_release(struct ttm_bo_global *glob) { - struct ttm_bo_global *glob = &ttm_bo_glob; - - mutex_lock(&ttm_global_mutex); - if (--glob->use_count > 0) - goto out; - kobject_del(&glob->kobj); kobject_put(&glob->kobj); ttm_mem_global_release(&ttm_mem_glob); -out: - mutex_unlock(&ttm_global_mutex); } EXPORT_SYMBOL(ttm_bo_global_release); -int ttm_bo_global_init(void) +int ttm_bo_global_init(struct ttm_bo_global *glob) { - struct ttm_bo_global *glob = &ttm_bo_glob; - int ret = 0; + int ret; unsigned i; - mutex_lock(&ttm_global_mutex); - if (++glob->use_count > 1) - goto out; - ret = ttm_mem_global_init(&ttm_mem_glob); if (ret) - goto out; + return ret; spin_lock_init(&glob->lru_lock); glob->mem_glob = &ttm_mem_glob; @@ -1568,7 +1552,7 @@ int ttm_bo_global_init(void) if (unlikely(glob->dummy_read_page == NULL)) { ret = -ENOMEM; - goto out; + goto out_no_drp; } for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) @@ -1580,8 +1564,9 @@ int ttm_bo_global_init(void) &glob->kobj, &ttm_bo_glob_kobj_type, ttm_get_kobj(), "buffer_objects"); if (unlikely(ret != 0)) kobject_put(&glob->kobj); -out: - mutex_unlock(&ttm_global_mutex); + return ret; +out_no_drp: + kfree(glob); return ret; } EXPORT_SYMBOL(ttm_bo_global_init); diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h index 26be74939f10..9cec8835b88f 100644 --- a/include/drm/ttm/ttm_bo_driver.h +++ b/include/drm/ttm/ttm_bo_driver.h @@ -398,7 +398,7 @@ struct ttm_bo_driver { * @swap_lru: Lru list of buffer objects used for swapping. */ -extern struct ttm_bo_global { +struct ttm_bo_global { /** * Constant after init. @@ -410,9 +410,8 @@ extern struct ttm_bo_global { spinlock_t lru_lock; /** - * Protected by ttm_global_mutex. + * Protected by device_list_mutex. */ - unsigned int use_count; struct list_head device_list; /** @@ -424,7 +423,7 @@ extern struct ttm_bo_global { * Internal protection. */ atomic_t bo_count; -} ttm_bo_glob; +}; #define TTM_NUM_MEM_TYPES 8 @@ -569,8 +568,8 @@ void ttm_bo_mem_put(struct ttm_buffer_object *bo, struct ttm_mem_reg *mem); void ttm_bo_mem_put_locked(struct ttm_buffer_object *bo, struct ttm_mem_reg *mem); -void ttm_bo_global_release(void); -int ttm_bo_global_init(void); +void ttm_bo_global_release(struct ttm_bo_global *glob); +int ttm_bo_global_init(struct ttm_bo_global *glob); int ttm_bo_device_release(struct ttm_bo_device *bdev); @@ -907,7 +906,7 @@ struct ttm_bo_global_ref { */ static inline int ttm_bo_global_ref_init(struct drm_global_reference *ref) { - return ttm_bo_global_init(); + return ttm_bo_global_init(ref->object); } /** @@ -921,7 +920,7 @@ static inline int ttm_bo_global_ref_init(struct drm_global_reference *ref) */ static inline void ttm_bo_global_ref_release(struct drm_global_reference *ref) { - ttm_bo_global_release(); + ttm_bo_global_release(ref->object); } #endif