From patchwork Fri Oct 19 08:54:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 10648881 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 4272D13A4 for ; Fri, 19 Oct 2018 08:55:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 328BF28915 for ; Fri, 19 Oct 2018 08:55:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 26A0E28924; Fri, 19 Oct 2018 08:55:44 +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 C8E5928915 for ; Fri, 19 Oct 2018 08:55:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 78A916E2B5; Fri, 19 Oct 2018 08:54:45 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1859D6E2A1; Fri, 19 Oct 2018 08:54:44 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 9CDB9AD57; Fri, 19 Oct 2018 08:54:42 +0000 (UTC) From: Thomas Zimmermann To: christian.koenig@amd.com, ray.huang@amd.com, Jerry.Zhang@amd.com, alexander.deucher@amd.com, David1.Zhou@amd.com, airlied@linux.ie, kraxel@redhat.com, bskeggs@redhat.com, syeh@vmware.com, z.liuxinliang@hisilicon.com, zourongrong@gmail.com, kong.kongxinwei@hisilicon.com, puck.chen@hisilicon.com Subject: [PATCH 17/18] drm/ttm: Implement struct ttm_global with struct ttm_global_ref Date: Fri, 19 Oct 2018 10:54:22 +0200 Message-Id: <20181019085423.28159-18-tzimmermann@suse.de> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181019085423.28159-1-tzimmermann@suse.de> References: <20181019085423.28159-1-tzimmermann@suse.de> 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: Thomas Zimmermann , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Thomas Zimmermann --- drivers/gpu/drm/ttm/ttm_global.c | 28 +++++++++++++++------------- include/drm/ttm/ttm_global.h | 5 ++--- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_global.c b/drivers/gpu/drm/ttm/ttm_global.c index 1e5c2f5eeca0..93d268daf97b 100644 --- a/drivers/gpu/drm/ttm/ttm_global.c +++ b/drivers/gpu/drm/ttm/ttm_global.c @@ -129,19 +129,21 @@ static void ttm_global_item_unref( * struct ttm_global */ -static int ttm_global_init_mem(struct drm_global_reference *ref) +static DEFINE_TTM_GLOBAL_ITEM_ARRAY(global_items); + +static int ttm_global_init_mem(struct ttm_global_ref *ref) { BUG_ON(!ref->object); return ttm_mem_global_init(ref->object); } -static void ttm_global_release_mem(struct drm_global_reference *ref) +static void ttm_global_release_mem(struct ttm_global_ref *ref) { BUG_ON(!ref->object); ttm_mem_global_release(ref->object); } -static int ttm_global_init_bo(struct drm_global_reference *ref) +static int ttm_global_init_bo(struct ttm_global_ref *ref) { struct ttm_global *glob = container_of(ref, struct ttm_global, bo_ref); @@ -150,7 +152,7 @@ static int ttm_global_init_bo(struct drm_global_reference *ref) return ttm_bo_global_init(ref->object, glob->mem_ref.object); } -static void ttm_global_release_bo(struct drm_global_reference *ref) +static void ttm_global_release_bo(struct ttm_global_ref *ref) { BUG_ON(!ref->object); ttm_bo_global_release(ref->object); @@ -160,28 +162,28 @@ int ttm_global_init(struct ttm_global *glob) { int ret; - glob->mem_ref.global_type = DRM_GLOBAL_TTM_MEM; + glob->mem_ref.global_type = TTM_GLOBAL_MEM; glob->mem_ref.size = sizeof(struct ttm_mem_global); glob->bo_ref.object = NULL; glob->mem_ref.init = &ttm_global_init_mem; glob->mem_ref.release = &ttm_global_release_mem; - ret = drm_global_item_ref(&glob->mem_ref); + ret = ttm_global_item_ref(global_items, &glob->mem_ref); if (ret) return ret; - glob->bo_ref.global_type = DRM_GLOBAL_TTM_BO; + glob->bo_ref.global_type = TTM_GLOBAL_BO; glob->bo_ref.size = sizeof(struct ttm_bo_global); glob->bo_ref.object = NULL; glob->bo_ref.init = &ttm_global_init_bo; glob->bo_ref.release = &ttm_global_release_bo; - ret = drm_global_item_ref(&glob->bo_ref); + ret = ttm_global_item_ref(global_items, &glob->bo_ref); if (ret) - goto err_drm_global_item_unref_mem; + goto err_ttm_global_item_unref; return 0; -err_drm_global_item_unref_mem: - drm_global_item_unref(&glob->mem_ref); +err_ttm_global_item_unref: + ttm_global_item_unref(global_items, &glob->mem_ref); return ret; } @@ -189,8 +191,8 @@ EXPORT_SYMBOL(ttm_global_init); void ttm_global_release(struct ttm_global *glob) { - drm_global_item_unref(&glob->bo_ref); - drm_global_item_unref(&glob->mem_ref); + ttm_global_item_unref(global_items, &glob->bo_ref); + ttm_global_item_unref(global_items, &glob->mem_ref); } EXPORT_SYMBOL(ttm_global_release); diff --git a/include/drm/ttm/ttm_global.h b/include/drm/ttm/ttm_global.h index 9aa0ddbbe2ef..8dedac053611 100644 --- a/include/drm/ttm/ttm_global.h +++ b/include/drm/ttm/ttm_global.h @@ -28,7 +28,6 @@ #ifndef _TTM_GLOBAL_H_ #define _TTM_GLOBAL_H_ -#include #include #include @@ -58,8 +57,8 @@ struct ttm_bo_global; * struct ttm_global - Stores references to global TTM state */ struct ttm_global { - struct drm_global_reference mem_ref; - struct drm_global_reference bo_ref; + struct ttm_global_ref mem_ref; + struct ttm_global_ref bo_ref; }; /**