diff mbox series

[v2,10/12] PCI: brcmstb: Check return value of all reset_control_xxx calls

Message ID 20240703180300.42959-11-james.quinlan@broadcom.com (mailing list archive)
State Superseded
Delegated to: Krzysztof Wilczyński
Headers show
Series PCI: brcnstb: Enable STB 7712 SOC | expand

Commit Message

Jim Quinlan July 3, 2024, 6:02 p.m. UTC
In some cases the result of a reset_control_xxx() call have been ignored.
Now we check all return values of such functions and at the least issue a
dev_err(...) message if the return value is not zero.

Signed-off-by: Jim Quinlan <james.quinlan@broadcom.com>
---
 drivers/pci/controller/pcie-brcmstb.c | 33 ++++++++++++++++++++-------
 1 file changed, 25 insertions(+), 8 deletions(-)

Comments

Stanimir Varbanov July 4, 2024, 1:49 p.m. UTC | #1
Hi Jim,

On 7/3/24 21:02, Jim Quinlan wrote:
> In some cases the result of a reset_control_xxx() call have been ignored.
> Now we check all return values of such functions and at the least issue a
> dev_err(...) message if the return value is not zero.
> 

When I made the comment for the return value of reset_control_xxx API I
was thinking for propagating the error to upper PCI layer and not just
print it.

Printing the error is a step forward but I don't think it is enough.
Please drop the patch from the series, we can fix that problem in the
driver with follow up patches.

~Stan

> Signed-off-by: Jim Quinlan <james.quinlan@broadcom.com>
> ---
>  drivers/pci/controller/pcie-brcmstb.c | 33 ++++++++++++++++++++-------
>  1 file changed, 25 insertions(+), 8 deletions(-)
>
Jim Quinlan July 5, 2024, 2:28 p.m. UTC | #2
On Thu, Jul 4, 2024 at 9:49 AM Stanimir Varbanov <svarbanov@suse.de> wrote:

> Hi Jim,
>
> On 7/3/24 21:02, Jim Quinlan wrote:
> > In some cases the result of a reset_control_xxx() call have been ignored.
> > Now we check all return values of such functions and at the least issue a
> > dev_err(...) message if the return value is not zero.
> >
>
> When I made the comment for the return value of reset_control_xxx API I
> was thinking for propagating the error to upper PCI layer and not just
> print it.
>
> Printing the error is a step forward but I don't think it is enough.
> Please drop the patch from the series, we can fix that problem in the
> driver with follow up patches.
>

I'll return the value up the chain as you want as there is a list of things
anyway for v3.

Regards
Jim Quinlan
Broadcom STB

>
> ~Stan
>
> > Signed-off-by: Jim Quinlan <james.quinlan@broadcom.com>
> > ---
> >  drivers/pci/controller/pcie-brcmstb.c | 33 ++++++++++++++++++++-------
> >  1 file changed, 25 insertions(+), 8 deletions(-)
> >
>
diff mbox series

Patch

diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c
index 5f632fdc0052..1c3ce0c182d1 100644
--- a/drivers/pci/controller/pcie-brcmstb.c
+++ b/drivers/pci/controller/pcie-brcmstb.c
@@ -743,11 +743,16 @@  static void __iomem *brcm7425_pcie_map_bus(struct pci_bus *bus,
 
 static void brcm_pcie_bridge_sw_init_set_generic(struct brcm_pcie *pcie, u32 val)
 {
+	int ret;
+
 	if (pcie->bridge) {
 		if (val)
-			reset_control_assert(pcie->bridge);
+			ret = reset_control_assert(pcie->bridge);
 		else
-			reset_control_deassert(pcie->bridge);
+			ret = reset_control_deassert(pcie->bridge);
+		if (ret)
+			dev_err(pcie->dev, "failed to %s 'bridge' reset, err=%d\n",
+				val ? "assert" : "deassert", ret);
 	} else {
 		u32 tmp, mask =  RGR1_SW_INIT_1_INIT_GENERIC_MASK;
 		u32 shift = RGR1_SW_INIT_1_INIT_GENERIC_SHIFT;
@@ -770,13 +775,20 @@  static void brcm_pcie_bridge_sw_init_set_7278(struct brcm_pcie *pcie, u32 val)
 
 static void brcm_pcie_perst_set_4908(struct brcm_pcie *pcie, u32 val)
 {
+	int ret;
+
 	if (WARN_ONCE(!pcie->perst_reset, "missing PERST# reset controller\n"))
 		return;
 
 	if (val)
-		reset_control_assert(pcie->perst_reset);
+		ret = reset_control_assert(pcie->perst_reset);
 	else
-		reset_control_deassert(pcie->perst_reset);
+		ret = reset_control_deassert(pcie->perst_reset);
+
+	if (ret)
+		dev_err(pcie->dev, "failed to %s 'perst' reset, err=%d\n",
+			val ? "assert" : "deassert", ret);
+
 }
 
 static void brcm_pcie_perst_set_7278(struct brcm_pcie *pcie, u32 val)
@@ -1460,7 +1472,7 @@  static int brcm_pcie_suspend_noirq(struct device *dev)
 {
 	struct brcm_pcie *pcie = dev_get_drvdata(dev);
 	struct pci_host_bridge *bridge = pci_host_bridge_from_priv(pcie);
-	int ret;
+	int ret, rret;
 
 	brcm_pcie_turn_off(pcie);
 	/*
@@ -1491,7 +1503,10 @@  static int brcm_pcie_suspend_noirq(struct device *dev)
 						     pcie->sr->supplies);
 			if (ret) {
 				dev_err(dev, "Could not turn off regulators\n");
-				reset_control_reset(pcie->rescal);
+				rret = reset_control_reset(pcie->rescal);
+				if (rret)
+					dev_err(dev, "failed to reset 'rascal' controller ret=%d\n",
+						rret);
 				return ret;
 			}
 		}
@@ -1506,7 +1521,7 @@  static int brcm_pcie_resume_noirq(struct device *dev)
 	struct brcm_pcie *pcie = dev_get_drvdata(dev);
 	void __iomem *base;
 	u32 tmp;
-	int ret;
+	int ret, rret;
 
 	base = pcie->base;
 	ret = clk_prepare_enable(pcie->clk);
@@ -1568,7 +1583,9 @@  static int brcm_pcie_resume_noirq(struct device *dev)
 	if (pcie->sr)
 		regulator_bulk_disable(pcie->sr->num_supplies, pcie->sr->supplies);
 err_reset:
-	reset_control_rearm(pcie->rescal);
+	rret = reset_control_rearm(pcie->rescal);
+	if (rret)
+		dev_err(pcie->dev, "failed to rearm 'rescal' reset, err=%d\n", rret);
 err_disable_clk:
 	clk_disable_unprepare(pcie->clk);
 	return ret;