From patchwork Sun Apr 8 13:09:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10328329 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 12F9B6020F for ; Sun, 8 Apr 2018 13:09:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 053FE28E5B for ; Sun, 8 Apr 2018 13:09:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EDB6728E5E; Sun, 8 Apr 2018 13:09:35 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, MAILING_LIST_MULTI, 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 5479028E5D for ; Sun, 8 Apr 2018 13:09:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751458AbeDHNJd (ORCPT ); Sun, 8 Apr 2018 09:09:33 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:40313 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751423AbeDHNJc (ORCPT ); Sun, 8 Apr 2018 09:09:32 -0400 Received: by mail-wr0-f194.google.com with SMTP id n2so5719799wrj.7; Sun, 08 Apr 2018 06:09:31 -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=48ZZH3ucbPuQfqfSTk5eVmHDFbZSvW9jmgDdLi0LDSU=; b=gsp4u0Bp/dF/JwdK5+J5WD9omisDzD6aXEquu887KFzDc45XPAZ6pY6V3rMed+Mkzh w7XlX32uOwufWd8VZ4LAJOU/YyA1jWImwChXQa66MB0SrqmTEywY1Zn7nve3huIFprDo wjEufWMl56rPwVCzs6zIru04bINKVAzLBTvf2A9uRcbHWOAHtXtVUehJqiwM6F5N/Iju V/uwgzDCtwXRPondOB6XxLLJiz2KQhCXBZVjn/gIgJQcOgW6SAWVp/w+7THkmTfAX7VI Ju9b1OsS3ahElSZc9RIcf+pZjEyfHdQAFFvFnLI7aT68VSgsQpV+8wZOgLv1wBLHA3hT 8KRg== 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=48ZZH3ucbPuQfqfSTk5eVmHDFbZSvW9jmgDdLi0LDSU=; b=PSDdDGIJDDZ3hQQpSjm16PwSyJMXyWl8/BsjAYUnNn8v9nIwlD/g6flN5JsZENv0P0 TSRmZ1D5/CAS5nRl3dktsEpaomAFwQMQKunkM4WN2MPp8eQMy8gpduRWLciMmNcIwYQm nq6FBZpPa5Q7PIgUcOxAYHVYRxe2k7qAvUfHTvjj81IwNdmPNMvWSgt5+vaB7tvEmNxy lfH+6lzdmi7oVI03vGCn3WynxBRaEcl79urjk6sZ+fbIDivjq4GlYKcjkf2wTYtIY4wu I8MlNzIeVEMBBx52LHKGB3+CqNMYjvVLtwkSty8YGl+WnvDpK85iURpYH9EI5zsU0gBK Hx7Q== X-Gm-Message-State: AElRT7FsjZzZBpKm13+SQrWZGBdxi/q7OLG+EnorAZ9nbb7V2Ej5Vo1K DcqbcTEIGfxP3uHtpTU0px14U7Do X-Google-Smtp-Source: AIpwx49AUrqPKiAEzOH9yM3EooJZkAzbggS8aHLSJ3LDCPiQu39Aot6sfwU3F4FsLs/Buu7oqdCSTA== X-Received: by 10.223.145.135 with SMTP id 7mr22703173wri.7.1523192970608; Sun, 08 Apr 2018 06:09:30 -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 s21sm9598209wra.66.2018.04.08.06.09.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 Apr 2018 06:09:29 -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 V5] PCI: rcar: Use runtime PM to control controller clock Date: Sun, 8 Apr 2018 15:09:25 +0200 Message-Id: <20180408130925.19088-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 Reviewed-by: Simon Horman Reviewed-by: Geert Uytterhoeven --- 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 V5: - Do not call pci_free_resource_list(&pcie->resources) if rcar_pcie_parse_request_of_pci_ranges() fails, since that functiona calls pci_free_resource_list() already. --- drivers/pci/host/pcie-rcar.c | 38 ++++++++++++-------------------------- 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c index 6ab28f29ac6a..25f68305322c 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); @@ -1174,9 +1161,8 @@ static int rcar_pcie_probe(struct platform_device *pdev) err_pm_disable: pm_runtime_disable(dev); - -err_free_resource_list: pci_free_resource_list(&pcie->resources); + err_free_bridge: pci_free_host_bridge(bridge);