From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id ABC39CD3436 for ; Fri, 8 May 2026 04:37:12 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4gBbt41JChz30P3; Fri, 08 May 2026 14:36:28 +1000 (AEST) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip="2600:3c0a:e001:78e:0:1991:8:25" ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1778214988; cv=none; b=L+TiS5YinBZIr9T0S3kDdP2Ot4ZtWgQhu9WcpPacYyhSRWTNzTJUlJbUPP3CFAbkP8Gtr1+fwDoiGfY7/ZuMov6WydCfbiIDxX4CH63kq5OZHx+G8s0ct7PlhFLypAaTU1NxMbYn2TrIvOd9GB6uHE06tMOv4BsEYSNod/Bab24kufvPo0HavJn31d1SB8GIiPYmNk0LbhBuGWBxHnfrbf9oguq5yzOJJGUbKoLTL9akIghVH/kO9ljROp8t2mhwoL3qHhdRbPzg8jaGeoF6QO2Mlf60k8Nc4ly5Cm/qSfw8IHuA757Agb+1+MMypxn+2ka8N82n4qIRAV6bR4XeSQ== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1778214988; c=relaxed/relaxed; bh=/VPJxeT03GaVKMvYydPv8LxL+/+acfcQ+GXDLWn0TRA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=mNMw3bSnDV2JTlOLwZMUeOXJCRkRQHzSjdHEDM9hiwJibBtMAhV/qZ1TEtcE1ckF36cQk5BPnleF8NSWM5uQY7snBFRfWbxYiioOBgJ6UGbD+AzoCgDjPbFptZ3LMistj4fwPXYZlwtI6XXUNNahtgxjtNR7rPbDohuEwj8iznh4Q4xlRWQvdhvUPUJJ+Ww83Uclo8fAm4UZ3NHo5JboMELWjhTM1gq3JOJh/1AwKhtfRoVZUdmTDJo1zf/TFBn+NejUHGqccDjhSJgRVBIZTz1af4xBQbOKPEC9cC5eVQV6Cgz5bdboyv5IITlVhKXUxbmT21iH/hb6/jTdynp2MA== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=rh/5q/KS; dkim-atps=neutral; spf=pass (client-ip=2600:3c0a:e001:78e:0:1991:8:25; helo=sea.source.kernel.org; envelope-from=kwilczynski@kernel.org; receiver=lists.ozlabs.org) smtp.mailfrom=kernel.org Authentication-Results: lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=rh/5q/KS; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org (client-ip=2600:3c0a:e001:78e:0:1991:8:25; helo=sea.source.kernel.org; envelope-from=kwilczynski@kernel.org; receiver=lists.ozlabs.org) Received: from sea.source.kernel.org (sea.source.kernel.org [IPv6:2600:3c0a:e001:78e:0:1991:8:25]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4gBbt32F1hz2xPb for ; Fri, 08 May 2026 14:36:27 +1000 (AEST) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id 4D2FB40DA9; Fri, 8 May 2026 04:36:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E00E3C2BCB4; Fri, 8 May 2026 04:36:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1778214985; bh=XwywdNQStJKB2nARSUHqZ+M01XWfSdEtG3nW3a2lTfI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rh/5q/KSOyqNiNpnrNf+NkkxPg8L1Zev7C/vrEesNsZlBBknrMXZvGpK11nn0XumL cFUnaIZb60HIJmq36t8QPr0VsyDaWP8wNPAhLdqEpj+LUzcNHTQH6wnjDXvOTgO+Ao BiLGRpySYs1oVUVWVEG84ViINV5tcIvMO7PV72uZogIH2M8YGkXWw5jVKKKDH+WgV/ tDAHSXJiWIyTe8ACpFvJP8XLpDpkrX1lmnl3P/QQ4qoKxSZKXU4Qu+xNAnPYz0T2K2 u2eWi84CXh/VCfhPfv7Wrh7ycf6NpDp5wdDRRsWYlfRcVXLXTqVueHq8VcCe2kABjp IzI1PYLxKCPEQ== From: =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= To: Bjorn Helgaas Cc: Bjorn Helgaas , Manivannan Sadhasivam , Lorenzo Pieralisi , Alex Williamson , Magnus Lindholm , Matt Turner , Richard Henderson , Christophe Leroy , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Dexuan Cui , =?UTF-8?q?Krzysztof=20Ha=C5=82asa?= , Lukas Wunner , "Oliver O'Halloran" , Saurabh Singh Sengar , Shuan He , Srivatsa Bhat , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , linux-pci@vger.kernel.org, linux-alpha@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: [PATCH v7 10/24] PCI/sysfs: Limit pci_sysfs_init() late_initcall compile scope Date: Fri, 8 May 2026 04:35:29 +0000 Message-ID: <20260508043543.217179-11-kwilczynski@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260508043543.217179-1-kwilczynski@kernel.org> References: <20260508043543.217179-1-kwilczynski@kernel.org> X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , List-Subscribe: , , List-Unsubscribe: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently, pci_sysfs_init() and sysfs_initialized compile unconditionally, even on platforms where static attribute groups handle all resource file creation. Thus, place them behind a new HAVE_PCI_SYSFS_INIT macro, especially as the late_initcall is only needed when: - HAVE_PCI_LEGACY is set, to iterate buses and create legacy I/O and memory files. - Neither HAVE_PCI_MMAP nor ARCH_GENERIC_PCI_MMAP_RESOURCE is set, to iterate devices and create resource files via the __weak pci_create_resource_files() stub override (this is how the Alpha architecture handles this currently). On most systems both conditions are false and the entire late_initcall compiles away. Tested-by: Shivaprasad G Bhat Signed-off-by: Krzysztof WilczyƄski --- drivers/pci/pci-sysfs.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index b2a2de622f39..225c3d0db74e 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c @@ -37,7 +37,14 @@ #define ARCH_PCI_DEV_GROUPS #endif +#if defined(HAVE_PCI_LEGACY) || \ + !defined(HAVE_PCI_MMAP) && !defined(ARCH_GENERIC_PCI_MMAP_RESOURCE) +#define HAVE_PCI_SYSFS_INIT +#endif + +#ifdef HAVE_PCI_SYSFS_INIT static int sysfs_initialized; /* = 0 */ +#endif /* show configuration fields */ #define pci_config_attr(field, format_string) \ @@ -1768,6 +1775,7 @@ void pci_remove_sysfs_dev_files(struct pci_dev *pdev) } #endif +#ifdef HAVE_PCI_SYSFS_INIT static int __init pci_sysfs_init(void) { #if defined(HAVE_PCI_MMAP) || defined(ARCH_GENERIC_PCI_MMAP_RESOURCE) @@ -1794,6 +1802,7 @@ static int __init pci_sysfs_init(void) return 0; } late_initcall(pci_sysfs_init); +#endif static struct attribute *pci_dev_dev_attrs[] = { &dev_attr_boot_vga.attr, -- 2.54.0