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: 10424919 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 ABFE860327 for ; Thu, 24 May 2018 14:36:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B88D92951B for ; Thu, 24 May 2018 14:36:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AD5E629620; Thu, 24 May 2018 14:36:51 +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 5DF642951B for ; Thu, 24 May 2018 14:36:51 +0000 (UTC) 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 X-Virus-Scanned: ClamAV using ClamSMTP 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)