[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20201104164647.pctgyk2cbhjcq65z@pali>
Date: Wed, 4 Nov 2020 17:46:47 +0100
From: Pali Rohár <pali@...nel.org>
To: Bjorn Helgaas <helgaas@...nel.org>
Cc: Bjorn Helgaas <bhelgaas@...gle.com>, linux-pci@...r.kernel.org,
linux-kernel@...r.kernel.org,
Lorenzo Pieralisi <lorenzo.pieralisi@....com>,
Gregory Clement <gregory.clement@...tlin.com>,
Andrew Lunn <andrew@...n.ch>,
Krzysztof Wilczyński <kw@...ux.com>,
Yinghai Lu <yinghai@...nel.org>
Subject: Re: PCI: Race condition in pci_create_sysfs_dev_files
On Tuesday 06 October 2020 17:22:22 Bjorn Helgaas wrote:
> It's not obvious from the code why we need pci_sysfs_init(), but
> Yinghai hinted [1] that we need to create sysfs after assigning
> resources. I experimented by removing pci_sysfs_init() and skipping
> the ROM BAR sizing. In that case, we create sysfs files in
> pci_bus_add_device() and later assign space for the ROM BAR, so we
> fail to create the "rom" sysfs file.
>
> The current solution to that is to delay the sysfs files until
> pci_sysfs_init(), a late_initcall(), which runs after resource
> assignments. But I think it would be better if we could create the
> sysfs file when we assign the BAR. Then we could get rid of the
> late_initcall() and that implicit ordering requirement.
>
> But I haven't tried to code it up, so it's probably more complicated
> than this. I guess ideally we would assign all the resources before
> pci_bus_add_device(). If we could do that, we could just remove
> pci_sysfs_init() and everything would just work, but I think that's a
> HUGE can of worms.
>
> [1] https://lore.kernel.org/linux-pci/CAE9FiQWBXHgz-gWCmpWLaBOfQQJwtRZemV6Ut9GVw_KJ-dTGTA@mail.gmail.com/
I found out that pci_sysfs_init() function was introduced in kernel
version 2.6.10 by this historic commit:
https://git.kernel.org/pub/scm/linux/kernel/git/history/history.git/commit/?id=f6d553444da20cd1e44f2c4864c2d0c56c934e0a
So it was really due to PCI ROM BAR and accessing it from sysfs.
Powered by blists - more mailing lists