From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8192318FDBD; Fri, 19 Jun 2026 08:52:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781859162; cv=none; b=bbf0mxDn0W5ahxBfS6mJ3cPcXfPWri5toLUWS/TTHDOAyKemdQF/3QjOEjWIA+ibWHNncKmZy7/OefZ9H2ChgYpEq34W7nBhigsIDUHDlm0DXornKGr8rtqqOX+vyBTkEsEaZ258MzW2tY01UepkrZta18RFLHJzIHsTfhcnCJs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781859162; c=relaxed/simple; bh=/wlqGYVuuaEQlDlolQ/yGz4+9vnxYImWi5k+LH64SDU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Ep04hDr7oVK5B49nlESJtAobv+q24/YAAYSU7JRj+dPplGo43ce4nec/qV1HL82uUTC0YanwlCB9bsLMqhyeLSF7vPLsLGi3nCuyJQPJZRZyDwuzO1YGvjQNltcVAWR7sKXX3RGs9+dhU9IpAZjaouiCDcz6W3SrEXS+JouthAA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=H1ZMOHhM; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="H1ZMOHhM" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2A9BB1F00AC4; Fri, 19 Jun 2026 08:52:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1781859161; bh=hZpSQCgMlKTKZQdytllooM44So4t4sr5jU9EJXYUHVc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=H1ZMOHhMl+y1+Dw1MeuXMLFbr5eQDs6bYt4mPEeMYE0+tCyo4Lse8Wpo9pgtcpS01 shrYlFlpaQWcEVBAxThHaQBTVmwGlLqvdHQbR4k+RCOhmVThTC5c1wsNCM7zrvnv3e uP2vf5UMwsykYQo9EA5NV7n9heStDbsN0Ltx6kiMPElumWMJNPk06p8GeIaP44lNyV e+G7djMnqKu4tDzVRtjs67K5dgbZB/MJM0qLeChO0wYikGmtvuqJJsTJrZId/yDzwf ehMto8Hh3ZsgiCfKM/g/VuK5HrVery5hw2skk+BrRY15aU1hyDWPwKH6e2YQsT9P8l 6QZnT1n9wz/KQ== 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 v8 10/25] PCI/sysfs: Limit pci_sysfs_init() late_initcall compile scope Date: Fri, 19 Jun 2026 08:51:45 +0000 Message-ID: <20260619085200.3729431-11-kwilczynski@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260619085200.3729431-1-kwilczynski@kernel.org> References: <20260619085200.3729431-1-kwilczynski@kernel.org> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 208ec7057b50..57d89e12bfec 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