From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED, USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0F93FECE562 for ; Mon, 17 Sep 2018 10:45:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C7D5220671 for ; Mon, 17 Sep 2018 10:45:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C7D5220671 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728396AbeIQQLz (ORCPT ); Mon, 17 Sep 2018 12:11:55 -0400 Received: from foss.arm.com ([217.140.101.70]:56888 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727491AbeIQQLy (ORCPT ); Mon, 17 Sep 2018 12:11:54 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7F56D18A; Mon, 17 Sep 2018 03:45:06 -0700 (PDT) Received: from e107981-ln.cambridge.arm.com (e107981-ln.emea.arm.com [10.4.13.117]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4DA143F5BD; Mon, 17 Sep 2018 03:45:05 -0700 (PDT) Date: Mon, 17 Sep 2018 11:45:02 +0100 From: Lorenzo Pieralisi To: Bjorn Andersson Cc: Stanimir Varbanov , Bjorn Helgaas , linux-pci@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] PCI: qcom: Fix error handling in pm_runtime support Message-ID: <20180917104502.GD7239@e107981-ln.cambridge.arm.com> References: <20180831225510.32230-1-bjorn.andersson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180831225510.32230-1-bjorn.andersson@linaro.org> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 31, 2018 at 03:55:10PM -0700, Bjorn Andersson wrote: > The driver does not cope with the fact that probe can fail in a number > of cases after enabling pm_runtime on the device, this results in > warnings about "Unbalanced pm_runtime_enable". Further more if probe > fails after invoking host_init the power-domain will be left referenced. > > As it's not possible for the error handling in qcom_pcie_host_init() to > handle errors happening after returning from that function the > pm_runtime_get_sync() is moved to probe() as well. > > Fixes: 854b69efbdd2 ("PCI: qcom: add runtime pm support to pcie_port") > Acked-by: Stanimir Varbanov > Signed-off-by: Bjorn Andersson > --- > > Changes since v1: > - Dropped remove function, as this can't be called > - Handle pm_runtime_get_sync() errors > - Add "Fixes" tag > > drivers/pci/controller/dwc/pcie-qcom.c | 56 ++++++++++++++++++-------- > 1 file changed, 39 insertions(+), 17 deletions(-) Applied to pci/dwc for v4.20, thanks. Lorenzo > diff --git a/drivers/pci/controller/dwc/pcie-qcom.c b/drivers/pci/controller/dwc/pcie-qcom.c > index d2373e4d141c..3bfaad052736 100644 > --- a/drivers/pci/controller/dwc/pcie-qcom.c > +++ b/drivers/pci/controller/dwc/pcie-qcom.c > @@ -1117,7 +1117,6 @@ static int qcom_pcie_host_init(struct pcie_port *pp) > struct qcom_pcie *pcie = to_qcom_pcie(pci); > int ret; > > - pm_runtime_get_sync(pci->dev); > qcom_ep_reset_assert(pcie); > > ret = pcie->ops->init(pcie); > @@ -1154,7 +1153,6 @@ static int qcom_pcie_host_init(struct pcie_port *pp) > phy_power_off(pcie->phy); > err_deinit: > pcie->ops->deinit(pcie); > - pm_runtime_put(pci->dev); > > return ret; > } > @@ -1244,6 +1242,12 @@ static int qcom_pcie_probe(struct platform_device *pdev) > return -ENOMEM; > > pm_runtime_enable(dev); > + ret = pm_runtime_get_sync(dev); > + if (ret < 0) { > + pm_runtime_disable(dev); > + return ret; > + } > + > pci->dev = dev; > pci->ops = &dw_pcie_ops; > pp = &pci->pp; > @@ -1253,44 +1257,56 @@ static int qcom_pcie_probe(struct platform_device *pdev) > pcie->ops = of_device_get_match_data(dev); > > pcie->reset = devm_gpiod_get_optional(dev, "perst", GPIOD_OUT_LOW); > - if (IS_ERR(pcie->reset)) > - return PTR_ERR(pcie->reset); > + if (IS_ERR(pcie->reset)) { > + ret = PTR_ERR(pcie->reset); > + goto err_pm_runtime_put; > + } > > res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "parf"); > pcie->parf = devm_ioremap_resource(dev, res); > - if (IS_ERR(pcie->parf)) > - return PTR_ERR(pcie->parf); > + if (IS_ERR(pcie->parf)) { > + ret = PTR_ERR(pcie->parf); > + goto err_pm_runtime_put; > + } > > res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dbi"); > pci->dbi_base = devm_pci_remap_cfg_resource(dev, res); > - if (IS_ERR(pci->dbi_base)) > - return PTR_ERR(pci->dbi_base); > + if (IS_ERR(pci->dbi_base)) { > + ret = PTR_ERR(pci->dbi_base); > + goto err_pm_runtime_put; > + } > > res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "elbi"); > pcie->elbi = devm_ioremap_resource(dev, res); > - if (IS_ERR(pcie->elbi)) > - return PTR_ERR(pcie->elbi); > + if (IS_ERR(pcie->elbi)) { > + ret = PTR_ERR(pcie->elbi); > + goto err_pm_runtime_put; > + } > > pcie->phy = devm_phy_optional_get(dev, "pciephy"); > - if (IS_ERR(pcie->phy)) > - return PTR_ERR(pcie->phy); > + if (IS_ERR(pcie->phy)) { > + ret = PTR_ERR(pcie->phy); > + goto err_pm_runtime_put; > + } > > ret = pcie->ops->get_resources(pcie); > if (ret) > - return ret; > + goto err_pm_runtime_put; > > pp->ops = &qcom_pcie_dw_ops; > > if (IS_ENABLED(CONFIG_PCI_MSI)) { > pp->msi_irq = platform_get_irq_byname(pdev, "msi"); > - if (pp->msi_irq < 0) > - return pp->msi_irq; > + if (pp->msi_irq < 0) { > + ret = pp->msi_irq; > + goto err_pm_runtime_put; > + } > } > > ret = phy_init(pcie->phy); > if (ret) { > pm_runtime_disable(&pdev->dev); > - return ret; > + goto err_pm_runtime_put; > } > > platform_set_drvdata(pdev, pcie); > @@ -1299,10 +1315,16 @@ static int qcom_pcie_probe(struct platform_device *pdev) > if (ret) { > dev_err(dev, "cannot initialize host\n"); > pm_runtime_disable(&pdev->dev); > - return ret; > + goto err_pm_runtime_put; > } > > return 0; > + > +err_pm_runtime_put: > + pm_runtime_put(dev); > + pm_runtime_disable(dev); > + > + return ret; > } > > static const struct of_device_id qcom_pcie_match[] = { > -- > 2.18.0 >