* [PATCH 1/1] PCI/sysfs: get rid of pci_sysfs_init late_initcall
@ 2023-03-16 10:30 Alexander Stein
0 siblings, 0 replies; only message in thread
From: Alexander Stein @ 2023-03-16 10:30 UTC (permalink / raw)
To: Bjorn Helgaas; +Cc: Alexander Stein, linux-pci, linux-kernel
All this initcall does is creating sysfs file for devices already
added to the bus. But this is racing with pci_host_probe which will
add sysfs files on it's own merit.
Link: https://bugzilla.kernel.org/show_bug.cgi?id=215515
Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
---
This is a different approach to fix the race condition mentioned in the
link. From what I can see is that the functions for creating sysfs are
called during pci bus registration anyway, so there is no need to
iterate once again.
drivers/pci/pci-sysfs.c | 33 ---------------------------------
1 file changed, 33 deletions(-)
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index dd0d9d9bc509..00c8cc3c40ff 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -31,8 +31,6 @@
#include <linux/aperture.h>
#include "pci.h"
-static int sysfs_initialized; /* = 0 */
-
/* show configuration fields */
#define pci_config_attr(field, format_string) \
static ssize_t \
@@ -953,9 +951,6 @@ void pci_create_legacy_files(struct pci_bus *b)
{
int error;
- if (!sysfs_initialized)
- return;
-
b->legacy_io = kcalloc(2, sizeof(struct bin_attribute),
GFP_ATOMIC);
if (!b->legacy_io)
@@ -1494,9 +1489,6 @@ static const struct attribute_group pci_dev_resource_resize_group = {
int __must_check pci_create_sysfs_dev_files(struct pci_dev *pdev)
{
- if (!sysfs_initialized)
- return -EACCES;
-
return pci_create_resource_files(pdev);
}
@@ -1508,34 +1500,9 @@ int __must_check pci_create_sysfs_dev_files(struct pci_dev *pdev)
*/
void pci_remove_sysfs_dev_files(struct pci_dev *pdev)
{
- if (!sysfs_initialized)
- return;
-
pci_remove_resource_files(pdev);
}
-static int __init pci_sysfs_init(void)
-{
- struct pci_dev *pdev = NULL;
- struct pci_bus *pbus = NULL;
- int retval;
-
- sysfs_initialized = 1;
- for_each_pci_dev(pdev) {
- retval = pci_create_sysfs_dev_files(pdev);
- if (retval) {
- pci_dev_put(pdev);
- return retval;
- }
- }
-
- while ((pbus = pci_find_next_bus(pbus)))
- pci_create_legacy_files(pbus);
-
- return 0;
-}
-late_initcall(pci_sysfs_init);
-
static struct attribute *pci_dev_dev_attrs[] = {
&dev_attr_boot_vga.attr,
NULL,
--
2.34.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2023-03-16 10:31 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-16 10:30 [PATCH 1/1] PCI/sysfs: get rid of pci_sysfs_init late_initcall Alexander Stein
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).