From patchwork Tue Jul 27 12:10:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 12402583 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C9720C432BE for ; Tue, 27 Jul 2021 12:10:51 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 612C161A52 for ; Tue, 27 Jul 2021 12:10:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 612C161A52 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 68F616E883; Tue, 27 Jul 2021 12:10:46 +0000 (UTC) Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by gabe.freedesktop.org (Postfix) with ESMTPS id 245836E4AB for ; Tue, 27 Jul 2021 12:10:45 +0000 (UTC) Received: by mail-wm1-x335.google.com with SMTP id a80-20020a1c98530000b0290245467f26a4so2204618wme.0 for ; Tue, 27 Jul 2021 05:10:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=JiDTKh8DNOhbwBce61iq5CGtRilbbuE9UNuHZ6HhVL0=; b=cOQVX5C3T1KmMGo8NPBlovcwKRMSGfUCil140q8sXoifee3Sl+QU0Vwga0SVQAS+At YLBuoYWz46xi9r9bny9sTqT0PAx3dF2mSfD/5hKAewYSdSE9wf2M88e9Zn82F2wEfgRZ wyzdwaw3bmV38tU/nS6Ohy2khWbesIqSxTbbg= 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:mime-version :content-transfer-encoding; bh=JiDTKh8DNOhbwBce61iq5CGtRilbbuE9UNuHZ6HhVL0=; b=SSSMTsbBFsWJqkMph1MtoGEWZZzKQOx8Xad3BDDPd2BpMm9q3Q+NMWVC1fgyxvfbf+ 3YTmgCqIgBvd/D8gC0A2VvDINlf0TH3mJN8BjOGdOK8pi0No+KGKfNVT9VGU9lX8YBJv K9JXcg0Kxuxb4+Lyxfhq8J+Nb7lZGP8XliMFH/Y23XHD0B3dhJ0Eevpvd8mxcPSixoRW 2oqHIZULsZZxbvd4QtyIk2YmhSa6oziTssWv5tp+5zmLNSvXzfMaR+h81+F6m526kmIf Civ7L3ARrPTpWDy1ap/PEjkNzpRpVAnLO+XVxtETCWz7HTgIb5Sdp0OprcCkKsTOB+27 Hbuw== X-Gm-Message-State: AOAM531KZZphp5C+D7u8CI+rBbJeabN+bd1R9TXMjmBME2My27eyUysm VwBOjIdAvNmx609zxq09YKnzbUz+Tl3IRg== X-Google-Smtp-Source: ABdhPJxp+Q/ktPBo6GzEOYrWnpBFMlBC3/yNZurQF3GhvbX5jLGJYVm9DNakRussrlLFTOT1w1KdGQ== X-Received: by 2002:a7b:c1ca:: with SMTP id a10mr3943757wmj.0.1627387843562; Tue, 27 Jul 2021 05:10:43 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id k186sm3010577wme.45.2021.07.27.05.10.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jul 2021 05:10:42 -0700 (PDT) From: Daniel Vetter To: DRI Development Date: Tue, 27 Jul 2021 14:10:27 +0200 Message-Id: <20210727121037.2041102-1-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v2 01/11] drm/i915: Check for nomodeset in i915_init() first X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daniel Vetter , Intel Graphics Development , Daniel Vetter Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" When modesetting (aka the full pci driver, which has nothing to do with disable_display option, which just gives you the full pci driver without the display driver) is disabled, we load nothing and do nothing. So move that check first, for a bit of orderliness. With Jason's module init/exit table this now becomes trivial. Reviewed-by: Jason Ekstrand Cc: Jason Ekstrand Signed-off-by: Daniel Vetter --- drivers/gpu/drm/i915/i915_pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c index f28206484552..eb520fcb32e4 100644 --- a/drivers/gpu/drm/i915/i915_pci.c +++ b/drivers/gpu/drm/i915/i915_pci.c @@ -1293,9 +1293,9 @@ static const struct { int (*init)(void); void (*exit)(void); } init_funcs[] = { + { i915_check_nomodeset, NULL }, { i915_globals_init, i915_globals_exit }, { i915_mock_selftests, NULL }, - { i915_check_nomodeset, NULL }, { i915_pmu_init, i915_pmu_exit }, { i915_register_pci_driver, i915_unregister_pci_driver }, { i915_perf_sysctl_register, i915_perf_sysctl_unregister }, From patchwork Tue Jul 27 12:10:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 12402585 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A58AC4338F for ; Tue, 27 Jul 2021 12:10:53 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EAF5861A40 for ; Tue, 27 Jul 2021 12:10:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org EAF5861A40 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B01036E8BC; Tue, 27 Jul 2021 12:10:46 +0000 (UTC) Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by gabe.freedesktop.org (Postfix) with ESMTPS id 161C16E4AB for ; Tue, 27 Jul 2021 12:10:46 +0000 (UTC) Received: by mail-wm1-x335.google.com with SMTP id l11-20020a7bc34b0000b029021f84fcaf75so1713390wmj.1 for ; Tue, 27 Jul 2021 05:10:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dv6v6igQ1oKOZ1Eun+l9MhtnCwva3rhJyFEX4Pf2kQ0=; b=aFzCTrleOrI2z32bCgVx9p/g2hH1VRi9wHYhfCs0Pjoi+fEhqPeNFd4lUQijRIB3EQ Lu1j83gEtF9wXyJsGZgNFnneYPh/IRXjzWhxLYbJStSMwv8csawIH/e+5/iYqUM+/hIy lEcDDNFxhD8gYvzcf8tu4/xENb0Kqy1dRqGVY= 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=dv6v6igQ1oKOZ1Eun+l9MhtnCwva3rhJyFEX4Pf2kQ0=; b=GCtx4zJ4sfj9o8y/RZei2fJvlrM2TyuP+wpOHwdpKIWPBxhOUuxu9759abo0A4igKO xrUu1PtDlxO+YIyXnXFpTviC+/j/w0VBVlnvSMII4e6nBzYKuW+exBujE8uKnmsq4lCe Cgm+rWiefBm4tzTz5ST7fuesvU8wgeP1zBC1BNyQhxMs2vwSlOhwHfRi4qA7MBn71mMs bhQeMU3rlorodNZrlRRtj9jS+pQjtl5zqq4KhrHul7SO+LJ4mzBDlSmodGv4qzfNtkYc pYEXx0/Toq+nzzObBZf0l/Rf/9QxWWkdNz2YSFOtGffw1cc63Tlb/d6aOepqqfj79CJ7 8rWg== X-Gm-Message-State: AOAM532ETU2b0U7izdpDiMy4C4RXwFB1CE0Cth8Un4m+KpxFYBYMyRSN q8lm9R9fVplZ7/Wm41KV6hjTpQ== X-Google-Smtp-Source: ABdhPJw52+IyaRzEIS3K2HqWrpga4Pu1Of3wXi6MHgYRBZuFv0SIyY5taAASC3x4OBivQ/OLJ6JFPA== X-Received: by 2002:a05:600c:5106:: with SMTP id o6mr3724746wms.18.1627387844472; Tue, 27 Jul 2021 05:10:44 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id k186sm3010577wme.45.2021.07.27.05.10.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jul 2021 05:10:43 -0700 (PDT) From: Daniel Vetter To: DRI Development Date: Tue, 27 Jul 2021 14:10:28 +0200 Message-Id: <20210727121037.2041102-2-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210727121037.2041102-1-daniel.vetter@ffwll.ch> References: <20210727121037.2041102-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v2 02/11] drm/i915: move i915_active slab to direct module init/exit X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daniel Vetter , Intel Graphics Development , Daniel Vetter Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" With the global kmem_cache shrink infrastructure gone there's nothing special and we can convert them over. I'm doing this split up into each patch because there's quite a bit of noise with removing the static global.slab_cache to just a slab_cache. v2: Make slab static (Jason, 0day) Reviewed-by: Jason Ekstrand Cc: Jason Ekstrand Signed-off-by: Daniel Vetter --- drivers/gpu/drm/i915/i915_active.c | 31 ++++++++++------------------- drivers/gpu/drm/i915/i915_active.h | 3 +++ drivers/gpu/drm/i915/i915_globals.c | 2 -- drivers/gpu/drm/i915/i915_globals.h | 1 - drivers/gpu/drm/i915/i915_pci.c | 2 ++ 5 files changed, 16 insertions(+), 23 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_active.c b/drivers/gpu/drm/i915/i915_active.c index 91723123ae9f..3103c1e1fd14 100644 --- a/drivers/gpu/drm/i915/i915_active.c +++ b/drivers/gpu/drm/i915/i915_active.c @@ -13,7 +13,6 @@ #include "i915_drv.h" #include "i915_active.h" -#include "i915_globals.h" /* * Active refs memory management @@ -22,10 +21,7 @@ * they idle (when we know the active requests are inactive) and allocate the * nodes from a local slab cache to hopefully reduce the fragmentation. */ -static struct i915_global_active { - struct i915_global base; - struct kmem_cache *slab_cache; -} global; +static struct kmem_cache *slab_cache; struct active_node { struct rb_node node; @@ -174,7 +170,7 @@ __active_retire(struct i915_active *ref) /* Finally free the discarded timeline tree */ rbtree_postorder_for_each_entry_safe(it, n, &root, node) { GEM_BUG_ON(i915_active_fence_isset(&it->base)); - kmem_cache_free(global.slab_cache, it); + kmem_cache_free(slab_cache, it); } } @@ -322,7 +318,7 @@ active_instance(struct i915_active *ref, u64 idx) * XXX: We should preallocate this before i915_active_ref() is ever * called, but we cannot call into fs_reclaim() anyway, so use GFP_ATOMIC. */ - node = kmem_cache_alloc(global.slab_cache, GFP_ATOMIC); + node = kmem_cache_alloc(slab_cache, GFP_ATOMIC); if (!node) goto out; @@ -788,7 +784,7 @@ void i915_active_fini(struct i915_active *ref) mutex_destroy(&ref->mutex); if (ref->cache) - kmem_cache_free(global.slab_cache, ref->cache); + kmem_cache_free(slab_cache, ref->cache); } static inline bool is_idle_barrier(struct active_node *node, u64 idx) @@ -908,7 +904,7 @@ int i915_active_acquire_preallocate_barrier(struct i915_active *ref, node = reuse_idle_barrier(ref, idx); rcu_read_unlock(); if (!node) { - node = kmem_cache_alloc(global.slab_cache, GFP_KERNEL); + node = kmem_cache_alloc(slab_cache, GFP_KERNEL); if (!node) goto unwind; @@ -956,7 +952,7 @@ int i915_active_acquire_preallocate_barrier(struct i915_active *ref, atomic_dec(&ref->count); intel_engine_pm_put(barrier_to_engine(node)); - kmem_cache_free(global.slab_cache, node); + kmem_cache_free(slab_cache, node); } return -ENOMEM; } @@ -1176,21 +1172,16 @@ struct i915_active *i915_active_create(void) #include "selftests/i915_active.c" #endif -static void i915_global_active_exit(void) +void i915_active_module_exit(void) { - kmem_cache_destroy(global.slab_cache); + kmem_cache_destroy(slab_cache); } -static struct i915_global_active global = { { - .exit = i915_global_active_exit, -} }; - -int __init i915_global_active_init(void) +int __init i915_active_module_init(void) { - global.slab_cache = KMEM_CACHE(active_node, SLAB_HWCACHE_ALIGN); - if (!global.slab_cache) + slab_cache = KMEM_CACHE(active_node, SLAB_HWCACHE_ALIGN); + if (!slab_cache) return -ENOMEM; - i915_global_register(&global.base); return 0; } diff --git a/drivers/gpu/drm/i915/i915_active.h b/drivers/gpu/drm/i915/i915_active.h index d0feda68b874..5fcdb0e2bc9e 100644 --- a/drivers/gpu/drm/i915/i915_active.h +++ b/drivers/gpu/drm/i915/i915_active.h @@ -247,4 +247,7 @@ static inline int __i915_request_await_exclusive(struct i915_request *rq, return err; } +void i915_active_module_exit(void); +int i915_active_module_init(void); + #endif /* _I915_ACTIVE_H_ */ diff --git a/drivers/gpu/drm/i915/i915_globals.c b/drivers/gpu/drm/i915/i915_globals.c index 91198f5b0a06..a53135ee831d 100644 --- a/drivers/gpu/drm/i915/i915_globals.c +++ b/drivers/gpu/drm/i915/i915_globals.c @@ -7,7 +7,6 @@ #include #include -#include "i915_active.h" #include "i915_buddy.h" #include "gem/i915_gem_context.h" #include "gem/i915_gem_object.h" @@ -34,7 +33,6 @@ static void __i915_globals_cleanup(void) } static __initconst int (* const initfn[])(void) = { - i915_global_active_init, i915_global_buddy_init, i915_global_context_init, i915_global_gem_context_init, diff --git a/drivers/gpu/drm/i915/i915_globals.h b/drivers/gpu/drm/i915/i915_globals.h index 9e6b4fd07528..d80901ba75e3 100644 --- a/drivers/gpu/drm/i915/i915_globals.h +++ b/drivers/gpu/drm/i915/i915_globals.h @@ -23,7 +23,6 @@ int i915_globals_init(void); void i915_globals_exit(void); /* constructors */ -int i915_global_active_init(void); int i915_global_context_init(void); int i915_global_gem_context_init(void); int i915_global_objects_init(void); diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c index eb520fcb32e4..2a1726e9ae7f 100644 --- a/drivers/gpu/drm/i915/i915_pci.c +++ b/drivers/gpu/drm/i915/i915_pci.c @@ -30,6 +30,7 @@ #include "display/intel_fbdev.h" +#include "i915_active.h" #include "i915_drv.h" #include "i915_perf.h" #include "i915_globals.h" @@ -1294,6 +1295,7 @@ static const struct { void (*exit)(void); } init_funcs[] = { { i915_check_nomodeset, NULL }, + { i915_active_module_init, i915_active_module_exit }, { i915_globals_init, i915_globals_exit }, { i915_mock_selftests, NULL }, { i915_pmu_init, i915_pmu_exit }, From patchwork Tue Jul 27 12:10:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 12402587 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5EF50C4320E for ; Tue, 27 Jul 2021 12:10:54 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 18BB161A40 for ; Tue, 27 Jul 2021 12:10:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 18BB161A40 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 05E076E4AB; Tue, 27 Jul 2021 12:10:49 +0000 (UTC) Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by gabe.freedesktop.org (Postfix) with ESMTPS id B98776E970 for ; Tue, 27 Jul 2021 12:10:46 +0000 (UTC) Received: by mail-wm1-x329.google.com with SMTP id o5-20020a1c4d050000b02901fc3a62af78so1696997wmh.3 for ; Tue, 27 Jul 2021 05:10:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mNVrIcj1pM8WYclTTCmxK+L8lzh0ZRJ/UCcPzQqMreA=; b=FrG/ZZXywf2MhdC82d4m8InqcyFYKEH8aeDCunxW8v7MG7QwwYuerM72gC2JNBi5Nq DAoNmFw9wmHO60siYyvKIBZl75BSqXDojRm4UTc5JHNUdHg5+N7Ei+Yvi2UcPuf/OCH+ bIcLZoDA6UDwSlVQoBEYWXr/qFKKHYxezdrE8= 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=mNVrIcj1pM8WYclTTCmxK+L8lzh0ZRJ/UCcPzQqMreA=; b=fwMLyELCbXPNohyPODIi+gFsDPB/iyMtcseHW/poXzX4AduVRXPv9bm8y79y51Vux+ CBL3MBnyAeRoawqO2o+XIjz7zZYk5fR+8BrYTcWGAbp6JkJUiIyTAUKssUIblkQitUtK JWFA4SmL5c9LkApX7UCg6sJCRWpZvsommGKVV051fViJxl2pLljS4XBkt7nXlHAHSjPE NLRSVEhrqRpJNB6mAMn2S9yRjgS0NV42E5B/DZum+A65ZlYK28INjorwKhYnbBgk40tv cKqMLkwCND1mWq6XTQ4uGr1W2MflG13/EYBbVaNjm1wxFEgiLCoLYf1rk/7VYxpHQ0S+ fw6w== X-Gm-Message-State: AOAM530mIcst1NCR98U/qN1/HtZzBuUZ6WOPTIZM+HV7A7uKuBFh75fN KtTkwUsSGRmxjF+04jmgXLtdMw== X-Google-Smtp-Source: ABdhPJzV3TxFIPbXnTnmpGNDfMJDllcxdMNyj9Zq0jBbVDEV14jOCtxlj52HyieU1Vslm/JtdThaOg== X-Received: by 2002:a05:600c:4304:: with SMTP id p4mr21762682wme.93.1627387845217; Tue, 27 Jul 2021 05:10:45 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id k186sm3010577wme.45.2021.07.27.05.10.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jul 2021 05:10:44 -0700 (PDT) From: Daniel Vetter To: DRI Development Date: Tue, 27 Jul 2021 14:10:29 +0200 Message-Id: <20210727121037.2041102-3-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210727121037.2041102-1-daniel.vetter@ffwll.ch> References: <20210727121037.2041102-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v2 03/11] drm/i915: move i915_buddy slab to direct module init/exit X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daniel Vetter , Intel Graphics Development , Daniel Vetter Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" With the global kmem_cache shrink infrastructure gone there's nothing special and we can convert them over. I'm doing this split up into each patch because there's quite a bit of noise with removing the static global.slab_blocks to just a slab_blocks. v2: Make slab static (Jason, 0day) Reviewed-by: Jason Ekstrand Cc: Jason Ekstrand Signed-off-by: Daniel Vetter --- drivers/gpu/drm/i915/i915_buddy.c | 25 ++++++++----------------- drivers/gpu/drm/i915/i915_buddy.h | 3 ++- drivers/gpu/drm/i915/i915_globals.c | 2 -- drivers/gpu/drm/i915/i915_pci.c | 2 ++ 4 files changed, 12 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_buddy.c b/drivers/gpu/drm/i915/i915_buddy.c index caabcaea3be7..7b274c51cac0 100644 --- a/drivers/gpu/drm/i915/i915_buddy.c +++ b/drivers/gpu/drm/i915/i915_buddy.c @@ -8,13 +8,9 @@ #include "i915_buddy.h" #include "i915_gem.h" -#include "i915_globals.h" #include "i915_utils.h" -static struct i915_global_buddy { - struct i915_global base; - struct kmem_cache *slab_blocks; -} global; +static struct kmem_cache *slab_blocks; static struct i915_buddy_block *i915_block_alloc(struct i915_buddy_mm *mm, struct i915_buddy_block *parent, @@ -25,7 +21,7 @@ static struct i915_buddy_block *i915_block_alloc(struct i915_buddy_mm *mm, GEM_BUG_ON(order > I915_BUDDY_MAX_ORDER); - block = kmem_cache_zalloc(global.slab_blocks, GFP_KERNEL); + block = kmem_cache_zalloc(slab_blocks, GFP_KERNEL); if (!block) return NULL; @@ -40,7 +36,7 @@ static struct i915_buddy_block *i915_block_alloc(struct i915_buddy_mm *mm, static void i915_block_free(struct i915_buddy_mm *mm, struct i915_buddy_block *block) { - kmem_cache_free(global.slab_blocks, block); + kmem_cache_free(slab_blocks, block); } static void mark_allocated(struct i915_buddy_block *block) @@ -410,21 +406,16 @@ int i915_buddy_alloc_range(struct i915_buddy_mm *mm, #include "selftests/i915_buddy.c" #endif -static void i915_global_buddy_exit(void) +void i915_buddy_module_exit(void) { - kmem_cache_destroy(global.slab_blocks); + kmem_cache_destroy(slab_blocks); } -static struct i915_global_buddy global = { { - .exit = i915_global_buddy_exit, -} }; - -int __init i915_global_buddy_init(void) +int __init i915_buddy_module_init(void) { - global.slab_blocks = KMEM_CACHE(i915_buddy_block, 0); - if (!global.slab_blocks) + slab_blocks = KMEM_CACHE(i915_buddy_block, 0); + if (!slab_blocks) return -ENOMEM; - i915_global_register(&global.base); return 0; } diff --git a/drivers/gpu/drm/i915/i915_buddy.h b/drivers/gpu/drm/i915/i915_buddy.h index d8f26706de52..3940d632f208 100644 --- a/drivers/gpu/drm/i915/i915_buddy.h +++ b/drivers/gpu/drm/i915/i915_buddy.h @@ -129,6 +129,7 @@ void i915_buddy_free(struct i915_buddy_mm *mm, struct i915_buddy_block *block); void i915_buddy_free_list(struct i915_buddy_mm *mm, struct list_head *objects); -int i915_global_buddy_init(void); +void i915_buddy_module_exit(void); +int i915_buddy_module_init(void); #endif diff --git a/drivers/gpu/drm/i915/i915_globals.c b/drivers/gpu/drm/i915/i915_globals.c index a53135ee831d..3de7cf22ec76 100644 --- a/drivers/gpu/drm/i915/i915_globals.c +++ b/drivers/gpu/drm/i915/i915_globals.c @@ -7,7 +7,6 @@ #include #include -#include "i915_buddy.h" #include "gem/i915_gem_context.h" #include "gem/i915_gem_object.h" #include "i915_globals.h" @@ -33,7 +32,6 @@ static void __i915_globals_cleanup(void) } static __initconst int (* const initfn[])(void) = { - i915_global_buddy_init, i915_global_context_init, i915_global_gem_context_init, i915_global_objects_init, diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c index 2a1726e9ae7f..22d9e769ec74 100644 --- a/drivers/gpu/drm/i915/i915_pci.c +++ b/drivers/gpu/drm/i915/i915_pci.c @@ -31,6 +31,7 @@ #include "display/intel_fbdev.h" #include "i915_active.h" +#include "i915_buddy.h" #include "i915_drv.h" #include "i915_perf.h" #include "i915_globals.h" @@ -1296,6 +1297,7 @@ static const struct { } init_funcs[] = { { i915_check_nomodeset, NULL }, { i915_active_module_init, i915_active_module_exit }, + { i915_buddy_module_init, i915_buddy_module_exit }, { i915_globals_init, i915_globals_exit }, { i915_mock_selftests, NULL }, { i915_pmu_init, i915_pmu_exit }, From patchwork Tue Jul 27 12:10:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 12402591 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E7EA9C4320A for ; Tue, 27 Jul 2021 12:11:07 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BBCB361A57 for ; Tue, 27 Jul 2021 12:11:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org BBCB361A57 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6FFB16E9D8; Tue, 27 Jul 2021 12:10:54 +0000 (UTC) Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by gabe.freedesktop.org (Postfix) with ESMTPS id 868896E4AB for ; Tue, 27 Jul 2021 12:10:47 +0000 (UTC) Received: by mail-wm1-x334.google.com with SMTP id b128so7421761wmb.4 for ; Tue, 27 Jul 2021 05:10:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=b4BwgseNz9tJsNOjDw1A2uU3vIb1IHlokt9Elg8K+yQ=; b=IHVMAc4S24tVJ4JIp0FPvfq8qvGZYmhH/g0xVdxjMYWJ099WlxpXfqlaCe/Ik/lUku 9DHT+/4DMOh1j0npWX8nDANvoblAc0DMp0VdsMS/Szj/tzEJUvvclknCsLgK/hhT4DLM 7ev8AQJYwfQ8rAT6CENXMcA95TnHNS1DbnUY0= 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=b4BwgseNz9tJsNOjDw1A2uU3vIb1IHlokt9Elg8K+yQ=; b=qsrnvFm5luYj/noDVQWvqoL6hqc2QJncXNRBuG9oAAwp2PROF8eebAVHMIh80ym18M 9vae3SgeWqIxrhNul2JublJdmlk6zbB3QhN2vj8BrpD7KuCBvjqlpnzCpTRchJaMOfYc uCCYKUISH4hcUoVE2aXlpsidBpqMOfvoei07hfIJ1Be+sy4Sq1xk6jvn7zZQvR+xDRkt j2ap1+iYJrQSD8pCgXWw/w7GZPKPYXW1hROaFLSvTyDUksxvzPsgmYteiWsrCKc08AGl Ez46OkwJfz7PruMnK8VNC02gxECVenWKcRwREIGb9t87s4CnkfhfuyHMh4W15E7JL2u+ bftA== X-Gm-Message-State: AOAM533GOOsSE4N0XJklJ2tncVRmd7py75Ok7yinHtuBRsLsilk+gu/e 7hwDhPcUWsnbv1Hl7xSfNIILfQ== X-Google-Smtp-Source: ABdhPJysM+TotvnCKn5Ve7JdXjzsRWD/SmaR3SKti4oXk/OjRtkeuyPmNzFlYhSI2WFRIqBHO1yS+g== X-Received: by 2002:a7b:cb92:: with SMTP id m18mr21857468wmi.29.1627387846091; Tue, 27 Jul 2021 05:10:46 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id k186sm3010577wme.45.2021.07.27.05.10.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jul 2021 05:10:45 -0700 (PDT) From: Daniel Vetter To: DRI Development Date: Tue, 27 Jul 2021 14:10:30 +0200 Message-Id: <20210727121037.2041102-4-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210727121037.2041102-1-daniel.vetter@ffwll.ch> References: <20210727121037.2041102-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v2 04/11] drm/i915: move intel_context slab to direct module init/exit X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daniel Vetter , Intel Graphics Development , Daniel Vetter Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" With the global kmem_cache shrink infrastructure gone there's nothing special and we can convert them over. I'm doing this split up into each patch because there's quite a bit of noise with removing the static global.slab_ce to just a slab_ce. v2: Make slab static (Jason, 0day) Reviewed-by: Jason Ekstrand Cc: Jason Ekstrand Signed-off-by: Daniel Vetter --- drivers/gpu/drm/i915/gt/intel_context.c | 25 ++++++++----------------- drivers/gpu/drm/i915/gt/intel_context.h | 3 +++ drivers/gpu/drm/i915/i915_globals.c | 2 -- drivers/gpu/drm/i915/i915_globals.h | 1 - drivers/gpu/drm/i915/i915_pci.c | 2 ++ 5 files changed, 13 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/i915/gt/intel_context.c b/drivers/gpu/drm/i915/gt/intel_context.c index baa05fddd690..0ba49d74f94d 100644 --- a/drivers/gpu/drm/i915/gt/intel_context.c +++ b/drivers/gpu/drm/i915/gt/intel_context.c @@ -7,7 +7,6 @@ #include "gem/i915_gem_pm.h" #include "i915_drv.h" -#include "i915_globals.h" #include "i915_trace.h" #include "intel_context.h" @@ -15,14 +14,11 @@ #include "intel_engine_pm.h" #include "intel_ring.h" -static struct i915_global_context { - struct i915_global base; - struct kmem_cache *slab_ce; -} global; +static struct kmem_cache *slab_ce; static struct intel_context *intel_context_alloc(void) { - return kmem_cache_zalloc(global.slab_ce, GFP_KERNEL); + return kmem_cache_zalloc(slab_ce, GFP_KERNEL); } static void rcu_context_free(struct rcu_head *rcu) @@ -30,7 +26,7 @@ static void rcu_context_free(struct rcu_head *rcu) struct intel_context *ce = container_of(rcu, typeof(*ce), rcu); trace_intel_context_free(ce); - kmem_cache_free(global.slab_ce, ce); + kmem_cache_free(slab_ce, ce); } void intel_context_free(struct intel_context *ce) @@ -410,22 +406,17 @@ void intel_context_fini(struct intel_context *ce) i915_active_fini(&ce->active); } -static void i915_global_context_exit(void) +void i915_context_module_exit(void) { - kmem_cache_destroy(global.slab_ce); + kmem_cache_destroy(slab_ce); } -static struct i915_global_context global = { { - .exit = i915_global_context_exit, -} }; - -int __init i915_global_context_init(void) +int __init i915_context_module_init(void) { - global.slab_ce = KMEM_CACHE(intel_context, SLAB_HWCACHE_ALIGN); - if (!global.slab_ce) + slab_ce = KMEM_CACHE(intel_context, SLAB_HWCACHE_ALIGN); + if (!slab_ce) return -ENOMEM; - i915_global_register(&global.base); return 0; } diff --git a/drivers/gpu/drm/i915/gt/intel_context.h b/drivers/gpu/drm/i915/gt/intel_context.h index 974ef85320c2..a0ca82e3c40d 100644 --- a/drivers/gpu/drm/i915/gt/intel_context.h +++ b/drivers/gpu/drm/i915/gt/intel_context.h @@ -30,6 +30,9 @@ void intel_context_init(struct intel_context *ce, struct intel_engine_cs *engine); void intel_context_fini(struct intel_context *ce); +void i915_context_module_exit(void); +int i915_context_module_init(void); + struct intel_context * intel_context_create(struct intel_engine_cs *engine); diff --git a/drivers/gpu/drm/i915/i915_globals.c b/drivers/gpu/drm/i915/i915_globals.c index 3de7cf22ec76..d36eb7dc40aa 100644 --- a/drivers/gpu/drm/i915/i915_globals.c +++ b/drivers/gpu/drm/i915/i915_globals.c @@ -7,7 +7,6 @@ #include #include -#include "gem/i915_gem_context.h" #include "gem/i915_gem_object.h" #include "i915_globals.h" #include "i915_request.h" @@ -32,7 +31,6 @@ static void __i915_globals_cleanup(void) } static __initconst int (* const initfn[])(void) = { - i915_global_context_init, i915_global_gem_context_init, i915_global_objects_init, i915_global_request_init, diff --git a/drivers/gpu/drm/i915/i915_globals.h b/drivers/gpu/drm/i915/i915_globals.h index d80901ba75e3..60daa738a188 100644 --- a/drivers/gpu/drm/i915/i915_globals.h +++ b/drivers/gpu/drm/i915/i915_globals.h @@ -23,7 +23,6 @@ int i915_globals_init(void); void i915_globals_exit(void); /* constructors */ -int i915_global_context_init(void); int i915_global_gem_context_init(void); int i915_global_objects_init(void); int i915_global_request_init(void); diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c index 22d9e769ec74..8a9b0daef029 100644 --- a/drivers/gpu/drm/i915/i915_pci.c +++ b/drivers/gpu/drm/i915/i915_pci.c @@ -33,6 +33,7 @@ #include "i915_active.h" #include "i915_buddy.h" #include "i915_drv.h" +#include "gem/i915_gem_context.h" #include "i915_perf.h" #include "i915_globals.h" #include "i915_selftest.h" @@ -1298,6 +1299,7 @@ static const struct { { i915_check_nomodeset, NULL }, { i915_active_module_init, i915_active_module_exit }, { i915_buddy_module_init, i915_buddy_module_exit }, + { i915_context_module_init, i915_context_module_exit }, { i915_globals_init, i915_globals_exit }, { i915_mock_selftests, NULL }, { i915_pmu_init, i915_pmu_exit }, From patchwork Tue Jul 27 12:10:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 12402589 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B2B8C4338F for ; Tue, 27 Jul 2021 12:11:07 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3628761A62 for ; Tue, 27 Jul 2021 12:11:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3628761A62 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 540B16E992; Tue, 27 Jul 2021 12:10:54 +0000 (UTC) Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5A6326E4AB for ; Tue, 27 Jul 2021 12:10:48 +0000 (UTC) Received: by mail-wm1-x329.google.com with SMTP id a192-20020a1c7fc90000b0290253b32e8796so1292546wmd.0 for ; Tue, 27 Jul 2021 05:10:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aOT6n5enISaqbbzPzh90YpaXBz2nUaqPSDT6nSriNZQ=; b=llDXKtPZFMJPjtlJDKGkOrDXzJJYO0utdwP4yhk0cPcSq/oViOnsn4kLGcRfC6p0BE keS7t2abRfNxUXFObvej8UGJ71UuCnMfl7PtPxssu4kjLszZS9pHiLBwkClXmuW4utWt GbY/0r2XUpVXw5ocn63wbLHFDZHjOgc7u++HM= 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=aOT6n5enISaqbbzPzh90YpaXBz2nUaqPSDT6nSriNZQ=; b=lOCbJjl1crZA1mIFqjwB0tt3F/RDsXi1fefZ767su+tbjkzfCIOijxQCbJw5rhhYQ0 G6EvGyh4aVfpgZruEQCRrH3KtxDojDJBIdSbmkGQRISV1SLw6VA51yx/yJ0NItxnCuxN pIWkELdTvsbMngwtAP1YJjKWe9e0rhuG7X8Qg8q0DHxGWTKpdQLmh1hJeEsn6d6yF8qA fKrEyT5qOifv/KxBkpwRgXQcMYUXroW364JBxivvkvmoDAQLOcqH5f7yx932OrkagXYt Qt0xBKiF7w+537QGwwAXgwleWt0bUDtnBmXHDB0eJ24RTJTgFm1MgpNjPreu+Ca3BKUy kMlQ== X-Gm-Message-State: AOAM532Mhgz5/b6JQnUhgpPVEUFxdKT2+XDEpfSP9ZBU8lxse5k4mkew CysnuY2Xk4G2OIWLuxMhvFX1Ww== X-Google-Smtp-Source: ABdhPJwZW+54kWL16D/cepDJGXBbOXQ3PB0pVzTEL9JH5U3qYUGDnB0nAW23HgoqK9r3vuHvsKrcYw== X-Received: by 2002:a05:600c:1c9f:: with SMTP id k31mr3885852wms.47.1627387846803; Tue, 27 Jul 2021 05:10:46 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id k186sm3010577wme.45.2021.07.27.05.10.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jul 2021 05:10:46 -0700 (PDT) From: Daniel Vetter To: DRI Development Date: Tue, 27 Jul 2021 14:10:31 +0200 Message-Id: <20210727121037.2041102-5-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210727121037.2041102-1-daniel.vetter@ffwll.ch> References: <20210727121037.2041102-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v2 05/11] drm/i915: move gem_context slab to direct module init/exit X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daniel Vetter , Intel Graphics Development , Daniel Vetter Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" With the global kmem_cache shrink infrastructure gone there's nothing special and we can convert them over. I'm doing this split up into each patch because there's quite a bit of noise with removing the static global.slab_luts to just a slab_luts. v2: Make slab static (Jason, 0day) Reviewed-by: Jason Ekstrand Cc: Jason Ekstrand Signed-off-by: Daniel Vetter --- drivers/gpu/drm/i915/gem/i915_gem_context.c | 25 +++++++-------------- drivers/gpu/drm/i915/gem/i915_gem_context.h | 3 +++ drivers/gpu/drm/i915/i915_globals.c | 2 -- drivers/gpu/drm/i915/i915_globals.h | 1 - drivers/gpu/drm/i915/i915_pci.c | 2 ++ 5 files changed, 13 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c index 89ca401bf9ae..087e1ede6c43 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_context.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c @@ -79,25 +79,21 @@ #include "gt/intel_ring.h" #include "i915_gem_context.h" -#include "i915_globals.h" #include "i915_trace.h" #include "i915_user_extensions.h" #define ALL_L3_SLICES(dev) (1 << NUM_L3_SLICES(dev)) - 1 -static struct i915_global_gem_context { - struct i915_global base; - struct kmem_cache *slab_luts; -} global; +static struct kmem_cache *slab_luts; struct i915_lut_handle *i915_lut_handle_alloc(void) { - return kmem_cache_alloc(global.slab_luts, GFP_KERNEL); + return kmem_cache_alloc(slab_luts, GFP_KERNEL); } void i915_lut_handle_free(struct i915_lut_handle *lut) { - return kmem_cache_free(global.slab_luts, lut); + return kmem_cache_free(slab_luts, lut); } static void lut_close(struct i915_gem_context *ctx) @@ -2282,21 +2278,16 @@ i915_gem_engines_iter_next(struct i915_gem_engines_iter *it) #include "selftests/i915_gem_context.c" #endif -static void i915_global_gem_context_exit(void) +void i915_gem_context_module_exit(void) { - kmem_cache_destroy(global.slab_luts); + kmem_cache_destroy(slab_luts); } -static struct i915_global_gem_context global = { { - .exit = i915_global_gem_context_exit, -} }; - -int __init i915_global_gem_context_init(void) +int __init i915_gem_context_module_init(void) { - global.slab_luts = KMEM_CACHE(i915_lut_handle, 0); - if (!global.slab_luts) + slab_luts = KMEM_CACHE(i915_lut_handle, 0); + if (!slab_luts) return -ENOMEM; - i915_global_register(&global.base); return 0; } diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.h b/drivers/gpu/drm/i915/gem/i915_gem_context.h index 20411db84914..18060536b0c2 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_context.h +++ b/drivers/gpu/drm/i915/gem/i915_gem_context.h @@ -224,6 +224,9 @@ i915_gem_engines_iter_next(struct i915_gem_engines_iter *it); for (i915_gem_engines_iter_init(&(it), (engines)); \ ((ce) = i915_gem_engines_iter_next(&(it)));) +void i915_gem_context_module_exit(void); +int i915_gem_context_module_init(void); + struct i915_lut_handle *i915_lut_handle_alloc(void); void i915_lut_handle_free(struct i915_lut_handle *lut); diff --git a/drivers/gpu/drm/i915/i915_globals.c b/drivers/gpu/drm/i915/i915_globals.c index d36eb7dc40aa..dbb3d81eeea7 100644 --- a/drivers/gpu/drm/i915/i915_globals.c +++ b/drivers/gpu/drm/i915/i915_globals.c @@ -7,7 +7,6 @@ #include #include -#include "gem/i915_gem_object.h" #include "i915_globals.h" #include "i915_request.h" #include "i915_scheduler.h" @@ -31,7 +30,6 @@ static void __i915_globals_cleanup(void) } static __initconst int (* const initfn[])(void) = { - i915_global_gem_context_init, i915_global_objects_init, i915_global_request_init, i915_global_scheduler_init, diff --git a/drivers/gpu/drm/i915/i915_globals.h b/drivers/gpu/drm/i915/i915_globals.h index 60daa738a188..f16752dbbdbf 100644 --- a/drivers/gpu/drm/i915/i915_globals.h +++ b/drivers/gpu/drm/i915/i915_globals.h @@ -23,7 +23,6 @@ int i915_globals_init(void); void i915_globals_exit(void); /* constructors */ -int i915_global_gem_context_init(void); int i915_global_objects_init(void); int i915_global_request_init(void); int i915_global_scheduler_init(void); diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c index 8a9b0daef029..410a85a1cbab 100644 --- a/drivers/gpu/drm/i915/i915_pci.c +++ b/drivers/gpu/drm/i915/i915_pci.c @@ -34,6 +34,7 @@ #include "i915_buddy.h" #include "i915_drv.h" #include "gem/i915_gem_context.h" +#include "gem/i915_gem_object.h" #include "i915_perf.h" #include "i915_globals.h" #include "i915_selftest.h" @@ -1300,6 +1301,7 @@ static const struct { { i915_active_module_init, i915_active_module_exit }, { i915_buddy_module_init, i915_buddy_module_exit }, { i915_context_module_init, i915_context_module_exit }, + { i915_gem_context_module_init, i915_gem_context_module_exit }, { i915_globals_init, i915_globals_exit }, { i915_mock_selftests, NULL }, { i915_pmu_init, i915_pmu_exit }, From patchwork Tue Jul 27 12:10:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 12402595 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8C9ADC432BE for ; Tue, 27 Jul 2021 12:11:08 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5817561A62 for ; Tue, 27 Jul 2021 12:11:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5817561A62 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B8FED6E9F3; Tue, 27 Jul 2021 12:10:54 +0000 (UTC) Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by gabe.freedesktop.org (Postfix) with ESMTPS id 37B9B6E970 for ; Tue, 27 Jul 2021 12:10:49 +0000 (UTC) Received: by mail-wm1-x32b.google.com with SMTP id m38-20020a05600c3b26b02902161fccabf1so1708742wms.2 for ; Tue, 27 Jul 2021 05:10:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HpaQGKtHk2ms/zqFH1p0AkiNURtx44b6tngT7q8EraQ=; b=AeHFbSOETmUOZPTQN+BeI6quAoJ/UnHf2T+1Qlh7li4HhC08PJ2zRPI1+KlfMwBlsV aNypZhMbQi0EGO7XuEsk6LNc/SUKC+DXBjUyuoA0Y+1WMMuMvjeA4y0aPgiNE6CvsRMs JUkKHo72tyQiaHT8epPzpN5d8wGaQ41VLNdNI= 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=HpaQGKtHk2ms/zqFH1p0AkiNURtx44b6tngT7q8EraQ=; b=PNWIWqoBETaAdcqd3e3+TdDge2JZ/cjzgTvH6q5acZJ7E5gUSSHfCA+ov1ZyzsKMnQ m8ObzlrHIQvK/9lyTtNOVkUnNGxOECqRzAQygOGMWUnfo8l5QlYWejAkXHdBRBVhuM4J D6sy/MKz+0+8KHIy0TIY1oPEVJjyAVEJWVP89/IFhO3Yc88jFy+CIIcWmT+8WoyX8p/5 TNxs+6c2WciJygKfmr15iXxWXQn6JuaCsX5gvT0/dyGeU0Fj2mMWhgc9wgvbzT1s3G7k Tg08GMbdNSZQJqcooa1LnxAa1AIW9HeWSJcj1IjxkUWC75ytTz0g4W6cN2wMS1Qh9sX1 O9BA== X-Gm-Message-State: AOAM5320jhVP8PGlgCwaJ1JrROtXnLSDLh4+3ANO0Y97cOMFArv6bq8N hRM5BhP/OUQrqW6MMABF+ikmWg== X-Google-Smtp-Source: ABdhPJw+v7xLcIfaRlKDE1ejgZqHRh17cLhySb1bKpNhxaWBGOoA6kMRBHNDRciwtWAYF4hPEuilOA== X-Received: by 2002:a1c:7314:: with SMTP id d20mr3793604wmb.156.1627387847617; Tue, 27 Jul 2021 05:10:47 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id k186sm3010577wme.45.2021.07.27.05.10.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jul 2021 05:10:47 -0700 (PDT) From: Daniel Vetter To: DRI Development Date: Tue, 27 Jul 2021 14:10:32 +0200 Message-Id: <20210727121037.2041102-6-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210727121037.2041102-1-daniel.vetter@ffwll.ch> References: <20210727121037.2041102-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v2 06/11] drm/i915: move gem_objects slab to direct module init/exit X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daniel Vetter , Intel Graphics Development , Daniel Vetter Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" With the global kmem_cache shrink infrastructure gone there's nothing special and we can convert them over. I'm doing this split up into each patch because there's quite a bit of noise with removing the static global.slab_objects to just a slab_objects. v2: Make slab static (Jason, 0day) Reviewed-by: Jason Ekstrand Cc: Jason Ekstrand Signed-off-by: Daniel Vetter --- drivers/gpu/drm/i915/gem/i915_gem_object.c | 26 +++++++--------------- drivers/gpu/drm/i915/gem/i915_gem_object.h | 3 +++ drivers/gpu/drm/i915/i915_globals.c | 1 - drivers/gpu/drm/i915/i915_globals.h | 1 - drivers/gpu/drm/i915/i915_pci.c | 1 + 5 files changed, 12 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object.c b/drivers/gpu/drm/i915/gem/i915_gem_object.c index 9d3497e1235a..6fb9afb65034 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_object.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_object.c @@ -30,14 +30,10 @@ #include "i915_gem_context.h" #include "i915_gem_mman.h" #include "i915_gem_object.h" -#include "i915_globals.h" #include "i915_memcpy.h" #include "i915_trace.h" -static struct i915_global_object { - struct i915_global base; - struct kmem_cache *slab_objects; -} global; +static struct kmem_cache *slab_objects; static const struct drm_gem_object_funcs i915_gem_object_funcs; @@ -45,7 +41,7 @@ struct drm_i915_gem_object *i915_gem_object_alloc(void) { struct drm_i915_gem_object *obj; - obj = kmem_cache_zalloc(global.slab_objects, GFP_KERNEL); + obj = kmem_cache_zalloc(slab_objects, GFP_KERNEL); if (!obj) return NULL; obj->base.funcs = &i915_gem_object_funcs; @@ -55,7 +51,7 @@ struct drm_i915_gem_object *i915_gem_object_alloc(void) void i915_gem_object_free(struct drm_i915_gem_object *obj) { - return kmem_cache_free(global.slab_objects, obj); + return kmem_cache_free(slab_objects, obj); } void i915_gem_object_init(struct drm_i915_gem_object *obj, @@ -658,23 +654,17 @@ void i915_gem_init__objects(struct drm_i915_private *i915) INIT_WORK(&i915->mm.free_work, __i915_gem_free_work); } -static void i915_global_objects_exit(void) +void i915_objects_module_exit(void) { - kmem_cache_destroy(global.slab_objects); + kmem_cache_destroy(slab_objects); } -static struct i915_global_object global = { { - .exit = i915_global_objects_exit, -} }; - -int __init i915_global_objects_init(void) +int __init i915_objects_module_init(void) { - global.slab_objects = - KMEM_CACHE(drm_i915_gem_object, SLAB_HWCACHE_ALIGN); - if (!global.slab_objects) + slab_objects = KMEM_CACHE(drm_i915_gem_object, SLAB_HWCACHE_ALIGN); + if (!slab_objects) return -ENOMEM; - i915_global_register(&global.base); return 0; } diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object.h b/drivers/gpu/drm/i915/gem/i915_gem_object.h index 0896ac532f5e..48112b9d76df 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_object.h +++ b/drivers/gpu/drm/i915/gem/i915_gem_object.h @@ -48,6 +48,9 @@ static inline bool i915_gem_object_size_2big(u64 size) void i915_gem_init__objects(struct drm_i915_private *i915); +void i915_objects_module_exit(void); +int i915_objects_module_init(void); + struct drm_i915_gem_object *i915_gem_object_alloc(void); void i915_gem_object_free(struct drm_i915_gem_object *obj); diff --git a/drivers/gpu/drm/i915/i915_globals.c b/drivers/gpu/drm/i915/i915_globals.c index dbb3d81eeea7..40a592fbc3e0 100644 --- a/drivers/gpu/drm/i915/i915_globals.c +++ b/drivers/gpu/drm/i915/i915_globals.c @@ -30,7 +30,6 @@ static void __i915_globals_cleanup(void) } static __initconst int (* const initfn[])(void) = { - i915_global_objects_init, i915_global_request_init, i915_global_scheduler_init, i915_global_vma_init, diff --git a/drivers/gpu/drm/i915/i915_globals.h b/drivers/gpu/drm/i915/i915_globals.h index f16752dbbdbf..9734740708f4 100644 --- a/drivers/gpu/drm/i915/i915_globals.h +++ b/drivers/gpu/drm/i915/i915_globals.h @@ -23,7 +23,6 @@ int i915_globals_init(void); void i915_globals_exit(void); /* constructors */ -int i915_global_objects_init(void); int i915_global_request_init(void); int i915_global_scheduler_init(void); int i915_global_vma_init(void); diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c index 410a85a1cbab..7a13570c04a5 100644 --- a/drivers/gpu/drm/i915/i915_pci.c +++ b/drivers/gpu/drm/i915/i915_pci.c @@ -1302,6 +1302,7 @@ static const struct { { i915_buddy_module_init, i915_buddy_module_exit }, { i915_context_module_init, i915_context_module_exit }, { i915_gem_context_module_init, i915_gem_context_module_exit }, + { i915_objects_module_init, i915_objects_module_exit }, { i915_globals_init, i915_globals_exit }, { i915_mock_selftests, NULL }, { i915_pmu_init, i915_pmu_exit }, From patchwork Tue Jul 27 12:10:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 12402599 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1B66CC4338F for ; Tue, 27 Jul 2021 12:11:10 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E0A9F61A54 for ; Tue, 27 Jul 2021 12:11:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E0A9F61A54 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 807916EA0B; Tue, 27 Jul 2021 12:10:55 +0000 (UTC) Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by gabe.freedesktop.org (Postfix) with ESMTPS id E64BE6E970 for ; Tue, 27 Jul 2021 12:10:49 +0000 (UTC) Received: by mail-wr1-x42f.google.com with SMTP id p5so9826408wro.7 for ; Tue, 27 Jul 2021 05:10:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SRIvipp+/rUrnGOkRac1/pvU10F62QyZRdjP7HrxZ/8=; b=Kca4K7//yhayfuyQhPoTsbnMUnuHZGjAeyptIn6fOwGEE7rOooa+CJK2M+i+WOGRnH kdtd9wLTwJ0YUOHtBls3O6sJJMgd1461pdG1qU49ie2Q5NzN9M7bshFCXK5ykK6PBVH+ CBKXowWuLb4jO8F8gXOqUzmVjkMp3CkBobabA= 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=SRIvipp+/rUrnGOkRac1/pvU10F62QyZRdjP7HrxZ/8=; b=iOMHj+kiwaUfImXsdVZJXm2xTxKDCOTE7R1CaUvU+FvQtk0HhyaZBDGuQzQO+Yl3WN peH4+K1RP/y0EyChY5pMl9ps6z6/lXfzRk4cJ+OmYGhtyqoTBGNdXvfHrZOpZuspC93y EGCnsiL6KqXjiHcNyWehviT8DGR65j3o+mnA2rP7mlbQmR/DV1ERJILJzW/m4MQEI+gV qgCbWjnz5a6+8NrLDx9EfBSi4F/lxlg6WBuci0dQmRD91Hkx05+bUtqJboePYf2QK8/t vhlKHfcDXXTSSzcxLOUG2RMzeI1ILE71fRVivYer0gy4sWhbXOt0VBjFgmDR6Cp78jVD g1ag== X-Gm-Message-State: AOAM531Sw6ebL97c7PZbpeVsFIKEYMgwlHHljvw6TKYpX+tfs4Gvvhrw R/qrsz1mB3DqXjbN5MuNEBJ9ew== X-Google-Smtp-Source: ABdhPJzP0KJDkPO+B0t6qoGyLcMmF7d9ryoPlA8zkTwpfNqqcbqOXMlg0Man+JSt5wlabQXHYOl0ug== X-Received: by 2002:a5d:40c6:: with SMTP id b6mr10402724wrq.222.1627387848470; Tue, 27 Jul 2021 05:10:48 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id k186sm3010577wme.45.2021.07.27.05.10.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jul 2021 05:10:48 -0700 (PDT) From: Daniel Vetter To: DRI Development Date: Tue, 27 Jul 2021 14:10:33 +0200 Message-Id: <20210727121037.2041102-7-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210727121037.2041102-1-daniel.vetter@ffwll.ch> References: <20210727121037.2041102-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v2 07/11] drm/i915: move request slabs to direct module init/exit X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daniel Vetter , Intel Graphics Development , Daniel Vetter Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" With the global kmem_cache shrink infrastructure gone there's nothing special and we can convert them over. I'm doing this split up into each patch because there's quite a bit of noise with removing the static global.slab_requests|execute_cbs to just a slab_requests|execute_cbs. v2: Make slab static (Jason, 0day) Reviewed-by: Jason Ekstrand Cc: Jason Ekstrand Signed-off-by: Daniel Vetter --- drivers/gpu/drm/i915/i915_globals.c | 2 -- drivers/gpu/drm/i915/i915_pci.c | 2 ++ drivers/gpu/drm/i915/i915_request.c | 47 ++++++++++++----------------- drivers/gpu/drm/i915/i915_request.h | 3 ++ 4 files changed, 24 insertions(+), 30 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_globals.c b/drivers/gpu/drm/i915/i915_globals.c index 40a592fbc3e0..8fffa8d93bc5 100644 --- a/drivers/gpu/drm/i915/i915_globals.c +++ b/drivers/gpu/drm/i915/i915_globals.c @@ -8,7 +8,6 @@ #include #include "i915_globals.h" -#include "i915_request.h" #include "i915_scheduler.h" #include "i915_vma.h" @@ -30,7 +29,6 @@ static void __i915_globals_cleanup(void) } static __initconst int (* const initfn[])(void) = { - i915_global_request_init, i915_global_scheduler_init, i915_global_vma_init, }; diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c index 7a13570c04a5..3f1716a3d74f 100644 --- a/drivers/gpu/drm/i915/i915_pci.c +++ b/drivers/gpu/drm/i915/i915_pci.c @@ -35,6 +35,7 @@ #include "i915_drv.h" #include "gem/i915_gem_context.h" #include "gem/i915_gem_object.h" +#include "i915_request.h" #include "i915_perf.h" #include "i915_globals.h" #include "i915_selftest.h" @@ -1303,6 +1304,7 @@ static const struct { { i915_context_module_init, i915_context_module_exit }, { i915_gem_context_module_init, i915_gem_context_module_exit }, { i915_objects_module_init, i915_objects_module_exit }, + { i915_request_module_init, i915_request_module_exit }, { i915_globals_init, i915_globals_exit }, { i915_mock_selftests, NULL }, { i915_pmu_init, i915_pmu_exit }, diff --git a/drivers/gpu/drm/i915/i915_request.c b/drivers/gpu/drm/i915/i915_request.c index 6594cb2f8ebd..3dd759be3c28 100644 --- a/drivers/gpu/drm/i915/i915_request.c +++ b/drivers/gpu/drm/i915/i915_request.c @@ -42,7 +42,6 @@ #include "i915_active.h" #include "i915_drv.h" -#include "i915_globals.h" #include "i915_trace.h" #include "intel_pm.h" @@ -52,11 +51,8 @@ struct execute_cb { struct i915_request *signal; }; -static struct i915_global_request { - struct i915_global base; - struct kmem_cache *slab_requests; - struct kmem_cache *slab_execute_cbs; -} global; +static struct kmem_cache *slab_requests; +static struct kmem_cache *slab_execute_cbs; static const char *i915_fence_get_driver_name(struct dma_fence *fence) { @@ -107,7 +103,7 @@ static signed long i915_fence_wait(struct dma_fence *fence, struct kmem_cache *i915_request_slab_cache(void) { - return global.slab_requests; + return slab_requests; } static void i915_fence_release(struct dma_fence *fence) @@ -159,7 +155,7 @@ static void i915_fence_release(struct dma_fence *fence) !cmpxchg(&rq->engine->request_pool, NULL, rq)) return; - kmem_cache_free(global.slab_requests, rq); + kmem_cache_free(slab_requests, rq); } const struct dma_fence_ops i915_fence_ops = { @@ -176,7 +172,7 @@ static void irq_execute_cb(struct irq_work *wrk) struct execute_cb *cb = container_of(wrk, typeof(*cb), work); i915_sw_fence_complete(cb->fence); - kmem_cache_free(global.slab_execute_cbs, cb); + kmem_cache_free(slab_execute_cbs, cb); } static __always_inline void @@ -514,7 +510,7 @@ __await_execution(struct i915_request *rq, if (i915_request_is_active(signal)) return 0; - cb = kmem_cache_alloc(global.slab_execute_cbs, gfp); + cb = kmem_cache_alloc(slab_execute_cbs, gfp); if (!cb) return -ENOMEM; @@ -868,7 +864,7 @@ request_alloc_slow(struct intel_timeline *tl, rq = list_first_entry(&tl->requests, typeof(*rq), link); i915_request_retire(rq); - rq = kmem_cache_alloc(global.slab_requests, + rq = kmem_cache_alloc(slab_requests, gfp | __GFP_RETRY_MAYFAIL | __GFP_NOWARN); if (rq) return rq; @@ -881,7 +877,7 @@ request_alloc_slow(struct intel_timeline *tl, retire_requests(tl); out: - return kmem_cache_alloc(global.slab_requests, gfp); + return kmem_cache_alloc(slab_requests, gfp); } static void __i915_request_ctor(void *arg) @@ -942,7 +938,7 @@ __i915_request_create(struct intel_context *ce, gfp_t gfp) * * Do not use kmem_cache_zalloc() here! */ - rq = kmem_cache_alloc(global.slab_requests, + rq = kmem_cache_alloc(slab_requests, gfp | __GFP_RETRY_MAYFAIL | __GFP_NOWARN); if (unlikely(!rq)) { rq = request_alloc_slow(tl, &ce->engine->request_pool, gfp); @@ -1029,7 +1025,7 @@ __i915_request_create(struct intel_context *ce, gfp_t gfp) GEM_BUG_ON(!list_empty(&rq->sched.waiters_list)); err_free: - kmem_cache_free(global.slab_requests, rq); + kmem_cache_free(slab_requests, rq); err_unreserve: intel_context_unpin(ce); return ERR_PTR(ret); @@ -2084,19 +2080,15 @@ void i915_request_show(struct drm_printer *m, #include "selftests/i915_request.c" #endif -static void i915_global_request_exit(void) +void i915_request_module_exit(void) { - kmem_cache_destroy(global.slab_execute_cbs); - kmem_cache_destroy(global.slab_requests); + kmem_cache_destroy(slab_execute_cbs); + kmem_cache_destroy(slab_requests); } -static struct i915_global_request global = { { - .exit = i915_global_request_exit, -} }; - -int __init i915_global_request_init(void) +int __init i915_request_module_init(void) { - global.slab_requests = + slab_requests = kmem_cache_create("i915_request", sizeof(struct i915_request), __alignof__(struct i915_request), @@ -2104,20 +2096,19 @@ int __init i915_global_request_init(void) SLAB_RECLAIM_ACCOUNT | SLAB_TYPESAFE_BY_RCU, __i915_request_ctor); - if (!global.slab_requests) + if (!slab_requests) return -ENOMEM; - global.slab_execute_cbs = KMEM_CACHE(execute_cb, + slab_execute_cbs = KMEM_CACHE(execute_cb, SLAB_HWCACHE_ALIGN | SLAB_RECLAIM_ACCOUNT | SLAB_TYPESAFE_BY_RCU); - if (!global.slab_execute_cbs) + if (!slab_execute_cbs) goto err_requests; - i915_global_register(&global.base); return 0; err_requests: - kmem_cache_destroy(global.slab_requests); + kmem_cache_destroy(slab_requests); return -ENOMEM; } diff --git a/drivers/gpu/drm/i915/i915_request.h b/drivers/gpu/drm/i915/i915_request.h index 717e5b292046..a79480f07f04 100644 --- a/drivers/gpu/drm/i915/i915_request.h +++ b/drivers/gpu/drm/i915/i915_request.h @@ -647,4 +647,7 @@ bool i915_request_active_engine(struct i915_request *rq, struct intel_engine_cs **active); +void i915_request_module_exit(void); +int i915_request_module_init(void); + #endif /* I915_REQUEST_H */ From patchwork Tue Jul 27 12:10:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 12402593 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10991C4320E for ; Tue, 27 Jul 2021 12:11:09 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D5F8F61A62 for ; Tue, 27 Jul 2021 12:11:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D5F8F61A62 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A836B6E9E5; Tue, 27 Jul 2021 12:10:54 +0000 (UTC) Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by gabe.freedesktop.org (Postfix) with ESMTPS id B5DE86E9A2 for ; Tue, 27 Jul 2021 12:10:50 +0000 (UTC) Received: by mail-wr1-x42a.google.com with SMTP id b9so14090437wrx.12 for ; Tue, 27 Jul 2021 05:10:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=o5oMDHT2wrSLzYTbhFXSyQLwbCJIzbqZgGbPzHr2Fi4=; b=aLcZQCUnSTqZj47u+JHZxyg8ZbqMr63IXSEIeS29arwiXwGUxHFALPLsoOzOqpfOE3 jk/Ldj2S57upykXKejpS/jE13bm6s/nju6s1/txxJyQeIjJB8bHZbO80aY3l+XcW0y3n /nIbGFQi1gXry7MOg2JgloJcZXa7W84drzHoY= 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=o5oMDHT2wrSLzYTbhFXSyQLwbCJIzbqZgGbPzHr2Fi4=; b=cAbu9r01xh5TigjpX+xpx8lpvtOszU3gp/4tBeMIv9ObbDQsbZFNOHkRk1Dp6VgJwv dgDsIEkWWf8/OjzE/FKD0hC3aXh4+uD0sZEj37sG6X0HmODbJzYb2rzLwcyM/2P3WrMN 3cBhB5yxzvJXG2l4PQrZzX2yq430mmFaWuxpx36zhVvYI45BpI7o1jxzAZQ0eWDuC7j6 YT9M/8uqcS9DMV/jlOzEHaEZAAPPY0A9CE+sXgvBIeZbkjq4uR1xJy7h73BIaj0d4Niv smiAhVq+oxwmW5Jih8pBP927KTu8GoaLdYyV91pPFVwmvV5Nw/GFsSHyz1rM3WfXPf23 4lbQ== X-Gm-Message-State: AOAM533g0mSbthIlL2lUgwT1GIvrTFkNKeW7jHzdyJPMZqHTqfYNxzUh 7gYSKR0sb32gihg6v7BgSfI5ClB0OuPb4Q== X-Google-Smtp-Source: ABdhPJycA4OkeX9owremvsDDIE5t35Uo8NNwjSbZoRZ9BafC2GVgw+f0PfsvXAPxoFR8DNqmQTuLyw== X-Received: by 2002:adf:de06:: with SMTP id b6mr15432850wrm.316.1627387849204; Tue, 27 Jul 2021 05:10:49 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id k186sm3010577wme.45.2021.07.27.05.10.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jul 2021 05:10:48 -0700 (PDT) From: Daniel Vetter To: DRI Development Date: Tue, 27 Jul 2021 14:10:34 +0200 Message-Id: <20210727121037.2041102-8-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210727121037.2041102-1-daniel.vetter@ffwll.ch> References: <20210727121037.2041102-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v2 08/11] drm/i915: move scheduler slabs to direct module init/exit X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daniel Vetter , Intel Graphics Development , Daniel Vetter Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" With the global kmem_cache shrink infrastructure gone there's nothing special and we can convert them over. I'm doing this split up into each patch because there's quite a bit of noise with removing the static global.slab_dependencies|priorities to just a slab_dependencies|priorities. v2: Make slab static (Jason, 0day) Reviewed-by: Jason Ekstrand Cc: Jason Ekstrand Signed-off-by: Daniel Vetter --- drivers/gpu/drm/i915/i915_globals.c | 2 -- drivers/gpu/drm/i915/i915_globals.h | 2 -- drivers/gpu/drm/i915/i915_pci.c | 2 ++ drivers/gpu/drm/i915/i915_scheduler.c | 39 +++++++++++---------------- drivers/gpu/drm/i915/i915_scheduler.h | 3 +++ 5 files changed, 20 insertions(+), 28 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_globals.c b/drivers/gpu/drm/i915/i915_globals.c index 8fffa8d93bc5..8923589057ab 100644 --- a/drivers/gpu/drm/i915/i915_globals.c +++ b/drivers/gpu/drm/i915/i915_globals.c @@ -8,7 +8,6 @@ #include #include "i915_globals.h" -#include "i915_scheduler.h" #include "i915_vma.h" static LIST_HEAD(globals); @@ -29,7 +28,6 @@ static void __i915_globals_cleanup(void) } static __initconst int (* const initfn[])(void) = { - i915_global_scheduler_init, i915_global_vma_init, }; diff --git a/drivers/gpu/drm/i915/i915_globals.h b/drivers/gpu/drm/i915/i915_globals.h index 9734740708f4..7a57bce1da05 100644 --- a/drivers/gpu/drm/i915/i915_globals.h +++ b/drivers/gpu/drm/i915/i915_globals.h @@ -23,8 +23,6 @@ int i915_globals_init(void); void i915_globals_exit(void); /* constructors */ -int i915_global_request_init(void); -int i915_global_scheduler_init(void); int i915_global_vma_init(void); #endif /* _I915_GLOBALS_H_ */ diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c index 3f1716a3d74f..500897d0d4b5 100644 --- a/drivers/gpu/drm/i915/i915_pci.c +++ b/drivers/gpu/drm/i915/i915_pci.c @@ -39,6 +39,7 @@ #include "i915_perf.h" #include "i915_globals.h" #include "i915_selftest.h" +#include "i915_scheduler.h" #define PLATFORM(x) .platform = (x) #define GEN(x) \ @@ -1305,6 +1306,7 @@ static const struct { { i915_gem_context_module_init, i915_gem_context_module_exit }, { i915_objects_module_init, i915_objects_module_exit }, { i915_request_module_init, i915_request_module_exit }, + { i915_scheduler_module_init, i915_scheduler_module_exit }, { i915_globals_init, i915_globals_exit }, { i915_mock_selftests, NULL }, { i915_pmu_init, i915_pmu_exit }, diff --git a/drivers/gpu/drm/i915/i915_scheduler.c b/drivers/gpu/drm/i915/i915_scheduler.c index 561c649e59f7..c7ea5a1f3b94 100644 --- a/drivers/gpu/drm/i915/i915_scheduler.c +++ b/drivers/gpu/drm/i915/i915_scheduler.c @@ -7,15 +7,11 @@ #include #include "i915_drv.h" -#include "i915_globals.h" #include "i915_request.h" #include "i915_scheduler.h" -static struct i915_global_scheduler { - struct i915_global base; - struct kmem_cache *slab_dependencies; - struct kmem_cache *slab_priorities; -} global; +static struct kmem_cache *slab_dependencies; +static struct kmem_cache *slab_priorities; static DEFINE_SPINLOCK(schedule_lock); @@ -93,7 +89,7 @@ i915_sched_lookup_priolist(struct i915_sched_engine *sched_engine, int prio) if (prio == I915_PRIORITY_NORMAL) { p = &sched_engine->default_priolist; } else { - p = kmem_cache_alloc(global.slab_priorities, GFP_ATOMIC); + p = kmem_cache_alloc(slab_priorities, GFP_ATOMIC); /* Convert an allocation failure to a priority bump */ if (unlikely(!p)) { prio = I915_PRIORITY_NORMAL; /* recurses just once */ @@ -122,7 +118,7 @@ i915_sched_lookup_priolist(struct i915_sched_engine *sched_engine, int prio) void __i915_priolist_free(struct i915_priolist *p) { - kmem_cache_free(global.slab_priorities, p); + kmem_cache_free(slab_priorities, p); } struct sched_cache { @@ -313,13 +309,13 @@ void i915_sched_node_reinit(struct i915_sched_node *node) static struct i915_dependency * i915_dependency_alloc(void) { - return kmem_cache_alloc(global.slab_dependencies, GFP_KERNEL); + return kmem_cache_alloc(slab_dependencies, GFP_KERNEL); } static void i915_dependency_free(struct i915_dependency *dep) { - kmem_cache_free(global.slab_dependencies, dep); + kmem_cache_free(slab_dependencies, dep); } bool __i915_sched_node_add_dependency(struct i915_sched_node *node, @@ -475,32 +471,27 @@ i915_sched_engine_create(unsigned int subclass) return sched_engine; } -static void i915_global_scheduler_exit(void) +void i915_scheduler_module_exit(void) { - kmem_cache_destroy(global.slab_dependencies); - kmem_cache_destroy(global.slab_priorities); + kmem_cache_destroy(slab_dependencies); + kmem_cache_destroy(slab_priorities); } -static struct i915_global_scheduler global = { { - .exit = i915_global_scheduler_exit, -} }; - -int __init i915_global_scheduler_init(void) +int __init i915_scheduler_module_init(void) { - global.slab_dependencies = KMEM_CACHE(i915_dependency, + slab_dependencies = KMEM_CACHE(i915_dependency, SLAB_HWCACHE_ALIGN | SLAB_TYPESAFE_BY_RCU); - if (!global.slab_dependencies) + if (!slab_dependencies) return -ENOMEM; - global.slab_priorities = KMEM_CACHE(i915_priolist, 0); - if (!global.slab_priorities) + slab_priorities = KMEM_CACHE(i915_priolist, 0); + if (!slab_priorities) goto err_priorities; - i915_global_register(&global.base); return 0; err_priorities: - kmem_cache_destroy(global.slab_priorities); + kmem_cache_destroy(slab_priorities); return -ENOMEM; } diff --git a/drivers/gpu/drm/i915/i915_scheduler.h b/drivers/gpu/drm/i915/i915_scheduler.h index 650ab8e0db9f..0a4f61fd0be0 100644 --- a/drivers/gpu/drm/i915/i915_scheduler.h +++ b/drivers/gpu/drm/i915/i915_scheduler.h @@ -98,4 +98,7 @@ void i915_request_show_with_schedule(struct drm_printer *m, const char *prefix, int indent); +void i915_scheduler_module_exit(void); +int i915_scheduler_module_init(void); + #endif /* _I915_SCHEDULER_H_ */ From patchwork Tue Jul 27 12:10:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 12402597 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D860C43216 for ; Tue, 27 Jul 2021 12:11:09 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6614F61A57 for ; Tue, 27 Jul 2021 12:11:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6614F61A57 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 651AB6EA0A; Tue, 27 Jul 2021 12:10:55 +0000 (UTC) Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by gabe.freedesktop.org (Postfix) with ESMTPS id AC7026E992 for ; Tue, 27 Jul 2021 12:10:51 +0000 (UTC) Received: by mail-wr1-x433.google.com with SMTP id n12so11384553wrr.2 for ; Tue, 27 Jul 2021 05:10:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Xj3UP63IRyaj+D/1PVk4ccyZVJg4VlH4yBD18mwyxOQ=; b=ElhEjd57frRM1j0D9qW9rYBnSebqr1c3LrpwmBHEU2H7LgZob+1MPWJsNEDDDuHnfc //o61az0phDjYid/7Ss25j0rzn8X0E/9xl9DZSRgoPy33VYe4t6G3I8ou38RnNjIwGF4 kE0qH9Qp4ijO+WArkebgwrYbF+YJIsYYU5vuA= 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=Xj3UP63IRyaj+D/1PVk4ccyZVJg4VlH4yBD18mwyxOQ=; b=goC6tTz0GV9YpR5sP5UPJCBjxRz6xREb+LQx2cCi13uxNeE1k4wGCwyHOA47NbaOVy nC37oJIhO5TJbvW1gfC1xzsjzpL93odwSwfdrEluHV6y6jA0Z2uGtLZpOuAtGxyARGQy vvt0/AbbiCPE2kupIuit6lFvUleiu8vBqkE3J7WlGBU46eRshBjcFiU4pC5yQ7/8JIps h8bnPXFDecbIvsFjuclexn9esckjypFs7WC/TPRxXXm9xA+4D7zJvUO9tgD49s3Ihsme h9oiHp1cQojQzDcE1D/f6fYdH0ohg4dXwLJQjj+DQiKaLfDm/z3rYfW+o8IUUUaK9uor YxYw== X-Gm-Message-State: AOAM530qOQesOiHMdC8xSnElkOJzLmv5WfAA8g/y2kKj280wAeys0293 vbk2xqKKIQ6i27Q4WPTa4qEMyQ== X-Google-Smtp-Source: ABdhPJwsPpF79YrhDoodjHHWa5hDTxnd2J/nrJsCG1yr7up6jyjLUDeSONCZyDQvXvB3M22+UrB76w== X-Received: by 2002:a5d:5305:: with SMTP id e5mr11606814wrv.243.1627387850023; Tue, 27 Jul 2021 05:10:50 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id k186sm3010577wme.45.2021.07.27.05.10.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jul 2021 05:10:49 -0700 (PDT) From: Daniel Vetter To: DRI Development Date: Tue, 27 Jul 2021 14:10:35 +0200 Message-Id: <20210727121037.2041102-9-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210727121037.2041102-1-daniel.vetter@ffwll.ch> References: <20210727121037.2041102-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v2 09/11] drm/i915: move vma slab to direct module init/exit X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daniel Vetter , Intel Graphics Development , Daniel Vetter Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" With the global kmem_cache shrink infrastructure gone there's nothing special and we can convert them over. I'm doing this split up into each patch because there's quite a bit of noise with removing the static global.slab_vmas to just a slab_vmas. We have to keep i915_drv.h include in i915_globals otherwise there's nothing anymore that pulls in GEM_BUG_ON. v2: Make slab static (Jason, 0day) Reviewed-by: Jason Ekstrand Cc: Jason Ekstrand Signed-off-by: Daniel Vetter --- drivers/gpu/drm/i915/i915_globals.c | 3 +-- drivers/gpu/drm/i915/i915_globals.h | 3 --- drivers/gpu/drm/i915/i915_pci.c | 2 ++ drivers/gpu/drm/i915/i915_vma.c | 25 ++++++++----------------- drivers/gpu/drm/i915/i915_vma.h | 3 +++ 5 files changed, 14 insertions(+), 22 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_globals.c b/drivers/gpu/drm/i915/i915_globals.c index 8923589057ab..04979789e7be 100644 --- a/drivers/gpu/drm/i915/i915_globals.c +++ b/drivers/gpu/drm/i915/i915_globals.c @@ -8,7 +8,7 @@ #include #include "i915_globals.h" -#include "i915_vma.h" +#include "i915_drv.h" static LIST_HEAD(globals); @@ -28,7 +28,6 @@ static void __i915_globals_cleanup(void) } static __initconst int (* const initfn[])(void) = { - i915_global_vma_init, }; int __init i915_globals_init(void) diff --git a/drivers/gpu/drm/i915/i915_globals.h b/drivers/gpu/drm/i915/i915_globals.h index 7a57bce1da05..57d2998bba45 100644 --- a/drivers/gpu/drm/i915/i915_globals.h +++ b/drivers/gpu/drm/i915/i915_globals.h @@ -22,7 +22,4 @@ void i915_global_register(struct i915_global *global); int i915_globals_init(void); void i915_globals_exit(void); -/* constructors */ -int i915_global_vma_init(void); - #endif /* _I915_GLOBALS_H_ */ diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c index 500897d0d4b5..14785d88dafb 100644 --- a/drivers/gpu/drm/i915/i915_pci.c +++ b/drivers/gpu/drm/i915/i915_pci.c @@ -40,6 +40,7 @@ #include "i915_globals.h" #include "i915_selftest.h" #include "i915_scheduler.h" +#include "i915_vma.h" #define PLATFORM(x) .platform = (x) #define GEN(x) \ @@ -1307,6 +1308,7 @@ static const struct { { i915_objects_module_init, i915_objects_module_exit }, { i915_request_module_init, i915_request_module_exit }, { i915_scheduler_module_init, i915_scheduler_module_exit }, + { i915_vma_module_init, i915_vma_module_exit }, { i915_globals_init, i915_globals_exit }, { i915_mock_selftests, NULL }, { i915_pmu_init, i915_pmu_exit }, diff --git a/drivers/gpu/drm/i915/i915_vma.c b/drivers/gpu/drm/i915/i915_vma.c index 09a7c47926f7..4b7fc4647e46 100644 --- a/drivers/gpu/drm/i915/i915_vma.c +++ b/drivers/gpu/drm/i915/i915_vma.c @@ -34,24 +34,20 @@ #include "gt/intel_gt_requests.h" #include "i915_drv.h" -#include "i915_globals.h" #include "i915_sw_fence_work.h" #include "i915_trace.h" #include "i915_vma.h" -static struct i915_global_vma { - struct i915_global base; - struct kmem_cache *slab_vmas; -} global; +static struct kmem_cache *slab_vmas; struct i915_vma *i915_vma_alloc(void) { - return kmem_cache_zalloc(global.slab_vmas, GFP_KERNEL); + return kmem_cache_zalloc(slab_vmas, GFP_KERNEL); } void i915_vma_free(struct i915_vma *vma) { - return kmem_cache_free(global.slab_vmas, vma); + return kmem_cache_free(slab_vmas, vma); } #if IS_ENABLED(CONFIG_DRM_I915_ERRLOG_GEM) && IS_ENABLED(CONFIG_DRM_DEBUG_MM) @@ -1414,21 +1410,16 @@ void i915_vma_make_purgeable(struct i915_vma *vma) #include "selftests/i915_vma.c" #endif -static void i915_global_vma_exit(void) +void i915_vma_module_exit(void) { - kmem_cache_destroy(global.slab_vmas); + kmem_cache_destroy(slab_vmas); } -static struct i915_global_vma global = { { - .exit = i915_global_vma_exit, -} }; - -int __init i915_global_vma_init(void) +int __init i915_vma_module_init(void) { - global.slab_vmas = KMEM_CACHE(i915_vma, SLAB_HWCACHE_ALIGN); - if (!global.slab_vmas) + slab_vmas = KMEM_CACHE(i915_vma, SLAB_HWCACHE_ALIGN); + if (!slab_vmas) return -ENOMEM; - i915_global_register(&global.base); return 0; } diff --git a/drivers/gpu/drm/i915/i915_vma.h b/drivers/gpu/drm/i915/i915_vma.h index eca452a9851f..ed69f66c7ab0 100644 --- a/drivers/gpu/drm/i915/i915_vma.h +++ b/drivers/gpu/drm/i915/i915_vma.h @@ -426,4 +426,7 @@ static inline int i915_vma_sync(struct i915_vma *vma) return i915_active_wait(&vma->active); } +void i915_vma_module_exit(void); +int i915_vma_module_init(void); + #endif From patchwork Tue Jul 27 12:10:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 12402601 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E9281C4338F for ; Tue, 27 Jul 2021 12:11:15 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B628861A71 for ; Tue, 27 Jul 2021 12:11:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B628861A71 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BE0106EA36; Tue, 27 Jul 2021 12:11:01 +0000 (UTC) Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6DE7C6E9D8 for ; Tue, 27 Jul 2021 12:10:52 +0000 (UTC) Received: by mail-wr1-x42f.google.com with SMTP id h14so6981564wrx.10 for ; Tue, 27 Jul 2021 05:10:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WCqsV70edJbQ7NVyAK9Rx/CfAlgYa6xJoV0SdrDjYT4=; b=b8uppblO0dnYxnJT7h9GKRHZB4tDWVgC+PT6/4kCfTJPO4jR6VTqXjwCqqNK4QXoU8 7TZXepbBqV3pIyLTpFCqAA/yPSck1DgI5qs2ApRMjITwQNGqTIVg9Mi6fcghRHvrRWAK dCM0Pi6Sq9eaLPZchaP1PSX1l29NKB5BoUq+4= 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=WCqsV70edJbQ7NVyAK9Rx/CfAlgYa6xJoV0SdrDjYT4=; b=NP961uP8yBR5KM2UhfZCyk835KWP5o/GsUqQN6kBPc8aWAQQDhR9HLeDYTI+trQSaZ ZdJ1BKb+T35vtDAT2FIfNCsOaR71fpaKYQXI15BVIGOQR892aA7ULWhnRFW2cXznopLC bGY9RPaZmXwpgpjQD8AQYIqvsAdlUaGK/3dILEr6y0g5EpH6Anplz1JHD3Dl4MpsCwd4 OKLxFvnZ6HgyhN/dj8c/AIESvv4oAQKhihOpKqLsbod7aFF5ntsCCjcdrbs+9vWhlSnh 1SHRVhSIxBuQulVSzJtxFOZgtzB75gqNPmzcI0SxhYN/GP4s5N67vr07ClBbbCKRBU4G 3YUQ== X-Gm-Message-State: AOAM532h3prIYyJ+VNXNRRMlCIZ/VveIDEk8quRhiuTGteUc0mvQD2yD izY7e+XL/ANaPWsPIAw4udJ10w== X-Google-Smtp-Source: ABdhPJyZD4BU3WtjQD0+yvAgeHFYR6EYk5JWEGJAUto9wQRWB05pnpkgDTwqfVMRFjr78KW5e9xs0g== X-Received: by 2002:adf:f110:: with SMTP id r16mr24183561wro.358.1627387851009; Tue, 27 Jul 2021 05:10:51 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id k186sm3010577wme.45.2021.07.27.05.10.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jul 2021 05:10:50 -0700 (PDT) From: Daniel Vetter To: DRI Development Date: Tue, 27 Jul 2021 14:10:36 +0200 Message-Id: <20210727121037.2041102-10-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210727121037.2041102-1-daniel.vetter@ffwll.ch> References: <20210727121037.2041102-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v2 10/11] drm/i915: Remove i915_globals X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daniel Vetter , Intel Graphics Development , Daniel Vetter Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" No longer used. Cc: Jason Ekstrand Signed-off-by: Daniel Vetter --- drivers/gpu/drm/i915/Makefile | 1 - drivers/gpu/drm/i915/gt/intel_gt_pm.c | 1 - drivers/gpu/drm/i915/i915_globals.c | 53 --------------------------- drivers/gpu/drm/i915/i915_globals.h | 25 ------------- drivers/gpu/drm/i915/i915_pci.c | 2 - 5 files changed, 82 deletions(-) delete mode 100644 drivers/gpu/drm/i915/i915_globals.c delete mode 100644 drivers/gpu/drm/i915/i915_globals.h diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile index 10b3bb6207ba..9022dc638ed6 100644 --- a/drivers/gpu/drm/i915/Makefile +++ b/drivers/gpu/drm/i915/Makefile @@ -166,7 +166,6 @@ i915-y += \ i915_gem_gtt.o \ i915_gem_ww.o \ i915_gem.o \ - i915_globals.o \ i915_query.o \ i915_request.o \ i915_scheduler.o \ diff --git a/drivers/gpu/drm/i915/gt/intel_gt_pm.c b/drivers/gpu/drm/i915/gt/intel_gt_pm.c index d86825437516..943c1d416ec0 100644 --- a/drivers/gpu/drm/i915/gt/intel_gt_pm.c +++ b/drivers/gpu/drm/i915/gt/intel_gt_pm.c @@ -6,7 +6,6 @@ #include #include "i915_drv.h" -#include "i915_globals.h" #include "i915_params.h" #include "intel_context.h" #include "intel_engine_pm.h" diff --git a/drivers/gpu/drm/i915/i915_globals.c b/drivers/gpu/drm/i915/i915_globals.c deleted file mode 100644 index 04979789e7be..000000000000 --- a/drivers/gpu/drm/i915/i915_globals.c +++ /dev/null @@ -1,53 +0,0 @@ -/* - * SPDX-License-Identifier: MIT - * - * Copyright © 2019 Intel Corporation - */ - -#include -#include - -#include "i915_globals.h" -#include "i915_drv.h" - -static LIST_HEAD(globals); - -void __init i915_global_register(struct i915_global *global) -{ - GEM_BUG_ON(!global->exit); - - list_add_tail(&global->link, &globals); -} - -static void __i915_globals_cleanup(void) -{ - struct i915_global *global, *next; - - list_for_each_entry_safe_reverse(global, next, &globals, link) - global->exit(); -} - -static __initconst int (* const initfn[])(void) = { -}; - -int __init i915_globals_init(void) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(initfn); i++) { - int err; - - err = initfn[i](); - if (err) { - __i915_globals_cleanup(); - return err; - } - } - - return 0; -} - -void i915_globals_exit(void) -{ - __i915_globals_cleanup(); -} diff --git a/drivers/gpu/drm/i915/i915_globals.h b/drivers/gpu/drm/i915/i915_globals.h deleted file mode 100644 index 57d2998bba45..000000000000 --- a/drivers/gpu/drm/i915/i915_globals.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * SPDX-License-Identifier: MIT - * - * Copyright © 2019 Intel Corporation - */ - -#ifndef _I915_GLOBALS_H_ -#define _I915_GLOBALS_H_ - -#include - -typedef void (*i915_global_func_t)(void); - -struct i915_global { - struct list_head link; - - i915_global_func_t exit; -}; - -void i915_global_register(struct i915_global *global); - -int i915_globals_init(void); -void i915_globals_exit(void); - -#endif /* _I915_GLOBALS_H_ */ diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c index 14785d88dafb..b4f5e88aaae6 100644 --- a/drivers/gpu/drm/i915/i915_pci.c +++ b/drivers/gpu/drm/i915/i915_pci.c @@ -37,7 +37,6 @@ #include "gem/i915_gem_object.h" #include "i915_request.h" #include "i915_perf.h" -#include "i915_globals.h" #include "i915_selftest.h" #include "i915_scheduler.h" #include "i915_vma.h" @@ -1309,7 +1308,6 @@ static const struct { { i915_request_module_init, i915_request_module_exit }, { i915_scheduler_module_init, i915_scheduler_module_exit }, { i915_vma_module_init, i915_vma_module_exit }, - { i915_globals_init, i915_globals_exit }, { i915_mock_selftests, NULL }, { i915_pmu_init, i915_pmu_exit }, { i915_register_pci_driver, i915_unregister_pci_driver }, From patchwork Tue Jul 27 12:10:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 12402603 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72BE0C4320A for ; Tue, 27 Jul 2021 12:11:16 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3FD7861A71 for ; Tue, 27 Jul 2021 12:11:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3FD7861A71 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 919F56EA2A; Tue, 27 Jul 2021 12:11:02 +0000 (UTC) Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4BD986E9D8 for ; Tue, 27 Jul 2021 12:10:53 +0000 (UTC) Received: by mail-wr1-x430.google.com with SMTP id r2so14985740wrl.1 for ; Tue, 27 Jul 2021 05:10:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QJnqoqOXB9+u6uqWz9HbnyQ59ICs56VzdaGB4gc4dXw=; b=VVYoVGzScvSTwe86Sro86PG/AQn/w7PUzP4czC1sC+v8U4rUuKHm979v15ACT+ToHL 98HCwNZzHjrvbJ4bJO37jIllURjW58cZbeQ4ORZwJ3WyAyyOwDL5ppFKNfgL47VJE0u0 XmYnWVc19KdZf6/1JWtUqRD3VSsjontF4o93M= 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=QJnqoqOXB9+u6uqWz9HbnyQ59ICs56VzdaGB4gc4dXw=; b=kO88khKoUT/uAKkGzLO0xZv5ymJImo4GzYzACS1Y7NW2EKS7HH7/iPY5y2DkMOnCGG ztMZDRwGkEEs0zg1PSl+IzwX76ZFVPqigj37gOLDqvte5Y3J7z26T7NW7ZcJquWAq0sy n83SXMlfzff4Coxx/hq/qOwkV+YMuQQzYB8oikStP232DOlrQyNXLNtq6ShsmxD43PoM OdPfDYC116M9Yg+hzrWL2N2j4yjT0+CaaVyO+JXXFu3TgUjdc5WjoNxOrix+AqDOkVoi Dj7n7TWPKypYzfUCbXixMpCnROyDrg7YUoh2sENZoSZzWIb0VGigyQeVBZMCDsEwGgsB g3ww== X-Gm-Message-State: AOAM5308JKYIGqF6tXPPkKqlu9ILaFAsMzJwsyfGTUuozjpPTHCmqxYH Q2cFvB75w5wBD8jAQqJnOxWFqfyRB15ckg== X-Google-Smtp-Source: ABdhPJw/k/TYh8/3Ihcad2+67nGgvgPfPNRIZGXw4MLMsZtmhE0ZilpkgviilaM2KMi2urq/5XgF/A== X-Received: by 2002:a5d:4e8f:: with SMTP id e15mr16395021wru.313.1627387851808; Tue, 27 Jul 2021 05:10:51 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id k186sm3010577wme.45.2021.07.27.05.10.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jul 2021 05:10:51 -0700 (PDT) From: Daniel Vetter To: DRI Development Date: Tue, 27 Jul 2021 14:10:37 +0200 Message-Id: <20210727121037.2041102-11-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210727121037.2041102-1-daniel.vetter@ffwll.ch> References: <20210727121037.2041102-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v2 11/11] drm/i915: Extract i915_module.c X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daniel Vetter , Daniel Vetter , Intel Graphics Development Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" The module init code is somewhat misplaced in i915_pci.c, since it needs to pull in init/exit functions from every part of the driver and pollutes the include list a lot. Extract an i915_module.c file which pulls all the bits together, and allows us to massively trim the include list of i915_pci.c. The downside is that have to drop the error path check Jason added to catch when we set up the pci driver too early. I think that risk is acceptable for this pretty nice include. Cc: Jason Ekstrand Cc: Tvrtko Ursulin Signed-off-by: Daniel Vetter Reviewed-by: Jason Ekstrand --- drivers/gpu/drm/i915/Makefile | 1 + drivers/gpu/drm/i915/i915_module.c | 113 ++++++++++++++++++++++++++++ drivers/gpu/drm/i915/i915_pci.c | 117 +---------------------------- drivers/gpu/drm/i915/i915_pci.h | 8 ++ 4 files changed, 125 insertions(+), 114 deletions(-) create mode 100644 drivers/gpu/drm/i915/i915_module.c create mode 100644 drivers/gpu/drm/i915/i915_pci.h diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile index 9022dc638ed6..4ebd9f417ddb 100644 --- a/drivers/gpu/drm/i915/Makefile +++ b/drivers/gpu/drm/i915/Makefile @@ -38,6 +38,7 @@ i915-y += i915_drv.o \ i915_irq.o \ i915_getparam.o \ i915_mitigations.o \ + i915_module.o \ i915_params.o \ i915_pci.o \ i915_scatterlist.o \ diff --git a/drivers/gpu/drm/i915/i915_module.c b/drivers/gpu/drm/i915/i915_module.c new file mode 100644 index 000000000000..c578ea8f56a0 --- /dev/null +++ b/drivers/gpu/drm/i915/i915_module.c @@ -0,0 +1,113 @@ +/* + * SPDX-License-Identifier: MIT + * + * Copyright © 2021 Intel Corporation + */ + +#include + +#include "gem/i915_gem_context.h" +#include "gem/i915_gem_object.h" +#include "i915_active.h" +#include "i915_buddy.h" +#include "i915_params.h" +#include "i915_pci.h" +#include "i915_perf.h" +#include "i915_request.h" +#include "i915_scheduler.h" +#include "i915_selftest.h" +#include "i915_vma.h" + +static int i915_check_nomodeset(void) +{ + bool use_kms = true; + + /* + * Enable KMS by default, unless explicitly overriden by + * either the i915.modeset prarameter or by the + * vga_text_mode_force boot option. + */ + + if (i915_modparams.modeset == 0) + use_kms = false; + + if (vgacon_text_force() && i915_modparams.modeset == -1) + use_kms = false; + + if (!use_kms) { + /* Silently fail loading to not upset userspace. */ + DRM_DEBUG_DRIVER("KMS disabled.\n"); + return 1; + } + + return 0; +} + +static const struct { + int (*init)(void); + void (*exit)(void); +} init_funcs[] = { + { i915_check_nomodeset, NULL }, + { i915_active_module_init, i915_active_module_exit }, + { i915_buddy_module_init, i915_buddy_module_exit }, + { i915_context_module_init, i915_context_module_exit }, + { i915_gem_context_module_init, i915_gem_context_module_exit }, + { i915_objects_module_init, i915_objects_module_exit }, + { i915_request_module_init, i915_request_module_exit }, + { i915_scheduler_module_init, i915_scheduler_module_exit }, + { i915_vma_module_init, i915_vma_module_exit }, + { i915_mock_selftests, NULL }, + { i915_pmu_init, i915_pmu_exit }, + { i915_register_pci_driver, i915_unregister_pci_driver }, + { i915_perf_sysctl_register, i915_perf_sysctl_unregister }, +}; +static int init_progress; + +static int __init i915_init(void) +{ + int err, i; + + for (i = 0; i < ARRAY_SIZE(init_funcs); i++) { + err = init_funcs[i].init(); + if (err < 0) { + while (i--) { + if (init_funcs[i].exit) + init_funcs[i].exit(); + } + return err; + } else if (err > 0) { + /* + * Early-exit success is reserved for things which + * don't have an exit() function because we have no + * idea how far they got or how to partially tear + * them down. + */ + WARN_ON(init_funcs[i].exit); + break; + } + } + + init_progress = i; + + return 0; +} + +static void __exit i915_exit(void) +{ + int i; + + for (i = init_progress - 1; i >= 0; i--) { + GEM_BUG_ON(i >= ARRAY_SIZE(init_funcs)); + if (init_funcs[i].exit) + init_funcs[i].exit(); + } +} + +module_init(i915_init); +module_exit(i915_exit); + +MODULE_AUTHOR("Tungsten Graphics, Inc."); +MODULE_AUTHOR("Intel Corporation"); + +MODULE_DESCRIPTION(DRIVER_DESC); +MODULE_LICENSE("GPL and additional rights"); diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c index b4f5e88aaae6..08651ca03478 100644 --- a/drivers/gpu/drm/i915/i915_pci.c +++ b/drivers/gpu/drm/i915/i915_pci.c @@ -22,24 +22,13 @@ * */ -#include #include #include #include -#include "display/intel_fbdev.h" - -#include "i915_active.h" -#include "i915_buddy.h" #include "i915_drv.h" -#include "gem/i915_gem_context.h" -#include "gem/i915_gem_object.h" -#include "i915_request.h" -#include "i915_perf.h" -#include "i915_selftest.h" -#include "i915_scheduler.h" -#include "i915_vma.h" +#include "i915_pci.h" #define PLATFORM(x) .platform = (x) #define GEN(x) \ @@ -1251,31 +1240,6 @@ static void i915_pci_shutdown(struct pci_dev *pdev) i915_driver_shutdown(i915); } -static int i915_check_nomodeset(void) -{ - bool use_kms = true; - - /* - * Enable KMS by default, unless explicitly overriden by - * either the i915.modeset prarameter or by the - * vga_text_mode_force boot option. - */ - - if (i915_modparams.modeset == 0) - use_kms = false; - - if (vgacon_text_force() && i915_modparams.modeset == -1) - use_kms = false; - - if (!use_kms) { - /* Silently fail loading to not upset userspace. */ - DRM_DEBUG_DRIVER("KMS disabled.\n"); - return 1; - } - - return 0; -} - static struct pci_driver i915_pci_driver = { .name = DRIVER_NAME, .id_table = pciidlist, @@ -1285,87 +1249,12 @@ static struct pci_driver i915_pci_driver = { .driver.pm = &i915_pm_ops, }; -static int i915_register_pci_driver(void) +int i915_register_pci_driver(void) { return pci_register_driver(&i915_pci_driver); } -static void i915_unregister_pci_driver(void) +void i915_unregister_pci_driver(void) { pci_unregister_driver(&i915_pci_driver); } - -static const struct { - int (*init)(void); - void (*exit)(void); -} init_funcs[] = { - { i915_check_nomodeset, NULL }, - { i915_active_module_init, i915_active_module_exit }, - { i915_buddy_module_init, i915_buddy_module_exit }, - { i915_context_module_init, i915_context_module_exit }, - { i915_gem_context_module_init, i915_gem_context_module_exit }, - { i915_objects_module_init, i915_objects_module_exit }, - { i915_request_module_init, i915_request_module_exit }, - { i915_scheduler_module_init, i915_scheduler_module_exit }, - { i915_vma_module_init, i915_vma_module_exit }, - { i915_mock_selftests, NULL }, - { i915_pmu_init, i915_pmu_exit }, - { i915_register_pci_driver, i915_unregister_pci_driver }, - { i915_perf_sysctl_register, i915_perf_sysctl_unregister }, -}; -static int init_progress; - -static int __init i915_init(void) -{ - int err, i; - - for (i = 0; i < ARRAY_SIZE(init_funcs); i++) { - err = init_funcs[i].init(); - if (err < 0) { - while (i--) { - if (init_funcs[i].exit) - init_funcs[i].exit(); - } - return err; - } else if (err > 0) { - /* - * Early-exit success is reserved for things which - * don't have an exit() function because we have no - * idea how far they got or how to partially tear - * them down. - */ - WARN_ON(init_funcs[i].exit); - - /* - * We don't want to advertise devices with an only - * partially initialized driver. - */ - WARN_ON(i915_pci_driver.driver.owner); - break; - } - } - - init_progress = i; - - return 0; -} - -static void __exit i915_exit(void) -{ - int i; - - for (i = init_progress - 1; i >= 0; i--) { - GEM_BUG_ON(i >= ARRAY_SIZE(init_funcs)); - if (init_funcs[i].exit) - init_funcs[i].exit(); - } -} - -module_init(i915_init); -module_exit(i915_exit); - -MODULE_AUTHOR("Tungsten Graphics, Inc."); -MODULE_AUTHOR("Intel Corporation"); - -MODULE_DESCRIPTION(DRIVER_DESC); -MODULE_LICENSE("GPL and additional rights"); diff --git a/drivers/gpu/drm/i915/i915_pci.h b/drivers/gpu/drm/i915/i915_pci.h new file mode 100644 index 000000000000..b386f319f52e --- /dev/null +++ b/drivers/gpu/drm/i915/i915_pci.h @@ -0,0 +1,8 @@ +/* + * SPDX-License-Identifier: MIT + * + * Copyright © 2021 Intel Corporation + */ + +int i915_register_pci_driver(void); +void i915_unregister_pci_driver(void);