From patchwork Tue Nov 30 13:25: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: 12647301 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 16A74C433FE for ; Tue, 30 Nov 2021 13:25:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232336AbhK3N2x (ORCPT ); Tue, 30 Nov 2021 08:28:53 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:60086 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232446AbhK3N2x (ORCPT ); Tue, 30 Nov 2021 08:28:53 -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 28978B817AF for ; Tue, 30 Nov 2021 13:25:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BDDA5C53FD0; Tue, 30 Nov 2021 13:25:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638278731; bh=7dWtS7IabxxufChgE1lrOYtnRbIhcoqfnxK0McNkq24=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vAV09VvlgCi4BmB785AnVmL78OyNnkcCbv5fASp2yOJfqoo1htW0GjYfe7prBsrNJ ohiLx4XYAuSnggHTXTZWrMJ7lZLNQVQ2g8+7l2MJSi4IXp6gpOaOo5gK3SlQDllur1 DqVL2OCOzEeY+bfny1AXNikSZWfYhnAWbrB0ARa9GzPErGv0nET0GlumofFav9gaHw Oq1t9a+ORF0xfzp8RWxzGc502VAdcCmGHzAMA0JRE8GkOuYJy87YQJXV+atuP/eTJg CrgzX031+kn0qdlKLrAxz3K8a0MA5fTVSTcvpoy5BqQ1h+35F1Dd4oAWluwVu//rg1 1AHLvCbhtL7vw== 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 v3 01/11] PCI: pci-bridge-emul: Add description for class_revision field Date: Tue, 30 Nov 2021 14:25:13 +0100 Message-Id: <20211130132523.28126-2-kabel@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211130132523.28126-1-kabel@kernel.org> References: <20211130132523.28126-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 13:25:14 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: 12647303 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 9D850C433EF for ; Tue, 30 Nov 2021 13:25:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240129AbhK3N2y (ORCPT ); Tue, 30 Nov 2021 08:28:54 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:60104 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232446AbhK3N2y (ORCPT ); Tue, 30 Nov 2021 08:28: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 A3EEBB819DC for ; Tue, 30 Nov 2021 13:25:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 50FC6C53FCD; Tue, 30 Nov 2021 13:25:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638278733; bh=hCMvjw7+86olvLyyB9MzuYiqNGz70CBKEjK+jLFNK8g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K7PWIjlacgyLjGVDrByxL6yNv+akSYUBs4VQ1jqzs8ZX+1SdaiTMxOnJJiatBxeO1 /n+EdaOua3sB3MEKpsyIy2bHPgrsIA3hhmymgtU1jw2vO+0S+zXDTR+QQ96JODUvHj nZF04ieExh1FM+gzQvwkX+8rIVAze+j+O5tuVNRkcXE+t0RlawsKtHRUTWqTplDSbg Z4YhosXdKMs9MwRyuwUwNrCmKapRTK88Md/jGKDWvf3blsQfkfe1D5E+M47wUAgD3E uyEuBMdyWpQO4mRHJ2j/7xU/sl7SL9P4RNbmr3V5QNlbIGXTnuTHwo17Mv9LsqG7gh jmQQ85rP3RTXg== 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 v3 02/11] PCI: pci-bridge-emul: Add definitions for missing capabilities registers Date: Tue, 30 Nov 2021 14:25:14 +0100 Message-Id: <20211130132523.28126-3-kabel@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211130132523.28126-1-kabel@kernel.org> References: <20211130132523.28126-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 --- Changes since v2: - updated definitions of registers PCI_EXP_DEVCAP2 and PCI_EXP_DEVCTL2 --- 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 13:25:15 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: 12647305 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 E4463C433EF for ; Tue, 30 Nov 2021 13:25:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240089AbhK3N25 (ORCPT ); Tue, 30 Nov 2021 08:28:57 -0500 Received: from sin.source.kernel.org ([145.40.73.55]:59346 "EHLO sin.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232446AbhK3N25 (ORCPT ); Tue, 30 Nov 2021 08:28:57 -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 B9FACCE16B4 for ; Tue, 30 Nov 2021 13:25:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D73E9C53FC7; Tue, 30 Nov 2021 13:25:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638278735; bh=Zom8OJtYEZV8oJ9yPxDBKMP/73UFTt2PWS5ADcIzuzs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qmsJCuL016XRklQH6gUTseH83ZOboQLAitvZd5ZM8I+WsCNH5Uhi2MFxe4En47HOP ggbRTMIsh2S5xvsCS1fj2Xt+lcS4BbBNIu0XhwwlTgeFjEfTWeFX9U57o5vXwV7sef KhCBAE5Sm+PYYceJDTDbWV7yIiqjRQSM1f8fd77hCI0CksWNpJIt3nIl3CURmyJl36 uNgYpMhvrg6sqV1skNun1LryxlqUVK44aGs4atvkKIiRYlSg5hZRiZYbSgRVc288l9 YtNyJg6t6D/ynXPQmLF3MuKg+VnmnsA5DvfE+1kxjHxldc3TkBKqSOl016+dL49d9S 1JoQFKqNYdY4Q== 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 v3 03/11] PCI: aardvark: Add support for DEVCAP2, DEVCTL2, LNKCAP2 and LNKCTL2 registers on emulated bridge Date: Tue, 30 Nov 2021 14:25:15 +0100 Message-Id: <20211130132523.28126-4-kabel@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211130132523.28126-1-kabel@kernel.org> References: <20211130132523.28126-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 13:25:16 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: 12647307 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 6414FC433EF for ; Tue, 30 Nov 2021 13:25:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240195AbhK3N27 (ORCPT ); Tue, 30 Nov 2021 08:28:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232446AbhK3N27 (ORCPT ); Tue, 30 Nov 2021 08:28:59 -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 F2856C061574 for ; Tue, 30 Nov 2021 05:25:39 -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 4AF73CE198C for ; Tue, 30 Nov 2021 13:25:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6955DC53FD1; Tue, 30 Nov 2021 13:25:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638278736; bh=fAeNKFXV7WUm8K8pBxkbvov2vC1OOlzEhU9AbCAwaN4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Qj5rKAfmEdHxtUch1dGbepcfIWYxr2EDq2f3Jz8Ldy12zQ++2KDT+Yp2YMAGFGPw4 sSepQwt5dk4PSSDTA6ik7+sj3zgS6mOsPyxjefe+2XEHNaRCKhc1xdHeJ95fM0AoKt gD3/53F0r45r5xNNWzmhzOMgssXQtHPa/8ZKywP9x6UiRUuACDu87cv0+s515e3DtG M8kxRxaP4OMYnEo2LaRpuwOJbJG/F4Qp54ninaBvAaECLmcCPhyAdvbOKtI35Sg7qC 912scYnSne2e7QIoxkcdQpf+zPLHNBlJAh+bvvpl+TMKp0nTI8ZUxdi1e7zFeitNyp RnCJR+8d2l6Tw== 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 v3 04/11] PCI: aardvark: Clear all MSIs at setup Date: Tue, 30 Nov 2021 14:25:16 +0100 Message-Id: <20211130132523.28126-5-kabel@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211130132523.28126-1-kabel@kernel.org> References: <20211130132523.28126-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 13:25:17 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: 12647309 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 99403C433FE for ; Tue, 30 Nov 2021 13:25:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240211AbhK3N3A (ORCPT ); Tue, 30 Nov 2021 08:29:00 -0500 Received: from sin.source.kernel.org ([145.40.73.55]:59364 "EHLO sin.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240175AbhK3N3A (ORCPT ); Tue, 30 Nov 2021 08:29:00 -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 D5D45CE177F for ; Tue, 30 Nov 2021 13:25:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EF7C9C53FD0; Tue, 30 Nov 2021 13:25:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638278738; bh=vViYlN52EqJfxR0NJjT0cQXo6zwIpZwfs3rrB0XD+ms=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PRv3yORkU87iKp90ENAvNcr/xQq5eCV7juCYrqcsh7aXgsX3fKwLWS757Wl13AOzn BLGELGhjEPZd7yMr97e/VVLaJtQbo27v3WxlG8rTL2cSGJZfmxCHDuQ5kyQfe6YrTl cBFkKXGb9qHl1rGwrYWB5w9T27oKBpVQ4Pk1AFDRfL1KjBbelMoWQs2JGPcDWca84q Hb7CriTO+kCwz7DYhWL8k7K+bWZiZN+ZSEVk3CBB9KgvBTFYLmb/y4sZYsnEX+A/Y2 39a4yb4o71fdDiefb4qM5VCbrPttYZL032LFS/Ug1DBvZCU805dxVXLPxLOeJO8Fap 8jeqD+taZzBow== 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 v3 05/11] PCI: aardvark: Comment actions in driver remove method Date: Tue, 30 Nov 2021 14:25:17 +0100 Message-Id: <20211130132523.28126-6-kabel@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211130132523.28126-1-kabel@kernel.org> References: <20211130132523.28126-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 13:25:18 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: 12647311 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 13403C433F5 for ; Tue, 30 Nov 2021 13:25:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240169AbhK3N3B (ORCPT ); Tue, 30 Nov 2021 08:29:01 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:60190 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232446AbhK3N3B (ORCPT ); Tue, 30 Nov 2021 08:29:01 -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 DA23EB817AB for ; Tue, 30 Nov 2021 13:25:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 823BFC53FC1; Tue, 30 Nov 2021 13:25:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638278739; bh=QKgxp5XP0fXOrZg15UE5s0Lac1xd4BuKA0mGlYPKvX4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wi9H68rgolEm3L6hg0YYNPsG6IUSBe3gSN9RaY5QP1XzGlwbDCGkgGAqodzJdztAo GLbWz0OVhFlvxvQxhmsl7ljCi1pvzFZLKVUNTS2RAiEHEM6mH6wWVoETiCLNW/QrvV k5AHfu1kujklAV6co+QmX1b9zXtNh3qzu+OpAe+Z76eKi7vVE0NUdiDoQ9GOkRMCjg yVmqLAqhhGPh4twjISAeh2F295+NdXgQUitJDlFpnOTcjofQEhbOl//ExYOhjyOMKH CZ9pHph959ou8/oJeGvopPdUq1puBzsQAUCj9WrD3DnFg0+bYDUFeAvM3F0sti7igW 00uZ98YB0UzHA== 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 v3 06/11] PCI: aardvark: Disable bus mastering when unbinding driver Date: Tue, 30 Nov 2021 14:25:18 +0100 Message-Id: <20211130132523.28126-7-kabel@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211130132523.28126-1-kabel@kernel.org> References: <20211130132523.28126-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 13:25:19 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: 12647313 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 C2837C433FE for ; Tue, 30 Nov 2021 13:25:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240175AbhK3N3D (ORCPT ); Tue, 30 Nov 2021 08:29:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240202AbhK3N3C (ORCPT ); Tue, 30 Nov 2021 08:29:02 -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 A2971C061574 for ; Tue, 30 Nov 2021 05:25:43 -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 6960CB817AB for ; Tue, 30 Nov 2021 13:25:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 180E8C5674A; Tue, 30 Nov 2021 13:25:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638278741; bh=n5HCETooZH/CiDD+dPplikHl8cWiZOySlpjrYkny2NU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X+ibTXUGWN61LGZK00gA/mJQLELlcY0+zE+R1iMSRHTr53lpDUNZnDdsQdlO9IL1w CJ+HiCnFYORy2R8xPRPDQcKivFYj3Uj06qNk0N3gWd60hq3gMTkhx8FbvRIHX3Zao4 qaqpe8XtiqzcEIrJbMrYnH2FCIo3OL3JGcOLd1lB42NRFJ59qqNsEJ3aqLsauwinaB RyQbeDOIRjOWcsoGnGiSE46oDYpgBRwkORh7UxvF0EZv+J5u13dGn8r5ZZ0oGQQ2iR PeatMHlCz7/mTUT2W7Lprx8EP+X6lxAlApJb3Fryx67M5zOPdbb4xcYVQXkeIZ+1ZR h9FOimovc8aoQ== 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 v3 07/11] PCI: aardvark: Mask all interrupts when unbinding driver Date: Tue, 30 Nov 2021 14:25:19 +0100 Message-Id: <20211130132523.28126-8-kabel@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211130132523.28126-1-kabel@kernel.org> References: <20211130132523.28126-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 13:25:20 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: 12647315 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 6517BC433EF for ; Tue, 30 Nov 2021 13:25:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232446AbhK3N3E (ORCPT ); Tue, 30 Nov 2021 08:29:04 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:60260 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240202AbhK3N3E (ORCPT ); Tue, 30 Nov 2021 08:29:04 -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 0304EB817AF for ; Tue, 30 Nov 2021 13:25:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9EAF9C53FC7; Tue, 30 Nov 2021 13:25:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638278742; bh=nanstgKNaG25ZIcyKPqk3VqUVXU/gblk2iUEYKx4BBE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gzh6oL+8eLueTThxbF7Gz5LATFfq3BivVk2ze53+7xycgrX9sGgccaRDEOZRtx3uf P6gT/qJJUQbu+a8KzVVIi2Cbsz0BVU4HFLwoFnFAY64/UGuNYTZCUWEygifpjEi3RJ BTkwwWiVTLOysV1PjtebtQ7e4qYCWLiQ2LphFcMRkciCwRP8bfyJwxO1GBXEOh7KVj XKZ0rl8YwkkF4uLh8XyHoKmx0YHK3zQClRbcBxShU4FAgIBZKpa+Z3j/tStS5N60nt ihIA5PnEwczhpL+CsDi0s6vC4J8KJG2mdlDJ1/mHzXdrnQrK74ppaqB6hRfBFk49PE QLd9H9SrmVnsA== 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 v3 08/11] PCI: aardvark: Fix memory leak in driver unbind Date: Tue, 30 Nov 2021 14:25:20 +0100 Message-Id: <20211130132523.28126-9-kabel@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211130132523.28126-1-kabel@kernel.org> References: <20211130132523.28126-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 13:25:21 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: 12647317 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 D2A41C433F5 for ; Tue, 30 Nov 2021 13:25:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240202AbhK3N3I (ORCPT ); Tue, 30 Nov 2021 08:29:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240231AbhK3N3H (ORCPT ); Tue, 30 Nov 2021 08:29:07 -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 C19E1C061574 for ; Tue, 30 Nov 2021 05:25:47 -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 18081CE198C for ; Tue, 30 Nov 2021 13:25:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 31444C53FD5; Tue, 30 Nov 2021 13:25:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638278744; bh=TfTi0hXpg38k3rRmwzOE2Jq1Mv1AbNIgyBJe+EvewW4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=INLf11PeIATajohTwFXR8bY4/d7ga+lvCAGfqVDhQbIfv4W0xg6C71vxUyIsMnzhj FlcSqGsErJYXwDCo3Dl5RjtwxQDf3MI6RJK+pPL4NXMK6V9EazFX6RaUthfKL6DZWg UMlxzAmFciry/TL6NrILPMr7CwZ1cK1/c3O3b1TqpMsVD8bDL3D3lQAWFw6mbAMNGF ldg7IUYVtz5mmZupGTpC1s1Yg4lp/nHyTQtaA9u4iyEty0+xt1LG2G2Vx61TOjGJz+ UHzsgPSAcpYjRpRGjchG2oAsbXmd6kq0wGru7GPm6W4QZRmcD6+fKc1k59pE73JCPK pC5HcS0fIi3DA== 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 v3 09/11] PCI: aardvark: Assert PERST# when unbinding driver Date: Tue, 30 Nov 2021 14:25:21 +0100 Message-Id: <20211130132523.28126-10-kabel@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211130132523.28126-1-kabel@kernel.org> References: <20211130132523.28126-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. 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 13:25:22 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: 12647319 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 74A08C433FE for ; Tue, 30 Nov 2021 13:25:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240231AbhK3N3J (ORCPT ); Tue, 30 Nov 2021 08:29:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240235AbhK3N3H (ORCPT ); Tue, 30 Nov 2021 08:29:07 -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 4D7E4C061746 for ; Tue, 30 Nov 2021 05:25:48 -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 16CFDB817AF for ; Tue, 30 Nov 2021 13:25:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B7D26C53FD0; Tue, 30 Nov 2021 13:25:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638278745; bh=dYfzN6X0G22H94LW3KF/P1tqeqWEbRgCPaXPmrfgByY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QGS8qhgYuRoVGeR3Fc73Y3IaBUZbFMfOqECXvYZEr1vcQxciwMlwJ89cLghEGiW9V 4JA9N+jCO34EXhH9SHVz4hp9qsUC17u8qHcFGqybOGZZWUQzT1KJ4WxefNkja1gg9P JKPbJ085FboHRQQJ2BiktdnJlU3H99iX5YyE+vZAJLu8fDFPhrle8rWsyNxX6/sH5D s50miMhMCSezJDRJhAUC8956dv1RRioAu8Rp50SX5xG0yVPd38s5gIQbayI1dnO/uV OjeJNL5bKa+Xhb4EKNw/trshsn6xtLmKkroJW/uwxnxyHIcfwt3Cy2n/CmL8EPndxv GQCIJZML/AC0Q== 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 v3 10/11] PCI: aardvark: Disable link training when unbinding driver Date: Tue, 30 Nov 2021 14:25:22 +0100 Message-Id: <20211130132523.28126-11-kabel@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211130132523.28126-1-kabel@kernel.org> References: <20211130132523.28126-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. 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 13:25:23 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: 12647321 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 CCBA5C433EF for ; Tue, 30 Nov 2021 13:25:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240275AbhK3N3J (ORCPT ); Tue, 30 Nov 2021 08:29:09 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:60318 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240253AbhK3N3I (ORCPT ); Tue, 30 Nov 2021 08:29:08 -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 9EBE3B819D8 for ; Tue, 30 Nov 2021 13:25:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 49E3AC56748; Tue, 30 Nov 2021 13:25:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638278747; bh=OyvDA4KdWu05oEmPO5pM0S8DH5a/aV8ZVB4bn8ffkxU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AF6pyn/nbq2iD260wB/zFAH5nFrmo3z+vHPP5AmJb88fRxSTK4SzhWIRUyxbF6mOn T873Ue9oDMuoNYS9p+SjbqbzThirdSQYFoE3T0TLYSGgw14xUtO3GrC7UYIwlLIu/n j3BBA03CnXr/+4sgGrzYEoGGYyMDeNbcEg1gSv3SkZvCrv6ggrrUpO1feJXz9C40x7 8rFj9gBJ2p6y7OEaVpxQv7oONOh2WeI8HstAO0Wk7QMU9IK+tVIjk5tsp90+9Y0Qra LqIDOKiQWyOLX8zNwvN6MsyoEc8/Ka8uf1aJXYxxHSEJDywyghdW9X5RNh2xfJVvDB jI3HtCAXd8uqw== 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 v3 11/11] PCI: aardvark: Disable common PHY when unbinding driver Date: Tue, 30 Nov 2021 14:25:23 +0100 Message-Id: <20211130132523.28126-12-kabel@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211130132523.28126-1-kabel@kernel.org> References: <20211130132523.28126-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, to save 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; }