linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rob Herring <robh@kernel.org>
To: Qinglang Miao <miaoqinglang@huawei.com>
Cc: Linus Walleij <linus.walleij@linaro.org>,
	Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
	Bjorn Helgaas <bhelgaas@google.com>,
	PCI <linux-pci@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] PCI: v3: fix missing clk_disable_unprepare() on error in v3_pci_probe
Date: Tue, 3 Nov 2020 08:16:01 -0600	[thread overview]
Message-ID: <CAL_JsqLy5B+4NVX1DXS9yjgEssLSn2d2Qg8n+YQ9E1G_05=i0A@mail.gmail.com> (raw)
In-Reply-To: <20201103073338.144465-1-miaoqinglang@huawei.com>

On Tue, Nov 3, 2020 at 1:28 AM Qinglang Miao <miaoqinglang@huawei.com> wrote:
>
> Fix the missing clk_disable_unprepare() before return
> from v3_pci_probe() in the error handling case.
>
> Moving the clock enable later to avoid some fixes.
>
> Fixes: 6e0832fa432e (" PCI: Collect all native drivers under drivers/pci/controller/")

I don't think this commit caused the problem.

> Suggested-by: Rob Herring <robh@kernel.org>
> Signed-off-by: Qinglang Miao <miaoqinglang@huawei.com>
> ---
>  drivers/pci/controller/pci-v3-semi.c | 40 ++++++++++++++++------------
>  1 file changed, 23 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/pci/controller/pci-v3-semi.c b/drivers/pci/controller/pci-v3-semi.c
> index 154a53986..90520555b 100644
> --- a/drivers/pci/controller/pci-v3-semi.c
> +++ b/drivers/pci/controller/pci-v3-semi.c
> @@ -725,18 +725,6 @@ static int v3_pci_probe(struct platform_device *pdev)
>         host->sysdata = v3;
>         v3->dev = dev;
>
> -       /* Get and enable host clock */
> -       clk = devm_clk_get(dev, NULL);
> -       if (IS_ERR(clk)) {
> -               dev_err(dev, "clock not found\n");
> -               return PTR_ERR(clk);
> -       }
> -       ret = clk_prepare_enable(clk);
> -       if (ret) {
> -               dev_err(dev, "unable to enable clock\n");
> -               return ret;
> -       }
> -
>         regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>         v3->base = devm_ioremap_resource(dev, regs);
>         if (IS_ERR(v3->base))
> @@ -761,17 +749,31 @@ static int v3_pci_probe(struct platform_device *pdev)
>         if (IS_ERR(v3->config_base))
>                 return PTR_ERR(v3->config_base);
>
> +       /* Get and enable host clock */
> +       clk = devm_clk_get(dev, NULL);
> +       if (IS_ERR(clk)) {
> +               dev_err(dev, "clock not found\n");
> +               return PTR_ERR(clk);
> +       }
> +       ret = clk_prepare_enable(clk);
> +       if (ret) {
> +               dev_err(dev, "unable to enable clock\n");
> +               return ret;
> +       }
> +
>         /* Get and request error IRQ resource */
>         irq = platform_get_irq(pdev, 0);
> -       if (irq < 0)
> +       if (irq < 0) {
> +               clk_disable_unprepare(clk);
>                 return irq;
> -
> +       }
>         ret = devm_request_irq(dev, irq, v3_irq, 0,
>                         "PCIv3 error", v3);
>         if (ret < 0) {
>                 dev_err(dev,
>                         "unable to request PCIv3 error IRQ %d (%d)\n",
>                         irq, ret);
> +               clk_disable_unprepare(clk);
>                 return ret;
>         }
>
> @@ -814,13 +816,15 @@ static int v3_pci_probe(struct platform_device *pdev)
>                 ret = v3_pci_setup_resource(v3, host, win);
>                 if (ret) {
>                         dev_err(dev, "error setting up resources\n");
> +                       clk_disable_unprepare(clk);
>                         return ret;
>                 }
>         }
>         ret = v3_pci_parse_map_dma_ranges(v3, np);
> -       if (ret)
> +       if (ret) {
> +               clk_disable_unprepare(clk);
>                 return ret;
> -
> +       }
>         /*
>          * Disable PCI to host IO cycles, enable I/O buffers @3.3V,
>          * set AD_LOW0 to 1 if one of the LB_MAP registers choose
> @@ -862,8 +866,10 @@ static int v3_pci_probe(struct platform_device *pdev)
>         /* Special Integrator initialization */
>         if (of_device_is_compatible(np, "arm,integrator-ap-pci")) {
>                 ret = v3_integrator_init(v3);
> -               if (ret)
> +               if (ret) {
> +                       clk_disable_unprepare(clk);

You should make all these a goto and just have one clk_disable_unprepare() call.

You are still missing error handling after pci_host_probe().

>                         return ret;
> +               }
>         }
>
>         /* Post-init: enable PCI memory and invalidate (master already on) */
> --
> 2.23.0
>

  reply	other threads:[~2020-11-03 14:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-03  7:33 [PATCH v2] PCI: v3: fix missing clk_disable_unprepare() on error in v3_pci_probe Qinglang Miao
2020-11-03 14:16 ` Rob Herring [this message]
2020-11-06  3:08   ` Qinglang Miao
2020-11-06  3:39   ` Qinglang Miao

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='CAL_JsqLy5B+4NVX1DXS9yjgEssLSn2d2Qg8n+YQ9E1G_05=i0A@mail.gmail.com' \
    --to=robh@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=miaoqinglang@huawei.com \
    /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;
as well as URLs for NNTP newsgroup(s).