From patchwork Tue Nov 30 17:29:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 12647877 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31D31C433F5 for ; Tue, 30 Nov 2021 17:29:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238554AbhK3Rck (ORCPT ); Tue, 30 Nov 2021 12:32:40 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:36626 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238731AbhK3Rck (ORCPT ); Tue, 30 Nov 2021 12:32:40 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 5DE25B81B13 for ; Tue, 30 Nov 2021 17:29:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 01296C53FCB; Tue, 30 Nov 2021 17:29:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638293359; bh=7dWtS7IabxxufChgE1lrOYtnRbIhcoqfnxK0McNkq24=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ryoKgyMEZmrz/QVZgRZz2ZTXN3b4mOGCxliayJFKvqfd8cJ5VZv6Aeigd+gPRAjNS cAQQo5Sh4+Uvj0fmmROpJp3XCnZrCade2qCMF6BhRh5/28hRcyYzJikLiRXsUynyQ6 Lf7q+WfwywBdzF6GWeSn3Dtf3s/t+u7od/WCc3SOcH5AVztM2s5D1rJDBJl5gbtQqn XkQ8H18Gh45MxIGxHyz7iksoSuhuNdk5NsmOmtVWCBn4MrH1pu5Tqr+zpa1JL1zoao vO0Zlc1POEBzOAnBWSTiluRzUXCBgibZ+XZwaeX1gbAVcN0v1mJowG9DcMrpKjfY9t xpFyLTGkIwETA== From: =?utf-8?q?Marek_Beh=C3=BAn?= To: Lorenzo Pieralisi Cc: pali@kernel.org, linux-pci@vger.kernel.org, =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH v4 01/11] PCI: pci-bridge-emul: Add description for class_revision field Date: Tue, 30 Nov 2021 18:29:03 +0100 Message-Id: <20211130172913.9727-2-kabel@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211130172913.9727-1-kabel@kernel.org> References: <20211130172913.9727-1-kabel@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Pali Rohár The current assignment to the class_revision member class_revision |= cpu_to_le32(PCI_CLASS_BRIDGE_PCI << 16); can make the reader think that class is at high 16 bits of the member and revision at low 16 bits. In reality, class is at high 24 bits, but the class for PCI Bridge Normal Decode is PCI_CLASS_BRIDGE_PCI << 8. Change the assignment and add a comment to make this clearer. Signed-off-by: Pali Rohár Signed-off-by: Marek Behún --- drivers/pci/pci-bridge-emul.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/pci/pci-bridge-emul.c b/drivers/pci/pci-bridge-emul.c index db97cddfc85e..a4af1a533d71 100644 --- a/drivers/pci/pci-bridge-emul.c +++ b/drivers/pci/pci-bridge-emul.c @@ -265,7 +265,11 @@ int pci_bridge_emul_init(struct pci_bridge_emul *bridge, { BUILD_BUG_ON(sizeof(bridge->conf) != PCI_BRIDGE_CONF_END); - bridge->conf.class_revision |= cpu_to_le32(PCI_CLASS_BRIDGE_PCI << 16); + /* + * class_revision: Class is high 24 bits and revision is low 8 bit of this member, + * while class for PCI Bridge Normal Decode has the 24-bit value: PCI_CLASS_BRIDGE_PCI << 8 + */ + bridge->conf.class_revision |= cpu_to_le32((PCI_CLASS_BRIDGE_PCI << 8) << 8); bridge->conf.header_type = PCI_HEADER_TYPE_BRIDGE; bridge->conf.cache_line_size = 0x10; bridge->conf.status = cpu_to_le16(PCI_STATUS_CAP_LIST); From patchwork Tue Nov 30 17:29:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 12647879 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 345FFC433F5 for ; Tue, 30 Nov 2021 17:29:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238731AbhK3Rcm (ORCPT ); Tue, 30 Nov 2021 12:32:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238691AbhK3Rcm (ORCPT ); Tue, 30 Nov 2021 12:32:42 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24C1EC061574 for ; Tue, 30 Nov 2021 09:29:23 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id DEEF4B81B16 for ; Tue, 30 Nov 2021 17:29:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8709BC53FCF; Tue, 30 Nov 2021 17:29:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638293360; bh=JIaOkragFbq+DbFogoWBStY5o3hFY6NzgpCpzH3ttY4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QD0TFyoHFLzt1FRNBqUnDHx0FPLN/lc5kOQNGZJZ9e34LnSpRFDmf5093LO3GqDlp Uk0KtvSuYoluMohSBdPpSE9nkwSzRiQe11dA2vMPifskQbluZr3J7Cs9HSZylPYYUi UEj8MZL6FNu66avavPNpASvPxikU+nMwfOOB0i5LgxY86kzWUDdnZkixiYSKfFMtJN sl8DKfKk+n4gBHktN9tJzNOWsr8qRzp6m5x6D1aYfyIdYVUlTSywtWTjCv05A7NIKm ZEnnMN0/qw1FJ3kDOaW80o+dj8rf+ZDB8OLm5IM+voaqbVK1aN/5qgI16B36T8JBT/ FziNMInojZKlQ== From: =?utf-8?q?Marek_Beh=C3=BAn?= To: Lorenzo Pieralisi Cc: pali@kernel.org, linux-pci@vger.kernel.org, =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH v4 02/11] PCI: pci-bridge-emul: Add definitions for missing capabilities registers Date: Tue, 30 Nov 2021 18:29:04 +0100 Message-Id: <20211130172913.9727-3-kabel@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211130172913.9727-1-kabel@kernel.org> References: <20211130172913.9727-1-kabel@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Pali Rohár pci-bridge-emul driver already allocates buffer for capabilities up to the PCI_EXP_SLTSTA2 register, but does not define bit access behavior for these registers. Add these missing definitions. Signed-off-by: Pali Rohár Signed-off-by: Marek Behún --- drivers/pci/pci-bridge-emul.c | 43 +++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/drivers/pci/pci-bridge-emul.c b/drivers/pci/pci-bridge-emul.c index a4af1a533d71..0d1177e52a43 100644 --- a/drivers/pci/pci-bridge-emul.c +++ b/drivers/pci/pci-bridge-emul.c @@ -251,6 +251,49 @@ struct pci_bridge_reg_behavior pcie_cap_regs_behavior[PCI_CAP_PCIE_SIZEOF / 4] = .ro = GENMASK(15, 0) | PCI_EXP_RTSTA_PENDING, .w1c = PCI_EXP_RTSTA_PME, }, + + [PCI_EXP_DEVCAP2 / 4] = { + /* + * Device capabilities 2 register has reserved bits [30:27]. + * Also bits [26:24] are reserved for non-upstream ports. + */ + .ro = BIT(31) | GENMASK(23, 0), + }, + + [PCI_EXP_DEVCTL2 / 4] = { + /* + * Device control 2 register is RW. Bit 11 is reserved for + * non-upstream ports. + * + * Device status 2 register is reserved. + */ + .rw = GENMASK(15, 12) | GENMASK(10, 0), + }, + + [PCI_EXP_LNKCAP2 / 4] = { + /* Link capabilities 2 register has reserved bits [30:25] and 0. */ + .ro = BIT(31) | GENMASK(24, 1), + }, + + [PCI_EXP_LNKCTL2 / 4] = { + /* + * Link control 2 register is RW. + * + * Link status 2 register has bits 5, 15 W1C; + * bits 10, 11 reserved and others are RO. + */ + .rw = GENMASK(15, 0), + .w1c = (BIT(15) | BIT(5)) << 16, + .ro = (GENMASK(14, 12) | GENMASK(9, 6) | GENMASK(4, 0)) << 16, + }, + + [PCI_EXP_SLTCAP2 / 4] = { + /* Slot capabilities 2 register is reserved. */ + }, + + [PCI_EXP_SLTCTL2 / 4] = { + /* Both Slot control 2 and Slot status 2 registers are reserved. */ + }, }; /* From patchwork Tue Nov 30 17:29:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 12647881 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 17730C433EF for ; Tue, 30 Nov 2021 17:29:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238751AbhK3Rcn (ORCPT ); Tue, 30 Nov 2021 12:32:43 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:36676 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238691AbhK3Rcn (ORCPT ); Tue, 30 Nov 2021 12:32:43 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 5FFF4B81B10 for ; Tue, 30 Nov 2021 17:29:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1791DC53FD1; Tue, 30 Nov 2021 17:29:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638293362; bh=Zom8OJtYEZV8oJ9yPxDBKMP/73UFTt2PWS5ADcIzuzs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FsmmWVubwgOayIr+3zpVF4ecDCQLAlk8oth/V6CCMC38GFMmCR2suWzx1fVBp4arN FjizH4lg0IX1dFQfqUcGg+gs9t0MrDM5yCLuGJoeyAGX6152CquUXtJfTdIAPo5wFN y/HhbRjxnOZQ10IVfXG/pHgbWU/tJ0bRWu4BuEDyvETzbScLE7gV7degFNnyDLxvpc tMPF+m+24K64rMRlhOdpHqsno6UYG5CqY3U9uVkIW65e4oE/tl9W7NEy0vySTXlHRL iuvJ/59yB8tZFSKw5guvzwCCBAAPldGLAWRJp5I85p6B29FeHbHwgn3FyaKhwJnUKR 8y/jy9vkp1mcw== From: =?utf-8?q?Marek_Beh=C3=BAn?= To: Lorenzo Pieralisi Cc: pali@kernel.org, linux-pci@vger.kernel.org, =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH v4 03/11] PCI: aardvark: Add support for DEVCAP2, DEVCTL2, LNKCAP2 and LNKCTL2 registers on emulated bridge Date: Tue, 30 Nov 2021 18:29:05 +0100 Message-Id: <20211130172913.9727-4-kabel@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211130172913.9727-1-kabel@kernel.org> References: <20211130172913.9727-1-kabel@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Pali Rohár PCI aardvark hardware supports access to DEVCAP2, DEVCTL2, LNKCAP2 and LNKCTL2 configuration registers of PCIe core via PCIE_CORE_PCIEXP_CAP. Export them via emulated software root bridge. Signed-off-by: Pali Rohár Signed-off-by: Marek Behún --- drivers/pci/controller/pci-aardvark.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index c5300d49807a..25af189a1052 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -884,8 +884,13 @@ advk_pci_bridge_emul_pcie_conf_read(struct pci_bridge_emul *bridge, case PCI_CAP_LIST_ID: case PCI_EXP_DEVCAP: case PCI_EXP_DEVCTL: + case PCI_EXP_DEVCAP2: + case PCI_EXP_DEVCTL2: + case PCI_EXP_LNKCAP2: + case PCI_EXP_LNKCTL2: *value = advk_readl(pcie, PCIE_CORE_PCIEXP_CAP + reg); return PCI_BRIDGE_EMUL_HANDLED; + default: return PCI_BRIDGE_EMUL_NOT_HANDLED; } @@ -899,10 +904,6 @@ advk_pci_bridge_emul_pcie_conf_write(struct pci_bridge_emul *bridge, struct advk_pcie *pcie = bridge->data; switch (reg) { - case PCI_EXP_DEVCTL: - advk_writel(pcie, new, PCIE_CORE_PCIEXP_CAP + reg); - break; - case PCI_EXP_LNKCTL: advk_writel(pcie, new, PCIE_CORE_PCIEXP_CAP + reg); if (new & PCI_EXP_LNKCTL_RL) @@ -924,6 +925,12 @@ advk_pci_bridge_emul_pcie_conf_write(struct pci_bridge_emul *bridge, advk_writel(pcie, new, PCIE_ISR0_REG); break; + case PCI_EXP_DEVCTL: + case PCI_EXP_DEVCTL2: + case PCI_EXP_LNKCTL2: + advk_writel(pcie, new, PCIE_CORE_PCIEXP_CAP + reg); + break; + default: break; } From patchwork Tue Nov 30 17:29:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 12647883 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58084C433F5 for ; Tue, 30 Nov 2021 17:29:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238763AbhK3Rcq (ORCPT ); Tue, 30 Nov 2021 12:32:46 -0500 Received: from sin.source.kernel.org ([145.40.73.55]:53130 "EHLO sin.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238691AbhK3Rcq (ORCPT ); Tue, 30 Nov 2021 12:32:46 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 7CDFBCE1AA0 for ; Tue, 30 Nov 2021 17:29:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9B595C53FD3; Tue, 30 Nov 2021 17:29:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638293363; bh=fAeNKFXV7WUm8K8pBxkbvov2vC1OOlzEhU9AbCAwaN4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HWgykWPNdsAMJsBYO+t40g2AYvYHM4K3bqg23zqbrOzsqy4+bjiw0IeMgF/GXMUyo bNLjUbc0gJaKdQnyiBosht0Z8s0p+V7sfSca8YU2XwB4Ai9HXCQPISAIp0I/cW7zl7 /CGvEqREFr2XT2kqOYHcC/KKJPoWD8hNsvbo8FNASVCpfZ8gPsUk2QqHBhWQpuBXgr Bj26OiO2Bsttpo2eku1GxA+pjxk+EKGpNy7Kn4W2rdSQqvbvpBDqgCI/M9DhdGocVN jz+HaTuvEVC93Hwi+hADljwloofH4yqf5aiDL53Ai1mWDZgqOcIusUvAwWN4fdzaGE zLsc+40KoJCMA== From: =?utf-8?q?Marek_Beh=C3=BAn?= To: Lorenzo Pieralisi Cc: pali@kernel.org, linux-pci@vger.kernel.org, =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH v4 04/11] PCI: aardvark: Clear all MSIs at setup Date: Tue, 30 Nov 2021 18:29:06 +0100 Message-Id: <20211130172913.9727-5-kabel@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211130172913.9727-1-kabel@kernel.org> References: <20211130172913.9727-1-kabel@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Pali Rohár We already clear all the other interrupts (ISR0, ISR1, HOST_CTRL_INT). Define a new macro PCIE_MSI_ALL_MASK and do the same clearing for MSIs, to ensure that we don't start receiving spurious interrupts. Use this new mask in advk_pcie_handle_msi(); Signed-off-by: Pali Rohár Signed-off-by: Marek Behún --- drivers/pci/controller/pci-aardvark.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index 25af189a1052..71ce9f02d596 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -116,6 +116,7 @@ #define PCIE_MSI_ADDR_HIGH_REG (CONTROL_BASE_ADDR + 0x54) #define PCIE_MSI_STATUS_REG (CONTROL_BASE_ADDR + 0x58) #define PCIE_MSI_MASK_REG (CONTROL_BASE_ADDR + 0x5C) +#define PCIE_MSI_ALL_MASK GENMASK(31, 0) #define PCIE_MSI_PAYLOAD_REG (CONTROL_BASE_ADDR + 0x9C) #define PCIE_MSI_DATA_MASK GENMASK(15, 0) @@ -571,6 +572,7 @@ static void advk_pcie_setup_hw(struct advk_pcie *pcie) advk_writel(pcie, reg, PCIE_CORE_CTRL2_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); @@ -583,7 +585,7 @@ static void advk_pcie_setup_hw(struct advk_pcie *pcie) advk_writel(pcie, PCIE_ISR1_ALL_MASK, PCIE_ISR1_MASK_REG); /* Unmask all MSIs */ - advk_writel(pcie, 0, PCIE_MSI_MASK_REG); + advk_writel(pcie, ~(u32)PCIE_MSI_ALL_MASK, PCIE_MSI_MASK_REG); /* Enable summary interrupt for GIC SPI source */ reg = PCIE_IRQ_ALL_MASK & (~PCIE_IRQ_ENABLE_INTS_MASK); @@ -1399,7 +1401,7 @@ static void advk_pcie_handle_msi(struct advk_pcie *pcie) msi_mask = advk_readl(pcie, PCIE_MSI_MASK_REG); msi_val = advk_readl(pcie, PCIE_MSI_STATUS_REG); - msi_status = msi_val & ~msi_mask; + msi_status = msi_val & ((~msi_mask) & PCIE_MSI_ALL_MASK); for (msi_idx = 0; msi_idx < MSI_IRQ_NUM; msi_idx++) { if (!(BIT(msi_idx) & msi_status)) From patchwork Tue Nov 30 17:29:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 12647885 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13B2BC433FE for ; Tue, 30 Nov 2021 17:29:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244734AbhK3Rcr (ORCPT ); Tue, 30 Nov 2021 12:32:47 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:36740 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242006AbhK3Rcq (ORCPT ); Tue, 30 Nov 2021 12:32:46 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 8AE53B819D9 for ; Tue, 30 Nov 2021 17:29:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2B26FC53FC1; Tue, 30 Nov 2021 17:29:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638293365; bh=vViYlN52EqJfxR0NJjT0cQXo6zwIpZwfs3rrB0XD+ms=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PGiZf+PFf59bmvnBydViUHRCKH5dLZSurpIfn7M1Ikqyc2igjdikJWoWMsM3n/pR1 fRHYTtyDNWc9DV5w1HwO/CiFWo4WIin6O/URAJ3V1sooFDRNJCwiRZjujYVqIJmPJ3 Y98oUFwIMbh9EokQxFYE9OVySrzz3TiQdJ+Va1qmMEOI8tOmmaUjpzMkOuLDP4S20o W7cWGjtR/gTGCr4aFP0gzi834+vgBhXALE5TY+DNlTgV2nwZ90kQLlBqKFSYv4jyJG XnNmsrb75BY7/tC7SVWfHxdD7xgTy+XDPQBUHbndi7ssZc1EQpHdEqGKP4t0fHi/KT xRBXw4/JaJ+zQ== From: =?utf-8?q?Marek_Beh=C3=BAn?= To: Lorenzo Pieralisi Cc: pali@kernel.org, linux-pci@vger.kernel.org, =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH v4 05/11] PCI: aardvark: Comment actions in driver remove method Date: Tue, 30 Nov 2021 18:29:07 +0100 Message-Id: <20211130172913.9727-6-kabel@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211130172913.9727-1-kabel@kernel.org> References: <20211130172913.9727-1-kabel@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Pali Rohár Add two more comments into the advk_pcie_remove() method. Signed-off-by: Pali Rohár Signed-off-by: Marek Behún --- drivers/pci/controller/pci-aardvark.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index 71ce9f02d596..6348584c33be 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -1697,11 +1697,13 @@ static int advk_pcie_remove(struct platform_device *pdev) struct pci_host_bridge *bridge = pci_host_bridge_from_priv(pcie); int i; + /* 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(); + /* Remove IRQ domains */ advk_pcie_remove_msi_irq_domain(pcie); advk_pcie_remove_irq_domain(pcie); From patchwork Tue Nov 30 17:29:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 12647887 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6CE1DC433EF for ; Tue, 30 Nov 2021 17:29:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242987AbhK3Rcu (ORCPT ); Tue, 30 Nov 2021 12:32:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242006AbhK3Rct (ORCPT ); Tue, 30 Nov 2021 12:32:49 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4531AC061574 for ; Tue, 30 Nov 2021 09:29:30 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 90E65CE1A93 for ; Tue, 30 Nov 2021 17:29:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AEF35C53FCF; Tue, 30 Nov 2021 17:29:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638293366; bh=QKgxp5XP0fXOrZg15UE5s0Lac1xd4BuKA0mGlYPKvX4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VTsF6tQ/zt82rb//SHOjk5ZWHFCSG0i7bf71TQSnrE1pMq+UIxkg1TOSCVWdlxyX4 sNU9+xOGjxxSPFsDh5ByTSuGYTLC4VEPVyp3wA9f9yRwftFqS+YIj1ocwmaEny/Ho3 z/xDIxNk7/g5PyfGwliCkM2Ppvp4ldYJvUJsKSzfS5VSbp+fGH4SOAkF6td4eIj1Ip gWuZEs4plbIh/dkK5ljvo4AArLtVnBX/s2dA0TL6n+A+kBAbAyj5Wz9GLb6XRh0suP JsU+lguFFLG1I47oFEMdXj9cW3SnZYbVouO9EEstlre5qbHb61o1i6b5yj1TxXQDNK BEk1yk4cLM/IA== From: =?utf-8?q?Marek_Beh=C3=BAn?= To: Lorenzo Pieralisi Cc: pali@kernel.org, linux-pci@vger.kernel.org, =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH v4 06/11] PCI: aardvark: Disable bus mastering when unbinding driver Date: Tue, 30 Nov 2021 18:29:08 +0100 Message-Id: <20211130172913.9727-7-kabel@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211130172913.9727-1-kabel@kernel.org> References: <20211130172913.9727-1-kabel@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Pali Rohár Ensure that after driver unbind PCIe cards are not able to forward memory and I/O requests in the upstream direction. Signed-off-by: Pali Rohár Signed-off-by: Marek Behún --- drivers/pci/controller/pci-aardvark.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index 6348584c33be..12eae05f3d10 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -1695,6 +1695,7 @@ 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; int i; /* Remove PCI bus with all devices */ @@ -1703,6 +1704,11 @@ static int advk_pcie_remove(struct platform_device *pdev) 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); + /* Remove IRQ domains */ advk_pcie_remove_msi_irq_domain(pcie); advk_pcie_remove_irq_domain(pcie); From patchwork Tue Nov 30 17:29:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 12647889 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 497FEC433F5 for ; Tue, 30 Nov 2021 17:29:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242006AbhK3Rcu (ORCPT ); Tue, 30 Nov 2021 12:32:50 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:36806 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238691AbhK3Rct (ORCPT ); Tue, 30 Nov 2021 12:32:49 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 9885EB81B18 for ; Tue, 30 Nov 2021 17:29:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3F5DEC53FD0; Tue, 30 Nov 2021 17:29:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638293368; bh=n5HCETooZH/CiDD+dPplikHl8cWiZOySlpjrYkny2NU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YxkU6fKDIL+IGzmwRBhh7KABJeDyGri7qiAZg9BeP4jhyjAn3m8ViGoV+9EieeV9T Rzu9Y7BcGvyBgvXhcxOHXE6ecEFl76KRigaBkdiLadeomDurMl02LRKjlVmUOEfOJ5 kHNHqcJ8S3tSyDEDAXvDcxVMgr4184re7KvWP3GhEKwQBHUCsrP6OkEazCseRRRQsq RaYaT1Iey9BeBlWZ79ZseHSKY681iAU+pPEyUL2EomDJnEku+lx5XWNlu0UNwsOlKY PXuDOLLu8cVM5U3CdNy0exBOoPVb+JS2e4z3s9FnyrvlQsF36/6nr/FMgtTktEc3JB hp2smalYIByng== From: =?utf-8?q?Marek_Beh=C3=BAn?= To: Lorenzo Pieralisi Cc: pali@kernel.org, linux-pci@vger.kernel.org, =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH v4 07/11] PCI: aardvark: Mask all interrupts when unbinding driver Date: Tue, 30 Nov 2021 18:29:09 +0100 Message-Id: <20211130172913.9727-8-kabel@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211130172913.9727-1-kabel@kernel.org> References: <20211130172913.9727-1-kabel@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Pali Rohár Ensure that no interrupt can be triggered after driver unbind. Signed-off-by: Pali Rohár Signed-off-by: Marek Behún --- drivers/pci/controller/pci-aardvark.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index 12eae05f3d10..08b34accfe2f 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -1709,6 +1709,27 @@ static int advk_pcie_remove(struct platform_device *pdev) 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); From patchwork Tue Nov 30 17:29:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 12647893 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7311AC433EF for ; Tue, 30 Nov 2021 17:29:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244817AbhK3Rc7 (ORCPT ); Tue, 30 Nov 2021 12:32:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238833AbhK3Rcv (ORCPT ); Tue, 30 Nov 2021 12:32:51 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5AB0DC061574 for ; Tue, 30 Nov 2021 09:29:32 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 250ADB81B11 for ; Tue, 30 Nov 2021 17:29:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C3CECC56749; Tue, 30 Nov 2021 17:29:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638293369; bh=nanstgKNaG25ZIcyKPqk3VqUVXU/gblk2iUEYKx4BBE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aY7hvnjIu7JOwnTP803QcLyJOBZfXIVp7NQB/vYCJ2qyg4xLlGfpQkUW9Ms2MiR62 iJIueACrkPhw7diUiRwxSEzD2/pmwp34etL/0oAYH+14HCxr83RBQL+Zwc93RyVxlL NoGFBCiIVlgADA3OEU8soM5s6e9chTkaDI2Rveg0aWroF8/GCCTnJ5djQnY6TRQVH6 hi1mO6lfZGrXyshlKqkPtVW9AXBlEVhV2m8R139e2sqaiJP1Fm0WL2YMUtclKMVVwB a3/m3z6RuaaWI67BmJ7rZQh9za1lWLU8HQCkEBymi+aw5XbSre4Ojv6EFD2hs/8brM /MzdR27bmC90w== From: =?utf-8?q?Marek_Beh=C3=BAn?= To: Lorenzo Pieralisi Cc: pali@kernel.org, linux-pci@vger.kernel.org, =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH v4 08/11] PCI: aardvark: Fix memory leak in driver unbind Date: Tue, 30 Nov 2021 18:29:10 +0100 Message-Id: <20211130172913.9727-9-kabel@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211130172913.9727-1-kabel@kernel.org> References: <20211130172913.9727-1-kabel@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Pali Rohár Free config space for emulated root bridge when unbinding driver to fix memory leak. Do it after disabling and masking all interrupts, since aardvark interrupt handler accesses config space of emulated root bridge. Signed-off-by: Pali Rohár Signed-off-by: Marek Behún --- drivers/pci/controller/pci-aardvark.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index 08b34accfe2f..b3d89cb449b6 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -1734,6 +1734,9 @@ static int advk_pcie_remove(struct platform_device *pdev) advk_pcie_remove_msi_irq_domain(pcie); advk_pcie_remove_irq_domain(pcie); + /* Free config space for emulated root bridge */ + pci_bridge_emul_cleanup(&pcie->bridge); + /* Disable outbound address windows mapping */ for (i = 0; i < OB_WIN_COUNT; i++) advk_pcie_disable_ob_win(pcie, i); From patchwork Tue Nov 30 17:29:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 12647897 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8039C433F5 for ; Tue, 30 Nov 2021 17:29:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238833AbhK3RdA (ORCPT ); Tue, 30 Nov 2021 12:33:00 -0500 Received: from sin.source.kernel.org ([145.40.73.55]:53180 "EHLO sin.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244801AbhK3Rcy (ORCPT ); Tue, 30 Nov 2021 12:32:54 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 3526ECE1A94 for ; Tue, 30 Nov 2021 17:29:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 54865C53FD1; Tue, 30 Nov 2021 17:29:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638293371; bh=pBomEVB82SlOMvHxL2Ymcsf/tRo4GB4F5I2CPf1ksvo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NK82sKKO0qh0koHlRWaGjYPaFa/xvt65DpWG6I1Dd73ATBcPTSNilSo+he2VKmqIX o3eyATXQurzmOSSVkJk4Ipx2RSN2vvNNUYvbJRqZE2TjpBCwu6MZrwCCzhuL4minSP nIiviWAvCpRZY/PNNIVBn+CnpDFcNOSVHkAlgvi0t4kTImKHuul12TrTO8qKTyOU5m iLILLVeHihWUK4Z+liXguaTaHal0olcgR2kclxt5QR6M42SVsucoLEGnfKDKTKMCsr psjkCb9tCnpSr87O7c0TFLPLk9krHNArtuE2jhDwTNerM2UDj5d7ikn32o+wSvMZWM TRi5V10j+J86A== From: =?utf-8?q?Marek_Beh=C3=BAn?= To: Lorenzo Pieralisi Cc: pali@kernel.org, linux-pci@vger.kernel.org, =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH v4 09/11] PCI: aardvark: Assert PERST# when unbinding driver Date: Tue, 30 Nov 2021 18:29:11 +0100 Message-Id: <20211130172913.9727-10-kabel@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211130172913.9727-1-kabel@kernel.org> References: <20211130172913.9727-1-kabel@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Pali Rohár Put the PCIe card into reset by asserting PERST# signal when unbinding driver. It doesn't make sense to leave the card working if it can't communicate with the host. This should also save some power. Signed-off-by: Pali Rohár Signed-off-by: Marek Behún --- drivers/pci/controller/pci-aardvark.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index b3d89cb449b6..271ebecee965 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -1737,6 +1737,10 @@ static int advk_pcie_remove(struct platform_device *pdev) /* Free config space for emulated root bridge */ pci_bridge_emul_cleanup(&pcie->bridge); + /* Assert PERST# signal which prepares PCIe card for power down */ + if (pcie->reset_gpio) + gpiod_set_value_cansleep(pcie->reset_gpio, 1); + /* Disable outbound address windows mapping */ for (i = 0; i < OB_WIN_COUNT; i++) advk_pcie_disable_ob_win(pcie, i); From patchwork Tue Nov 30 17:29:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 12647891 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85C03C433FE for ; Tue, 30 Nov 2021 17:29:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238691AbhK3RdA (ORCPT ); Tue, 30 Nov 2021 12:33:00 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:36874 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244797AbhK3Rcy (ORCPT ); Tue, 30 Nov 2021 12:32:54 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 28E93B81A1F for ; Tue, 30 Nov 2021 17:29:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D8867C53FD0; Tue, 30 Nov 2021 17:29:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638293373; bh=DtXCis8UpAm0IwqZ7ib0fmmnItpB6w4HA0kaw+icOw8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EVA1Lo/eCYgxGio4LHVsnV1TADaRzIOZehBr+w3syJabds6+k98xrQdMO2ZTxHLAI NTc+TligZIB/57w1RoR950hGkHabq0gRWhanDYWyEdvdosbIiEIxfIE3wqgOxozwh6 T/Cmr1yuLo8Y/mk6DEVLxptsbkOfw0aK5o+WDzugROq88uhgR/8M+7qyiWSAEJ7yFc wgi4s1KJ2vbkUrSLFBWFySrktWFaiT3/t6KaIoeNqccVhXtqt4Wzv7kV1IQzB41DMU 5e0MSKTVx9tujNgIY9csO+uUENO+U9Ps6+k1DFrMf/2cLJcRvAhB7APBWOLC/qd3K/ +jZwBMPH4DpuQ== From: =?utf-8?q?Marek_Beh=C3=BAn?= To: Lorenzo Pieralisi Cc: pali@kernel.org, linux-pci@vger.kernel.org, =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH v4 10/11] PCI: aardvark: Disable link training when unbinding driver Date: Tue, 30 Nov 2021 18:29:12 +0100 Message-Id: <20211130172913.9727-11-kabel@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211130172913.9727-1-kabel@kernel.org> References: <20211130172913.9727-1-kabel@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Pali Rohár Disable link training circuit in driver unbind sequence. We want to leave link training in the same state as it was before the driver was probed. Signed-off-by: Pali Rohár Signed-off-by: Marek Behún --- drivers/pci/controller/pci-aardvark.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index 271ebecee965..e5c88f1c177b 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -1741,6 +1741,11 @@ static int advk_pcie_remove(struct platform_device *pdev) if (pcie->reset_gpio) gpiod_set_value_cansleep(pcie->reset_gpio, 1); + /* Disable link training */ + val = advk_readl(pcie, PCIE_CORE_CTRL0_REG); + val &= ~LINK_TRAINING_EN; + advk_writel(pcie, val, PCIE_CORE_CTRL0_REG); + /* Disable outbound address windows mapping */ for (i = 0; i < OB_WIN_COUNT; i++) advk_pcie_disable_ob_win(pcie, i); From patchwork Tue Nov 30 17:29:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 12647895 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 401F9C4332F for ; Tue, 30 Nov 2021 17:29:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244793AbhK3RdA (ORCPT ); Tue, 30 Nov 2021 12:33:00 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:36898 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244804AbhK3Rc4 (ORCPT ); Tue, 30 Nov 2021 12:32:56 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id C3960B819D9 for ; Tue, 30 Nov 2021 17:29:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 688E2C53FC7; Tue, 30 Nov 2021 17:29:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638293374; bh=M6tNWO536plERaZIuHbYRn6PBnGBdabqikBGDvoXKgw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Cuuw7SwWcH74zBZftlYHBouIh/D5n84XG4qddd3riI6Yj0gb2ZH3ABGzMlqqnnpA8 E+0pB1dKjRr6bSeKSLvtFzczsuQfXa56Uc7pNnxUPG1uDUgIMfPsauhW3KrhjVEcuy WdgecgEx3FMMYUA1QxgHbtXerfREQUdB940zy/95VvgricGB3tzrOYxAG4vsGFRdel A23jURAiDrtFAWqUwkGJ70QzFKs1KAF/RCow+l2MGybC2luvwcvkKbvJS3kCSu+33S MiTBdmcBggMC5VufjA1jaKKHaPqTglzovPBKJrHfs1mCc06xDKvTz+MIcYpJ06huzL LKddX3hBcx6VQ== From: =?utf-8?q?Marek_Beh=C3=BAn?= To: Lorenzo Pieralisi Cc: pali@kernel.org, linux-pci@vger.kernel.org, =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH v4 11/11] PCI: aardvark: Disable common PHY when unbinding driver Date: Tue, 30 Nov 2021 18:29:13 +0100 Message-Id: <20211130172913.9727-12-kabel@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211130172913.9727-1-kabel@kernel.org> References: <20211130172913.9727-1-kabel@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Pali Rohár Disable the PCIe PHY when unbinding driver. This should save some power. Signed-off-by: Pali Rohár Signed-off-by: Marek Behún --- drivers/pci/controller/pci-aardvark.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index e5c88f1c177b..2a82c4652c28 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -1750,6 +1750,9 @@ static int advk_pcie_remove(struct platform_device *pdev) for (i = 0; i < OB_WIN_COUNT; i++) advk_pcie_disable_ob_win(pcie, i); + /* Disable phy */ + advk_pcie_disable_phy(pcie); + return 0; }