From patchwork Wed Nov 8 09:58:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10048173 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 3376160247 for ; Wed, 8 Nov 2017 09:58:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 19B92292D6 for ; Wed, 8 Nov 2017 09:58:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0E50A2A51E; Wed, 8 Nov 2017 09:58: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=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham 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 65A19292D6 for ; Wed, 8 Nov 2017 09:58:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751839AbdKHJ6c (ORCPT ); Wed, 8 Nov 2017 04:58:32 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:46643 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751829AbdKHJ6b (ORCPT ); Wed, 8 Nov 2017 04:58:31 -0500 Received: by mail-wm0-f67.google.com with SMTP id r68so9199381wmr.1; Wed, 08 Nov 2017 01:58:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=vgJEvVgcixQJN4CIo/9/ufofCxZWqRWkjeB2VWAw8bQ=; b=inT0US+sgkKl3DV5N0TGiScfHjDsIVQC81x0m+TzoOZataFYO1vZ4rzGYmzQYhD4z8 TVkkOZylrtd6wxJOuZvSM9a1JwuzumuBCAhxEnYiNTKjPT9iPB3+hJcoWmilGpMlOkDS XZsLksMN7+/e9PtflZAJhjszNPPghcPIzArIZE+CNHOzAqNX39sXDqL3pHbZMCke+I5w +Th+SZJVkQpUcnR0rJp4dS6dRsDMCzL0rQ07jO84QMXsh9bUgbQKeoaDKvjbLJaRNBJj YuEOGjYeFuAeyIkzYcVEe6Wvbo6J+DfZ/jFlcoTfAqtf2N8nLwGvS3qs6vzDo9suPD7g 9+Ew== 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=vgJEvVgcixQJN4CIo/9/ufofCxZWqRWkjeB2VWAw8bQ=; b=kBGTj54SV/TC4Qw7B0q34wfsLKTWuThxbXxsp6gUKqw44dy0UV9WBl3Kcl12O3rb9H q6pZR+tD1dmpF8nlOmjy7HwlwFce0gKFCuIhjm0YofyOCdRHhT38PR6XDFByRfAIEOOC gD1TfbQuE6fwq84kCshCjfkiAGDPB99aOdo26ATf48ZjHMrOiUVOhNv/VYOKEGSxIOwl PDeuRAk3JS7ux+htNj7vkelCqlkMXoEKFgg3xlHvn9IKzbBnxqXRr+eKedyc5g3URaA2 N4SYcmFoKg2bZjOyl+dG4NKwQLeJSgB8l12JpEnX/Ehs8LU57f4vFiXvWexddWtW+4il cqOg== X-Gm-Message-State: AJaThX6yl5k4XBF0o4i6cXUvnm3vO6TUot4SMjZ9l+FYeJC0PvIpha6p BTdYCoxplBtlKCvx2J1pO/1bMIKR X-Google-Smtp-Source: ABhQp+S9Qa7PAk+l87ualZWgmbwlr+dVRcwuM2BmvbWLIJx1+YPuIOgtM9zg9usCb1cFjoEnp9LStw== X-Received: by 10.28.74.193 with SMTP id n62mr1727435wmi.61.1510135109393; Wed, 08 Nov 2017 01:58:29 -0800 (PST) Received: from kurokawa.lan (ip-86-49-107-50.net.upcbroadband.cz. [86.49.107.50]) by smtp.gmail.com with ESMTPSA id 19sm2772934wmv.41.2017.11.08.01.58.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Nov 2017 01:58:28 -0800 (PST) From: Marek Vasut X-Google-Original-From: Marek Vasut To: linux-pci@vger.kernel.org Cc: Dien Pham , Hien Dang , Marek Vasut , Geert Uytterhoeven , Simon Horman , Wolfram Sang , linux-renesas-soc@vger.kernel.org Subject: [PATCH V2] PCI: rcar: Use runtime PM to control controller clock Date: Wed, 8 Nov 2017 10:58:16 +0100 Message-Id: <20171108095816.14192-1-marek.vasut+renesas@gmail.com> X-Mailer: git-send-email 2.11.0 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: 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() --- drivers/pci/host/pcie-rcar.c | 37 ++++++++++++------------------------- 1 file changed, 12 insertions(+), 25 deletions(-) diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c index 12796eccb2be..1a7254ec16da 100644 --- a/drivers/pci/host/pcie-rcar.c +++ b/drivers/pci/host/pcie-rcar.c @@ -145,7 +145,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; }; @@ -917,24 +916,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) { @@ -956,8 +945,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; } @@ -1125,6 +1112,13 @@ static int rcar_pcie_probe(struct platform_device *pdev) rcar_pcie_parse_request_of_pci_ranges(pcie); + 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); @@ -1135,13 +1129,6 @@ static int rcar_pcie_probe(struct platform_device *pdev) if (err) goto err_free_bridge; - 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; - } - /* Failure to get a link might just be that no cards are inserted */ hw_init_fn = of_device_get_match_data(dev); err = hw_init_fn(pcie); @@ -1173,13 +1160,13 @@ 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_bridge: pci_free_host_bridge(bridge); pci_free_resource_list(&pcie->resources); +err_pm_disable: + pm_runtime_disable(dev); + return err; }