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 4FC13E99046 for ; Fri, 10 Apr 2026 07:14:43 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4fsSjY4MsMz2ynh; Fri, 10 Apr 2026 17:14:41 +1000 (AEST) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=172.105.4.254 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1775800280; cv=none; b=YDwl4nwMlOnkP36lS4w7VP224Qmdd0YSC2NqY2Y/m/YK6m2zNEpBqIKbLh8+VX2PZyrDKk1QvbaFIJc60n9Ge82seGDjEURjPr0ZNGJOnOnnMusUbkKwVglDLU1/vCpbSx4jLkNw/+SrMV29N4QU8XvkC9nKNJ7SR7D0KIE2lGAreJyw/9mxm2l5bFBeD2DB/SbaRA62fHzlmPDEgGui/QYNk9X1udQtc788WlCRzAzlaXUBi6x9iXXR/DkGG8M/X10tMh3qnZYkNSCthIz+t/9W4VywRMvYYEpaK23R18+ew2u9qD2ce0PU/ktVp6gWHHO75FNiaK2H0Jrl2O0zmA== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1775800280; c=relaxed/relaxed; bh=QD+/cW6h0q9mGUMgMdUdQ8FCVWTEz9IOGPDR4jJN19Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=DgSlDE+WU1LA34zQeZ93CqHm1nhU5vDNs5Qpx6riKY6Kf28Oxp5Py1TbMoTDgcvs5yQD9LGRhZr4a7tcApf5P36gnCjUPBdvDpqhZzMPNw1eYskiuPmU2cSBVt0a4aEgZhkua1WHTLBB4Pk8idOcZQBbPVgkq1QI7XjjO3UWeC4RD5A+iU9MA8l+hOBa7DPnYNEZItEAiDCcxc77254grFPpRQOHJAvV0ynheQH5sXcjv5KBVL36g20N/tkA2gS705cpyoZVU49jYNHWoDmDgILpmqQKe+H4l0m9ZHZK0900QbBieQDX4CfkataZXe8VgKQSn7G6b6DkAM/zW5OXDw== 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=CVeUMnFB; dkim-atps=neutral; spf=pass (client-ip=172.105.4.254; helo=tor.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=CVeUMnFB; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org (client-ip=172.105.4.254; helo=tor.source.kernel.org; envelope-from=kwilczynski@kernel.org; receiver=lists.ozlabs.org) Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) (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 4fsQsM4Km6z2yRl for ; Fri, 10 Apr 2026 15:51:19 +1000 (AEST) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id 825D76014C; Fri, 10 Apr 2026 05:51:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0B6F9C2BCAF; Fri, 10 Apr 2026 05:51:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1775800277; bh=3hptuhV9yvRK5QFViJmdIejaERCBcfDgF46k3rwUdzg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CVeUMnFB92kckEyX6w4AOLTj43SKV6JPyWI+WtBUYmkpZDDOQKifdnGtDYcPQlEPl afN0P4N57mX3XV53stpV1j8HBs+zNnRRsrSDWkSZW2FeRnTy0lYBaKE78W/7GD6iXz to+Zhxoks60apXrm5tH+1kUihP78QNon1tQB4gDPxTrIUjv9To/eMvOTNpYH1sBOaN pzJm/EIB9e7iJ63Tjxx2RJtHBPsEChZ3vdZssI0RN4+ZdYCHcrh3rHGg2cXIUr5LMG gg/NUq3Cu6u2LyDUIPOP81q2j00XYpnfbEUrXfYgt54IOy+Znj7kTfry/QjxyPHBdO 7iMU488IS78SQ== From: =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= To: Bjorn Helgaas Cc: Bjorn Helgaas , Manivannan Sadhasivam , Lorenzo Pieralisi , 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 09/20] PCI/sysfs: Limit pci_sysfs_init() late_initcall compile scope Date: Fri, 10 Apr 2026 05:50:29 +0000 Message-ID: <20260410055040.39233-10-kwilczynski@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260410055040.39233-1-kwilczynski@kernel.org> References: <20260410055040.39233-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. 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 e200514bbaed..062921d5df9b 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) \ @@ -1791,6 +1798,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) @@ -1817,6 +1825,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.53.0