From patchwork Thu May 24 14:36:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 919909 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com 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="s5no3r6C"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40sBmF1CSPz9s0w for ; Fri, 25 May 2018 00:37:01 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S970461AbeEXOg6 (ORCPT ); Thu, 24 May 2018 10:36:58 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:43739 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S970451AbeEXOge (ORCPT ); Thu, 24 May 2018 10:36:34 -0400 Received: by mail-wr0-f195.google.com with SMTP id r13-v6so3548909wrj.10; Thu, 24 May 2018 07:36:33 -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:in-reply-to:references; bh=7tEu2mruVZDuG+fmYccKQn1fiYLUOmibFHIEJYk5bwc=; b=s5no3r6CmtKY6DxKx7eUHecaLiqbnEk1q3hhBYwywfdTBGbw0jMpgc72+I6ADtrYj4 eInhHglNpAkQN1kL1PjYjW4DbScNryEyCChk/uhSurnr6zearWhUwzHNbSQL5LicwCfC sMVhvdP4ZWqeZ8RPQDO/JEvCcMCBoShsGfKiEqXzzMBC7aRDSggvpTRN7VOeiwrpsAbl BxNNc35oOJr5l+XDwoXrstoOMJMW5bvjUCYTge9xLVXqTEBsxlKyNwC97X3NH3aGqJV/ UFDJJIduTCHn4TJTOcaI2ZA701U9q8M8EIh8GuR6pGqvosQudfxor8qcdgNelhoRfohu 2EXw== 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:in-reply-to :references; bh=7tEu2mruVZDuG+fmYccKQn1fiYLUOmibFHIEJYk5bwc=; b=hUAGOuIAcGP0P4PYF2KlR+W2/xDRtcw2O6Jxymsh+/gV6jbvuH4FEXlp5JXGuIxSRt /nlCg4glOeluUqLMWgo57nhyg2eYneBfQDUZkqBN+28RWOQaVmUumL43jTW+fvninyLE 9I7oGGLY4dmuWjbZ/VrvZTRHhQHAYyZJ29bZ0B7cW0/wyOOpCFzLICY3RcrH7/VXfeJd meey1yf6jwapL+9OK9S8IovPjaQiEM3/xsgfakUReeELr3FCF84T8DnDti8GxtOXbBIA MC0Ccc0IaQggiKc4Ze0CFCyAQcvdLuWw44c3rbKpzguqKotqmrI2yW35Mhtm9urzbirI YY9w== X-Gm-Message-State: ALKqPwcwJxZza3YVlsw3l+PRE30kDvqv/+PURdesjm036Oz6SCgzaFS4 BrqB5akTth7sDkWaQuev9J9G5mgw X-Google-Smtp-Source: AB8JxZoPZXfjfedd+gRGR0x5TBwyF6wgFpFVjRPcUt3A4NVo+kf0f3nYB/yLkI6VZUlLNVSISLVS7A== X-Received: by 2002:adf:e447:: with SMTP id t7-v6mr2801333wrm.145.1527172592413; Thu, 24 May 2018 07:36:32 -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 x17-v6sm14348276wmd.46.2018.05.24.07.36.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 May 2018 07:36:31 -0700 (PDT) From: Marek Vasut X-Google-Original-From: Marek Vasut To: linux-pci@vger.kernel.org Cc: Marek Vasut , Geert Uytterhoeven , Lorenzo Pieralisi , Phil Edworthy , Simon Horman , Wolfram Sang , linux-renesas-soc@vger.kernel.org Subject: [PATCH v4 1/6] PCI: rcar: Pull bus clock enable/disable from rcar_pcie_get_resources() Date: Thu, 24 May 2018 16:36:19 +0200 Message-Id: <20180524143624.26718-2-marek.vasut+renesas@gmail.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180524143624.26718-1-marek.vasut+renesas@gmail.com> References: <20180524143624.26718-1-marek.vasut+renesas@gmail.com> 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: Lorenzo Pieralisi Cc: Phil Edworthy Cc: Simon Horman Cc: Wolfram Sang Cc: linux-renesas-soc@vger.kernel.org Acked-by: Simon Horman --- V2: No change V3: No change V4: Rebase on top of Lorenzo's pci/rcar, fix up the rebase breakage induced by patches therein --- 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); From patchwork Thu May 24 14:36:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 919908 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com 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="TexUs9jL"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40sBmC2HK4z9s08 for ; Fri, 25 May 2018 00:36:59 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S970459AbeEXOg5 (ORCPT ); Thu, 24 May 2018 10:36:57 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:37952 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S970452AbeEXOgf (ORCPT ); Thu, 24 May 2018 10:36:35 -0400 Received: by mail-wr0-f195.google.com with SMTP id 94-v6so3568078wrf.5; Thu, 24 May 2018 07:36:34 -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:in-reply-to:references; bh=CsX2fXjIhW6AdP9tP4h0fWxpYZzaJ2XIwIMcRJ45/90=; b=TexUs9jLzKbI4eUNu5OLBz6KaA6OWXzhp0zE8qDj2R2q86BZi2TyY6F3mWKi/j4q4t 53raP7h3khxbCqpRH/UNE+k8UeVJi6mfczUcMvJP78L65Bw7GdIc1OeDPKDNU3GYk2Pz CDgGG/PToLsZvXQqSvFhiruxS3Hz2fX6YzXyl6l5freBYMVclwSdyBXPRTLIDcoYWHSp CcVxIeUSL6DUKRKLT5XEaNtq4oYya1aYsAysfEBk4Q9rbllya9MpxIBgIZ8DEjkuWbmd sf/97tMkDMPq06QgqP2WPvP47oCGLwf0fT6/CyDvP7HYBanLLv6shq/1UTdLsoswUAvx vZ/A== 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:in-reply-to :references; bh=CsX2fXjIhW6AdP9tP4h0fWxpYZzaJ2XIwIMcRJ45/90=; b=Wc8yscakadc9vOwEqUq+cl7rKKgCQgfVIiC+HL+RJ5xDrVhdOcPb+3ZIPUEXtwpPgQ WnOqHYLcYG2Q6yiF8ChRkB4STBVnSdUQTSoROigkROt2ffgh6GhE4AVekyPuL5HG5gtD uAzSoc+xt3DvOM6msERdp2OlBsJw+rcpbtInMmSUaZw+/m5vNPuzM3eG4Sg4DyKd01kC n1TsPkrJhY3cke+ZKSHhHykImlFB4zOL87viv3PkfCCWXRDDbsZhZVVzoNtp3JxqJV06 PD2/aiIVm7zBd2NtjizErZRVYKLLRjZnwzXgMM9ao2uHaUAD69ncpvyTtlviU3ql+Akg qz4g== X-Gm-Message-State: ALKqPweWGBm0N7Byx93benc7EGxZWUINM+FbLbePFqG/EgEvVd0NJ4hj iEmsehpI12IVsic+BQNe3pfgcY/t X-Google-Smtp-Source: AB8JxZqnwvEXTzORN6BF9ogXO90H+caqqunNy+tIXr6AmIwDmroMU5wKCcyeZJNXr+lJ/xgWm4aYvw== X-Received: by 2002:adf:988c:: with SMTP id w12-v6mr6187363wrb.215.1527172593725; Thu, 24 May 2018 07:36:33 -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 x17-v6sm14348276wmd.46.2018.05.24.07.36.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 May 2018 07:36:32 -0700 (PDT) From: Marek Vasut X-Google-Original-From: Marek Vasut To: linux-pci@vger.kernel.org Cc: Marek Vasut , Geert Uytterhoeven , Lorenzo Pieralisi , Phil Edworthy , Simon Horman , Wolfram Sang , linux-renesas-soc@vger.kernel.org Subject: [PATCH v4 2/6] PCI: rcar: Add missing irq_dispose_mapping() into failpath Date: Thu, 24 May 2018 16:36:20 +0200 Message-Id: <20180524143624.26718-3-marek.vasut+renesas@gmail.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180524143624.26718-1-marek.vasut+renesas@gmail.com> References: <20180524143624.26718-1-marek.vasut+renesas@gmail.com> 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 maps MSI IRQs via irq_of_parse_and_map(). In case anything fails afterward, the IRQ mapping must be disposed through irq_dispose_mapping() which is not done. This patch handles irq_of_parse_and_map() failures in by disposing of the mapping in rcar_pcie_get_resources() as well as in probe. 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 Acked-by: Simon Horman --- V2: No change V3: No change V4: Rebase on top of Lorenzo's pci/rcar, fix up the rebase breakage induced by patches therein --- drivers/pci/host/pcie-rcar.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c index 0879880f7975..6bb1cdec26be 100644 --- a/drivers/pci/host/pcie-rcar.c +++ b/drivers/pci/host/pcie-rcar.c @@ -950,18 +950,25 @@ static int rcar_pcie_get_resources(struct rcar_pcie *pcie) i = irq_of_parse_and_map(dev->of_node, 0); if (!i) { dev_err(dev, "cannot get platform resources for msi interrupt\n"); - return -ENOENT; + err = -ENOENT; + goto err_irq1; } 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"); - return -ENOENT; + err = -ENOENT; + goto err_irq2; } pcie->msi.irq2 = i; return 0; + +err_irq2: + irq_dispose_mapping(pcie->msi.irq1); +err_irq1: + return err; } static int rcar_pcie_inbound_ranges(struct rcar_pcie *pcie, @@ -1108,7 +1115,7 @@ static int rcar_pcie_probe(struct platform_device *pdev) err = clk_prepare_enable(pcie->bus_clk); if (err) { dev_err(dev, "failed to enable bus clock: %d\n", err); - goto err_pm_put; + goto err_unmap_msi_irqs; } err = rcar_pcie_parse_map_dma_ranges(pcie, dev->of_node); @@ -1151,6 +1158,10 @@ static int rcar_pcie_probe(struct platform_device *pdev) err_clk_disable: clk_disable_unprepare(pcie->bus_clk); +err_unmap_msi_irqs: + irq_dispose_mapping(pcie->msi.irq2); + irq_dispose_mapping(pcie->msi.irq1); + err_pm_put: pm_runtime_put(dev); From patchwork Thu May 24 14:36:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 919907 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com 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="CGzr/Zy8"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40sBm630J6z9s08 for ; Fri, 25 May 2018 00:36:54 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1033380AbeEXOgw (ORCPT ); Thu, 24 May 2018 10:36:52 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:34980 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1033374AbeEXOgg (ORCPT ); Thu, 24 May 2018 10:36:36 -0400 Received: by mail-wr0-f196.google.com with SMTP id i14-v6so3574305wre.2; Thu, 24 May 2018 07:36:35 -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:in-reply-to:references; bh=fl+pxIjduDuE/7h0+24hskwtNMLsyGxIQjrZ6mTnnIM=; b=CGzr/Zy8fvBDgT+Ff8Bjcf+23NJ83Kv21wRs5n9Pl7GZ9VTY4KNLCtrOp/636p9N8B CBhP7Y+dHEF6mmch/4X4W+7u9vvaQQu02El+ckQ+fWmKJ54aLGUhnHNZwRtS4D5UFW0M 1R6I0KcAsPKBlZnX9lJY8S9LFaJQiiihYqqZ98jWSxs35ylbHwG++NdiOgWUu/6kRQhB VWRSreOnJCZfPGY07PRmkepJ+XH+TLsWKDK4kc/ji+OPatLbEB7Ib+8X7WgdHd/kOCzb ZCQ6aVbysfFxcEEkCAXnU+wN/UW/C9PUc98HrA1dywo/FkIEn8cPMwHNuWxBlbDa9Q5+ dIPw== 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:in-reply-to :references; bh=fl+pxIjduDuE/7h0+24hskwtNMLsyGxIQjrZ6mTnnIM=; b=gBnavmBTEDtRkKoEfyJ+wC+2JLjqsDeSfU/G6R4i/d6hTd0Q+bnwtb5vkn3/d0CyCY Sk4Q32Oh2lyOEzpb70VnoUfVHO5pFk0QyC3qzIZNJH/qmiz7ij1XoqNCqnZXJGZ4iQVA ONHHYB7ZgQslxY/tGG0HRWxPuDlNNJYqihcUdV2NaX5oP2RaIFIlHBOqq2gibmiaqcx7 GUVIKXo6PGd+U/PjQwSn37eyck81xtGodtzfxev7XNxMCk+p5GDF+pFpRXp7s5dCJOQt iYo1sHlgk1DW+K2RKlIPM/Rx659XVag9NKzMSgKY7LBLMHdaNqnjq5qdBEW09GDFg46k Uezw== X-Gm-Message-State: ALKqPwdvSoQlHtsxK6NrXvyeAo3DY3q7GCwAlAhKWCzQUw8tUHvDkNPP uaV+ncSQFHX6dQrzBjZJNbAI9MSq X-Google-Smtp-Source: AB8JxZocequCVy8OM34njyw4R7tOrZavNpvlYCsmY3luN068nHmwJDgnTMhs2cYSaKerJjZijecvDQ== X-Received: by 2002:adf:9724:: with SMTP id r33-v6mr2478279wrb.79.1527172594967; Thu, 24 May 2018 07:36:34 -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 x17-v6sm14348276wmd.46.2018.05.24.07.36.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 May 2018 07:36:34 -0700 (PDT) From: Marek Vasut X-Google-Original-From: Marek Vasut To: linux-pci@vger.kernel.org Cc: Marek Vasut , Geert Uytterhoeven , Lorenzo Pieralisi , Phil Edworthy , Simon Horman , Wolfram Sang , linux-renesas-soc@vger.kernel.org Subject: [PATCH v4 3/6] PCI: rcar: Teardown MSI setup if rcar_pcie_enable() fails Date: Thu, 24 May 2018 16:36:21 +0200 Message-Id: <20180524143624.26718-4-marek.vasut+renesas@gmail.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180524143624.26718-1-marek.vasut+renesas@gmail.com> References: <20180524143624.26718-1-marek.vasut+renesas@gmail.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org If the rcar_pcie_enable() fails and MSIs are enabled, the setup done in rcar_pcie_enable_msi() is never undone. Add a function to tear down the MSI setup by disabling the MSI handling in the PCIe block, deallocating the pages requested for the MSIs and zapping the IRQ mapping. 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 Reviewed-by: Simon Horman --- V2: No change V3: No change V4: Rebase on top of Lorenzo's pci/rcar, fix up the rebase breakage induced by patches therein --- drivers/pci/host/pcie-rcar.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c index 6bb1cdec26be..d6a7e8482dcf 100644 --- a/drivers/pci/host/pcie-rcar.c +++ b/drivers/pci/host/pcie-rcar.c @@ -923,6 +923,28 @@ static int rcar_pcie_enable_msi(struct rcar_pcie *pcie) return err; } +static void rcar_pcie_teardown_msi(struct rcar_pcie *pcie) +{ + struct rcar_msi *msi = &pcie->msi; + int irq, i; + + /* Disable all MSI interrupts */ + rcar_pci_write_reg(pcie, 0, PCIEMSIIER); + + /* Disable address decoding of the MSI interrupt, MSIFE */ + rcar_pci_write_reg(pcie, 0, PCIEMSIALR); + + free_pages(msi->pages, 0); + + for (i = 0; i < INT_PCI_MSI_NR; i++) { + irq = irq_find_mapping(msi->domain, i); + if (irq > 0) + irq_dispose_mapping(irq); + } + + irq_domain_remove(msi->domain); +} + static int rcar_pcie_get_resources(struct rcar_pcie *pcie) { struct device *dev = pcie->dev; @@ -1151,10 +1173,14 @@ static int rcar_pcie_probe(struct platform_device *pdev) err = rcar_pcie_enable(pcie); if (err) - goto err_clk_disable; + goto err_msi_teardown; return 0; +err_msi_teardown: + if (IS_ENABLED(CONFIG_PCI_MSI)) + rcar_pcie_teardown_msi(pcie); + err_clk_disable: clk_disable_unprepare(pcie->bus_clk); From patchwork Thu May 24 14:36:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 919903 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com 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="aoXoNonR"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40sBlw2nhrz9s08 for ; Fri, 25 May 2018 00:36:44 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965695AbeEXOgl (ORCPT ); Thu, 24 May 2018 10:36:41 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:37332 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1033380AbeEXOgh (ORCPT ); Thu, 24 May 2018 10:36:37 -0400 Received: by mail-wr0-f195.google.com with SMTP id i12-v6so3580071wrc.4; Thu, 24 May 2018 07:36:37 -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:in-reply-to:references; bh=3yb5Kj6X3v3zRqVJsSIUDem1QP9z+BCyImgl9SH+bak=; b=aoXoNonREHcPrehsq3LQjHEAK8fSE/foDWJnSeuAvqWi30eG/F/GV/0zI3RgzDH4FK eB+BrQLEmin6xSicJ+5MbERY+Vq8HjQjjK2Y3rFG9ED25nrO1lSnww81U+z3iJGEl7ml OCbQpYau5zoCTFuQwmR9snFfpKjitUGUeiV5QlUE/Z7EKletolGDmRLCYCfjroJWhB33 59rIgc495VE3NqTKfZIuEw15i6kGsNyZZPB9EB32BSMujmVLEc2JbOlTHRjoEtQXs8/M bFjbuutCLrDYdZL97FEaDdnsbt9tayaJvmDyQBJEwJEC469dST5zQg2KiC7kvojqDhGr qcRQ== 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:in-reply-to :references; bh=3yb5Kj6X3v3zRqVJsSIUDem1QP9z+BCyImgl9SH+bak=; b=X9cSxqnDa6OXNhj3zvC8DiYA4cPfJPjG1RiHQGlal34ZF186swDYJ0vLiVfhBFrUBT JmXMTHomUfcygBqIUXIcA6Z+wRCdxhUV+Gyq7M69Iy4iE96V86CY3hNdxgtXh47E65+o CAhcSPcM6CjtB5yY6pLFqBxA38eILd3euIRSuQvfQgJZ8OKYTxt9xv8o0tN6e/vZlBL+ aEUvRvPACEqkFfrUB/sLRji44Csi/WXgTN+gk5IUfaBj0QfSywcEvkOCyCNGSrG68Rj5 vpjlwWBizLcX2HGS1XnqRQNE8+63gjBxSt6w+Uc4INedsrvCWxrncAGOmY9K6A68GzpF nlmw== X-Gm-Message-State: ALKqPwekA4dUepoHn3ROURX6Ipn14Hjy4eIZReaOd8k3NOwCpnRPMiST 4RRrY238e0owtQ7gBzBd4Bl3rHpv X-Google-Smtp-Source: AB8JxZoQF+i01O23ZZlyWkV8zUyMqd9yckzPlishOvp6SlGO5HNOWBdTzqY3QthmfGJ8CpDFBwi+3Q== X-Received: by 2002:adf:9246:: with SMTP id 64-v6mr7491483wrj.90.1527172596174; Thu, 24 May 2018 07:36:36 -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 x17-v6sm14348276wmd.46.2018.05.24.07.36.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 May 2018 07:36:35 -0700 (PDT) From: Marek Vasut X-Google-Original-From: Marek Vasut To: linux-pci@vger.kernel.org Cc: Marek Vasut , Geert Uytterhoeven , Lorenzo Pieralisi , Phil Edworthy , Simon Horman , Wolfram Sang , linux-renesas-soc@vger.kernel.org Subject: [PATCH v4 4/6] PCI: rcar: Poll more often in rcar_pcie_wait_for_dl() Date: Thu, 24 May 2018 16:36:22 +0200 Message-Id: <20180524143624.26718-5-marek.vasut+renesas@gmail.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180524143624.26718-1-marek.vasut+renesas@gmail.com> References: <20180524143624.26718-1-marek.vasut+renesas@gmail.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org The data link active signal usually takes ~20 uSec to be asserted, poll the bit more often to avoid useless delays in this function. Use udelay() instead of usleep() for such a small delay as suggested by the timer documentation and because this will be used in atomic context later on when the suspend/resume patches land. 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 Acked-by: Simon Horman --- V2: s/content/context in commit message V3: Add cpu_relax() V4: Rebase on top of Lorenzo's pci/rcar, fix up the rebase breakage induced by patches therein --- drivers/pci/host/pcie-rcar.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c index d6a7e8482dcf..4843a4dc6059 100644 --- a/drivers/pci/host/pcie-rcar.c +++ b/drivers/pci/host/pcie-rcar.c @@ -546,13 +546,14 @@ static int rcar_pcie_wait_for_phyrdy(struct rcar_pcie *pcie) static int rcar_pcie_wait_for_dl(struct rcar_pcie *pcie) { - unsigned int timeout = 10; + unsigned int timeout = 10000; while (timeout--) { if ((rcar_pci_read_reg(pcie, PCIETSTR) & DATA_LINK_ACTIVE)) return 0; - msleep(5); + udelay(5); + cpu_relax(); } return -ETIMEDOUT; From patchwork Thu May 24 14:36:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 919906 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com 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="IuJ79R1Z"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40sBm32BCvz9s0w for ; Fri, 25 May 2018 00:36:51 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S970449AbeEXOgs (ORCPT ); Thu, 24 May 2018 10:36:48 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:40276 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S970456AbeEXOgj (ORCPT ); Thu, 24 May 2018 10:36:39 -0400 Received: by mail-wm0-f67.google.com with SMTP id j5-v6so5971850wme.5; Thu, 24 May 2018 07:36:38 -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:in-reply-to:references; bh=nLlfJa25mykgEhDdh3ETwBvfY2A8bI5/eBJgdzk633w=; b=IuJ79R1ZxYmrCBH1GIR6WZSpiKvthqVGgB8LN9od4BNrQb/wT7Ksl08+B4PeZ8GhDS 1Lp4EJlfGTLpl+LPyh+sNfY1ogYC+JTJ1QGFyzP2if+kX241zgcwWblpKcVQPFKWZfyt PNpO1hh7/m3QtqxSZRKYffhLfH76HpGGdgeLdgIo1tINi0VIglaSt33j7S+apgM1zUB5 /r9UGf/44isG0a3hRNwJPP5GtFU3BF1rC0mKOP3FJxRJcn8A2nYTeYStmkZYx9UVrHNJ OWYbaVXPI/1jo1QUy15mTlNeS+Yzxof3/5zdrG4D31rEWguT4AmX9J/okwWzSuOZ8zMv EH0A== 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:in-reply-to :references; bh=nLlfJa25mykgEhDdh3ETwBvfY2A8bI5/eBJgdzk633w=; b=YnlwlQ3O/usoi4NsdkKk3LtF6/QcPJUkEMZr38cxKPORxFT1knTaYUDZIbZjJr2oQD 80tC6upHmw1UBu9w0q6Z9mZirmmfjzGEPTdZUw7QFdi6c6AEUjCmw7iS8eXK+55zQK6c WnzE3xSkLX1OVL0YqX/DJDuzElEWfaUIQ7eIJ4+4PArJjjzAEHSE1xRkZxxEVU1MgAnR O0YStJxwBO8NG46aBAD3epYXhjECv9Ot9dcWe40B1fM+wkyBqq37wV7iN6IBVI6yUaCo DdqoWnJxupRFXnQb9PrOJjzqOH/T6LoUIrwwXB0kTE7qON5Nj3DdjBDtuEHZY8tXPfPd 5MaA== X-Gm-Message-State: ALKqPwckKma4g0szTHCQ0HlJ9h7djAXvg6nYYkD06BiZgp/G20urW+pE Webc5v33P/KLIuyQWKPpt93F2Tdj X-Google-Smtp-Source: AB8JxZp+9GuvFBStZspav18uKrmh6inyZFdoyWIUnEbg4bdTViSKrKT65h6kSUf+bu1dH/up60l5vA== X-Received: by 2002:a1c:b245:: with SMTP id b66-v6mr7048541wmf.31.1527172597236; Thu, 24 May 2018 07:36:37 -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 x17-v6sm14348276wmd.46.2018.05.24.07.36.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 May 2018 07:36:36 -0700 (PDT) From: Marek Vasut X-Google-Original-From: Marek Vasut To: linux-pci@vger.kernel.org Cc: Marek Vasut , Geert Uytterhoeven , Lorenzo Pieralisi , Phil Edworthy , Simon Horman , Wolfram Sang , linux-renesas-soc@vger.kernel.org Subject: [PATCH v4 5/6] PCI: rcar: Remove IRQ mappings in rcar_pcie_enable_msi failpath Date: Thu, 24 May 2018 16:36:23 +0200 Message-Id: <20180524143624.26718-6-marek.vasut+renesas@gmail.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180524143624.26718-1-marek.vasut+renesas@gmail.com> References: <20180524143624.26718-1-marek.vasut+renesas@gmail.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org The rcar_pcie_enable_msi() creates IRQ mappings using irq_create_mapping() before requesting the IRQs using devm_request_irq(). If devm_request_irq() fails for some reason, rcar_pcie_enable_msi() does not remove the mapping. Pull out the code for disposing IRQ mappings from rcar_pcie_teardown_msi() into a separate function and call it from both rcar_pcie_teardown_msi() and rcar_pcie_enable_msi() failpath to remove the mappings correctly. Signed-off-by: Marek Vasut Reported-by: Geert Uytterhoeven Cc: Geert Uytterhoeven Cc: Lorenzo Pieralisi Cc: Phil Edworthy Cc: Simon Horman Cc: Wolfram Sang Cc: linux-renesas-soc@vger.kernel.org Acked-by: Simon Horman --- V2: No change V3: No change V4: Rebase on top of Lorenzo's pci/rcar, fix up the rebase breakage induced by patches therein --- drivers/pci/host/pcie-rcar.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c index 4843a4dc6059..636c3c5095d2 100644 --- a/drivers/pci/host/pcie-rcar.c +++ b/drivers/pci/host/pcie-rcar.c @@ -866,6 +866,20 @@ static const struct irq_domain_ops msi_domain_ops = { .map = rcar_msi_map, }; +static void rcar_pcie_unmap_msi(struct rcar_pcie *pcie) +{ + struct rcar_msi *msi = &pcie->msi; + int i, irq; + + for (i = 0; i < INT_PCI_MSI_NR; i++) { + irq = irq_find_mapping(msi->domain, i); + if (irq > 0) + irq_dispose_mapping(irq); + } + + irq_domain_remove(msi->domain); +} + static int rcar_pcie_enable_msi(struct rcar_pcie *pcie) { struct device *dev = pcie->dev; @@ -920,14 +934,13 @@ static int rcar_pcie_enable_msi(struct rcar_pcie *pcie) return 0; err: - irq_domain_remove(msi->domain); + rcar_pcie_unmap_msi(pcie); return err; } static void rcar_pcie_teardown_msi(struct rcar_pcie *pcie) { struct rcar_msi *msi = &pcie->msi; - int irq, i; /* Disable all MSI interrupts */ rcar_pci_write_reg(pcie, 0, PCIEMSIIER); @@ -937,13 +950,7 @@ static void rcar_pcie_teardown_msi(struct rcar_pcie *pcie) free_pages(msi->pages, 0); - for (i = 0; i < INT_PCI_MSI_NR; i++) { - irq = irq_find_mapping(msi->domain, i); - if (irq > 0) - irq_dispose_mapping(irq); - } - - irq_domain_remove(msi->domain); + rcar_pcie_unmap_msi(pcie); } static int rcar_pcie_get_resources(struct rcar_pcie *pcie) From patchwork Thu May 24 14:36:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 919905 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com 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="sNX0rHh1"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40sBm20ZJvz9s1w for ; Fri, 25 May 2018 00:36:50 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S970458AbeEXOgq (ORCPT ); Thu, 24 May 2018 10:36:46 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:42729 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S970449AbeEXOgk (ORCPT ); Thu, 24 May 2018 10:36:40 -0400 Received: by mail-wr0-f195.google.com with SMTP id w10-v6so3563263wrk.9; Thu, 24 May 2018 07:36:39 -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:in-reply-to:references; bh=xGVSewyvnr7SLIDMtVcKqPt5EeRhEfZ6OxhzgQogU/s=; b=sNX0rHh1AfDhuynd5QeH02JdDj262R91/OdcZKp4H7UU7pN7qf4MFaeu+RXtQ+8nHb gysmWmSquei1aRfOj2Pb6DKWAYjonhrrHiBN/321j2ZiZMi9s5WkCEU0Iy7avaZvAifr /COK6xyM8/w0Y22HidgNLdp/Ijd4keKyDlPeG8Ol5/SHwaPcaYuAejGfxNja1PKkHCli aolAcE+Cfo+HzW3wXUXZipq8pfhnTfjBzreToC9KQuevB3P0sgnXp3I4nbFwThFzdMcm BD4DbDiHlLxhFYGB2t6XkYF3E3iVbdzWvQgP6Nj8LbeJ9epGf3D8tAgbJLWuUEggxIDf 0HdA== 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:in-reply-to :references; bh=xGVSewyvnr7SLIDMtVcKqPt5EeRhEfZ6OxhzgQogU/s=; b=Gu4K604n+l0nsj2PJHw1zdoMOGmmyJYYrJ0t2L/0b6VcT01TdLPhw9VJLHTylXiO3u /Yjopf4oobh63+LGQT3QT7VlSQQnr0YWn8iFqXGTG2cuZoZXxjaIuxSsD5tKTC4zoU4y 4z/lkOl6JfuodFmGgrKN6NsFieVX3JN1aWHWR+RYDMhgogvFSvSbydYuBcoOFT8H09Ts j2ppk21sfbspN0DnaMeJZSZ6aOqvxR1Bs9b18D3JLB4qwerzqCsTu6N4HLqu8zGf/udv zbgWMpnd8BjNtie6x/MEuHNa+yhQfdqvklJXKmGCcfZXaV/f2zRs2joL6dk0tKfIZduu 7/eA== X-Gm-Message-State: ALKqPwfW8iveDqXi1/CFF1VO3Pn4YGlyH30o1N29BZMtK0ModhdB/r6b gHHV92yXoRUguZMPYm5Ez5KpweE2 X-Google-Smtp-Source: AB8JxZpFv3mTWsZvJnCwDACRreWn90pD/mvJ5/FrymdsmLwS5DlsWUxo4S1gKIFxp0WZOsjqMLJwvA== X-Received: by 2002:adf:c358:: with SMTP id e24-v6mr2304773wrg.257.1527172598311; Thu, 24 May 2018 07:36:38 -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 x17-v6sm14348276wmd.46.2018.05.24.07.36.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 May 2018 07:36:37 -0700 (PDT) From: Marek Vasut X-Google-Original-From: Marek Vasut To: linux-pci@vger.kernel.org Cc: Marek Vasut , Geert Uytterhoeven , Lorenzo Pieralisi , Phil Edworthy , Simon Horman , Wolfram Sang , linux-renesas-soc@vger.kernel.org Subject: [PATCH v4 6/6] PCI: rcar: Shut the PHY down in failpath Date: Thu, 24 May 2018 16:36:24 +0200 Message-Id: <20180524143624.26718-7-marek.vasut+renesas@gmail.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180524143624.26718-1-marek.vasut+renesas@gmail.com> References: <20180524143624.26718-1-marek.vasut+renesas@gmail.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org If anything fails past phy_init_fn() and the system is a Gen3 with a PHY, the PHY will be left on and inited. This is caused by the phy_init_fn, which is in fact a pointer to rcar_pcie_phy_init_gen3() function, which starts the PHY, yet has no counterpart in the failpath. Add that counterpart. 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 Fixes: 517ca93a7159 ("PCI: rcar: Add R-Car gen3 PHY support") Reviewed-by: Geert Uytterhoeven Acked-by: Simon Horman --- V4: New patch --- drivers/pci/host/pcie-rcar.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c index 636c3c5095d2..695781934f0a 100644 --- a/drivers/pci/host/pcie-rcar.c +++ b/drivers/pci/host/pcie-rcar.c @@ -1163,7 +1163,7 @@ static int rcar_pcie_probe(struct platform_device *pdev) if (rcar_pcie_hw_init(pcie)) { dev_info(dev, "PCIe link down\n"); err = -ENODEV; - goto err_clk_disable; + goto err_phy_shutdown; } data = rcar_pci_read_reg(pcie, MACSR); @@ -1175,7 +1175,7 @@ static int rcar_pcie_probe(struct platform_device *pdev) dev_err(dev, "failed to enable MSI support: %d\n", err); - goto err_clk_disable; + goto err_phy_shutdown; } } @@ -1189,6 +1189,12 @@ static int rcar_pcie_probe(struct platform_device *pdev) if (IS_ENABLED(CONFIG_PCI_MSI)) rcar_pcie_teardown_msi(pcie); +err_phy_shutdown: + if (pcie->phy) { + phy_power_off(pcie->phy); + phy_exit(pcie->phy); + } + err_clk_disable: clk_disable_unprepare(pcie->bus_clk);