From patchwork Thu May 24 07:23:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 919692 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="cAiC78LT"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40s1880Snbz9rvt for ; Thu, 24 May 2018 17:23:36 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935623AbeEXHXe (ORCPT ); Thu, 24 May 2018 03:23:34 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:45293 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935346AbeEXHXd (ORCPT ); Thu, 24 May 2018 03:23:33 -0400 Received: by mail-wr0-f193.google.com with SMTP id w3-v6so1097764wrl.12; Thu, 24 May 2018 00:23:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=5w2rncQUNsIVomWo4NCjLjYtYLWyjkAUQbw2ovQf6sM=; b=cAiC78LTOx6HLdztpxJB4sUdwvMiNoI/AABLoTBfjQ35Tc9pCvCi1yfHQQcYnT9CBy GpFZpZWHcpO1O8EEnSXE+BHYEW1d6dDLP7vtEX81xN+leg7LhxpMe8orNEnGnupM4W1j QziCxHE2ZhNcsq0q6onWYY4Tnb7L7FshbUQE/uMPelVL/uzaZKeVGm4j5+dUpdhVVcv2 lvyh1aSTy5Y3vax7Y3wUlRMIPdrUg+4eXdW0upuvh2xtwdkNHqPMxf3TRQ+QpXVsv8HF kfZnGhbPgnsEx1Q37I3M7J+vWxWMncqdqRcECmqyscJNmFauZklWJ2titmxjovQ5IhU/ Y/ZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=5w2rncQUNsIVomWo4NCjLjYtYLWyjkAUQbw2ovQf6sM=; b=WyAbcJcFPhQ0f/9i2jTon2L+XL/UekO8sihGEFO1kASn8oIYMZVkVBjVDrAHkwrOf5 Z3E/GXFuaHHedCUvVDWf5rqc6lrqnxcuDxR5+ugj3mqCqcdXnRGSG6S5vfhuyrTzRehE b/i2HufoZucOtIE5aslqW2w1dfWjRrH4LE5g8xR3ah++XsihzHGnjuj+trjHZimSgskW QQInKMtzmM/1sCFc11D1tnRzVmJ6sjN+fIMgG1LIctTshF9ODrSs6toBF1OxCon50L/r KxLPH7FcnWRpPB7j0BFWY1Gs14TkxYKoVl0i/aKoPuT2l8gI/7tGStOzwm/AxRN+UjJ3 Tqcg== X-Gm-Message-State: ALKqPweeUiXaMDx0kpjEytobiQc3TaVQtrfN48t/dvSBZn6NIwK5nU40 5timdtveOCrd4T/cKyWTL3B4x7P1 X-Google-Smtp-Source: AB8JxZrhmX5+ZOquD6xtMjff7iWNsskxMjJgk5lq8pokC/nsBa0mkCEavxtRFvaIJggnnDK9J5PpnA== X-Received: by 2002:adf:99f4:: with SMTP id y107-v6mr3734948wrb.277.1527146611537; Thu, 24 May 2018 00:23:31 -0700 (PDT) Received: from kurokawa.lan (ip-86-49-107-50.net.upcbroadband.cz. [86.49.107.50]) by smtp.gmail.com with ESMTPSA id j13-v6sm10997919wre.38.2018.05.24.00.23.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 May 2018 00:23:30 -0700 (PDT) From: Marek Vasut X-Google-Original-From: Marek Vasut To: linux-pci@vger.kernel.org Cc: Marek Vasut , Geert Uytterhoeven , Phil Edworthy , Simon Horman , Wolfram Sang , linux-renesas-soc@vger.kernel.org Subject: [PATCH 1/6] PCI: rcar: Pull bus clock enable/disable from rcar_pcie_get_resources() Date: Thu, 24 May 2018 09:23:18 +0200 Message-Id: <20180524072323.22115-1-marek.vasut+renesas@gmail.com> X-Mailer: git-send-email 2.16.2 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org The rcar_pcie_get_resources() is another misnomer with a side effect. The function does not only get resources, but also enables/disables bus clock. This is forgotten in the probe() function though and if anything in probe() fails after rcar_pcie_get_resources() is called, the bus clock are never disabled. This patch pulls the clock handling out of the rcar_pcie_get_resources() and enables clock after all the resources were requested. Moreover, this patch also always disables the clock in case of failure. Signed-off-by: Marek Vasut Cc: Geert Uytterhoeven Cc: Phil Edworthy Cc: Simon Horman Cc: Wolfram Sang Cc: linux-renesas-soc@vger.kernel.org --- drivers/pci/host/pcie-rcar.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c index 8d161563bce8..0879880f7975 100644 --- a/drivers/pci/host/pcie-rcar.c +++ b/drivers/pci/host/pcie-rcar.c @@ -946,32 +946,22 @@ static int rcar_pcie_get_resources(struct rcar_pcie *pcie) dev_err(dev, "cannot get pcie bus clock\n"); return PTR_ERR(pcie->bus_clk); } - err = clk_prepare_enable(pcie->bus_clk); - if (err) - return err; i = irq_of_parse_and_map(dev->of_node, 0); if (!i) { dev_err(dev, "cannot get platform resources for msi interrupt\n"); - err = -ENOENT; - goto err_map_reg; + return -ENOENT; } pcie->msi.irq1 = i; i = irq_of_parse_and_map(dev->of_node, 1); if (!i) { dev_err(dev, "cannot get platform resources for msi interrupt\n"); - err = -ENOENT; - goto err_map_reg; + return -ENOENT; } pcie->msi.irq2 = i; return 0; - -err_map_reg: - clk_disable_unprepare(pcie->bus_clk); - - return err; } static int rcar_pcie_inbound_ranges(struct rcar_pcie *pcie, @@ -1115,22 +1105,28 @@ static int rcar_pcie_probe(struct platform_device *pdev) goto err_pm_put; } + err = clk_prepare_enable(pcie->bus_clk); + if (err) { + dev_err(dev, "failed to enable bus clock: %d\n", err); + goto err_pm_put; + } + err = rcar_pcie_parse_map_dma_ranges(pcie, dev->of_node); if (err) - goto err_pm_put; + goto err_clk_disable; phy_init_fn = of_device_get_match_data(dev); err = phy_init_fn(pcie); if (err) { dev_err(dev, "failed to init PCIe PHY\n"); - goto err_pm_put; + goto err_clk_disable; } /* Failure to get a link might just be that no cards are inserted */ if (rcar_pcie_hw_init(pcie)) { dev_info(dev, "PCIe link down\n"); err = -ENODEV; - goto err_pm_put; + goto err_clk_disable; } data = rcar_pci_read_reg(pcie, MACSR); @@ -1142,16 +1138,19 @@ static int rcar_pcie_probe(struct platform_device *pdev) dev_err(dev, "failed to enable MSI support: %d\n", err); - goto err_pm_put; + goto err_clk_disable; } } err = rcar_pcie_enable(pcie); if (err) - goto err_pm_put; + goto err_clk_disable; return 0; +err_clk_disable: + clk_disable_unprepare(pcie->bus_clk); + err_pm_put: pm_runtime_put(dev);