From patchwork Wed Sep 26 19:20:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Hellstrom X-Patchwork-Id: 10616571 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 21F3A174A for ; Wed, 26 Sep 2018 19:20:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1173A2B6E2 for ; Wed, 26 Sep 2018 19:20:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F2D332B670; Wed, 26 Sep 2018 19:20:30 +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 8272F2B620 for ; Wed, 26 Sep 2018 19:20:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 66FA86E007; Wed, 26 Sep 2018 19:20:06 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0058.outbound.protection.outlook.com [104.47.36.58]) by gabe.freedesktop.org (Postfix) with ESMTPS id 73D8C6E007 for ; Wed, 26 Sep 2018 19:20:04 +0000 (UTC) Received: from SN6PR05MB4589.namprd05.prod.outlook.com (52.135.75.151) by SN6PR05MB4336.namprd05.prod.outlook.com (52.135.73.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1185.16; Wed, 26 Sep 2018 19:20:02 +0000 Received: from SN6PR05MB4589.namprd05.prod.outlook.com ([fe80::38a5:a632:bd0f:c117]) by SN6PR05MB4589.namprd05.prod.outlook.com ([fe80::38a5:a632:bd0f:c117%4]) with mapi id 15.20.1207.006; Wed, 26 Sep 2018 19:20:02 +0000 From: Thomas Hellstrom To: linux-graphics-maintainer , "dri-devel@lists.freedesktop.org" Subject: [PATCH] drm/ttm, drm/vmwgfx: Move the lock- and object functionality to the vmwgfx driver Thread-Topic: [PATCH] drm/ttm, drm/vmwgfx: Move the lock- and object functionality to the vmwgfx driver Thread-Index: AQHUVc3ssXQ8TEBSRkS1yqOkfykdVw== Date: Wed, 26 Sep 2018 19:20:01 +0000 Message-ID: <20180926191930.52019-1-thellstrom@vmware.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: DM6PR08CA0023.namprd08.prod.outlook.com (2603:10b6:5:80::36) To SN6PR05MB4589.namprd05.prod.outlook.com (2603:10b6:805:38::23) x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [155.4.205.56] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; SN6PR05MB4336; 20:kx7w/MVsnrNy8TlxCEn1W/nQ7RUgzCHscDBVC+ZzIWPoXwYEwyml4jNHnVjYtGGqYfrgn7i+p1KXaOv7uyGTYDy0qM6vOzu+b6c8WrnD98eTZF1Ay9q2I7pH95wbmtv74cI/DiFprjjO/afoLSDk1p1Jod5n5QUKRzXYk/srFLc= x-ms-office365-filtering-correlation-id: e8b169de-9865-43cc-a997-08d623e50e15 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:SN6PR05MB4336; x-ms-traffictypediagnostic: SN6PR05MB4336: x-ld-processed: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0,ExtAddr bcl: 0 x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(767451399110)(61668805478150); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(10201501046)(93006095)(93001095)(3231355)(944501410)(52105095)(3002001)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(20161123564045)(20161123562045)(201708071742011)(7699051); SRVR:SN6PR05MB4336; BCL:0; PCL:0; RULEID:; SRVR:SN6PR05MB4336; x-forefront-prvs: 08076ABC99 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(979002)(136003)(376002)(346002)(39860400002)(396003)(366004)(199004)(189003)(5660300001)(4326008)(6512007)(105586002)(305945005)(7736002)(478600001)(106356001)(36756003)(386003)(6506007)(1857600001)(102836004)(26005)(476003)(2616005)(486006)(53936002)(81166006)(81156014)(52116002)(99286004)(575784001)(8676002)(86362001)(97736004)(8936002)(2501003)(68736007)(5024004)(14444005)(256004)(316002)(71190400001)(71200400001)(54906003)(2900100001)(3846002)(1076002)(6116002)(6436002)(2906002)(66066001)(6486002)(110136005)(14454004)(25786009)(5250100002)(34290500001)(40753002)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:SN6PR05MB4336; H:SN6PR05MB4589.namprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: vmware.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: 4e8W7tlfcyLad8d9Y4X3Ku5bUFhsBVkhm0Iad7cYH7uqOxiOvMiVlYRM9ApejKO//a5+IvX+DJIxDsUih6gaRkYlgMF1KNIyYtRmGQ8aZXqxwyn+aqC6owAt3mKrM5Sq55hIme/tmwAkMiDH+OCEKCKbR+hQ2V3Qzhzv3Y3+DdbR35nYiezm9uQ8MsHobFKAqKEiCOdHbXSgmqBFGpNrROnE5KtQsARPLr+eIy84lniB+N7dBXsRnkNx5lulJmdvb14jN6LDZ2wtHVV/u0hUU8bZBnPxT4g4sWcwE/xgT11H8vgj2Yt7dHVOQwm4ojhpaU7OcTxfzUjekPlAgWZ9DWVDHgOD8bwPmSBcvYHx5TY= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-ID: MIME-Version: 1.0 X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-Network-Message-Id: e8b169de-9865-43cc-a997-08d623e50e15 X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Sep 2018 19:20:01.9584 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR05MB4336 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 Hellstrom , =?utf-8?q?Christian_K=C3=B6nig?= Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP No other driver is using this functionality so move it out of TTM and into the vmwgfx driver. Update includes and remove exports. Also annotate to remove false static analyzer lock balance warnings. Cc: Christian König Signed-off-by: Thomas Hellstrom Reviewed-by: Christian König --- drivers/gpu/drm/ttm/Makefile | 4 ++-- drivers/gpu/drm/vmwgfx/Makefile | 3 ++- drivers/gpu/drm/{ttm => vmwgfx}/ttm_lock.c | 13 ++---------- .../ttm => drivers/gpu/drm/vmwgfx}/ttm_lock.h | 0 drivers/gpu/drm/{ttm => vmwgfx}/ttm_object.c | 20 +++---------------- .../gpu/drm/vmwgfx}/ttm_object.h | 3 +-- drivers/gpu/drm/vmwgfx/vmwgfx_bo.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 4 ++-- drivers/gpu/drm/vmwgfx/vmwgfx_prime.c | 2 +- 10 files changed, 15 insertions(+), 38 deletions(-) rename drivers/gpu/drm/{ttm => vmwgfx}/ttm_lock.c (95%) rename {include/drm/ttm => drivers/gpu/drm/vmwgfx}/ttm_lock.h (100%) rename drivers/gpu/drm/{ttm => vmwgfx}/ttm_object.c (96%) rename {include/drm/ttm => drivers/gpu/drm/vmwgfx}/ttm_object.h (99%) diff --git a/drivers/gpu/drm/ttm/Makefile b/drivers/gpu/drm/ttm/Makefile index a60e560804e0..01fc670ce7a2 100644 --- a/drivers/gpu/drm/ttm/Makefile +++ b/drivers/gpu/drm/ttm/Makefile @@ -4,8 +4,8 @@ ttm-y := ttm_memory.o ttm_tt.o ttm_bo.o \ ttm_bo_util.o ttm_bo_vm.o ttm_module.o \ - ttm_object.o ttm_lock.o ttm_execbuf_util.o ttm_page_alloc.o \ - ttm_bo_manager.o ttm_page_alloc_dma.o + ttm_execbuf_util.o ttm_page_alloc.o ttm_bo_manager.o \ + ttm_page_alloc_dma.o ttm-$(CONFIG_AGP) += ttm_agp_backend.o obj-$(CONFIG_DRM_TTM) += ttm.o diff --git a/drivers/gpu/drm/vmwgfx/Makefile b/drivers/gpu/drm/vmwgfx/Makefile index 09b2aa08363e..22fdc07e03ad 100644 --- a/drivers/gpu/drm/vmwgfx/Makefile +++ b/drivers/gpu/drm/vmwgfx/Makefile @@ -7,6 +7,7 @@ vmwgfx-y := vmwgfx_execbuf.o vmwgfx_gmr.o vmwgfx_kms.o vmwgfx_drv.o \ vmwgfx_surface.o vmwgfx_prime.o vmwgfx_mob.o vmwgfx_shader.o \ vmwgfx_cmdbuf_res.o vmwgfx_cmdbuf.o vmwgfx_stdu.o \ vmwgfx_cotable.o vmwgfx_so.o vmwgfx_binding.o vmwgfx_msg.o \ - vmwgfx_simple_resource.o vmwgfx_va.o vmwgfx_blit.o + vmwgfx_simple_resource.o vmwgfx_va.o vmwgfx_blit.o \ + ttm_object.o ttm_lock.o obj-$(CONFIG_DRM_VMWGFX) := vmwgfx.o diff --git a/drivers/gpu/drm/ttm/ttm_lock.c b/drivers/gpu/drm/vmwgfx/ttm_lock.c similarity index 95% rename from drivers/gpu/drm/ttm/ttm_lock.c rename to drivers/gpu/drm/vmwgfx/ttm_lock.c index 20694b8a01ca..0d59f5a19e17 100644 --- a/drivers/gpu/drm/ttm/ttm_lock.c +++ b/drivers/gpu/drm/vmwgfx/ttm_lock.c @@ -29,13 +29,13 @@ * Authors: Thomas Hellstrom */ -#include #include #include #include #include #include -#include +#include "ttm_lock.h" +#include "ttm_object.h" #define TTM_WRITE_LOCK_PENDING (1 << 0) #define TTM_VT_LOCK_PENDING (1 << 1) @@ -52,7 +52,6 @@ void ttm_lock_init(struct ttm_lock *lock) lock->kill_takers = false; lock->signal = SIGKILL; } -EXPORT_SYMBOL(ttm_lock_init); void ttm_read_unlock(struct ttm_lock *lock) { @@ -61,7 +60,6 @@ void ttm_read_unlock(struct ttm_lock *lock) wake_up_all(&lock->queue); spin_unlock(&lock->lock); } -EXPORT_SYMBOL(ttm_read_unlock); static bool __ttm_read_lock(struct ttm_lock *lock) { @@ -92,7 +90,6 @@ int ttm_read_lock(struct ttm_lock *lock, bool interruptible) wait_event(lock->queue, __ttm_read_lock(lock)); return ret; } -EXPORT_SYMBOL(ttm_read_lock); static bool __ttm_read_trylock(struct ttm_lock *lock, bool *locked) { @@ -144,7 +141,6 @@ void ttm_write_unlock(struct ttm_lock *lock) wake_up_all(&lock->queue); spin_unlock(&lock->lock); } -EXPORT_SYMBOL(ttm_write_unlock); static bool __ttm_write_lock(struct ttm_lock *lock) { @@ -185,7 +181,6 @@ int ttm_write_lock(struct ttm_lock *lock, bool interruptible) return ret; } -EXPORT_SYMBOL(ttm_write_lock); static int __ttm_vt_unlock(struct ttm_lock *lock) { @@ -262,14 +257,12 @@ int ttm_vt_lock(struct ttm_lock *lock, return ret; } -EXPORT_SYMBOL(ttm_vt_lock); int ttm_vt_unlock(struct ttm_lock *lock) { return ttm_ref_object_base_unref(lock->vt_holder, lock->base.hash.key, TTM_REF_USAGE); } -EXPORT_SYMBOL(ttm_vt_unlock); void ttm_suspend_unlock(struct ttm_lock *lock) { @@ -278,7 +271,6 @@ void ttm_suspend_unlock(struct ttm_lock *lock) wake_up_all(&lock->queue); spin_unlock(&lock->lock); } -EXPORT_SYMBOL(ttm_suspend_unlock); static bool __ttm_suspend_lock(struct ttm_lock *lock) { @@ -300,4 +292,3 @@ void ttm_suspend_lock(struct ttm_lock *lock) { wait_event(lock->queue, __ttm_suspend_lock(lock)); } -EXPORT_SYMBOL(ttm_suspend_lock); diff --git a/include/drm/ttm/ttm_lock.h b/drivers/gpu/drm/vmwgfx/ttm_lock.h similarity index 100% rename from include/drm/ttm/ttm_lock.h rename to drivers/gpu/drm/vmwgfx/ttm_lock.h diff --git a/drivers/gpu/drm/ttm/ttm_object.c b/drivers/gpu/drm/vmwgfx/ttm_object.c similarity index 96% rename from drivers/gpu/drm/ttm/ttm_object.c rename to drivers/gpu/drm/vmwgfx/ttm_object.c index 74f1b1eb1f8e..190e2591e1f5 100644 --- a/drivers/gpu/drm/ttm/ttm_object.c +++ b/drivers/gpu/drm/vmwgfx/ttm_object.c @@ -59,13 +59,12 @@ #define pr_fmt(fmt) "[TTM] " fmt -#include #include #include #include #include -#include #include +#include "ttm_object.h" struct ttm_object_file { struct ttm_object_device *tdev; @@ -194,7 +193,6 @@ int ttm_base_object_init(struct ttm_object_file *tfile, out_err0: return ret; } -EXPORT_SYMBOL(ttm_base_object_init); static void ttm_release_base(struct kref *kref) { @@ -225,7 +223,6 @@ void ttm_base_object_unref(struct ttm_base_object **p_base) kref_put(&base->refcount, ttm_release_base); } -EXPORT_SYMBOL(ttm_base_object_unref); struct ttm_base_object *ttm_base_object_lookup(struct ttm_object_file *tfile, uint32_t key) @@ -247,7 +244,6 @@ struct ttm_base_object *ttm_base_object_lookup(struct ttm_object_file *tfile, return base; } -EXPORT_SYMBOL(ttm_base_object_lookup); struct ttm_base_object * ttm_base_object_lookup_for_ref(struct ttm_object_device *tdev, uint32_t key) @@ -269,7 +265,6 @@ ttm_base_object_lookup_for_ref(struct ttm_object_device *tdev, uint32_t key) return base; } -EXPORT_SYMBOL(ttm_base_object_lookup_for_ref); /** * ttm_ref_object_exists - Check whether a caller has a valid ref object @@ -315,7 +310,6 @@ bool ttm_ref_object_exists(struct ttm_object_file *tfile, rcu_read_unlock(); return false; } -EXPORT_SYMBOL(ttm_ref_object_exists); int ttm_ref_object_add(struct ttm_object_file *tfile, struct ttm_base_object *base, @@ -391,9 +385,9 @@ int ttm_ref_object_add(struct ttm_object_file *tfile, return ret; } -EXPORT_SYMBOL(ttm_ref_object_add); -static void ttm_ref_object_release(struct kref *kref) +static void __releases(tfile->lock) __acquires(tfile->lock) +ttm_ref_object_release(struct kref *kref) { struct ttm_ref_object *ref = container_of(kref, struct ttm_ref_object, kref); @@ -435,7 +429,6 @@ int ttm_ref_object_base_unref(struct ttm_object_file *tfile, spin_unlock(&tfile->lock); return 0; } -EXPORT_SYMBOL(ttm_ref_object_base_unref); void ttm_object_file_release(struct ttm_object_file **p_tfile) { @@ -464,7 +457,6 @@ void ttm_object_file_release(struct ttm_object_file **p_tfile) ttm_object_file_unref(&tfile); } -EXPORT_SYMBOL(ttm_object_file_release); struct ttm_object_file *ttm_object_file_init(struct ttm_object_device *tdev, unsigned int hash_order) @@ -499,7 +491,6 @@ struct ttm_object_file *ttm_object_file_init(struct ttm_object_device *tdev, return NULL; } -EXPORT_SYMBOL(ttm_object_file_init); struct ttm_object_device * ttm_object_device_init(struct ttm_mem_global *mem_glob, @@ -530,7 +521,6 @@ ttm_object_device_init(struct ttm_mem_global *mem_glob, kfree(tdev); return NULL; } -EXPORT_SYMBOL(ttm_object_device_init); void ttm_object_device_release(struct ttm_object_device **p_tdev) { @@ -542,7 +532,6 @@ void ttm_object_device_release(struct ttm_object_device **p_tdev) kfree(tdev); } -EXPORT_SYMBOL(ttm_object_device_release); /** * get_dma_buf_unless_doomed - get a dma_buf reference if possible. @@ -648,7 +637,6 @@ int ttm_prime_fd_to_handle(struct ttm_object_file *tfile, return ret; } -EXPORT_SYMBOL_GPL(ttm_prime_fd_to_handle); /** * ttm_prime_handle_to_fd - Return a dma_buf fd from a ttm prime object @@ -739,7 +727,6 @@ int ttm_prime_handle_to_fd(struct ttm_object_file *tfile, ttm_base_object_unref(&base); return ret; } -EXPORT_SYMBOL_GPL(ttm_prime_handle_to_fd); /** * ttm_prime_object_init - Initialize a ttm_prime_object @@ -772,4 +759,3 @@ int ttm_prime_object_init(struct ttm_object_file *tfile, size_t size, ttm_prime_refcount_release, ref_obj_release); } -EXPORT_SYMBOL(ttm_prime_object_init); diff --git a/include/drm/ttm/ttm_object.h b/drivers/gpu/drm/vmwgfx/ttm_object.h similarity index 99% rename from include/drm/ttm/ttm_object.h rename to drivers/gpu/drm/vmwgfx/ttm_object.h index a98bfeb4239e..1c1b9cc118f8 100644 --- a/include/drm/ttm/ttm_object.h +++ b/drivers/gpu/drm/vmwgfx/ttm_object.h @@ -42,8 +42,7 @@ #include #include #include - -#include "ttm_memory.h" +#include /** * enum ttm_ref_type diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_bo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_bo.c index 2dda03345761..36e84acee3ea 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_bo.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_bo.c @@ -30,7 +30,7 @@ #include #include "vmwgfx_drv.h" -#include "drm/ttm/ttm_object.h" +#include "ttm_object.h" /** diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c index bb6dbbe18835..d9c178e235b4 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c @@ -30,9 +30,9 @@ #include #include "vmwgfx_drv.h" #include "vmwgfx_binding.h" +#include "ttm_object.h" #include #include -#include #include #include diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h index 1abe21758b0d..1aa11c39f07f 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h @@ -35,11 +35,11 @@ #include #include #include -#include -#include #include #include #include "vmwgfx_fence.h" +#include "ttm_object.h" +#include "ttm_lock.h" #include #define VMWGFX_DRIVER_NAME "vmwgfx" diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_prime.c b/drivers/gpu/drm/vmwgfx/vmwgfx_prime.c index 0861c821a7fe..e420675e8db3 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_prime.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_prime.c @@ -31,8 +31,8 @@ */ #include "vmwgfx_drv.h" +#include "ttm_object.h" #include -#include /* * DMA-BUF attach- and mapping methods. No need to implement