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 e0b20f58c604..56b49d3cae19 100644
--- a/drivers/pci/controller/pcie-brcmstb.c
+++ b/drivers/pci/controller/pcie-brcmstb.c
@@ -1416,7 +1416,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);
+ pcie->sr = NULL;
goto no_regulators;
}
--
2.43.0
On Fri, Feb 14, 2025 at 12:39:32PM -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 e0b20f58c604..56b49d3cae19 100644
> --- a/drivers/pci/controller/pcie-brcmstb.c
> +++ b/drivers/pci/controller/pcie-brcmstb.c
> @@ -1416,7 +1416,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);
Why is this dev_info() instead of dev_err()?
> + pcie->sr = NULL;
Why can't you set 'pcie->sr' after successfull regulator_bulk_get()?
- Mani
--
மணிவண்ணன் சதாசிவம்
On Tue, Mar 4, 2025 at 10:03 AM Manivannan Sadhasivam
<manivannan.sadhasivam@linaro.org> wrote:
>
> On Fri, Feb 14, 2025 at 12:39:32PM -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 e0b20f58c604..56b49d3cae19 100644
> > --- a/drivers/pci/controller/pcie-brcmstb.c
> > +++ b/drivers/pci/controller/pcie-brcmstb.c
> > @@ -1416,7 +1416,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);
>
> Why is this dev_info() instead of dev_err()?
I will change this.
>
> > + pcie->sr = NULL;
>
> Why can't you set 'pcie->sr' after successfull regulator_bulk_get()?
Not sure I understand -- it is already set before a successful
regulator_bulk_get() call.
I set it to NULL after an unsuccessful result so the structure will
not be passed to subsequent calls.
Regards,
Jim Quinlan
Broadcom STB/CM
>
> - Mani
>
> --
> மணிவண்ணன் சதாசிவம்
On Tue, Mar 04, 2025 at 11:55:05AM -0500, Jim Quinlan wrote:
> On Tue, Mar 4, 2025 at 10:03 AM Manivannan Sadhasivam
> <manivannan.sadhasivam@linaro.org> wrote:
> >
> > On Fri, Feb 14, 2025 at 12:39:32PM -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 e0b20f58c604..56b49d3cae19 100644
> > > --- a/drivers/pci/controller/pcie-brcmstb.c
> > > +++ b/drivers/pci/controller/pcie-brcmstb.c
> > > @@ -1416,7 +1416,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);
> >
> > Why is this dev_info() instead of dev_err()?
>
> I will change this.
> >
> > > + pcie->sr = NULL;
> >
> > Why can't you set 'pcie->sr' after successfull regulator_bulk_get()?
>
> Not sure I understand -- it is already set before a successful
> regulator_bulk_get() call.
Didn't I say 'after'?
> I set it to NULL after an unsuccessful result so the structure will
> not be passed to subsequent calls.
>
If you set the pointer after a successful regulator_bulk_get(), you do not need
to set it to NULL for a failure.
- Mani
--
மணிவண்ணன் சதாசிவம்
On Tue, Mar 4, 2025 at 12:07 PM Manivannan Sadhasivam
<manivannan.sadhasivam@linaro.org> wrote:
>
> On Tue, Mar 04, 2025 at 11:55:05AM -0500, Jim Quinlan wrote:
> > On Tue, Mar 4, 2025 at 10:03 AM Manivannan Sadhasivam
> > <manivannan.sadhasivam@linaro.org> wrote:
> > >
> > > On Fri, Feb 14, 2025 at 12:39:32PM -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 e0b20f58c604..56b49d3cae19 100644
> > > > --- a/drivers/pci/controller/pcie-brcmstb.c
> > > > +++ b/drivers/pci/controller/pcie-brcmstb.c
> > > > @@ -1416,7 +1416,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);
> > >
> > > Why is this dev_info() instead of dev_err()?
> >
> > I will change this.
> > >
> > > > + pcie->sr = NULL;
> > >
> > > Why can't you set 'pcie->sr' after successfull regulator_bulk_get()?
> >
> > Not sure I understand -- it is already set before a successful
> > regulator_bulk_get() call.
>
> Didn't I say 'after'?
Sorry, I misinterpreted your question. I can change it but it would
just be churn because a new commit is going to refactor this function.
However,
I can set pcie->num_regulators "after" in the new commit.
Regards,
Jim Quinlan
Broadcom STB/CM
>
> > I set it to NULL after an unsuccessful result so the structure will
> > not be passed to subsequent calls.
> >
>
> If you set the pointer after a successful regulator_bulk_get(), you do not need
> to set it to NULL for a failure.
>
> - Mani
>
> --
> மணிவண்ணன் சதாசிவம்
On Tue, Mar 04, 2025 at 12:24:56PM -0500, Jim Quinlan wrote:
> On Tue, Mar 4, 2025 at 12:07 PM Manivannan Sadhasivam
> <manivannan.sadhasivam@linaro.org> wrote:
> >
> > On Tue, Mar 04, 2025 at 11:55:05AM -0500, Jim Quinlan wrote:
> > > On Tue, Mar 4, 2025 at 10:03 AM Manivannan Sadhasivam
> > > <manivannan.sadhasivam@linaro.org> wrote:
> > > >
> > > > On Fri, Feb 14, 2025 at 12:39:32PM -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 e0b20f58c604..56b49d3cae19 100644
> > > > > --- a/drivers/pci/controller/pcie-brcmstb.c
> > > > > +++ b/drivers/pci/controller/pcie-brcmstb.c
> > > > > @@ -1416,7 +1416,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);
> > > >
> > > > Why is this dev_info() instead of dev_err()?
> > >
> > > I will change this.
> > > >
> > > > > + pcie->sr = NULL;
> > > >
> > > > Why can't you set 'pcie->sr' after successfull regulator_bulk_get()?
> > >
> > > Not sure I understand -- it is already set before a successful
> > > regulator_bulk_get() call.
> >
> > Didn't I say 'after'?
>
> Sorry, I misinterpreted your question. I can change it but it would
> just be churn because a new commit is going to refactor this function.
> However,
> I can set pcie->num_regulators "after" in the new commit.
>
If a new patch is going to change the beahvior, then I'm fine with it for now.
After all, this series is already merged.
- Mani
--
மணிவண்ணன் சதாசிவம்
Hello, [...] > > > > > > - dev_info(dev, "No regulators for downstream device\n"); > > > > > > + dev_info(dev, "Did not get regulators; err=%d\n", ret); > > > > > > > > > > Why is this dev_info() instead of dev_err()? > > > > > > > > I will change this. I can update this directly on the branch if you want. > > > > > > > > > > > + pcie->sr = NULL; > > > > > > > > > > Why can't you set 'pcie->sr' after successfull regulator_bulk_get()? > > > > > > > > Not sure I understand -- it is already set before a successful > > > > regulator_bulk_get() call. > > > > > > Didn't I say 'after'? > > > > Sorry, I misinterpreted your question. I can change it but it would > > just be churn because a new commit is going to refactor this function. > > However, > > I can set pcie->num_regulators "after" in the new commit. > > > > If a new patch is going to change the beahvior, then I'm fine with it for now. > After all, this series is already merged. There is still time if a follow-up patch would be of benefit there. Same goes for Krzysztof
On Fri, Feb 14, 2025 at 12:39:32PM -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 e0b20f58c604..56b49d3cae19 100644
> --- a/drivers/pci/controller/pcie-brcmstb.c
> +++ b/drivers/pci/controller/pcie-brcmstb.c
> @@ -1416,7 +1416,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);
> + pcie->sr = NULL;
Is alloc_subdev_regulators() buying us something useful? It seems
like it would be simpler to have:
struct brcm_pcie {
...
struct regulator_bulk_data supplies[3];
...
};
I think that's what most callers of devm_regulator_bulk_get() do.
> goto no_regulators;
> }
>
> --
> 2.43.0
>
On Mon, Mar 3, 2025 at 1:40 PM Bjorn Helgaas <helgaas@kernel.org> wrote:
>
> On Fri, Feb 14, 2025 at 12:39:32PM -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 e0b20f58c604..56b49d3cae19 100644
> > --- a/drivers/pci/controller/pcie-brcmstb.c
> > +++ b/drivers/pci/controller/pcie-brcmstb.c
> > @@ -1416,7 +1416,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);
> > + pcie->sr = NULL;
>
> Is alloc_subdev_regulators() buying us something useful? It seems
> like it would be simpler to have:
>
> struct brcm_pcie {
> ...
> struct regulator_bulk_data supplies[3];
> ...
> };
>
> I think that's what most callers of devm_regulator_bulk_get() do.
Ack.
Jim Quinlan
Broadcom STB/CM
>
> > goto no_regulators;
> > }
> >
> > --
> > 2.43.0
> >
On Tue, Mar 4, 2025 at 9:49 AM Jim Quinlan <james.quinlan@broadcom.com> wrote:
>
> On Mon, Mar 3, 2025 at 1:40 PM Bjorn Helgaas <helgaas@kernel.org> wrote:
> >
> > On Fri, Feb 14, 2025 at 12:39:32PM -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 e0b20f58c604..56b49d3cae19 100644
> > > --- a/drivers/pci/controller/pcie-brcmstb.c
> > > +++ b/drivers/pci/controller/pcie-brcmstb.c
> > > @@ -1416,7 +1416,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);
> > > + pcie->sr = NULL;
> >
> > Is alloc_subdev_regulators() buying us something useful? It seems
> > like it would be simpler to have:
> >
> > struct brcm_pcie {
> > ...
> > struct regulator_bulk_data supplies[3];
> > ...
> > };
> >
> > I think that's what most callers of devm_regulator_bulk_get() do.
>
> Ack.
Hi Bjorn,
Manivannan stated that this series has already been merged. So shall
I implement your comments with a commit sometime in the future?
Thanks,
Jim Quinlan
Broadcom STB/CM
>
> Jim Quinlan
> Broadcom STB/CM
> >
> > > goto no_regulators;
> > > }
> > >
> > > --
> > > 2.43.0
> > >
On Thu, Mar 06, 2025 at 10:24:56AM -0500, Jim Quinlan wrote:
> On Tue, Mar 4, 2025 at 9:49 AM Jim Quinlan <james.quinlan@broadcom.com> wrote:
> > On Mon, Mar 3, 2025 at 1:40 PM Bjorn Helgaas <helgaas@kernel.org> wrote:
> > > On Fri, Feb 14, 2025 at 12:39:32PM -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 e0b20f58c604..56b49d3cae19 100644
> > > > --- a/drivers/pci/controller/pcie-brcmstb.c
> > > > +++ b/drivers/pci/controller/pcie-brcmstb.c
> > > > @@ -1416,7 +1416,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);
> > > > + pcie->sr = NULL;
> > >
> > > Is alloc_subdev_regulators() buying us something useful? It seems
> > > like it would be simpler to have:
> > >
> > > struct brcm_pcie {
> > > ...
> > > struct regulator_bulk_data supplies[3];
> > > ...
> > > };
> > >
> > > I think that's what most callers of devm_regulator_bulk_get() do.
>
> Manivannan stated that this series has already been merged. So shall
> I implement your comments with a commit sometime in the future?
Sorry, I should have mentioned this would be something possible for
the future. This current series is all set to go.
Bjorn
On 2/14/2025 9:39 AM, 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>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
--
Florian
© 2016 - 2025 Red Hat, Inc.