mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 3/3] PCI: qcom: Allow post_init to fail
@ 2017-07-16  6:42 Bjorn Andersson
  2017-08-03 12:45 ` Stanimir Varbanov
  0 siblings, 1 reply; 2+ messages in thread
From: Bjorn Andersson @ 2017-07-16  6:42 UTC (permalink / raw)
  To: Stanimir Varbanov, Bjorn Helgaas; +Cc: linux-pci, linux-arm-msm, linux-kernel

host_init should detect and propagate errors from post_init.

In addition, by acknowleding that post_init can fail we must disable the
post_init resources in a step separate from the deinit, so that we don't
try to disable the post_init resources a second time.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---
 drivers/pci/dwc/pcie-qcom.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/dwc/pcie-qcom.c b/drivers/pci/dwc/pcie-qcom.c
index 7b703741a3fd..26e84a957c35 100644
--- a/drivers/pci/dwc/pcie-qcom.c
+++ b/drivers/pci/dwc/pcie-qcom.c
@@ -124,6 +124,7 @@ struct qcom_pcie_ops {
 	int (*init)(struct qcom_pcie *pcie);
 	int (*post_init)(struct qcom_pcie *pcie);
 	void (*deinit)(struct qcom_pcie *pcie);
+	void (*post_deinit)(struct qcom_pcie *pcie);
 	void (*ltssm_enable)(struct qcom_pcie *pcie);
 };
 
@@ -517,13 +518,19 @@ static void qcom_pcie_deinit_v2(struct qcom_pcie *pcie)
 {
 	struct qcom_pcie_resources_v2 *res = &pcie->res.v2;
 
-	clk_disable_unprepare(res->pipe_clk);
 	clk_disable_unprepare(res->slave_clk);
 	clk_disable_unprepare(res->master_clk);
 	clk_disable_unprepare(res->cfg_clk);
 	clk_disable_unprepare(res->aux_clk);
 }
 
+static void qcom_pcie_post_deinit_v2(struct qcom_pcie *pcie)
+{
+	struct qcom_pcie_resources_v2 *res = &pcie->res.v2;
+
+	clk_disable_unprepare(res->pipe_clk);
+}
+
 static int qcom_pcie_init_v2(struct qcom_pcie *pcie)
 {
 	struct qcom_pcie_resources_v2 *res = &pcie->res.v2;
@@ -907,8 +914,11 @@ static int qcom_pcie_host_init(struct pcie_port *pp)
 	if (ret)
 		goto err_deinit;
 
-	if (pcie->ops->post_init)
-		pcie->ops->post_init(pcie);
+	if (pcie->ops->post_init) {
+		ret = pcie->ops->post_init(pcie);
+		if (ret)
+			goto err_disable_phy;
+	}
 
 	dw_pcie_setup_rc(pp);
 
@@ -924,6 +934,9 @@ static int qcom_pcie_host_init(struct pcie_port *pp)
 	return 0;
 err:
 	qcom_ep_reset_assert(pcie);
+	if (pcie->ops->post_deinit)
+		pcie->ops->post_deinit(pcie);
+err_disable_phy:
 	phy_power_off(pcie->phy);
 err_deinit:
 	pcie->ops->deinit(pcie);
@@ -971,6 +984,7 @@ static const struct qcom_pcie_ops ops_v2 = {
 	.init = qcom_pcie_init_v2,
 	.post_init = qcom_pcie_post_init_v2,
 	.deinit = qcom_pcie_deinit_v2,
+	.post_deinit = qcom_pcie_post_deinit_v2,
 	.ltssm_enable = qcom_pcie_v2_ltssm_enable,
 };
 
-- 
2.12.0

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH 3/3] PCI: qcom: Allow post_init to fail
  2017-07-16  6:42 [PATCH 3/3] PCI: qcom: Allow post_init to fail Bjorn Andersson
@ 2017-08-03 12:45 ` Stanimir Varbanov
  0 siblings, 0 replies; 2+ messages in thread
From: Stanimir Varbanov @ 2017-08-03 12:45 UTC (permalink / raw)
  To: Bjorn Andersson, Bjorn Helgaas; +Cc: linux-pci, linux-arm-msm, linux-kernel

Bjorn, thanks for the patch!

On 07/16/2017 09:42 AM, Bjorn Andersson wrote:
> host_init should detect and propagate errors from post_init.
> 
> In addition, by acknowleding that post_init can fail we must disable the
> post_init resources in a step separate from the deinit, so that we don't
> try to disable the post_init resources a second time.
> 
> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
> ---
>  drivers/pci/dwc/pcie-qcom.c | 20 +++++++++++++++++---
>  1 file changed, 17 insertions(+), 3 deletions(-)

The patch looks good to me,

Acked-by: Stanimir Varbanov <svarbanov@mm-sol.com>

regards,
Stan

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-08-03 12:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-16  6:42 [PATCH 3/3] PCI: qcom: Allow post_init to fail Bjorn Andersson
2017-08-03 12:45 ` Stanimir Varbanov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome