From patchwork Wed May 23 10:52: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: 10420921 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 11AE960545 for ; Wed, 23 May 2018 10:52:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 034AC28E52 for ; Wed, 23 May 2018 10:52:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EC0EC28E62; Wed, 23 May 2018 10:52:31 +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 9CD3D28E61 for ; Wed, 23 May 2018 10:52:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754409AbeEWKwa (ORCPT ); Wed, 23 May 2018 06:52:30 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:55306 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754329AbeEWKw3 (ORCPT ); Wed, 23 May 2018 06:52:29 -0400 Received: by mail-wm0-f65.google.com with SMTP id a8-v6so7684281wmg.5; Wed, 23 May 2018 03:52:28 -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=u5RxALr620Hm4bO//wM91cmE7aXRftg8R4syYWo4O2M=; b=X+c943mgpUrkq3B3dXTuJwrQxU63cR9xJvO0WIN/4HMMVD84qxNubp1sEZzg1Tqqwv 1t+vmAIcqXVAgiuIGJCNTY2b7WK0meXoyYxCEkhVnLO/OACL74Vl0BCddf6WcyHIcX2p O1f58Gn3+wKsT/RzyrvCif++0o1tApqAIEClXsHePYA8dbbBWyapn9ctycnvMC0kPnqR NP3OWaH6FtJLYKz7Gp+F7/4SYiH8PUFGVlJNpinKOYEnhJhwi6cH2whD1TzVF6BV2sBm Pq2NzxRLQDrAKIBZvEB4C+G2o2F5+URdn5IZy/saxsZzp+Au6ZHqnvpuhyankpauPv7l sh3A== 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=u5RxALr620Hm4bO//wM91cmE7aXRftg8R4syYWo4O2M=; b=goGfloYbRO6TzRRPT8i6R5sL2sx33rIfBzouGBIgh5v6osPFNsyc3MEY4CNUxv3+b3 J5EYfwou/7OkA1NKPlKiA2xdJLCnW4P31j7SGDTjpvq6ChBusRiu/MR4SONVoUaOxeTQ 37BnQkx04zb2rBo5ewCkxkSXEyUT75u0DktRViqJu2rMC9c7vmlGB4JU++gSOQ0quMKU no5GvoAx3MbOAJZCcxAqhCc/Gz0JdgsN4RHqzZIURVdy0mqe5yBoQxHjYKTG80wK9y0B n+6g+dva7/QLx/JeZZKIWH/qNoa5+IF/g/k48K6RTwoCs0BAdceppi1eTjWDwkCum1i3 R5yw== X-Gm-Message-State: ALKqPwdJ99LEKm3F3wf4J5fpF578B1DYApZt8pitgDLE8YsWsdudFTC6 pzKS1/aV470CPiUrDmz8x8sAf3DI X-Google-Smtp-Source: AB8JxZpBjsE50+mebc++YWB8wZaUVorf9ZwwuYbN8AzuxCh4lMR32CARUDL1oNtfXuvFsEYtKSfClw== X-Received: by 2002:a1c:d212:: with SMTP id j18-v6mr3885453wmg.29.1527072747864; Wed, 23 May 2018 03:52:27 -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 v196-v6sm1874670wmf.36.2018.05.23.03.52.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 May 2018 03:52:27 -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] PCI: rcar: Remove IRQ mappings in rcar_pcie_enable_msi failpath Date: Wed, 23 May 2018 12:52:20 +0200 Message-Id: <20180523105220.25518-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 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: Phil Edworthy Cc: Simon Horman Cc: Wolfram Sang Cc: linux-renesas-soc@vger.kernel.org Reviewed-by: Geert Uytterhoeven Reviewed-by: Simon Horman --- 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 3aa6fe5f2d64..e738d65c22e9 100644 --- a/drivers/pci/host/pcie-rcar.c +++ b/drivers/pci/host/pcie-rcar.c @@ -843,6 +843,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; @@ -897,14 +911,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); @@ -914,13 +927,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)