From: Bjorn Helgaas <helgaas@kernel.org>
To: Jim Quinlan <james.quinlan@broadcom.com>
Cc: linux-pci@vger.kernel.org,
"Nicolas Saenz Julienne" <nsaenz@kernel.org>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Lorenzo Pieralisi" <lorenzo.pieralisi@arm.com>,
"Cyril Brulebois" <kibi@debian.org>,
"Stanimir Varbanov" <svarbanov@suse.de>,
bcm-kernel-feedback-list@broadcom.com, jim2101024@gmail.com,
"Florian Fainelli" <florian.fainelli@broadcom.com>,
"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
"Krzysztof Wilczyński" <kw@linux.com>,
"Manivannan Sadhasivam" <manivannan.sadhasivam@linaro.org>,
"Rob Herring" <robh@kernel.org>,
"moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE"
<linux-rpi-kernel@lists.infradead.org>,
"moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE"
<linux-arm-kernel@lists.infradead.org>,
"open list" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v1 2/6] PCI: brcmstb: Fix error path upon call of regulator_bulk_get()
Date: Thu, 6 Feb 2025 12:34:55 -0600 [thread overview]
Message-ID: <20250206183455.GA994612@bhelgaas> (raw)
In-Reply-To: <CA+-6iNwws3On9-VJ-vF55o5LwKYpOHtfRYLtoQ5=bh7uGTfYkg@mail.gmail.com>
On Thu, Feb 06, 2025 at 01:22:54PM -0500, Jim Quinlan wrote:
> On Thu, Feb 6, 2025 at 12:29 PM Bjorn Helgaas <helgaas@kernel.org> wrote:
> > On Wed, Feb 05, 2025 at 02:12:02PM -0500, Jim Quinlan wrote:
> > > If regulator_bulk_get() returns an error, no regulators are
> > > created and we need to set their number to zero. If we do
> > > not do this and the PCIe link-up fails, regulator_bulk_free()
> > > will be invoked and effect a panic.
> > >
> > > Also print out the error value, as we cannot return an error
> > > upwards as Linux will WARN on an error from add_bus().
> > > Fixes: 9e6be018b263 ("PCI: brcmstb: Enable child bus device regulators from DT")
> > > Signed-off-by: Jim Quinlan <james.quinlan@broadcom.com>
> > > ---
> > > drivers/pci/controller/pcie-brcmstb.c | 3 ++-
> > > 1 file changed, 2 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c
> > > index f8fc3d620ee2..bf919467cbcd 100644
> > > --- a/drivers/pci/controller/pcie-brcmstb.c
> > > +++ b/drivers/pci/controller/pcie-brcmstb.c
> > > @@ -1417,7 +1417,8 @@ static int brcm_pcie_add_bus(struct pci_bus *bus)
> > >
> > > ret = regulator_bulk_get(dev, sr->num_supplies, sr->supplies);
> > > if (ret) {
> > > - dev_info(dev, "No regulators for downstream device\n");
> > > + dev_info(dev, "Did not get regulators; err=%d\n", ret);
> > > + sr->num_supplies = 0;
> > > goto no_regulators;
> >
> > I think it might have been better if we could do the
> > regulator_bulk_get() separately, before pci_host_probe(), so that if
> > this error happens, we can deal with it more easily.
>
> Keep in mind that brcm_pcie_add_bus() cannot return a non-zero error
> code, as it will get a WARN() from the caller if it does.
>
> Would you accept deallocating the "sr" array and setting it to NULL
> like the following error condition does? In that way we would not be
> invoking any regulator_bulk_xxxx() functions with nr==0. I'm really
> wary of moving things around...
Yeah, don't move anything around right now. My wondering is just
about whether the alloc and bulk_get() could be done earlier, leaving
only the bulk_enable() to be done in brcm_pcie_add_bus().
The alloc and bulk_get() depend on DT things and it's nice to catch
those errors earlier.
Bjorn
next prev parent reply other threads:[~2025-02-06 19:04 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-05 19:12 [PATCH v1 0/6] PCI: brcmstb: Misc small tweaks and fixes Jim Quinlan
2025-02-05 19:12 ` [PATCH v1 1/6] PCI: brcmstb: Refactor max speed limit functionality Jim Quinlan
2025-02-06 17:04 ` Bjorn Helgaas
2025-02-06 18:27 ` Jim Quinlan
2025-02-06 20:18 ` Bjorn Helgaas
2025-02-05 19:12 ` [PATCH v1 2/6] PCI: brcmstb: Fix error path upon call of regulator_bulk_get() Jim Quinlan
2025-02-06 17:29 ` Bjorn Helgaas
2025-02-06 18:22 ` Jim Quinlan
2025-02-06 18:34 ` Bjorn Helgaas [this message]
2025-02-06 19:39 ` Jim Quinlan
2025-02-05 19:12 ` [PATCH v1 3/6] PCI: brcmstb: Fix potential premature regluator disabling Jim Quinlan
2025-02-06 17:32 ` Bjorn Helgaas
2025-02-06 17:57 ` Jim Quinlan
2025-02-05 19:12 ` [PATCH v1 4/6] PCI: brcmstb: Use same constant table for config space access Jim Quinlan
2025-02-05 19:12 ` [PATCH v1 5/6] PCI: brcmstb: Make two changes in MDIO register fields Jim Quinlan
2025-02-05 19:12 ` [PATCH v1 6/6] PCI: brcmstb: Cast an int variable to an irq_hw_number_t Jim Quinlan
2025-02-06 22:19 ` Stefan Wahren
2025-02-14 16:17 ` Jim Quinlan
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=20250206183455.GA994612@bhelgaas \
--to=helgaas@kernel.org \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=bhelgaas@google.com \
--cc=florian.fainelli@broadcom.com \
--cc=james.quinlan@broadcom.com \
--cc=jim2101024@gmail.com \
--cc=kibi@debian.org \
--cc=kw@linux.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-rpi-kernel@lists.infradead.org \
--cc=lorenzo.pieralisi@arm.com \
--cc=lpieralisi@kernel.org \
--cc=manivannan.sadhasivam@linaro.org \
--cc=nsaenz@kernel.org \
--cc=robh@kernel.org \
--cc=svarbanov@suse.de \
/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