Linux PCI subsystem development
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: Manivannan Sadhasivam <mani@kernel.org>
Cc: bhelgaas@google.com, lukas@wunner.de, linux-pci@vger.kernel.org,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	Jim Quinlan <james.quinlan@broadcom.com>
Subject: Re: [PATCH v2] PCI/pwrctrl: Skip creating pwrctrl device unless CONFIG_PCI_PWRCTRL is enabled
Date: Tue, 22 Jul 2025 14:15:06 -0500	[thread overview]
Message-ID: <20250722191506.GA2810550@bhelgaas> (raw)
In-Reply-To: <20250722185810.GA2809731@bhelgaas>

[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_PKAxXRU78svPMRHDKKci8AGXAUPg@mail.gmail.com
> > 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_PKAxXRU78svPMRHDKKci8AGXAUPg@mail.gmail.com
>     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.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
> > 

      reply	other threads:[~2025-07-22 19:15 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-01  6:47 [PATCH v2] PCI/pwrctrl: Skip creating pwrctrl device unless CONFIG_PCI_PWRCTRL is enabled Manivannan Sadhasivam
2025-07-01  7:00 ` Lukas Wunner
2025-07-01 11:57   ` Manivannan Sadhasivam
2025-07-01 12:49     ` Lukas Wunner
2025-07-01 20:35 ` Bjorn Helgaas
2025-07-02  6:47   ` Manivannan Sadhasivam
2025-07-02 17:53     ` Bjorn Helgaas
2025-07-02 18:30       ` Manivannan Sadhasivam
2025-07-02 20:04         ` Bjorn Helgaas
2025-07-01 21:01 ` Bjorn Helgaas
2025-07-02  7:20   ` Manivannan Sadhasivam
2025-07-22 18:58 ` Bjorn Helgaas
2025-07-22 19:15   ` Bjorn Helgaas [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250722191506.GA2810550@bhelgaas \
    --to=helgaas@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=james.quinlan@broadcom.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lukas@wunner.de \
    --cc=mani@kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox