From patchwork Thu May 6 15:31:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 12242669 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9CF6CC433B4 for ; Thu, 6 May 2021 16:03:44 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 25DD4610E9 for ; Thu, 6 May 2021 16:03:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 25DD4610E9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=VfdFajHBZQZRm/rdGvy3XI1Bj1DZmjQBmSnxiyCkFLc=; b=WwCzmCkhiUNqvWI53q/mwIQP3 4HgTgdK8758HvO81zQ2rbTqm+p2fQ3MonkimKtZEq6nh6sPjHnB+Rq2Q1lXQ5192a/zsDyzyBwEb8 vkseUmZsjzjdESQ7ZbgtQF5X1fZqkxUuIcp49uh8J1qbVk+opsbG4tgW7oC6671q4xteyAKzfStMW zU9OR5cuHyE4zBHXWOQufoaf/r38GCbOIKxA/uEsRGXYJXoZ/sOnRtFsLtTqfx+OdsbagHvUWJhYj Tpeq+RwaEnj6InVCJxboVMcDdEFXbQc8/KQ6M5FtH5wDAPWtKhzQaWG55xuiwXPLYE15JZsNVoQnq dy5hC5vXg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1legFS-004fRS-Gx; Thu, 06 May 2021 15:49:10 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lefzq-004a7h-7Z for linux-arm-kernel@desiato.infradead.org; Thu, 06 May 2021 15:33:02 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Sender:Reply-To:Content-ID:Content-Description; bh=hmxApFxt2mEPrdELGx0l7tBeLA4UXfRPKXuVbw+E29g=; b=xtBDD8egKAdmQcg6gMcLHdo5vr e+pYM1hJm9WBzj8MHJUMbbFB4vlTlLhbhbx7y5fxFCfbGUMhwSLmaGV9d9p1rbt/lObxr6bnFvDnQ suzkwYEQN/ZPizIY3qiTzzjTVHkpwemJW9Aha6UXVnOLaQxd+hOFdgwqVYFN756kU4egB79ZZK+Nk lXe9bv9P6EbxK7XTFoW3xqYe4lGZ6PkFINuJomgOLURj2SG6OJ3piZIhyWwRguvciIuYNoLaynSns OXRdfT+cHUl3jAriT43L0uXYaZG8gk6kerjKUIT0DVBQFHFPXubGMFRelbVDbFdfLamvitCNqtvdv qLudmmYA==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lefzk-0069n8-Md for linux-arm-kernel@lists.infradead.org; Thu, 06 May 2021 15:33:00 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 76E81613C8; Thu, 6 May 2021 15:32:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620315172; bh=/zvV+LVq+BiEj5EQTG+PoYjWSGUTXma5kYGSqhsmE2o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SO4Lkojzvq1tCkR9lzFTQufbRmYayxaQGTdisCbUsxZ0Z3kWr1XkuhWm+fPrHfxHG DX2++QMrlApeHy3cGTI3+Gsmr+CKws/TMblvtyr1bqQSpLFLdMjj9zFSADPqgdZIx0 DA5eQMjWt4tSv73F4F03zuw2HhYHACD1AbZ37q4od1/d+8aTKC9emiwng6Qxbeghda aHACbdDsFgesmZzRt1FxvperRklvPAtnyS5ZSzddI9XYFEZNtYCdiBrxFv/292PLgK MaljOZpHcz2yyQ7rb31uZsxQbgvVBnJCE2tX2Yovxpb/NK2e+er7ylKnkrrAzzAgTN YV5e48uXIdK0Q== Received: by pali.im (Postfix) id 2E51B89A; Thu, 6 May 2021 17:32:52 +0200 (CEST) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: Lorenzo Pieralisi , Thomas Petazzoni , Rob Herring , Bjorn Helgaas Cc: Russell King , =?utf-8?q?Marek_Beh=C3=BAn?= , Remi Pommarel , Xogium , Tomasz Maciej Nowak , Marc Zyngier , linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 27/42] PCI: aardvark: Disable bus mastering and mask all interrupts when unbinding driver Date: Thu, 6 May 2021 17:31:38 +0200 Message-Id: <20210506153153.30454-28-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210506153153.30454-1-pali@kernel.org> References: <20210506153153.30454-1-pali@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210506_083256_829890_2F653AD0 X-CRM114-Status: GOOD ( 11.03 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Ensure that after unbinding aardvark driver, PCIe cards are not be able to forward memory and I/O requests in the upstream direction and also that no interrupt can be triggered. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Fixes: 526a76991b7b ("PCI: aardvark: Implement driver 'remove' function and allow to build it as module") --- drivers/pci/controller/pci-aardvark.c | 29 +++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index 92f93ec48d6b..28ddffce1bec 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -1453,12 +1453,41 @@ static int advk_pcie_remove(struct platform_device *pdev) { struct advk_pcie *pcie = platform_get_drvdata(pdev); struct pci_host_bridge *bridge = pci_host_bridge_from_priv(pcie); + u32 val; + /* Remove PCI bus with all devices */ pci_lock_rescan_remove(); pci_stop_root_bus(bridge->bus); pci_remove_root_bus(bridge->bus); pci_unlock_rescan_remove(); + /* Disable Root Bridge I/O space, memory space and bus mastering */ + val = advk_readl(pcie, PCIE_CORE_CMD_STATUS_REG); + val &= ~(PCI_COMMAND_IO | PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER); + advk_writel(pcie, val, PCIE_CORE_CMD_STATUS_REG); + + /* Disable MSI */ + val = advk_readl(pcie, PCIE_CORE_CTRL2_REG); + val &= ~PCIE_CORE_CTRL2_MSI_ENABLE; + advk_writel(pcie, val, PCIE_CORE_CTRL2_REG); + + /* Clear MSI address */ + advk_writel(pcie, 0, PCIE_MSI_ADDR_LOW_REG); + advk_writel(pcie, 0, PCIE_MSI_ADDR_HIGH_REG); + + /* Mask all interrupts */ + advk_writel(pcie, PCIE_MSI_ALL_MASK, PCIE_MSI_MASK_REG); + advk_writel(pcie, PCIE_ISR0_ALL_MASK, PCIE_ISR0_MASK_REG); + advk_writel(pcie, PCIE_ISR1_ALL_MASK, PCIE_ISR1_MASK_REG); + advk_writel(pcie, PCIE_IRQ_ALL_MASK, HOST_CTRL_INT_MASK_REG); + + /* Clear all interrupts */ + advk_writel(pcie, PCIE_MSI_ALL_MASK, PCIE_MSI_STATUS_REG); + advk_writel(pcie, PCIE_ISR0_ALL_MASK, PCIE_ISR0_REG); + advk_writel(pcie, PCIE_ISR1_ALL_MASK, PCIE_ISR1_REG); + advk_writel(pcie, PCIE_IRQ_ALL_MASK, HOST_CTRL_INT_STATUS_REG); + + /* Remove IRQ domains */ advk_pcie_remove_msi_irq_domain(pcie); advk_pcie_remove_irq_domain(pcie);