From patchwork Thu May 24 07:23: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: 10422957 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 599B160545 for ; Thu, 24 May 2018 07:23:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 42C5629010 for ; Thu, 24 May 2018 07:23:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3758429014; Thu, 24 May 2018 07:23:42 +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=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 D036129012 for ; Thu, 24 May 2018 07:23:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935646AbeEXHXk (ORCPT ); Thu, 24 May 2018 03:23:40 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:52530 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935346AbeEXHXi (ORCPT ); Thu, 24 May 2018 03:23:38 -0400 Received: by mail-wm0-f67.google.com with SMTP id w194-v6so2153642wmf.2; Thu, 24 May 2018 00:23: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=Q0Wt3E32Gn8ylN4OJO9c39DfjKkmP35lC/R4NVr2WmY=; b=NQNT1EEySWpOWtt2ieC7lgvM/v0p28r442Ze/m2KT0D4xsdGXN7mwtxSW4x4Cll4IZ Z6dkXw/RLPsdm6KALthuh4uYuk8nzlGiUt0oCGlx5h+F38Xr9zxEfU4hzPOWRU7ZoL6M NnXThrqWh2UtIzONrWOgZ4E29NrDl4GmO+J8hVfolTKoZKbjbWUMsfAq+yIKW8L9E06B qzAADYYuz8XoD7JaKQhramA5hOieqkt1p/AYj8jkiRmTBfr5kJ7KFiBqR3V2GAdkjz/r 0cFwsEWz5NTmoYf9QiW6jHjvKepSWCXyupNh3ad4EeMsX7KtxybmFQjXA28wtT8eFGZo Mh1Q== 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=Q0Wt3E32Gn8ylN4OJO9c39DfjKkmP35lC/R4NVr2WmY=; b=N5xChQkHH/K0e+HOH2AeqbYf2oV1Zbx8KKaOz4GdTmR3rB4TrptI5hE10SSsDSl1CG ns+L2TKrHLvSkX/Eli567WSAY69jgHSp3I9VEXNAI9feuNdJqBXwHJiakMKHKFWWfj0a FR7EBQ/bAA05Xa3Ss4QNxKisTe87W4Kxg7DjfcKwL6eUsA/8vuX1qv/hQhzCHg51lCDu +nXWnvVxk/XKN56Ieaw0TvIUIi+OUtWAfzqJe77XQQJRZUYWXPOI9TWGVhDpXAnjeV3B MINxc7zA+VjvHi0J9pBX3MmAakvjMft1eA+XsPHrYG3jcm3KulBJsjy0iDHaTxBxajkK qVwQ== X-Gm-Message-State: ALKqPwfIKgGi6AH+g8U666dj3t90tLdE1ETi6d6o8rB3XzKqRDCjByZs igGqpwApG3DES8VD5Tw20ebcNEQ2 X-Google-Smtp-Source: AB8JxZqU1x3fnxMN6FRKVk9c9ZPn4Efr76sGxbvMpo+s9mEsHY3yH7uXvoISEXoW19zWWkP5X47Ukw== X-Received: by 2002:a1c:b884:: with SMTP id i126-v6mr5835959wmf.30.1527146617125; Thu, 24 May 2018 00:23: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 j13-v6sm10997919wre.38.2018.05.24.00.23.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 May 2018 00:23:36 -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 5/6] PCI: rcar: Remove IRQ mappings in rcar_pcie_enable_msi failpath Date: Thu, 24 May 2018 09:23:22 +0200 Message-Id: <20180524072323.22115-5-marek.vasut+renesas@gmail.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180524072323.22115-1-marek.vasut+renesas@gmail.com> References: <20180524072323.22115-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: Phil Edworthy Cc: Simon Horman Cc: Wolfram Sang Cc: linux-renesas-soc@vger.kernel.org --- 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)