Skip to contentSkip to conversation

Allow deferred execution of iomem_get_mapping()

PATCH In review Krzysztof Wilczyński 3 participants 9 messages Jul 29, 2021 – Aug 6, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v3 cover Allow deferred execution of iomem_get_mapping()

Hello,

At the moment, the dependency on iomem_get_mapping() that is currently used in the pci_create_resource_files() and pci_create_legacy_files() stops us from completely retiring the late_initcall() that is used to invoke pci_sysfs_init() when creating sysfs object for PCI devices.

This dependency on iomem_get_mapping() stops us from retiring the late_initcall at the moment as when we convert dynamically added sysfs objects, that are primarily added in the pci_create_resource_files() and pci_create_legacy_files(), as these attributes are added before the VFS completes its initialisation, and since most of the PCI devices are typically enumerated in subsys_initcall this leads to a failure and an Oops related to iomem_get_mapping() access.

See relevant conversations:
https://lore.kernel.org/linux-pci/[email protected]/
https://lore.kernel.org/linux-pci/20210313215747.GA2394467@bjorn-Precision-5520/

After some deliberation about the problem at hand, Dan Williams suggested a solution to the problem, as per:
https://lore.kernel.org/linux-pci/CAPcyv4i0y_4cMGEpNVShLUyUk3nyWH203Ry3S87BqnDJE0Rmxg@mail.gmail.com/

The idea is to defer execution of the iomem_get_mapping() to only when the sysfs open callback is run, and thus removing the reliance of fs_initcalls to complete before any other sub-system that uses the iomem_get_mapping().

Currently, the PCI sub-system will benefit the most from this change allowing for it to complete the transition from dynamically created to static sysfs objects.

This series aims to take Dan Williams' idea through the finish line.

Related to:
https://lore.kernel.org/linux-pci/20210527205845.GA1421476@bjorn-Precision-5520/
https://lore.kernel.org/linux-pci/[email protected]/
https://lore.kernel.org/linux-pci/20200716110423.xtfyb3n6tn5ixedh@pali/

Krzysztof

---
Changes in v3:
Squashed first two patches from v2 into a single patch to resolve compile time issues.
Carried over Dan Williams' review from v2 as there are no code or functional changes.

Changes in v2:
Added "Signed-off-by" and "Reviewed-by" from Dan Williams as per his feedback.
Added third patch that renames struct bin_attribute member "mapping" to "f_mapping" to keep the naming consistent with struct file. N.B. this patch can definitely be dropped as the rename is not required for anything else to work.

Krzysztof Wilczyński (2):
sysfs: Invoke iomem_get_mapping() from the sysfs open callback
sysfs: Rename struct bin_attribute member to f_mapping

 drivers/pci/pci-sysfs.c | 6 +++---
 fs/sysfs/file.c         | 4 ++--
 include/linux/sysfs.h   | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)
Signature · 1 line
2.32.0
#1 lore raw

PATCH v3 1/2 sysfs: Invoke iomem_get_mapping() from the sysfs open callback

Defer invocation of the iomem_get_mapping() to the sysfs open callback so that it can be executed as needed when the binary sysfs object has been accessed.

To do that, convert the "mapping" member of the struct bin_attribute from a pointer to the struct address_space into a function pointer with a signature that requires the same return type, and then updates the sysfs_kf_bin_open() to invoke provided function should the function pointer be valid.

Also, convert every invocation of iomem_get_mapping() into a function pointer assignment, therefore allowing for the iomem_get_mapping() invocation to be deferred to when the sysfs open callback runs.

Thus, this change removes the need for the fs_initcalls to complete before any other sub-system that uses the iomem_get_mapping() would be able to invoke it safely without leading to a failure and an Oops related to an invalid iomem_get_mapping() access.

---
 drivers/pci/pci-sysfs.c | 6 +++---
 fs/sysfs/file.c         | 2 +-
 include/linux/sysfs.h   | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)
drivers/pci/pci-sysfs.c +3 -3
index 5d63df7c1820..76e5545d0e73 100644
@@ -965,7 +965,7 @@ void pci_create_legacy_files(struct pci_bus *b)
 	b->legacy_io->read = pci_read_legacy_io;
 	b->legacy_io->write = pci_write_legacy_io;
 	b->legacy_io->mmap = pci_mmap_legacy_io;
-	b->legacy_io->mapping = iomem_get_mapping();
+	b->legacy_io->mapping = iomem_get_mapping;
 	pci_adjust_legacy_attr(b, pci_mmap_io);
 	error = device_create_bin_file(&b->dev, b->legacy_io);
 	if (error)
@@ -978,7 +978,7 @@ void pci_create_legacy_files(struct pci_bus *b)
 	b->legacy_mem->size = 1024*1024;
 	b->legacy_mem->attr.mode = 0600;
 	b->legacy_mem->mmap = pci_mmap_legacy_mem;
-	b->legacy_io->mapping = iomem_get_mapping();
+	b->legacy_io->mapping = iomem_get_mapping;
 	pci_adjust_legacy_attr(b, pci_mmap_mem);
 	error = device_create_bin_file(&b->dev, b->legacy_mem);
 	if (error)
@@ -1195,7 +1195,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
 		}
 	}
 	if (res_attr->mmap)
-		res_attr->mapping = iomem_get_mapping();
+		res_attr->mapping = iomem_get_mapping;
 	res_attr->attr.name = res_attr_name;
 	res_attr->attr.mode = 0600;
 	res_attr->size = pci_resource_len(pdev, num);
fs/sysfs/file.c +1 -1
index 9aefa7779b29..a3ee4c32a264 100644
@@ -175,7 +175,7 @@ static int sysfs_kf_bin_open(struct kernfs_open_file *of)
 	struct bin_attribute *battr = of->kn->priv;
 
 	if (battr->mapping)
-		of->file->f_mapping = battr->mapping;
+		of->file->f_mapping = battr->mapping();
 
 	return 0;
 }
include/linux/sysfs.h +1 -1
index a12556a4b93a..d5bcc897583c 100644
@@ -176,7 +176,7 @@ struct bin_attribute {
 	struct attribute	attr;
 	size_t			size;
 	void			*private;
-	struct address_space	*mapping;
+	struct address_space *(*mapping)(void);
 	ssize_t (*read)(struct file *, struct kobject *, struct bin_attribute *,
 			char *, loff_t, size_t);
 	ssize_t (*write)(struct file *, struct kobject *, struct bin_attribute *,
Signature · 1 line
2.32.0
#3 lore raw

PATCH v3 2/2 sysfs: Rename struct bin_attribute member to f_mapping

In reply to Krzysztof Wilczyński

There are two users of iomem_get_mapping(), the struct file and struct bin_attribute. The former has a member called "f_mapping" and the latter has a member called "mapping", and both are poniters to struct address_space.

Rename struct bin_attribute member to "f_mapping" to keep both meaning and the usage consistent with other users of iomem_get_mapping().

---
 drivers/pci/pci-sysfs.c | 6 +++---
 fs/sysfs/file.c         | 4 ++--
 include/linux/sysfs.h   | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)
drivers/pci/pci-sysfs.c +3 -3
index 76e5545d0e73..f65382915f01 100644
@@ -965,7 +965,7 @@ void pci_create_legacy_files(struct pci_bus *b)
 	b->legacy_io->read = pci_read_legacy_io;
 	b->legacy_io->write = pci_write_legacy_io;
 	b->legacy_io->mmap = pci_mmap_legacy_io;
-	b->legacy_io->mapping = iomem_get_mapping;
+	b->legacy_io->f_mapping = iomem_get_mapping;
 	pci_adjust_legacy_attr(b, pci_mmap_io);
 	error = device_create_bin_file(&b->dev, b->legacy_io);
 	if (error)
@@ -978,7 +978,7 @@ void pci_create_legacy_files(struct pci_bus *b)
 	b->legacy_mem->size = 1024*1024;
 	b->legacy_mem->attr.mode = 0600;
 	b->legacy_mem->mmap = pci_mmap_legacy_mem;
-	b->legacy_io->mapping = iomem_get_mapping;
+	b->legacy_io->f_mapping = iomem_get_mapping;
 	pci_adjust_legacy_attr(b, pci_mmap_mem);
 	error = device_create_bin_file(&b->dev, b->legacy_mem);
 	if (error)
@@ -1195,7 +1195,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
 		}
 	}
 	if (res_attr->mmap)
-		res_attr->mapping = iomem_get_mapping;
+		res_attr->f_mapping = iomem_get_mapping;
 	res_attr->attr.name = res_attr_name;
 	res_attr->attr.mode = 0600;
 	res_attr->size = pci_resource_len(pdev, num);
fs/sysfs/file.c +2 -2
index a3ee4c32a264..d019d6ac6ad0 100644
@@ -174,8 +174,8 @@ static int sysfs_kf_bin_open(struct kernfs_open_file *of)
 {
 	struct bin_attribute *battr = of->kn->priv;
 
-	if (battr->mapping)
-		of->file->f_mapping = battr->mapping();
+	if (battr->f_mapping)
+		of->file->f_mapping = battr->f_mapping();
 
 	return 0;
 }
include/linux/sysfs.h +1 -1
index d5bcc897583c..e3f1e8ac1f85 100644
@@ -176,7 +176,7 @@ struct bin_attribute {
 	struct attribute	attr;
 	size_t			size;
 	void			*private;
-	struct address_space *(*mapping)(void);
+	struct address_space *(*f_mapping)(void);
 	ssize_t (*read)(struct file *, struct kobject *, struct bin_attribute *,
 			char *, loff_t, size_t);
 	ssize_t (*write)(struct file *, struct kobject *, struct bin_attribute *,
Signature · 1 line
2.32.0
#5 lore raw
In reply to Krzysztof Wilczyński
Quoted 32 lines · Krzysztof Wilczyński

Hello,

At the moment, the dependency on iomem_get_mapping() that is currently used in the pci_create_resource_files() and pci_create_legacy_files() stops us from completely retiring the late_initcall() that is used to invoke pci_sysfs_init() when creating sysfs object for PCI devices.

This dependency on iomem_get_mapping() stops us from retiring the late_initcall at the moment as when we convert dynamically added sysfs objects, that are primarily added in the pci_create_resource_files() and pci_create_legacy_files(), as these attributes are added before the VFS completes its initialisation, and since most of the PCI devices are typically enumerated in subsys_initcall this leads to a failure and an Oops related to iomem_get_mapping() access.

See relevant conversations:
https://lore.kernel.org/linux-pci/[email protected]/
https://lore.kernel.org/linux-pci/20210313215747.GA2394467@bjorn-Precision-5520/

After some deliberation about the problem at hand, Dan Williams suggested a solution to the problem, as per:
https://lore.kernel.org/linux-pci/CAPcyv4i0y_4cMGEpNVShLUyUk3nyWH203Ry3S87BqnDJE0Rmxg@mail.gmail.com/

The idea is to defer execution of the iomem_get_mapping() to only when the sysfs open callback is run, and thus removing the reliance of fs_initcalls to complete before any other sub-system that uses the iomem_get_mapping().

Currently, the PCI sub-system will benefit the most from this change allowing for it to complete the transition from dynamically created to static sysfs objects.

Quoted 9 lines

This series aims to take Dan Williams' idea through the finish line.

Related to:
https://lore.kernel.org/linux-pci/20210527205845.GA1421476@bjorn-Precision-5520/
https://lore.kernel.org/linux-pci/[email protected]/
https://lore.kernel.org/linux-pci/20200716110423.xtfyb3n6tn5ixedh@pali/

Krzysztof

No objection from me on these, Bjorn, mind if I take them through my driver core tree?

thanks,

greg k-h

Acked-by on v3 1/2
#2 lore raw

Re: [PATCH v3 1/2] sysfs: Invoke iomem_get_mapping() from the sysfs open callback

In reply to Krzysztof Wilczyński
Quoted 19 lines · Krzysztof Wilczyński

Defer invocation of the iomem_get_mapping() to the sysfs open callback so that it can be executed as needed when the binary sysfs object has been accessed.

To do that, convert the "mapping" member of the struct bin_attribute from a pointer to the struct address_space into a function pointer with a signature that requires the same return type, and then updates the sysfs_kf_bin_open() to invoke provided function should the function pointer be valid.

Also, convert every invocation of iomem_get_mapping() into a function pointer assignment, therefore allowing for the iomem_get_mapping() invocation to be deferred to when the sysfs open callback runs.

Thus, this change removes the need for the fs_initcalls to complete before any other sub-system that uses the iomem_get_mapping() would be able to invoke it safely without leading to a failure and an Oops related to an invalid iomem_get_mapping() access.

Quoted 4 lines
Quoted 66 lines
---
 drivers/pci/pci-sysfs.c | 6 +++---
 fs/sysfs/file.c         | 2 +-
 include/linux/sysfs.h   | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)
drivers/pci/pci-sysfs.c +3 -3
index 5d63df7c1820..76e5545d0e73 100644
@@ -965,7 +965,7 @@ void pci_create_legacy_files(struct pci_bus *b)
 	b->legacy_io->read = pci_read_legacy_io;
 	b->legacy_io->write = pci_write_legacy_io;
 	b->legacy_io->mmap = pci_mmap_legacy_io;
-	b->legacy_io->mapping = iomem_get_mapping();
+	b->legacy_io->mapping = iomem_get_mapping;
 	pci_adjust_legacy_attr(b, pci_mmap_io);
 	error = device_create_bin_file(&b->dev, b->legacy_io);
 	if (error)
@@ -978,7 +978,7 @@ void pci_create_legacy_files(struct pci_bus *b)
 	b->legacy_mem->size = 1024*1024;
 	b->legacy_mem->attr.mode = 0600;
 	b->legacy_mem->mmap = pci_mmap_legacy_mem;
-	b->legacy_io->mapping = iomem_get_mapping();
+	b->legacy_io->mapping = iomem_get_mapping;
 	pci_adjust_legacy_attr(b, pci_mmap_mem);
 	error = device_create_bin_file(&b->dev, b->legacy_mem);
 	if (error)
@@ -1195,7 +1195,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
 		}
 	}
 	if (res_attr->mmap)
-		res_attr->mapping = iomem_get_mapping();
+		res_attr->mapping = iomem_get_mapping;
 	res_attr->attr.name = res_attr_name;
 	res_attr->attr.mode = 0600;
 	res_attr->size = pci_resource_len(pdev, num);
fs/sysfs/file.c +1 -1
index 9aefa7779b29..a3ee4c32a264 100644
@@ -175,7 +175,7 @@ static int sysfs_kf_bin_open(struct kernfs_open_file *of)
 	struct bin_attribute *battr = of->kn->priv;
 
 	if (battr->mapping)
-		of->file->f_mapping = battr->mapping;
+		of->file->f_mapping = battr->mapping();
 
 	return 0;
 }
include/linux/sysfs.h +1 -1
index a12556a4b93a..d5bcc897583c 100644
@@ -176,7 +176,7 @@ struct bin_attribute {
 	struct attribute	attr;
 	size_t			size;
 	void			*private;
-	struct address_space	*mapping;
+	struct address_space *(*mapping)(void);
 	ssize_t (*read)(struct file *, struct kobject *, struct bin_attribute *,
 			char *, loff_t, size_t);
 	ssize_t (*write)(struct file *, struct kobject *, struct bin_attribute *,
Signature · 1 line
2.32.0
Acked-by on v3 2/2
#4 lore raw

Re: [PATCH v3 2/2] sysfs: Rename struct bin_attribute member to f_mapping

In reply to Krzysztof Wilczyński
Quoted 4 lines · Krzysztof Wilczyński

There are two users of iomem_get_mapping(), the struct file and struct bin_attribute. The former has a member called "f_mapping" and the latter has a member called "mapping", and both are poniters to struct address_space.

Nit: s/poniters/pointers/

Quoted 4 lines

Rename struct bin_attribute member to "f_mapping" to keep both meaning and the usage consistent with other users of iomem_get_mapping().

Quoted 68 lines
---
 drivers/pci/pci-sysfs.c | 6 +++---
 fs/sysfs/file.c         | 4 ++--
 include/linux/sysfs.h   | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)
drivers/pci/pci-sysfs.c +3 -3
index 76e5545d0e73..f65382915f01 100644
@@ -965,7 +965,7 @@ void pci_create_legacy_files(struct pci_bus *b)
 	b->legacy_io->read = pci_read_legacy_io;
 	b->legacy_io->write = pci_write_legacy_io;
 	b->legacy_io->mmap = pci_mmap_legacy_io;
-	b->legacy_io->mapping = iomem_get_mapping;
+	b->legacy_io->f_mapping = iomem_get_mapping;
 	pci_adjust_legacy_attr(b, pci_mmap_io);
 	error = device_create_bin_file(&b->dev, b->legacy_io);
 	if (error)
@@ -978,7 +978,7 @@ void pci_create_legacy_files(struct pci_bus *b)
 	b->legacy_mem->size = 1024*1024;
 	b->legacy_mem->attr.mode = 0600;
 	b->legacy_mem->mmap = pci_mmap_legacy_mem;
-	b->legacy_io->mapping = iomem_get_mapping;
+	b->legacy_io->f_mapping = iomem_get_mapping;
 	pci_adjust_legacy_attr(b, pci_mmap_mem);
 	error = device_create_bin_file(&b->dev, b->legacy_mem);
 	if (error)
@@ -1195,7 +1195,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
 		}
 	}
 	if (res_attr->mmap)
-		res_attr->mapping = iomem_get_mapping;
+		res_attr->f_mapping = iomem_get_mapping;
 	res_attr->attr.name = res_attr_name;
 	res_attr->attr.mode = 0600;
 	res_attr->size = pci_resource_len(pdev, num);
fs/sysfs/file.c +2 -2
index a3ee4c32a264..d019d6ac6ad0 100644
@@ -174,8 +174,8 @@ static int sysfs_kf_bin_open(struct kernfs_open_file *of)
 {
 	struct bin_attribute *battr = of->kn->priv;
 
-	if (battr->mapping)
-		of->file->f_mapping = battr->mapping();
+	if (battr->f_mapping)
+		of->file->f_mapping = battr->f_mapping();
 
 	return 0;
 }
include/linux/sysfs.h +1 -1
index d5bcc897583c..e3f1e8ac1f85 100644
@@ -176,7 +176,7 @@ struct bin_attribute {
 	struct attribute	attr;
 	size_t			size;
 	void			*private;
-	struct address_space *(*mapping)(void);
+	struct address_space *(*f_mapping)(void);
 	ssize_t (*read)(struct file *, struct kobject *, struct bin_attribute *,
 			char *, loff_t, size_t);
 	ssize_t (*write)(struct file *, struct kobject *, struct bin_attribute *,
Signature · 1 line
2.32.0
#6 lore raw
In reply to Greg Kroah-Hartman
Quoted 40 lines · Greg Kroah-Hartman
Quoted 39 lines · Krzysztof Wilczyński

Hello,

At the moment, the dependency on iomem_get_mapping() that is currently used in the pci_create_resource_files() and pci_create_legacy_files() stops us from completely retiring the late_initcall() that is used to invoke pci_sysfs_init() when creating sysfs object for PCI devices.

This dependency on iomem_get_mapping() stops us from retiring the late_initcall at the moment as when we convert dynamically added sysfs objects, that are primarily added in the pci_create_resource_files() and pci_create_legacy_files(), as these attributes are added before the VFS completes its initialisation, and since most of the PCI devices are typically enumerated in subsys_initcall this leads to a failure and an Oops related to iomem_get_mapping() access.

See relevant conversations:
https://lore.kernel.org/linux-pci/[email protected]/
https://lore.kernel.org/linux-pci/20210313215747.GA2394467@bjorn-Precision-5520/

After some deliberation about the problem at hand, Dan Williams suggested a solution to the problem, as per:
https://lore.kernel.org/linux-pci/CAPcyv4i0y_4cMGEpNVShLUyUk3nyWH203Ry3S87BqnDJE0Rmxg@mail.gmail.com/

The idea is to defer execution of the iomem_get_mapping() to only when the sysfs open callback is run, and thus removing the reliance of fs_initcalls to complete before any other sub-system that uses the iomem_get_mapping().

Currently, the PCI sub-system will benefit the most from this change allowing for it to complete the transition from dynamically created to static sysfs objects.

This series aims to take Dan Williams' idea through the finish line.

Related to:
https://lore.kernel.org/linux-pci/20210527205845.GA1421476@bjorn-Precision-5520/
https://lore.kernel.org/linux-pci/[email protected]/
https://lore.kernel.org/linux-pci/20200716110423.xtfyb3n6tn5ixedh@pali/

Quoted 5 lines
Quoted 2 lines

Krzysztof

No objection from me on these, Bjorn, mind if I take them through my driver core tree?

That'd be great!

Is your tree immutable? I'm hoping we can take advantage of this to get rid of pci_sysfs_init(), which will fix a race that people seem to be hitting frequently now [1]. I think Krzysztof is getting pretty close.

[1] https://lore.kernel.org/r/[email protected]

#7 lore raw
Quoted 47 lines · Bjorn Helgaas
Quoted 40 lines · Greg Kroah-Hartman
Quoted 39 lines · Krzysztof Wilczyński

Hello,

At the moment, the dependency on iomem_get_mapping() that is currently used in the pci_create_resource_files() and pci_create_legacy_files() stops us from completely retiring the late_initcall() that is used to invoke pci_sysfs_init() when creating sysfs object for PCI devices.

This dependency on iomem_get_mapping() stops us from retiring the late_initcall at the moment as when we convert dynamically added sysfs objects, that are primarily added in the pci_create_resource_files() and pci_create_legacy_files(), as these attributes are added before the VFS completes its initialisation, and since most of the PCI devices are typically enumerated in subsys_initcall this leads to a failure and an Oops related to iomem_get_mapping() access.

See relevant conversations:
https://lore.kernel.org/linux-pci/[email protected]/
https://lore.kernel.org/linux-pci/20210313215747.GA2394467@bjorn-Precision-5520/

After some deliberation about the problem at hand, Dan Williams suggested a solution to the problem, as per:
https://lore.kernel.org/linux-pci/CAPcyv4i0y_4cMGEpNVShLUyUk3nyWH203Ry3S87BqnDJE0Rmxg@mail.gmail.com/

The idea is to defer execution of the iomem_get_mapping() to only when the sysfs open callback is run, and thus removing the reliance of fs_initcalls to complete before any other sub-system that uses the iomem_get_mapping().

Currently, the PCI sub-system will benefit the most from this change allowing for it to complete the transition from dynamically created to static sysfs objects.

This series aims to take Dan Williams' idea through the finish line.

Related to:
https://lore.kernel.org/linux-pci/20210527205845.GA1421476@bjorn-Precision-5520/
https://lore.kernel.org/linux-pci/[email protected]/
https://lore.kernel.org/linux-pci/20200716110423.xtfyb3n6tn5ixedh@pali/

Quoted 5 lines
Quoted 2 lines

Krzysztof

No objection from me on these, Bjorn, mind if I take them through my driver core tree?

Quoted 8 lines

That'd be great!

Is your tree immutable? I'm hoping we can take advantage of this to get rid of pci_sysfs_init(), which will fix a race that people seem to be hitting frequently now [1]. I think Krzysztof is getting pretty close.

[1] https://lore.kernel.org/r/[email protected]

Yes, my tree is immutable. Let me create a branch just for this that you can pull from after it passes 0-day...

thanks,

greg k-h

#8 lore raw
Quoted 55 lines · Greg Kroah-Hartman
Quoted 54 lines · Bjorn Helgaas
Quoted 40 lines · Greg Kroah-Hartman
Quoted 39 lines · Krzysztof Wilczyński

Hello,

At the moment, the dependency on iomem_get_mapping() that is currently used in the pci_create_resource_files() and pci_create_legacy_files() stops us from completely retiring the late_initcall() that is used to invoke pci_sysfs_init() when creating sysfs object for PCI devices.

This dependency on iomem_get_mapping() stops us from retiring the late_initcall at the moment as when we convert dynamically added sysfs objects, that are primarily added in the pci_create_resource_files() and pci_create_legacy_files(), as these attributes are added before the VFS completes its initialisation, and since most of the PCI devices are typically enumerated in subsys_initcall this leads to a failure and an Oops related to iomem_get_mapping() access.

See relevant conversations:
https://lore.kernel.org/linux-pci/[email protected]/
https://lore.kernel.org/linux-pci/20210313215747.GA2394467@bjorn-Precision-5520/

After some deliberation about the problem at hand, Dan Williams suggested a solution to the problem, as per:
https://lore.kernel.org/linux-pci/CAPcyv4i0y_4cMGEpNVShLUyUk3nyWH203Ry3S87BqnDJE0Rmxg@mail.gmail.com/

The idea is to defer execution of the iomem_get_mapping() to only when the sysfs open callback is run, and thus removing the reliance of fs_initcalls to complete before any other sub-system that uses the iomem_get_mapping().

Currently, the PCI sub-system will benefit the most from this change allowing for it to complete the transition from dynamically created to static sysfs objects.

This series aims to take Dan Williams' idea through the finish line.

Related to:
https://lore.kernel.org/linux-pci/20210527205845.GA1421476@bjorn-Precision-5520/
https://lore.kernel.org/linux-pci/[email protected]/
https://lore.kernel.org/linux-pci/20200716110423.xtfyb3n6tn5ixedh@pali/

Quoted 5 lines
Quoted 2 lines

Krzysztof

No objection from me on these, Bjorn, mind if I take them through my driver core tree?

That'd be great!

Is your tree immutable? I'm hoping we can take advantage of this to get rid of pci_sysfs_init(), which will fix a race that people seem to be hitting frequently now [1]. I think Krzysztof is getting pretty close.

Quoted 4 lines
Quoted 1 line

[1] https://lore.kernel.org/r/[email protected]

Yes, my tree is immutable. Let me create a branch just for this that you can pull from after it passes 0-day...

Ok, here you go, a signed tag for you to pull from:

The following changes since commit ff1176468d368232b684f75e82563369208bc371:

Linux 5.14-rc3 (2021-07-25 15:35:14 -0700)

are available in the Git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git tags/sysfs_defferred_iomem_get_mapping-5.15

for you to fetch changes up to f06aff924f975881a6abf91d2af0078fc8cd37bf:

sysfs: Rename struct bin_attribute member to f_mapping (2021-08-05 14:47:31 +0200)

----------------------------------------------------------------
sysfs: Allow deferred execution of iomem_get_mapping()

Tag for toerh trees/branches to pull from in order to have a stable base to build off of for the "Allow deferred execution of iomem_get_mapping()" set of sysfs changes

----------------------------------------------------------------
Krzysztof Wilczyński (2):
sysfs: Invoke iomem_get_mapping() from the sysfs open callback
sysfs: Rename struct bin_attribute member to f_mapping

 drivers/pci/pci-sysfs.c | 6 +++---
 fs/sysfs/file.c         | 4 ++--
 include/linux/sysfs.h   | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)