From patchwork Mon May 21 13:11: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: 917605 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="K8QgZ3++"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40qK1D0wp8z9s16 for ; Mon, 21 May 2018 23:11:44 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751181AbeEUNLl (ORCPT ); Mon, 21 May 2018 09:11:41 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:45017 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751127AbeEUNLl (ORCPT ); Mon, 21 May 2018 09:11:41 -0400 Received: by mail-wr0-f193.google.com with SMTP id y15-v6so15952302wrg.11; Mon, 21 May 2018 06:11: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=1F1DHD5SDDMq8ugqeyfT6RCZ4NOdbmq6p4IbR639f1I=; b=K8QgZ3++PdYMi6RYk7jLBdyyKJa5uKUJLJ/JTCPi1oi9ORdNVsoG8bKRxddFrCDETe MVSbM7GEzWzOqArLVUNPtfugmUYEpq4NXkatUSfE4uGVozmSgSVTg+FjAFK7hjO0FTB2 CsF9BD1qHIb0zhxFTY8m+F+Tr3o6dhC8OghcniL0n6+LS6cl21Z+UpOt0F9uZaR6h1Dn /55uL1k05pGq5Ag3XVNmBp3A8KlzL8DJjF6miOCUZCXag+r9fbZtjDpufgk8791BPdSh kKJ9qh2U5ORGCD6rxp/rvsumJerxsRkLRAk9gXrn2FnBnWBCxRlVu1z/FFKPP1zLXPkV yE4A== 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=1F1DHD5SDDMq8ugqeyfT6RCZ4NOdbmq6p4IbR639f1I=; b=hDYzoIY5BWW/ZoYeasthY7jE67oeygmpRRjZtchUBXs66ggkTUnbYbOSsnBN6MRV6A Z04EGA9o1mGCVCfSkmGskuCCzXQMXCE+Ltyw9o8/EqI6N5OeItO/lVmkq1UGcTleIUWZ v5qohoAv7V5FMs0BCbE7Q2gRXL5RAJ6pHbTrIQsfz/YVRxkvpO8VuTAn7owRqe6ixgYN hQqmgeB5cVpHafm2hi7AObseotfQX5h7nheRxfMSlU87XjcnqWiNSS2qH5s+jVELo2qv j3LGjDU+bDRKqMEC2QP4u7R76/QwVLc3rkPcX4Y92DH5RiIHlk+fzd+KcAiw+0qcwpzH Y+PA== X-Gm-Message-State: ALKqPwcHu3Q6ZzKRgG9dKGX1w6MRb4Fbcqnr1dVQuWTZGcljOBXYbI/i HMJjLu4/cwD0vE1Qt/xCftA/H6oX X-Google-Smtp-Source: AB8JxZqYzSDqwgbNWKE1knkTAy8HFvtsKVzhS/KZh6P/OZ0ikhhrz+Ax6dp80OFRg+PGDulrRhkhAA== X-Received: by 2002:adf:9a54:: with SMTP id z78-v6mr14838356wrb.235.1526908299472; Mon, 21 May 2018 06:11: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 f15-v6sm3077068wrm.52.2018.05.21.06.11.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 May 2018 06:11:38 -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/4] PCI: rcar: Rename rcar_pcie_parse_request_of_pci_ranges() Date: Mon, 21 May 2018 15:11:20 +0200 Message-Id: <20180521131123.2009-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 function name is just too confusing, rename it, no functional change. Rename the function to rcar_pcie_alloc_and_parse_pci_resource_list() as it's matching failpath function is pci_free_resource_list() so the names align much better and the new name also describes what the function does much better. Signed-off-by: Marek Vasut Cc: Geert Uytterhoeven Cc: Phil Edworthy Cc: Simon Horman Cc: Wolfram Sang Cc: linux-renesas-soc@vger.kernel.org Reviewed-by: Simon Horman Reviewed-by: Geert Uytterhoeven --- drivers/pci/host/pcie-rcar.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c index e403c5206b24..dbc80e457f95 100644 --- a/drivers/pci/host/pcie-rcar.c +++ b/drivers/pci/host/pcie-rcar.c @@ -1051,7 +1051,7 @@ static const struct of_device_id rcar_pcie_of_match[] = { {}, }; -static int rcar_pcie_parse_request_of_pci_ranges(struct rcar_pcie *pci) +static int rcar_pcie_alloc_and_parse_pci_resource_list(struct rcar_pcie *pci) { int err; struct device *dev = pci->dev; @@ -1108,7 +1108,7 @@ static int rcar_pcie_probe(struct platform_device *pdev) INIT_LIST_HEAD(&pcie->resources); - err = rcar_pcie_parse_request_of_pci_ranges(pcie); + err = rcar_pcie_alloc_and_parse_pci_resource_list(pcie); if (err) goto err_free_bridge; From patchwork Mon May 21 13:11: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: 917606 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="Vu0y0CcG"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40qK1D6pmKz9s32 for ; Mon, 21 May 2018 23:11:44 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751188AbeEUNLn (ORCPT ); Mon, 21 May 2018 09:11:43 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:46790 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751141AbeEUNLm (ORCPT ); Mon, 21 May 2018 09:11:42 -0400 Received: by mail-wr0-f194.google.com with SMTP id x9-v6so13105351wrl.13; Mon, 21 May 2018 06:11:41 -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=uF4Vip1zj70Dbw983A3zf95jJOpBdfWnk3cSPx0nupI=; b=Vu0y0CcG0AjhqmgeXUfNehD4SAK+6ij1h8e6HVUypepY6PlKFcjJAjPHGEtDOI0kdp Pgf1xW7DgspztrJmNBawsMphTQc2CbyIfPiF3IgdQmULB4FDhL7OOIMrPV6Vbe6OCMm7 aAqjdcwsTIzRomV5dJFG+LRGV8M1w8Jgemou/SiNjztrZSCULELZCa9Bt0HIJ/peo+r7 cjo8RXkb/R6murK2x3jfEIv46+A00oWd6xwGmXIUBt7WgID65RjWpfgX7ifOOEymRxjh 4MdleSd0HS5ebabqV06nC0oXuJK6rVVSBzF1Gj07Ac2l07s2Ipe058079Nm3FW2Sx7wX J/dg== 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=uF4Vip1zj70Dbw983A3zf95jJOpBdfWnk3cSPx0nupI=; b=DvBEig0lWcDP7B+DTZiIaa2VvPcnTMg7gV5jzSlSa3r5Kw4qyVZJOQVtYkyevtH8/m wS6VltbF7V4M1woS0Lu8XQzcbxh2Y/Scy7C14nH81pICzxgRyDCWRog8D5Z3hbPxgFQY OsOKpXRLLhODz4NoiHcs13NRuh6uIYlS2LLZmUvxXNLBub1POZ1hTd4W0b/EphlfmDwD /8qfQBHlcJgYsHrOjuOfdsORphcX0Bi3PFopQTkm7yVroCWLtwqJbx5+ShdFsJPlH3I0 OI/VxtFoFMwOKwoJsGF+TVjXqeDYI4tU48G5twXc8Z1XYZBelYHfJqCKN0fAYmW95XRG MerA== X-Gm-Message-State: ALKqPwdYMBYDGRy7MH0DG6DVKz2+udsSe30Xdp2wHI19R1j27ZX/klFO /U9kK47Qt+utIbge4buofHhhHgmZ X-Google-Smtp-Source: AB8JxZoP5ravf9qw8nz+d+veokHe4+fjXcToLv9594VDtpGqSjOaGXIBng9560y0VODTR5t1ZNIHOw== X-Received: by 2002:adf:df81:: with SMTP id z1-v6mr10094210wrl.49.1526908300482; Mon, 21 May 2018 06:11:40 -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 f15-v6sm3077068wrm.52.2018.05.21.06.11.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 May 2018 06:11:39 -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 2/4] PCI: rcar: Pull bus clock enable/disable from rcar_pcie_get_resources() Date: Mon, 21 May 2018 15:11:21 +0200 Message-Id: <20180521131123.2009-2-marek.vasut+renesas@gmail.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180521131123.2009-1-marek.vasut+renesas@gmail.com> References: <20180521131123.2009-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: Phil Edworthy Cc: Simon Horman Cc: Wolfram Sang Cc: linux-renesas-soc@vger.kernel.org Reviewed-by: Simon Horman Reported-by: Geert Uytterhoeven Reviewed-by: Geert Uytterhoeven --- drivers/pci/host/pcie-rcar.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c index dbc80e457f95..eac4b71d9c60 100644 --- a/drivers/pci/host/pcie-rcar.c +++ b/drivers/pci/host/pcie-rcar.c @@ -919,32 +919,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, @@ -1125,9 +1115,15 @@ 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; /* Failure to get a link might just be that no cards are inserted */ hw_init_fn = of_device_get_match_data(dev); @@ -1135,7 +1131,7 @@ static int rcar_pcie_probe(struct platform_device *pdev) if (err) { dev_info(dev, "PCIe link down\n"); err = -ENODEV; - goto err_pm_put; + goto err_clk_disable; } data = rcar_pci_read_reg(pcie, MACSR); @@ -1147,16 +1143,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 Mon May 21 13:11: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: 917607 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="Vj2zZqpZ"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40qK1G5LZkz9s16 for ; Mon, 21 May 2018 23:11:46 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751719AbeEUNLp (ORCPT ); Mon, 21 May 2018 09:11:45 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:43272 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751127AbeEUNLn (ORCPT ); Mon, 21 May 2018 09:11:43 -0400 Received: by mail-wr0-f194.google.com with SMTP id r13-v6so3613872wrj.10; Mon, 21 May 2018 06:11:42 -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=fsoEk4V+rVSRQd9IT2+luK4FaXxTqdyXPTrcBCRHgfY=; b=Vj2zZqpZ5Jn2OCPW14m1oNOJMJX30xqoRh47aEeOsBeGDedVfo6nsyKSitx3Qthkbe KooV2uj7VvaTlftYP4DXDUU3V9cJHhnSb7EWikif0Mfnw4vj/2tvlKwmJ45tIrYBzR7m SRXtaWlYNI2WrjC2oOpc+GSip30cXtkGq41c2FD5r1CyvgD+WzVVUu/dowz5tuTbBz6o wSiXzg9DIilgF6aBUieauGSSQuUKMiPxKRZ2s4VcL4JVj463a2Qat4+D3q6xMLvh8yJt XMT9GJkgPhI9zXKaKl4OAhTMdRL9PdZTiuQPxUgAPYM0YAO+xdUeA2rrM4aRUerAAZNv eOLQ== 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=fsoEk4V+rVSRQd9IT2+luK4FaXxTqdyXPTrcBCRHgfY=; b=bnDEybDZu9wgpB5V/JqPj1J+POfoXN1WZM7gXKB42JtAxx3Mqtj1cilDfDsrMb/S17 nDfNeQh5P+yb+WwHn34VKRWD7+1zVqTpAt4beCgiOmunuO0BOKrs80J4AzPcg1fxaoMK YDB3RDtC9M7TWNcaOCCuEmQFeOWciQpTa3ya/oTjArBszMHCAYUGVtTOELDEtDyUlqfY w6FAOdpdDg94vItur+yQE0cTq7aal2uAJwbDnDhY469AXTfs20siAx6PAnaWmP4E+Im3 MaLeGYCW3/1nWXCcCXwOmy8Ck37qFCpy/F7HinJIRTNXmid1sSegSxhd/P/YGj3bgHmS 6O9A== X-Gm-Message-State: ALKqPwc0qwsXJCnn+SNbIFIfIjk1tFjOpZMZa9pnlOLGffM82HIJ7eSx GVZ4mprMmiQ6XzOhLWSpMz4KhfYn X-Google-Smtp-Source: AB8JxZrlE3AgvvVTIUmbmXMJOj2k/nje5jrf1zwFjnppWFq+UtMcpHXgSjlPLvYVlE/opjwh/nGqXQ== X-Received: by 2002:adf:904f:: with SMTP id h73-v6mr3839683wrh.188.1526908301540; Mon, 21 May 2018 06:11:41 -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 f15-v6sm3077068wrm.52.2018.05.21.06.11.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 May 2018 06:11:40 -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 3/4] PCI: rcar: Add missing irq_dispose_mapping() into failpath Date: Mon, 21 May 2018 15:11:22 +0200 Message-Id: <20180521131123.2009-3-marek.vasut+renesas@gmail.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180521131123.2009-1-marek.vasut+renesas@gmail.com> References: <20180521131123.2009-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: Phil Edworthy Cc: Simon Horman Cc: Wolfram Sang Cc: linux-renesas-soc@vger.kernel.org Reviewed-by: Simon Horman Reviewed-by: Geert Uytterhoeven --- 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 eac4b71d9c60..3cc84f7e05f7 100644 --- a/drivers/pci/host/pcie-rcar.c +++ b/drivers/pci/host/pcie-rcar.c @@ -923,18 +923,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, @@ -1118,7 +1125,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); @@ -1156,6 +1163,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 Mon May 21 13:11: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: 917608 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="Q4fs0THQ"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40qK1H4R55z9s32 for ; Mon, 21 May 2018 23:11:47 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751115AbeEUNLq (ORCPT ); Mon, 21 May 2018 09:11:46 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:51848 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751574AbeEUNLo (ORCPT ); Mon, 21 May 2018 09:11:44 -0400 Received: by mail-wm0-f67.google.com with SMTP id j4-v6so25335224wme.1; Mon, 21 May 2018 06:11:43 -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=IilIbE7TfHwIYh21avNsLq6GeFPQuMFuPyyfgyKtJaw=; b=Q4fs0THQ1dVL8EEJjgIu3F0s4bwyxyHd0N7JgPytx1fouWbROjIN1SY5n4U6M9o9Ul e50GsFFKmkZbyMuSNLPnnwSeHEPCvI7nDqFJtFRK+amS0dkgFmFLuU5Y56UYgG9LWp3d hCY0yYkTxW/gBNGnUx2F4ItLphMNXfKD7XOvMlpUUPY47ksWWQvhB0EKNVz9hH/GNiPy rN3cUQzZpm3zpepLrVeQzncj/TQ2z268g36IvZZXvSYtC30YN5kGgnYQEREEXaMq2Ze2 OdfUlYmYm+sX5mgjkQbgn32oDgxRXeYeGvxajYVkRyGJfgBqDTR2UmbKy/bTYNdhEBPg uvPQ== 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=IilIbE7TfHwIYh21avNsLq6GeFPQuMFuPyyfgyKtJaw=; b=rA0m0dhC8Rmdy7uAvqcrtAus4U+3aWydRCK+jJFgz6lyU/fQJwjKEZ3sF3276QUsSL 0R6YtqUtP9S/MmSp38QRWrGhpk5TD37TZdIUfOoQghl5gpA3fnyAR/5nkNNWogFDTMYB UJVH5D9+BHpQP6Yq6XzhMV53t7/xFR/mbINtXtVe2IKZ1fjF0NV6FguOol6Ur0v6kfwo zxakBs7KiEknsoS+Rtj2p9lYclto4WdJSW8WQ2JyrFYrFaxTKNW0LvrLIANr2o9sfiDv 4LDfKFOT+73X4z/+Bd+9+NhZaNb4SyIiR/60BNS5OkotSzqO1NXN/G/d95lgkw+LwMNz oe5w== X-Gm-Message-State: ALKqPwctUDaJauTChy2s/PX0OmFmYbRLUgtNCSXvu2p1NBulmxV1CC/x tL+cLVQyBsfL5dVBA4/k90fULtJB X-Google-Smtp-Source: AB8JxZqTndZlmF1bizSdZS71Y+3FOaeEy7KdbjT9ERpkZKNWyGY9wPhSXryYxbyeVQA/QAj3yTOPKw== X-Received: by 2002:a1c:a8c9:: with SMTP id r192-v6mr11593781wme.134.1526908302605; Mon, 21 May 2018 06:11:42 -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 f15-v6sm3077068wrm.52.2018.05.21.06.11.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 May 2018 06:11:42 -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 4/4] PCI: rcar: Teardown MSI setup if rcar_pcie_enable() fails Date: Mon, 21 May 2018 15:11:23 +0200 Message-Id: <20180521131123.2009-4-marek.vasut+renesas@gmail.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180521131123.2009-1-marek.vasut+renesas@gmail.com> References: <20180521131123.2009-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: Phil Edworthy Cc: Simon Horman Cc: Wolfram Sang Cc: linux-renesas-soc@vger.kernel.org Reviewed-by: Simon Horman Reported-by: Geert Uytterhoeven Reviewed-by: Geert Uytterhoeven --- 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 3cc84f7e05f7..5c365f743df5 100644 --- a/drivers/pci/host/pcie-rcar.c +++ b/drivers/pci/host/pcie-rcar.c @@ -900,6 +900,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; @@ -1156,10 +1178,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);