If devicetree describes power supplies related to a PCI device, we previously created a pwrctrl device even if CONFIG_PCI_PWRCTL was not enabled.
When pci_pwrctrl_create_device() creates and returns a pwrctrl device, pci_scan_device() doesn't enumerate the PCI device. It assumes the pwrctrl core will rescan the bus after turning on the power. However, if CONFIG_PCI_PWRCTL is not enabled, the rescan never happens.
This may break PCI enumeration on any system that describes power supplies in devicetree but does not use pwrctrl. Jim reported that some brcmstb platforms break this way.
While the actual fix would be to convert all the platforms to use pwrctrl framework, we also need to skip creating the pwrctrl device if CONFIG_PCI_PWRCTL is not enabled and let the PCI core scan the device normally (assuming it is already powered on or by the controller driver).
Cc: stable@vger.kernel.org # 6.15 Fixes: 957f40d039a9 ("PCI/pwrctrl: Move creation of pwrctrl devices to pci_scan_device()") Reported-by: Jim Quinlan james.quinlan@broadcom.com Closes: https://lore.kernel.org/r/CA+-6iNwgaByXEYD3j=-+H_PKAxXRU78svPMRHDKKci8AGXAUP... Signed-off-by: Manivannan Sadhasivam manivannan.sadhasivam@linaro.org ---
Changes in v2:
* Used the stub instead of returning NULL inside the function
drivers/pci/probe.c | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 4b8693ec9e4c..e6a34db77826 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -2508,6 +2508,7 @@ bool pci_bus_read_dev_vendor_id(struct pci_bus *bus, int devfn, u32 *l, } EXPORT_SYMBOL(pci_bus_read_dev_vendor_id);
+#if IS_ENABLED(CONFIG_PCI_PWRCTRL) static struct platform_device *pci_pwrctrl_create_device(struct pci_bus *bus, int devfn) { struct pci_host_bridge *host = pci_find_host_bridge(bus); @@ -2537,6 +2538,12 @@ static struct platform_device *pci_pwrctrl_create_device(struct pci_bus *bus, in
return pdev; } +#else +static struct platform_device *pci_pwrctrl_create_device(struct pci_bus *bus, int devfn) +{ + return NULL; +} +#endif
/* * Read the config data for a PCI device, sanity-check it,
On Tue, Jul 01, 2025 at 12:17:31PM +0530, Manivannan Sadhasivam wrote:
--- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -2508,6 +2508,7 @@ bool pci_bus_read_dev_vendor_id(struct pci_bus *bus, int devfn, u32 *l, } EXPORT_SYMBOL(pci_bus_read_dev_vendor_id); +#if IS_ENABLED(CONFIG_PCI_PWRCTRL) static struct platform_device *pci_pwrctrl_create_device(struct pci_bus *bus, int devfn) {
Hm, why does pci_pwrctrl_create_device() return a pointer, even though the sole caller doesn't make any use of it? Why not return a negative errno?
Then you could just do this:
if (!IS_ENABLED(CONFIG_PCI_PWRCTRL)) return 0;
... at the top of the function and you don't need the extra LoC for the empty inline stub.
Another option is to set "struct pci_dev *pdev = NULL;" and #ifdef the body of the function, save for the "return pdev;" at the bottom.
Of course you could also do:
if (!IS_ENABLED(CONFIG_PCI_PWRCTRL)) return NULL;
... at the top of the function, but again, the caller doesn't make any use of the returned pointer.
Thanks,
Lukas
On Tue, Jul 01, 2025 at 09:00:34AM GMT, Lukas Wunner wrote:
On Tue, Jul 01, 2025 at 12:17:31PM +0530, Manivannan Sadhasivam wrote:
--- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -2508,6 +2508,7 @@ bool pci_bus_read_dev_vendor_id(struct pci_bus *bus, int devfn, u32 *l, } EXPORT_SYMBOL(pci_bus_read_dev_vendor_id); +#if IS_ENABLED(CONFIG_PCI_PWRCTRL) static struct platform_device *pci_pwrctrl_create_device(struct pci_bus *bus, int devfn) {
Hm, why does pci_pwrctrl_create_device() return a pointer, even though the sole caller doesn't make any use of it? Why not return a negative errno?
Then you could just do this:
if (!IS_ENABLED(CONFIG_PCI_PWRCTRL)) return 0;
... at the top of the function and you don't need the extra LoC for the empty inline stub.
This is what I initially submitted [1] though that returned NULL, but the idea was the same. But Bjorn didn't like that.
Another option is to set "struct pci_dev *pdev = NULL;" and #ifdef the body of the function, save for the "return pdev;" at the bottom.
This is similar to what Bjorn submitted [2], but you were in favor of providing a stub instead [3]. It also looked better to my eyes.
Of course you could also do:
if (!IS_ENABLED(CONFIG_PCI_PWRCTRL)) return NULL;
... at the top of the function, but again, the caller doesn't make any use of the returned pointer.
Right. I could make it to return a errno, but that's not the scope of this patch. Bjorn wanted to have the #ifdef to be guarded to make the compiled out part more visible [4], so I ended up with this version.
But whatever the style is, we should make sure that the patch lands in 6.16-rcS. It is taking more time than needed.
- Mani
[1] https://lore.kernel.org/all/20250522140326.93869-1-manivannan.sadhasivam@lin... [2] https://lore.kernel.org/linux-pci/20250523201935.1586198-1-helgaas@kernel.or... [3] https://lore.kernel.org/linux-pci/aDFnWhFa9ZGqr67T@wunner.de/ [4] https://lore.kernel.org/linux-pci/20250629190219.GA1717534@bhelgaas/
Thanks,
Lukas
On Tue, Jul 01, 2025 at 05:27:27PM +0530, Manivannan Sadhasivam wrote:
On Tue, Jul 01, 2025 at 09:00:34AM GMT, Lukas Wunner wrote:
Hm, why does pci_pwrctrl_create_device() return a pointer, even though the sole caller doesn't make any use of it? Why not return a negative errno?
Then you could just do this:
if (!IS_ENABLED(CONFIG_PCI_PWRCTRL)) return 0;
... at the top of the function and you don't need the extra LoC for the empty inline stub.
This is what I initially submitted [1] though that returned NULL, but the idea was the same. But Bjorn didn't like that.
[...]
Thanks for summarizing the state of the discussion, I apologize for not having paid sufficient attention to the thread.
Reviewed-by: Lukas Wunner lukas@wunner.de
Lukas
[+cc Bart]
On Tue, Jul 01, 2025 at 12:17:31PM +0530, Manivannan Sadhasivam wrote:
If devicetree describes power supplies related to a PCI device, we previously created a pwrctrl device even if CONFIG_PCI_PWRCTL was not enabled.
When pci_pwrctrl_create_device() creates and returns a pwrctrl device, pci_scan_device() doesn't enumerate the PCI device. It assumes the pwrctrl core will rescan the bus after turning on the power. However, if CONFIG_PCI_PWRCTL is not enabled, the rescan never happens.
Separate from this patch, can we refine the comment in pci_scan_device() to explain *why* we should skip scanning if a pwrctrl device was created? The current comment leaves me with two questions:
1) How do we know the pwrctrl device is currently off? If it is already on, why should we defer enumerating the device?
2) If the pwrctrl device is currently off, won't the Vendor ID read just fail like it does for every other non-existent device? If so, why can't we just let that happen?
This behavior is from 2489eeb777af ("PCI/pwrctrl: Skip scanning for the device further if pwrctrl device is created"), which just says "there's no need to continue scanning." Prior to 2489eeb777af, it looks like we *did* what try to enumerate the device even if a pwrctrl device was created, and 2489eeb777af doesn't mention a bug fix, so I assume it's just an optimization.
Bjorn
On Tue, Jul 01, 2025 at 03:35:26PM -0500, Bjorn Helgaas wrote:
[+cc Bart]
On Tue, Jul 01, 2025 at 12:17:31PM +0530, Manivannan Sadhasivam wrote:
If devicetree describes power supplies related to a PCI device, we previously created a pwrctrl device even if CONFIG_PCI_PWRCTL was not enabled.
When pci_pwrctrl_create_device() creates and returns a pwrctrl device, pci_scan_device() doesn't enumerate the PCI device. It assumes the pwrctrl core will rescan the bus after turning on the power. However, if CONFIG_PCI_PWRCTL is not enabled, the rescan never happens.
Separate from this patch, can we refine the comment in pci_scan_device() to explain *why* we should skip scanning if a pwrctrl device was created? The current comment leaves me with two questions:
- How do we know the pwrctrl device is currently off? If it is already on, why should we defer enumerating the device?
I believe you meant to ask "how do we know the PCI device is currently off". If the pwrctrl device is created, then we for sure know that the pwrctrl driver will power on the PCI device at some point (depending on when the driver gets loaded). Even if the device was already powered on, we do not want to probe the client driver because, we have seen race between pwrctrl driver and PCI client driver probing in parallel. So I had imposed a devlink dependency (see b458ff7e8176) that makes sure that the PCI client driver wouldn't get probed until the pwrctrl driver (if the pwrctrl device was created) is probed. This will ensure that the PCI device state is reset and initialized by the pwrctrl driver before the client driver probes.
- If the pwrctrl device is currently off, won't the Vendor ID read just fail like it does for every other non-existent device? If so, why can't we just let that happen?
Again, it is not the pwrctrl device that is off, it is the PCI device. If it is not turned on, yes VID read will fail, but why do we need to read the VID in the first place if we know that the PCI device requires pwrctrl and the pwrctrl driver is going to be probed later.
This behavior is from 2489eeb777af ("PCI/pwrctrl: Skip scanning for the device further if pwrctrl device is created"), which just says "there's no need to continue scanning." Prior to 2489eeb777af, it looks like we *did* what try to enumerate the device even if a pwrctrl device was created, and 2489eeb777af doesn't mention a bug fix, so I assume it's just an optimization.
Yes, it is indeed an optimization.
To summarize, we have imposed a dependency between the PCI client driver and pwrctrl driver to make sure that the PCI device state is fully reset and initialized before the client driver probes. So irrespective of whether the PCI device is already powered on or not, it is guaranteed by devlink that the PCI client driver will only get probed *after* the pwrctrl driver (if the device requires it). So we skip scanning the device further if the pwrctrl device is created (which means, the device depends on pwrctrl driver to power manage it).
- Mani
On Wed, Jul 02, 2025 at 12:17:00PM +0530, Manivannan Sadhasivam wrote:
On Tue, Jul 01, 2025 at 03:35:26PM -0500, Bjorn Helgaas wrote:
[+cc Bart]
On Tue, Jul 01, 2025 at 12:17:31PM +0530, Manivannan Sadhasivam wrote:
If devicetree describes power supplies related to a PCI device, we previously created a pwrctrl device even if CONFIG_PCI_PWRCTL was not enabled.
When pci_pwrctrl_create_device() creates and returns a pwrctrl device, pci_scan_device() doesn't enumerate the PCI device. It assumes the pwrctrl core will rescan the bus after turning on the power. However, if CONFIG_PCI_PWRCTL is not enabled, the rescan never happens.
Separate from this patch, can we refine the comment in pci_scan_device() to explain *why* we should skip scanning if a pwrctrl device was created? The current comment leaves me with two questions:
- How do we know the pwrctrl device is currently off? If it is already on, why should we defer enumerating the device?
I believe you meant to ask "how do we know the PCI device is currently off". If the pwrctrl device is created, then we for sure know that the pwrctrl driver will power on the PCI device at some point (depending on when the driver gets loaded). Even if the device was already powered on, we do not want to probe the client driver because, we have seen race between pwrctrl driver and PCI client driver probing in parallel. So I had imposed a devlink dependency (see b458ff7e8176) that makes sure that the PCI client driver wouldn't get probed until the pwrctrl driver (if the pwrctrl device was created) is probed. This will ensure that the PCI device state is reset and initialized by the pwrctrl driver before the client driver probes.
I'm confused about this. Assume there is a pwrctrl device and the related PCI device is already powered on when Linux boots. Apparently we do NOT want to enumerate the PCI device? We want to wait for the pwrctrl driver to claim the pwrctrl device and do a rescan? Even though the pwrctrl driver may be a loadable module and may not even be available at all?
It seems to me that a PCI device that is already powered on should be enumerated and made available. If there's a pwrctrl device for it, and we decide to load pwrctrl, then we also get the ability to turn the PCI device off and on again as needed. But if we *don't* load pwrctrl, it seems like we should still be able to use a PCI device that's already powered on.
- If the pwrctrl device is currently off, won't the Vendor ID read just fail like it does for every other non-existent device? If so, why can't we just let that happen?
Again, it is not the pwrctrl device that is off, it is the PCI device. If it is not turned on, yes VID read will fail, but why do we need to read the VID in the first place if we know that the PCI device requires pwrctrl and the pwrctrl driver is going to be probed later.
I was assuming pwrctrl is only required if we want to turn the PCI device power on or off. Maybe that's not true?
This behavior is from 2489eeb777af ("PCI/pwrctrl: Skip scanning for the device further if pwrctrl device is created"), which just says "there's no need to continue scanning." Prior to 2489eeb777af, it looks like we *did* what try to enumerate the device even if a pwrctrl device was created, and 2489eeb777af doesn't mention a bug fix, so I assume it's just an optimization.
Yes, it is indeed an optimization.
To summarize, we have imposed a dependency between the PCI client driver and pwrctrl driver to make sure that the PCI device state is fully reset and initialized before the client driver probes.
If the PCI device is already powered on, what more should we do to fully reset and initialize it? If it needed more initialization, I assume the platform should have left it powered off.
So irrespective of whether the PCI device is already powered on or not, it is guaranteed by devlink that the PCI client driver will only get probed *after* the pwrctrl driver (if the device requires it). So we skip scanning the device further if the pwrctrl device is created (which means, the device depends on pwrctrl driver to power manage it).
I'm just as confused as I was before. I'm assuming pwrctrl basically gives us a way to control the main power rails to the PCI device, and the device only depends on pwrctrl in the sense that pwrctrl can remove main power and put the device in D3cold, and then restore main power so the device can return to D0uninitialized.
Bjorn
On Wed, Jul 02, 2025 at 12:53:07PM GMT, Bjorn Helgaas wrote:
On Wed, Jul 02, 2025 at 12:17:00PM +0530, Manivannan Sadhasivam wrote:
On Tue, Jul 01, 2025 at 03:35:26PM -0500, Bjorn Helgaas wrote:
[+cc Bart]
On Tue, Jul 01, 2025 at 12:17:31PM +0530, Manivannan Sadhasivam wrote:
If devicetree describes power supplies related to a PCI device, we previously created a pwrctrl device even if CONFIG_PCI_PWRCTL was not enabled.
When pci_pwrctrl_create_device() creates and returns a pwrctrl device, pci_scan_device() doesn't enumerate the PCI device. It assumes the pwrctrl core will rescan the bus after turning on the power. However, if CONFIG_PCI_PWRCTL is not enabled, the rescan never happens.
Separate from this patch, can we refine the comment in pci_scan_device() to explain *why* we should skip scanning if a pwrctrl device was created? The current comment leaves me with two questions:
- How do we know the pwrctrl device is currently off? If it is already on, why should we defer enumerating the device?
I believe you meant to ask "how do we know the PCI device is currently off". If the pwrctrl device is created, then we for sure know that the pwrctrl driver will power on the PCI device at some point (depending on when the driver gets loaded). Even if the device was already powered on, we do not want to probe the client driver because, we have seen race between pwrctrl driver and PCI client driver probing in parallel. So I had imposed a devlink dependency (see b458ff7e8176) that makes sure that the PCI client driver wouldn't get probed until the pwrctrl driver (if the pwrctrl device was created) is probed. This will ensure that the PCI device state is reset and initialized by the pwrctrl driver before the client driver probes.
I'm confused about this. Assume there is a pwrctrl device and the related PCI device is already powered on when Linux boots. Apparently we do NOT want to enumerate the PCI device? We want to wait for the pwrctrl driver to claim the pwrctrl device and do a rescan? Even though the pwrctrl driver may be a loadable module and may not even be available at all?
It seems to me that a PCI device that is already powered on should be enumerated and made available. If there's a pwrctrl device for it, and we decide to load pwrctrl, then we also get the ability to turn the PCI device off and on again as needed. But if we *don't* load pwrctrl, it seems like we should still be able to use a PCI device that's already powered on.
The problem with enumerating the PCI device which was already powered on is that the pwrctrl driver cannot reliably know whether the device is powered on or not. So by the time the pwrctrl driver probes, the client driver might also be probing. For the case of WLAN chipsets, the pwrctrl driver used to sample the EN (Enable) GPIO pin to know whether the device is powered on or not (see a9aaf1ff88a8), but that also turned out to be racy and people were complaining.
So to simplify things, we enforced this dependency.
- If the pwrctrl device is currently off, won't the Vendor ID read just fail like it does for every other non-existent device? If so, why can't we just let that happen?
Again, it is not the pwrctrl device that is off, it is the PCI device. If it is not turned on, yes VID read will fail, but why do we need to read the VID in the first place if we know that the PCI device requires pwrctrl and the pwrctrl driver is going to be probed later.
I was assuming pwrctrl is only required if we want to turn the PCI device power on or off. Maybe that's not true?
Pretty much so, but we will also use it to do D3Cold (during system suspend) in the near future.
This behavior is from 2489eeb777af ("PCI/pwrctrl: Skip scanning for the device further if pwrctrl device is created"), which just says "there's no need to continue scanning." Prior to 2489eeb777af, it looks like we *did* what try to enumerate the device even if a pwrctrl device was created, and 2489eeb777af doesn't mention a bug fix, so I assume it's just an optimization.
Yes, it is indeed an optimization.
To summarize, we have imposed a dependency between the PCI client driver and pwrctrl driver to make sure that the PCI device state is fully reset and initialized before the client driver probes.
If the PCI device is already powered on, what more should we do to fully reset and initialize it? If it needed more initialization, I assume the platform should have left it powered off.
As I mentioned above, we cannot reliably detect whether a device is already powered on or not from the pwrctrl driver when it probes. So because of that reason, we enforce dependency and always reset/initialize the device to POR state. If there is a reliable way
- Mani
On Thu, Jul 03, 2025 at 12:00:43AM +0530, Manivannan Sadhasivam wrote:
On Wed, Jul 02, 2025 at 12:53:07PM GMT, Bjorn Helgaas wrote:
On Wed, Jul 02, 2025 at 12:17:00PM +0530, Manivannan Sadhasivam wrote:
On Tue, Jul 01, 2025 at 03:35:26PM -0500, Bjorn Helgaas wrote:
[+cc Bart]
On Tue, Jul 01, 2025 at 12:17:31PM +0530, Manivannan Sadhasivam wrote:
If devicetree describes power supplies related to a PCI device, we previously created a pwrctrl device even if CONFIG_PCI_PWRCTL was not enabled.
When pci_pwrctrl_create_device() creates and returns a pwrctrl device, pci_scan_device() doesn't enumerate the PCI device. It assumes the pwrctrl core will rescan the bus after turning on the power. However, if CONFIG_PCI_PWRCTL is not enabled, the rescan never happens.
Separate from this patch, can we refine the comment in pci_scan_device() to explain *why* we should skip scanning if a pwrctrl device was created? The current comment leaves me with two questions:
- How do we know the pwrctrl device is currently off? If it is already on, why should we defer enumerating the device?
I believe you meant to ask "how do we know the PCI device is currently off". If the pwrctrl device is created, then we for sure know that the pwrctrl driver will power on the PCI device at some point (depending on when the driver gets loaded). Even if the device was already powered on, we do not want to probe the client driver because, we have seen race between pwrctrl driver and PCI client driver probing in parallel. So I had imposed a devlink dependency (see b458ff7e8176) that makes sure that the PCI client driver wouldn't get probed until the pwrctrl driver (if the pwrctrl device was created) is probed. This will ensure that the PCI device state is reset and initialized by the pwrctrl driver before the client driver probes.
I'm confused about this. Assume there is a pwrctrl device and the related PCI device is already powered on when Linux boots. Apparently we do NOT want to enumerate the PCI device? We want to wait for the pwrctrl driver to claim the pwrctrl device and do a rescan? Even though the pwrctrl driver may be a loadable module and may not even be available at all?
It seems to me that a PCI device that is already powered on should be enumerated and made available. If there's a pwrctrl device for it, and we decide to load pwrctrl, then we also get the ability to turn the PCI device off and on again as needed. But if we *don't* load pwrctrl, it seems like we should still be able to use a PCI device that's already powered on.
The problem with enumerating the PCI device which was already powered on is that the pwrctrl driver cannot reliably know whether the device is powered on or not. So by the time the pwrctrl driver probes, the client driver might also be probing. For the case of WLAN chipsets, the pwrctrl driver used to sample the EN (Enable) GPIO pin to know whether the device is powered on or not (see a9aaf1ff88a8), but that also turned out to be racy and people were complaining.
So to simplify things, we enforced this dependency.
Oh, thank you! This inability of pwrctrl to determine the current device power state is a critical missing piece in understanding the race.
Although d8b762070c3f ("power: sequencing: qcom-wcn: set the wlan-enable GPIO to output") suggests that gpiod_get_value_cansleep() *does* read the current GPIO state, i.e., the current device power state.
29da3e8748f9 ("power: sequencing: qcom-wcn: explain why we need the WLAN_EN GPIO hack") adds a comment that we *should* use GPIOD_OUT_LOW (which would toggle WLAN power) but can't until the qcom controller driver implements link-down handling.
Is power-cycling the PCI device when pwrctrl loads a requirement of the pwrctrl design? A power cycle adds significant latency, so it seems a little aggressive to me unless it is absolutely required.
29da3e8748f9 also mentions some platforms that still fail to probe WLAN due to some unspecified qcom issue that needs a workaround, so I guess this is still an open issue?
So I wonder if this inability to determine the current power state is real or just an artifact of the various workarounds so far.
- If the pwrctrl device is currently off, won't the Vendor ID read just fail like it does for every other non-existent device? If so, why can't we just let that happen?
Again, it is not the pwrctrl device that is off, it is the PCI device. If it is not turned on, yes VID read will fail, but why do we need to read the VID in the first place if we know that the PCI device requires pwrctrl and the pwrctrl driver is going to be probed later.
I was assuming pwrctrl is only required if we want to turn the PCI device power on or off. Maybe that's not true?
Pretty much so, but we will also use it to do D3Cold (during system suspend) in the near future.
Turning main power on and off is exactly what D3cold is about. I expected this kind of use for suspend, which is why I asked about overlap with ACPI, which also provides ways to control main power.
Bjorn
[+cc Bart, Krzysztof, update Mani's addr to kernel.org]
On Tue, Jul 01, 2025 at 12:17:31PM +0530, Manivannan Sadhasivam wrote:
If devicetree describes power supplies related to a PCI device, we previously created a pwrctrl device even if CONFIG_PCI_PWRCTL was not enabled.
When pci_pwrctrl_create_device() creates and returns a pwrctrl device, pci_scan_device() doesn't enumerate the PCI device. It assumes the pwrctrl core will rescan the bus after turning on the power. However, if CONFIG_PCI_PWRCTL is not enabled, the rescan never happens.
This may break PCI enumeration on any system that describes power supplies in devicetree but does not use pwrctrl. Jim reported that some brcmstb platforms break this way.
While the actual fix would be to convert all the platforms to use pwrctrl framework, we also need to skip creating the pwrctrl device if CONFIG_PCI_PWRCTL is not enabled and let the PCI core scan the device normally (assuming it is already powered on or by the controller driver).
I'm fine with this change, but I think the commit log leaves the wrong impression. If CONFIG_PCI_PWRCTRL is not enabled, we shouldn't do anything related to it, independent of what other platforms or drivers do.
So I wouldn't describe this as "the actual fix is converting all platforms to use pwrctrl." Even if all platforms use pwrctrl, we *still* shouldn't run pci_pwrctrl_create_device() unless CONFIG_PCI_PWRCTRL is enabled.
I think all we need to say is something like this:
We only need pci_pwrctrl_create_device() when CONFIG_PCI_PWRCTRL is enabled. Compile it out when CONFIG_PCI_PWRCTRL is not enabled.
Cc: stable@vger.kernel.org # 6.15 Fixes: 957f40d039a9 ("PCI/pwrctrl: Move creation of pwrctrl devices to pci_scan_device()")
Not sure about this. If the problem we're solving is "we run pwrctrl code when CONFIG_PCI_PWRCTRL is not enabled," 957f40d039a9 is not the commit that added that behavior.
Maybe 8fb18619d910 ("PCI/pwrctl: Create platform devices for child OF nodes of the port node") would be more appropriate?
Reported-by: Jim Quinlan james.quinlan@broadcom.com Closes: https://lore.kernel.org/r/CA+-6iNwgaByXEYD3j=-+H_PKAxXRU78svPMRHDKKci8AGXAUP...
I'm also not sure this really merits a "Closes:" tag. All this does is enable a workaround (disable CONFIG_PCI_PWRCTRL when brcmstb is enabled). That's not a fix because we *should* be able to enable both pwrctrl and brcmstb at the same time.
If 2489eeb777af ("PCI/pwrctrl: Skip scanning for the device further if pwrctrl device is created") was purely an optimization (see https://lore.kernel.org/r/20250701203526.GA1849466@bhelgaas), I think I would:
- Revert 2489eeb777af with a stable tag for v6.15, and
- Apply this patch with a Fixes: 8fb18619d910 ("PCI/pwrctl: Create platform devices for child OF nodes of the port node") but no stable tag. 8fb18619d910 appeared in v6.11 and the "don't enable CONFIG_PCI_PWRCTRL" workaround was enough for brcmstb until 2489eeb777af, so if we revert 2489eeb777af, we wouldn't need to backport *this* patch.
Signed-off-by: Manivannan Sadhasivam manivannan.sadhasivam@linaro.org
Changes in v2:
- Used the stub instead of returning NULL inside the function
drivers/pci/probe.c | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 4b8693ec9e4c..e6a34db77826 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -2508,6 +2508,7 @@ bool pci_bus_read_dev_vendor_id(struct pci_bus *bus, int devfn, u32 *l, } EXPORT_SYMBOL(pci_bus_read_dev_vendor_id); +#if IS_ENABLED(CONFIG_PCI_PWRCTRL) static struct platform_device *pci_pwrctrl_create_device(struct pci_bus *bus, int devfn) { struct pci_host_bridge *host = pci_find_host_bridge(bus); @@ -2537,6 +2538,12 @@ static struct platform_device *pci_pwrctrl_create_device(struct pci_bus *bus, in return pdev; } +#else +static struct platform_device *pci_pwrctrl_create_device(struct pci_bus *bus, int devfn) +{
- return NULL;
+} +#endif /*
- Read the config data for a PCI device, sanity-check it,
-- 2.43.0 {
On Tue, Jul 01, 2025 at 04:01:38PM -0500, Bjorn Helgaas wrote:
[+cc Bart, Krzysztof, update Mani's addr to kernel.org]
On Tue, Jul 01, 2025 at 12:17:31PM +0530, Manivannan Sadhasivam wrote:
If devicetree describes power supplies related to a PCI device, we previously created a pwrctrl device even if CONFIG_PCI_PWRCTL was not enabled.
When pci_pwrctrl_create_device() creates and returns a pwrctrl device, pci_scan_device() doesn't enumerate the PCI device. It assumes the pwrctrl core will rescan the bus after turning on the power. However, if CONFIG_PCI_PWRCTL is not enabled, the rescan never happens.
This may break PCI enumeration on any system that describes power supplies in devicetree but does not use pwrctrl. Jim reported that some brcmstb platforms break this way.
While the actual fix would be to convert all the platforms to use pwrctrl framework, we also need to skip creating the pwrctrl device if CONFIG_PCI_PWRCTL is not enabled and let the PCI core scan the device normally (assuming it is already powered on or by the controller driver).
I'm fine with this change, but I think the commit log leaves the wrong impression. If CONFIG_PCI_PWRCTRL is not enabled, we shouldn't do anything related to it, independent of what other platforms or drivers do.
So I wouldn't describe this as "the actual fix is converting all platforms to use pwrctrl." Even if all platforms use pwrctrl, we *still* shouldn't run pci_pwrctrl_create_device() unless CONFIG_PCI_PWRCTRL is enabled.
I think all we need to say is something like this:
We only need pci_pwrctrl_create_device() when CONFIG_PCI_PWRCTRL is enabled. Compile it out when CONFIG_PCI_PWRCTRL is not enabled.
Sounds fair.
Cc: stable@vger.kernel.org # 6.15 Fixes: 957f40d039a9 ("PCI/pwrctrl: Move creation of pwrctrl devices to pci_scan_device()")
Not sure about this. If the problem we're solving is "we run pwrctrl code when CONFIG_PCI_PWRCTRL is not enabled," 957f40d039a9 is not the commit that added that behavior.
Well, this exact commit causes breakage on Jim's platform. That's why I've added it as the fixes tag irrespective of the pwrctrl functionality.
Maybe 8fb18619d910 ("PCI/pwrctl: Create platform devices for child OF nodes of the port node") would be more appropriate?
Reported-by: Jim Quinlan james.quinlan@broadcom.com Closes: https://lore.kernel.org/r/CA+-6iNwgaByXEYD3j=-+H_PKAxXRU78svPMRHDKKci8AGXAUP...
I'm also not sure this really merits a "Closes:" tag. All this does is enable a workaround (disable CONFIG_PCI_PWRCTRL when brcmstb is enabled). That's not a fix because we *should* be able to enable both pwrctrl and brcmstb at the same time.
Hmm, yeah. For this patch to work, one has to make sure that CONFIG_PCI_PWRCTRL is not set. This requires not supporting the ATH11K/12K chipsets and Jim said that they don't have a usecase for supporting these chipsets yet on the brcmstb platform (which only the internal team uses to run mainline).
If 2489eeb777af ("PCI/pwrctrl: Skip scanning for the device further if pwrctrl device is created") was purely an optimization (see https://lore.kernel.org/r/20250701203526.GA1849466@bhelgaas), I think I would:
- Revert 2489eeb777af with a stable tag for v6.15, and
But reverting 2489eeb777af alone wouldn't fix this regression [1].
- Apply this patch with a Fixes: 8fb18619d910 ("PCI/pwrctl: Create platform devices for child OF nodes of the port node") but no stable tag. 8fb18619d910 appeared in v6.11 and the "don't enable CONFIG_PCI_PWRCTRL" workaround was enough for brcmstb until 2489eeb777af, so if we revert 2489eeb777af, we wouldn't need to backport *this* patch.
Which means, this patch will only get applied for v6.16. I don't understand how that will ensure v6.15 is not broken (even after the revert).
- Mani
[1] https://lore.kernel.org/all/CA+-6iNxkYumAvk5G6KhYqON9K3bwxGn+My-22KZnGF5Pg8c...
- Mani
On Tue, Jul 01, 2025 at 12:17:31PM +0530, Manivannan Sadhasivam wrote:
If devicetree describes power supplies related to a PCI device, we previously created a pwrctrl device even if CONFIG_PCI_PWRCTL was not enabled.
When pci_pwrctrl_create_device() creates and returns a pwrctrl device, pci_scan_device() doesn't enumerate the PCI device. It assumes the pwrctrl core will rescan the bus after turning on the power. However, if CONFIG_PCI_PWRCTL is not enabled, the rescan never happens.
This may break PCI enumeration on any system that describes power supplies in devicetree but does not use pwrctrl. Jim reported that some brcmstb platforms break this way.
While the actual fix would be to convert all the platforms to use pwrctrl framework, we also need to skip creating the pwrctrl device if CONFIG_PCI_PWRCTL is not enabled and let the PCI core scan the device normally (assuming it is already powered on or by the controller driver).
Cc: stable@vger.kernel.org # 6.15 Fixes: 957f40d039a9 ("PCI/pwrctrl: Move creation of pwrctrl devices to pci_scan_device()") Reported-by: Jim Quinlan james.quinlan@broadcom.com Closes: https://lore.kernel.org/r/CA+-6iNwgaByXEYD3j=-+H_PKAxXRU78svPMRHDKKci8AGXAUP... Signed-off-by: Manivannan Sadhasivam manivannan.sadhasivam@linaro.org
I (finally) applied this to for-linus for v6.16 with the following commit log:
PCI/pwrctrl: Create pwrctrl devices only when CONFIG_PCI_PWRCTRL is enabled
If devicetree describes power supplies related to a PCI device, we unnecessarily created a pwrctrl device even if CONFIG_PCI_PWRCTL was not enabled.
We only need pci_pwrctrl_create_device() when CONFIG_PCI_PWRCTRL is enabled. Compile it out when CONFIG_PCI_PWRCTRL is not enabled.
When pci_pwrctrl_create_device() creates and returns a pwrctrl device, pci_scan_device() doesn't enumerate the PCI device. It assumes the pwrctrl core will rescan the bus after turning on the power. However, if CONFIG_PCI_PWRCTRL is not enabled, the rescan never happens, which breaks PCI enumeration on any system that describes power supplies in devicetree but does not use pwrctrl.
Jim reported that some brcmstb platforms break this way. The brcmstb driver is still broken if CONFIG_PCI_PWRCTRL is enabled, but this commit at least allows brcmstb to work when it's NOT enabled.
Fixes: 957f40d039a9 ("PCI/pwrctrl: Move creation of pwrctrl devices to pci_scan_device()") Reported-by: Jim Quinlan james.quinlan@broadcom.com Link: https://lore.kernel.org/r/CA+-6iNwgaByXEYD3j=-+H_PKAxXRU78svPMRHDKKci8AGXAUP... Signed-off-by: Manivannan Sadhasivam manivannan.sadhasivam@linaro.org [bhelgaas: commit log] Signed-off-by: Bjorn Helgaas bhelgaas@google.com Reviewed-by: Lukas Wunner lukas@wunner.de Cc: stable@vger.kernel.org # v6.15 Link: https://patch.msgid.link/20250701064731.52901-1-manivannan.sadhasivam@linaro...
Changes in v2:
- Used the stub instead of returning NULL inside the function
drivers/pci/probe.c | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 4b8693ec9e4c..e6a34db77826 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -2508,6 +2508,7 @@ bool pci_bus_read_dev_vendor_id(struct pci_bus *bus, int devfn, u32 *l, } EXPORT_SYMBOL(pci_bus_read_dev_vendor_id); +#if IS_ENABLED(CONFIG_PCI_PWRCTRL) static struct platform_device *pci_pwrctrl_create_device(struct pci_bus *bus, int devfn) { struct pci_host_bridge *host = pci_find_host_bridge(bus); @@ -2537,6 +2538,12 @@ static struct platform_device *pci_pwrctrl_create_device(struct pci_bus *bus, in return pdev; } +#else +static struct platform_device *pci_pwrctrl_create_device(struct pci_bus *bus, int devfn) +{
- return NULL;
+} +#endif /*
- Read the config data for a PCI device, sanity-check it,
-- 2.43.0
[use Mani's new email addr]
On Tue, Jul 22, 2025 at 01:58:11PM -0500, Bjorn Helgaas wrote:
On Tue, Jul 01, 2025 at 12:17:31PM +0530, Manivannan Sadhasivam wrote:
If devicetree describes power supplies related to a PCI device, we previously created a pwrctrl device even if CONFIG_PCI_PWRCTL was not enabled.
When pci_pwrctrl_create_device() creates and returns a pwrctrl device, pci_scan_device() doesn't enumerate the PCI device. It assumes the pwrctrl core will rescan the bus after turning on the power. However, if CONFIG_PCI_PWRCTL is not enabled, the rescan never happens.
This may break PCI enumeration on any system that describes power supplies in devicetree but does not use pwrctrl. Jim reported that some brcmstb platforms break this way.
While the actual fix would be to convert all the platforms to use pwrctrl framework, we also need to skip creating the pwrctrl device if CONFIG_PCI_PWRCTL is not enabled and let the PCI core scan the device normally (assuming it is already powered on or by the controller driver).
Cc: stable@vger.kernel.org # 6.15 Fixes: 957f40d039a9 ("PCI/pwrctrl: Move creation of pwrctrl devices to pci_scan_device()") Reported-by: Jim Quinlan james.quinlan@broadcom.com Closes: https://lore.kernel.org/r/CA+-6iNwgaByXEYD3j=-+H_PKAxXRU78svPMRHDKKci8AGXAUP... Signed-off-by: Manivannan Sadhasivam manivannan.sadhasivam@linaro.org
I (finally) applied this to for-linus for v6.16 with the following commit log:
PCI/pwrctrl: Create pwrctrl devices only when CONFIG_PCI_PWRCTRL is enabled
If devicetree describes power supplies related to a PCI device, we unnecessarily created a pwrctrl device even if CONFIG_PCI_PWRCTL was not enabled. We only need pci_pwrctrl_create_device() when CONFIG_PCI_PWRCTRL is enabled. Compile it out when CONFIG_PCI_PWRCTRL is not enabled. When pci_pwrctrl_create_device() creates and returns a pwrctrl device, pci_scan_device() doesn't enumerate the PCI device. It assumes the pwrctrl core will rescan the bus after turning on the power. However, if CONFIG_PCI_PWRCTRL is not enabled, the rescan never happens, which breaks PCI enumeration on any system that describes power supplies in devicetree but does not use pwrctrl. Jim reported that some brcmstb platforms break this way. The brcmstb driver is still broken if CONFIG_PCI_PWRCTRL is enabled, but this commit at least allows brcmstb to work when it's NOT enabled. Fixes: 957f40d039a9 ("PCI/pwrctrl: Move creation of pwrctrl devices to pci_scan_device()") Reported-by: Jim Quinlan james.quinlan@broadcom.com Link: https://lore.kernel.org/r/CA+-6iNwgaByXEYD3j=-+H_PKAxXRU78svPMRHDKKci8AGXAUP... Signed-off-by: Manivannan Sadhasivam manivannan.sadhasivam@linaro.org [bhelgaas: commit log] Signed-off-by: Bjorn Helgaas bhelgaas@google.com Reviewed-by: Lukas Wunner lukas@wunner.de Cc: stable@vger.kernel.org # v6.15 Link: https://patch.msgid.link/20250701064731.52901-1-manivannan.sadhasivam@linaro...
Changes in v2:
- Used the stub instead of returning NULL inside the function
drivers/pci/probe.c | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 4b8693ec9e4c..e6a34db77826 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -2508,6 +2508,7 @@ bool pci_bus_read_dev_vendor_id(struct pci_bus *bus, int devfn, u32 *l, } EXPORT_SYMBOL(pci_bus_read_dev_vendor_id); +#if IS_ENABLED(CONFIG_PCI_PWRCTRL) static struct platform_device *pci_pwrctrl_create_device(struct pci_bus *bus, int devfn) { struct pci_host_bridge *host = pci_find_host_bridge(bus); @@ -2537,6 +2538,12 @@ static struct platform_device *pci_pwrctrl_create_device(struct pci_bus *bus, in return pdev; } +#else +static struct platform_device *pci_pwrctrl_create_device(struct pci_bus *bus, int devfn) +{
- return NULL;
+} +#endif /*
- Read the config data for a PCI device, sanity-check it,
-- 2.43.0
linux-stable-mirror@lists.linaro.org