From patchwork Sun Mar 18 10:52:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10291085 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CF8EF60385 for ; Sun, 18 Mar 2018 10:52:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C0B9128A38 for ; Sun, 18 Mar 2018 10:52:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B544628A63; Sun, 18 Mar 2018 10:52:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 51C9628A48 for ; Sun, 18 Mar 2018 10:52:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753813AbeCRKwm (ORCPT ); Sun, 18 Mar 2018 06:52:42 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:32941 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753775AbeCRKwl (ORCPT ); Sun, 18 Mar 2018 06:52:41 -0400 Received: by mail-wm0-f67.google.com with SMTP id s206so8662618wme.0; Sun, 18 Mar 2018 03:52:40 -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=VNY8i1qch6oGNTb2rT/33XGUNGekZgFIwe+eGXZ53l4=; b=sC1++Ho+faVRoObOvnKtdUWamIf2VpA8Q1/IKJ6qxoIV8/yDxSUKKyhWmBDkLqeF0+ 7fQ+xF7HkUP6KHsnqYL2o7bDYsqJ8fFYUgT+U488LPMdUzKITiCsobGsrn/xrGj9QW4z Wt7mZ0rvJRk2DZcjcOedtUn/gzMhVGpPNAD1blX7vdXk6R49DMqkFvlNtPZE65EntYeT zU0R74x8KEu6/TEYdQ7S+zodL6+HrKO84KcTGdJ4aDPBykQwRoJSyahpFPk1RYC97r5z MC2gg6seUeVN9LUtVsI1zhmrfyZlPvfNNGIGx6Ec4ltY14vkA3goq4YBqmHPqcGrXTOo W3dQ== 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=VNY8i1qch6oGNTb2rT/33XGUNGekZgFIwe+eGXZ53l4=; b=HDYYz06zIaLgVj+7FEqRG9k5xfZF3y2UoADPbSmA8iaRjyZUZbYP+3tsXO2zq8SHX0 01RG4kU8p14D48C8qXXqwSVMTnCs2qVRzwehLoU9k56ZtmKAAOV4SkpI4Crn3kpEVtri XSsibaXXf8kSWtkMx4V2X8VmUT/2meQKEPLMG2tM6jSoyJV2rMeMaDMNH1bQex1J2u9q umNLp8gdXPp8OQGW0Uq2M41QH2tyQjgZ2Ds+k6u21f6Ug64HyEvTLHlI3dtKkq76EKrq CoWuwZ7S2AYIvQXqOC74JZYpWp6sf+fAzCUinaoTxZbTjcs7c8az/ppuOLGJ+ASCZwZA aydw== X-Gm-Message-State: AElRT7HXE1L9j9yHND4pk1ieUhK43ZYN1rsinn0TXo7cqvBD5FaoKD4I jPAplxdvCs/z4zRpSO5V9sQWk6Yx X-Google-Smtp-Source: AG47ELshhVekwfrmeGl9Zm9DDkpQXTPq653GiZpLew2/uz9sxvyLtvGyPZ1L0QI3zMbMoO4dy3k0Yg== X-Received: by 10.28.24.207 with SMTP id 198mr6467878wmy.113.1521370359201; Sun, 18 Mar 2018 03:52:39 -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 p21sm8236959wmc.43.2018.03.18.03.52.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Mar 2018 03:52:38 -0700 (PDT) From: Marek Vasut X-Google-Original-From: Marek Vasut To: linux-pci@vger.kernel.org Cc: Dien Pham , Hien Dang , Marek Vasut , Geert Uytterhoeven , Lorenzo Pieralisi , Phil Edworthy , Simon Horman , Wolfram Sang , linux-renesas-soc@vger.kernel.org Subject: [PATCH V4] PCI: rcar: Use runtime PM to control controller clock Date: Sun, 18 Mar 2018 11:52:09 +0100 Message-Id: <20180318105209.5922-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 X-Virus-Scanned: ClamAV using ClamSMTP From: Dien Pham The controller clock can be switched off during suspend/resume, let runtime PM take care of that. Signed-off-by: Dien Pham Signed-off-by: Hien Dang Signed-off-by: Marek Vasut Cc: Geert Uytterhoeven Cc: Lorenzo Pieralisi Cc: Phil Edworthy Cc: Simon Horman Cc: Wolfram Sang Cc: linux-renesas-soc@vger.kernel.org To: linux-pci@vger.kernel.org --- V2: - Reorder the fail path in rcar_pcie_probe() to cater for the reordering of function calls in probe - Dispose of fail_clk in rcar_pcie_get_resources() V3: - Fix up the failpath in probe function V4: - Rebase on recent linux-next --- drivers/pci/host/pcie-rcar.c | 40 ++++++++++++---------------------------- 1 file changed, 12 insertions(+), 28 deletions(-) diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c index b4c4aad2cf66..93d59f15c589 100644 --- a/drivers/pci/host/pcie-rcar.c +++ b/drivers/pci/host/pcie-rcar.c @@ -142,7 +142,6 @@ struct rcar_pcie { void __iomem *base; struct list_head resources; int root_bus_nr; - struct clk *clk; struct clk *bus_clk; struct rcar_msi msi; }; @@ -914,24 +913,14 @@ static int rcar_pcie_get_resources(struct rcar_pcie *pcie) if (IS_ERR(pcie->base)) return PTR_ERR(pcie->base); - pcie->clk = devm_clk_get(dev, "pcie"); - if (IS_ERR(pcie->clk)) { - dev_err(dev, "cannot get platform clock\n"); - return PTR_ERR(pcie->clk); - } - err = clk_prepare_enable(pcie->clk); - if (err) - return err; - pcie->bus_clk = devm_clk_get(dev, "pcie_bus"); if (IS_ERR(pcie->bus_clk)) { dev_err(dev, "cannot get pcie bus clock\n"); - err = PTR_ERR(pcie->bus_clk); - goto fail_clk; + return PTR_ERR(pcie->bus_clk); } err = clk_prepare_enable(pcie->bus_clk); if (err) - goto fail_clk; + return err; i = irq_of_parse_and_map(dev->of_node, 0); if (!i) { @@ -953,8 +942,6 @@ static int rcar_pcie_get_resources(struct rcar_pcie *pcie) err_map_reg: clk_disable_unprepare(pcie->bus_clk); -fail_clk: - clk_disable_unprepare(pcie->clk); return err; } @@ -1124,22 +1111,22 @@ static int rcar_pcie_probe(struct platform_device *pdev) if (err) goto err_free_bridge; + pm_runtime_enable(pcie->dev); + err = pm_runtime_get_sync(pcie->dev); + if (err < 0) { + dev_err(pcie->dev, "pm_runtime_get_sync failed\n"); + goto err_pm_disable; + } + err = rcar_pcie_get_resources(pcie); if (err < 0) { dev_err(dev, "failed to request resources: %d\n", err); - goto err_free_resource_list; + goto err_pm_put; } err = rcar_pcie_parse_map_dma_ranges(pcie, dev->of_node); if (err) - goto err_free_resource_list; - - pm_runtime_enable(dev); - err = pm_runtime_get_sync(dev); - if (err < 0) { - dev_err(dev, "pm_runtime_get_sync failed\n"); - goto err_pm_disable; - } + goto err_pm_put; /* Failure to get a link might just be that no cards are inserted */ hw_init_fn = of_device_get_match_data(dev); @@ -1171,13 +1158,10 @@ static int rcar_pcie_probe(struct platform_device *pdev) err_pm_put: pm_runtime_put(dev); - err_pm_disable: pm_runtime_disable(dev); - -err_free_resource_list: - pci_free_resource_list(&pcie->resources); err_free_bridge: + pci_free_resource_list(&pcie->resources); pci_free_host_bridge(bridge); return err;