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);