From patchwork Thu May 6 15:31:12 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: 12242483 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=-22.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,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 4E90EC433ED for ; Thu, 6 May 2021 15:35:38 +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 A42EA610C8 for ; Thu, 6 May 2021 15:35:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A42EA610C8 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=0+77uKVk/4ULIxWlDboy7IZsVvECtA1brHj6JU0y/zw=; b=DEMv1Wy3sa4okfWt0WdGSPWZi p57fenocMTPOc2Wj7t0Wpr+OihfW+43aYW+3r3tHZeLfi5TAKitOO6bQfWqvU0OGYw9w0RCkFaKbP iBsWrrKP0E31/H88qYdifPm6DhDhEMojCHUVsJ4ppx9ifcb1krWKgrSVB2IOZaWlU3ysOJS3nJmhY MD2H2ZePf/38WO1gEzqAiTYdX5mhBAcKYaeazZ2QROV4c+PNwd1DOM9UYeBep8xMBKRXobX9gCK+o aJgf10Z9FduRTEI0WjvK/UQUFPSTB8RhCEWDjMCIOcD0Uoy9lhhiPQAuySUYl1ZDPF0+DLFxff0no RwoW332Zg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1leg0n-004aPI-Cp; Thu, 06 May 2021 15:34:01 +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 1lefzg-004a2r-L9 for linux-arm-kernel@desiato.infradead.org; Thu, 06 May 2021 15:32:52 +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=+u31kIFm5zZJgYRpI5nPFxm4N80JqTvM466qjbl87Dc=; b=MHxGWv1DaYy094iLR/MJZuYsqc KfPi1i08wmgzdsVBQfeAfQYDsS6B3eoiR9bY0pcVwM8jLCK927+7UItDdlMr18udWI7PclnNpDRT1 7kEqQ7VG+2Il3OHUnEKEcEQP9hNBsfti61C00N5m2dwjs7fxDYlYo8+pR8nGAt6ZfRMaLoaSlfjVt WrbpFl5W5Licep1YfV3zBzF80WCEhkMl/3B/Ag5z45Nlcvh77r4kmn1ReO4lmEGOC+yJ8fP8ye2CR BbJYH+2hc2MkZ/+qNklWOtQiV6FPoS8d4Y70UBW3cgS5PdXz0TBkAWOmtfry3wGbvMAxxYYeB8HfO HZq9j2qA==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lefzb-0069f3-W3 for linux-arm-kernel@lists.infradead.org; Thu, 06 May 2021 15:32:51 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 22EC66101A; Thu, 6 May 2021 15:32:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620315167; bh=s/YJwMrqvoOsPJSEvD5WAEweomBui7Dy2w8ikfwL2rE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jMcfh4hFHod7LXZBOUUtvmvy4wKrI7+Jptr9J5rR2eVvG5FFNHPHSOEEb6liiPu8s ne7QsyByM7KFV6dkVidzC6nn0oLthCWzodUR0UaW0zmSs+bGLH6IUkw4g9Qvr9maQ9 gLYST0fQlC+n9u2zAgGDodvZY4OjNlkaeMpRrsgLHZrlGacTTn2odt2/k4WEAigRow g447gIpekZ5d9Mf5ju7AbcR3h4pLGUkjpAMjRy3j6jDlY10CUqm7EtYRgfx1FKvmcv lL402eKQINe/Rdi2kYIKPgrEi2CdHF5NqIegO7TwoWYoEfNMmAQj8aa4uGrHUo+Y4z bz5q802AXJzWA== Received: by pali.im (Postfix) id 32F3D89A; Thu, 6 May 2021 17:32:44 +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 01/42] PCI: aardvark: Fix kernel panic during PIO transfer Date: Thu, 6 May 2021 17:31:12 +0200 Message-Id: <20210506153153.30454-2-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_083248_152764_95AF65AF X-CRM114-Status: GOOD ( 21.97 ) 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 Trying to start a new PIO transfer by writing value 0 in PIO_START register when previous transfer has not yet completed (which is indicated by value 1 in PIO_START) causes an External Abort on CPU, which results in kernel panic: SError Interrupt on CPU0, code 0xbf000002 -- SError Kernel panic - not syncing: Asynchronous SError Interrupt To prevent kernel panic, it is required to reject a new PIO transfer when previous one has not finished yet. If previous PIO transfer is not finished yet, the kernel may issue a new PIO request only if the previous PIO transfer timed out. In the past the root cause of this issue was incorrectly identified (as it often happens during link retraining or after link down event) and special hack was implemented in Trusted Firmware to catch all SError events in EL3, to ignore errors with code 0xbf000002 and not forwarding any other errors to kernel and instead throw panic from EL3 Trusted Firmware handler. Links to discussion and patches about this issue: https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/commit/?id=3c7dcdac5c50 https://lore.kernel.org/linux-pci/20190316161243.29517-1-repk@triplefau.lt/ https://lore.kernel.org/linux-pci/971be151d24312cc533989a64bd454b4@www.loen.fr/ https://review.trustedfirmware.org/c/TF-A/trusted-firmware-a/+/1541 But the real cause was the fact that during link retraning or after link down event the PIO transfer may take longer time, up to the 1.44s until it times out. This increased probability that a new PIO transfer would be issued by kernel while previous one has not finished yet. After applying this change into the kernel, it is possible to revert the mentioned TF-A hack and SError events do not have to be caught in TF-A EL3. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Cc: stable@vger.kernel.org # 7fbcb5da811b ("PCI: aardvark: Don't rely on jiffies while holding spinlock") --- drivers/pci/controller/pci-aardvark.c | 49 ++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 9 deletions(-) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index 051b48bd7985..e3f5e7ab7606 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -514,7 +514,7 @@ static int advk_pcie_wait_pio(struct advk_pcie *pcie) udelay(PIO_RETRY_DELAY); } - dev_err(dev, "config read/write timed out\n"); + dev_err(dev, "PIO read/write transfer time out\n"); return -ETIMEDOUT; } @@ -657,6 +657,35 @@ static bool advk_pcie_valid_device(struct advk_pcie *pcie, struct pci_bus *bus, return true; } +static bool advk_pcie_pio_is_running(struct advk_pcie *pcie) +{ + struct device *dev = &pcie->pdev->dev; + + /* + * Trying to start a new PIO transfer when previous has not completed + * cause External Abort on CPU which results in kernel panic: + * + * SError Interrupt on CPU0, code 0xbf000002 -- SError + * Kernel panic - not syncing: Asynchronous SError Interrupt + * + * Functions advk_pcie_rd_conf() and advk_pcie_wr_conf() are protected + * by raw_spin_lock_irqsave() at pci_lock_config() level to prevent + * concurrent calls at the same time. But because PIO transfer may take + * about 1.5s when link is down or card is disconnected, it means that + * advk_pcie_wait_pio() does not always have to wait for completion. + * + * Some versions of ARM Trusted Firmware handles this External Abort at + * EL3 level and mask it to prevent kernel panic. Relevant TF-A commit: + * https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/commit/?id=3c7dcdac5c50 + */ + if (advk_readl(pcie, PIO_START)) { + dev_err(dev, "Previous PIO read/write transfer is still running\n"); + return true; + } + + return false; +} + static int advk_pcie_rd_conf(struct pci_bus *bus, u32 devfn, int where, int size, u32 *val) { @@ -673,9 +702,10 @@ static int advk_pcie_rd_conf(struct pci_bus *bus, u32 devfn, return pci_bridge_emul_conf_read(&pcie->bridge, where, size, val); - /* Start PIO */ - advk_writel(pcie, 0, PIO_START); - advk_writel(pcie, 1, PIO_ISR); + if (advk_pcie_pio_is_running(pcie)) { + *val = 0xffffffff; + return PCIBIOS_SET_FAILED; + } /* Program the control register */ reg = advk_readl(pcie, PIO_CTRL); @@ -694,7 +724,8 @@ static int advk_pcie_rd_conf(struct pci_bus *bus, u32 devfn, /* Program the data strobe */ advk_writel(pcie, 0xf, PIO_WR_DATA_STRB); - /* Start the transfer */ + /* Clear PIO DONE ISR and start the transfer */ + advk_writel(pcie, 1, PIO_ISR); advk_writel(pcie, 1, PIO_START); ret = advk_pcie_wait_pio(pcie); @@ -734,9 +765,8 @@ static int advk_pcie_wr_conf(struct pci_bus *bus, u32 devfn, if (where % size) return PCIBIOS_SET_FAILED; - /* Start PIO */ - advk_writel(pcie, 0, PIO_START); - advk_writel(pcie, 1, PIO_ISR); + if (advk_pcie_pio_is_running(pcie)) + return PCIBIOS_SET_FAILED; /* Program the control register */ reg = advk_readl(pcie, PIO_CTRL); @@ -763,7 +793,8 @@ static int advk_pcie_wr_conf(struct pci_bus *bus, u32 devfn, /* Program the data strobe */ advk_writel(pcie, data_strobe, PIO_WR_DATA_STRB); - /* Start the transfer */ + /* Clear PIO DONE ISR and start the transfer */ + advk_writel(pcie, 1, PIO_ISR); advk_writel(pcie, 1, PIO_START); ret = advk_pcie_wait_pio(pcie); From patchwork Thu May 6 15:31:13 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: 12242477 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 3E7C0C433B4 for ; Thu, 6 May 2021 15:34:18 +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 8DD9C613BA for ; Thu, 6 May 2021 15:34:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8DD9C613BA 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=ldE5PNVSZ/F6BTwMIITtlVpoRq3X7414xGmHm8sGjZY=; b=Q0xfh2CqqPm4KqOK05Z8wV2M3 /yh9G6eeSLNmk9ZvHC0ospi3ngpVRmwupDke5u0oINrX6kALZ+oJU17QAAZbe339LfFHrwNodUNZO yHB/qgrir56a5R30PhgxLJz8GB6HMHDHEVspRwuaNMJToLzkdo95Ox3E9IRulcO942t0S2g6m9TeP cSYHtn83Md72WBlRdtje2033MLkLdlhwK1gXopT5ILxNhFgTNJRvsTWcrVdBhwYZXpZo2ZZ1AGEhg FSB0pWi7gpmKSvsTEyzB6IwEgXO0SUaLKuiNoFmJBqAlszWGth3pBLEmVWUN9OC1bcKawDSeTHUhY EOa+vQPgw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lefzi-004a38-MN; Thu, 06 May 2021 15:32:54 +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 1lefze-004a2P-Gm for linux-arm-kernel@desiato.infradead.org; Thu, 06 May 2021 15:32:51 +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=Y0Zr/pYf4JPGoC87XGhE+dZcHLj8VRQ7ooKGV3dcPSA=; b=AI+aiZ9OtmpH73eBI8dBMENKeV Mk7jgs6+jtsmzLMtF8nyCxStf4q4eqlc1Npc5N23jGvdjQydF+K4hKGmyJHIcR3f/NL+C+l2202Ic QrbFySpwk4sl4hyaXj4E/+hHtlkcz0Vs+V60qYpwWvvu2Rp1xCwGMfuYA0njyUuqd5esyj2GLKBoL WmAxdVEv27KCVza26Ih34e/99hInLhkv6SSo2oDoJp21S3Sb6EhE8HQkzucOK4PJ9H3AO4NngAs2k +E6mhBvyeIvSyG8SMjD5X0+4TOOiyOu0EORdxNk5VkAYLAPBRsfEAxCbQmWo67IUN8w2htGgbQIAb EEG+Rz0A==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lefzb-0069f2-W6 for linux-arm-kernel@lists.infradead.org; Thu, 06 May 2021 15:32:49 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 28B1761104; Thu, 6 May 2021 15:32:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620315167; bh=ticgXE7CjNhWfVymrLf5bGBpQYvv4IhRaSX2oXSsd1I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M7KJ+oKkDugqW1SIubabh+zVXWcvfilXeQofjOvulJH5lqSyxMlYCXZqKJGZftFch tQgvE47XG8DnWi+gpTZyv6uOvnSVyVmLA7Dg9wOGHxdC8J/8+gEN5Q+bivDBT1qXrK 6FHe5MX1xciUQFjZdGKjOKDw2dvqmsAPUt54bp/idv22QxVN2PyBQVGC5LefR2twWS m2eKpXwvT6v6AZgH6opcZnT+Kpqt27R5V5SMWNRvH9bLg0RQbIlyBcvqD3QNMqlDBN U/cEMW9uB64eXFYDlamrhzD25hdjIMb7OryPDz+aZkXcp6pt/AmnTkqu3/232lYgvS YRaf3iHQ/wyOQ== Received: by pali.im (Postfix) id 938538A1; Thu, 6 May 2021 17:32:44 +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 02/42] PCI: aardvark: Fix checking for PIO Non-posted Request Date: Thu, 6 May 2021 17:31:13 +0200 Message-Id: <20210506153153.30454-3-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_083248_085321_EDB558E6 X-CRM114-Status: GOOD ( 10.11 ) 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 PIO_NON_POSTED_REQ for PIO_STAT register is incorrectly defined. Bit 10 in register PIO_STAT indicates the response is to a non-posted request. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Cc: stable@vger.kernel.org --- drivers/pci/controller/pci-aardvark.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index e3f5e7ab7606..2f8380a1f84f 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -57,7 +57,7 @@ #define PIO_COMPLETION_STATUS_UR 1 #define PIO_COMPLETION_STATUS_CRS 2 #define PIO_COMPLETION_STATUS_CA 4 -#define PIO_NON_POSTED_REQ BIT(0) +#define PIO_NON_POSTED_REQ BIT(10) #define PIO_ADDR_LS (PIO_BASE_ADDR + 0x8) #define PIO_ADDR_MS (PIO_BASE_ADDR + 0xc) #define PIO_WR_DATA (PIO_BASE_ADDR + 0x10) From patchwork Thu May 6 15:31:14 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: 12242481 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 7EC60C43460 for ; Thu, 6 May 2021 15:35:05 +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 E5E40610C8 for ; Thu, 6 May 2021 15:35:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E5E40610C8 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=XKdJc69t4jzQv5fDH/KMQIu92JKaM4kdG1DAXBX7xTU=; b=gVR2PZTXfIellg5wiL3yLbvcJ NVkfIUdKG7Hts6HJWiwRLDLGNUjK45CW1d2+va8D3IlY3ghj8zp8/YuLv1RdsyNPMKbSbGV1VEaR6 vCMzIexGZKkbB/HYnU84i4TrkgHYbqM8NFFTYcuzCqzxJXrZdgQxNa3HGKQJLTOa1GwJYhxo4//eo qvi46rexpDICswlYCV2tw51NqtqlaenmMXtnzW1Ocuz1oCeU9qgvmIWr6BLJI5TZPnKP4vJeo2zL9 Ehv/QulVat+Y9mNGZKTS+kkDyHWq7htD25pgzipVlft+wwny66OVNEZPrVu6X2kDH032qohHBbETO N3QNjRH0w==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1leg0N-004aIA-DP; Thu, 06 May 2021 15:33:35 +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 1lefzg-004a2p-Hi for linux-arm-kernel@desiato.infradead.org; Thu, 06 May 2021 15:32:52 +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=XsPgc7bIvYP03GMTAo4H2GSsadfaTqDy1rGt8fB9ZbI=; b=miwFXIk0bIIpeI8wGXMUy5Pn1N 2g1/FqhMtgDkvJlSXTCVu3Hw/oskDCPakZz90yAVWxMsGw4sGDc1MZLx45h+oNcezleuUigtHwD6D GJxjqx03x0HMke36Z0WRCZd9iZsjPWkszJWBmVVYB7jTLpDjJnLZKkpW3F1jmxnO8l+JrJAXNUdy/ sweIH/JJTeR9YLS4EBsvbiSNlqkzvZz2AWHo0WkSDGIAD+cdk/VEbTIWBEk6htKFE2TJwfJDa1HKV 4Xh/IOS5KK+v3iO9/onFZEka5g35HRWNJKALwPi+vCFkZQXhYgQ5F3F3AkcZ/VYB49UNQqtq5xUD5 nvjqchFA==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lefzb-0069f4-W4 for linux-arm-kernel@lists.infradead.org; Thu, 06 May 2021 15:32:51 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2B80F61168; Thu, 6 May 2021 15:32:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620315167; bh=Fu4/t9pMjXwvsBTR1oTGCXyaBjHyoagLyBJfrUrRITM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Tvv6Aru/o7L85xCaZOCy8rUW3aMkT6HCjU1p3R9hyH4Y06DgBjU6ma+WfLSk86O8C J2bzfs9PBV9RCicsRr7kyOh673+gkaNBfb4BPPuPefC5HZ4wDjVsJ3t3uBiV7zO57j CBr18OLYW4MkaFxwzGJMZqfO6cGgFVPUy0OvP4P6yQmLuSMdKcUPAf3y+Elp/qRwCd YVdiCiL4lqocEHxmysDM7b2qSP5Vl3YaIN+mDmSkKekQRQoIZn+3i61kooaL16Jtx0 0iqmdbmL+i8P4tcl6Vw8bx0Ge86s2T6bB0PnlCn/5rtMspqoMy2Jlpr6W3eO3A8HZm or+s1vmzqwNeg== Received: by pali.im (Postfix) id CBBC4BF9; Thu, 6 May 2021 17:32:44 +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 03/42] PCI: aardvark: Fix checking for PIO status Date: Thu, 6 May 2021 17:31:14 +0200 Message-Id: <20210506153153.30454-4-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_083248_176761_6C62D4DB X-CRM114-Status: GOOD ( 25.19 ) 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 From: Evan Wang There is an issue that when PCIe switch is connected to an Armada 3700 board, there will be lots of warnings about PIO errors when reading the config space. According to Aardvark PIO read and write sequence in HW specification, the current way to check PIO status has the following issues: 1) For PIO read operation, it reports the error message, which should be avoided according to HW specification. 2) For PIO read and write operations, it only checks PIO operation complete status, which is not enough, and error status should also be checked. This patch aligns the code with Aardvark PIO read and write sequence in HW specification on PIO status check and fix the warnings when reading config space. This patch also returns Completion Retry Status value when the read request timeout, to give the caller a chance to send the request again instead of failing. Signed-off-by: Evan Wang Reviewed-by: Victor Gu Tested-by: Victor Gu [pali: Return CRS also after timeout] Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Cc: stable@vger.kernel.org # b1bd5714472c ("PCI: aardvark: Indicate error in 'val' when config read fails") --- drivers/pci/controller/pci-aardvark.c | 93 +++++++++++++++++++++++---- 1 file changed, 80 insertions(+), 13 deletions(-) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index 2f8380a1f84f..a37ba86f1b2d 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -58,6 +58,7 @@ #define PIO_COMPLETION_STATUS_CRS 2 #define PIO_COMPLETION_STATUS_CA 4 #define PIO_NON_POSTED_REQ BIT(10) +#define PIO_ERR_STATUS BIT(11) #define PIO_ADDR_LS (PIO_BASE_ADDR + 0x8) #define PIO_ADDR_MS (PIO_BASE_ADDR + 0xc) #define PIO_WR_DATA (PIO_BASE_ADDR + 0x10) @@ -176,6 +177,9 @@ #define MSI_IRQ_NUM 32 +#define CFG_RD_UR_VAL 0xffffffff +#define CFG_RD_CRS_VAL 0xffff0001 + struct advk_pcie { struct platform_device *pdev; void __iomem *base; @@ -461,7 +465,7 @@ static void advk_pcie_setup_hw(struct advk_pcie *pcie) advk_writel(pcie, reg, PCIE_CORE_CMD_STATUS_REG); } -static void advk_pcie_check_pio_status(struct advk_pcie *pcie) +static int advk_pcie_check_pio_status(struct advk_pcie *pcie, u32 *val) { struct device *dev = &pcie->pdev->dev; u32 reg; @@ -472,15 +476,50 @@ static void advk_pcie_check_pio_status(struct advk_pcie *pcie) status = (reg & PIO_COMPLETION_STATUS_MASK) >> PIO_COMPLETION_STATUS_SHIFT; - if (!status) - return; - + /* + * According to HW spec, the PIO status check sequence as below: + * 1) even if COMPLETION_STATUS(bit9:7) indicates successful, + * it still needs to check Error Status(bit11), only when this bit + * indicates no error happen, the operation is successful. + * 2) value Unsupported Request(1) of COMPLETION_STATUS(bit9:7) only + * means a PIO write error, and for PIO read it is successful with + * a read value of 0xFFFFFFFF. + * 3) value Completion Retry Status(CRS) of COMPLETION_STATUS(bit9:7) + * only means a PIO write error, and for PIO read it is successful + * with a read value of 0xFFFF0001. + * 4) value Completer Abort (CA) of COMPLETION_STATUS(bit9:7) means + * error for both PIO read and PIO write operation. + * 5) other errors are indicated as 'unknown'. + */ switch (status) { + case PIO_COMPLETION_STATUS_OK: + if (reg & PIO_ERR_STATUS) { + strcomp_status = "COMP_ERR"; + break; + } + /* Get the read result */ + if (val) + *val = advk_readl(pcie, PIO_RD_DATA); + /* No error */ + strcomp_status = NULL; + break; case PIO_COMPLETION_STATUS_UR: - strcomp_status = "UR"; + if (val) { + /* For reading, UR is not an error status */ + *val = CFG_RD_UR_VAL; + strcomp_status = NULL; + } else { + strcomp_status = "UR"; + } break; case PIO_COMPLETION_STATUS_CRS: - strcomp_status = "CRS"; + if (val) { + /* For reading, CRS is not an error status */ + *val = CFG_RD_CRS_VAL; + strcomp_status = NULL; + } else { + strcomp_status = "CRS"; + } break; case PIO_COMPLETION_STATUS_CA: strcomp_status = "CA"; @@ -490,6 +529,9 @@ static void advk_pcie_check_pio_status(struct advk_pcie *pcie) break; } + if (!strcomp_status) + return 0; + if (reg & PIO_NON_POSTED_REQ) str_posted = "Non-posted"; else @@ -497,6 +539,8 @@ static void advk_pcie_check_pio_status(struct advk_pcie *pcie) dev_err(dev, "%s PIO Response Status: %s, %#x @ %#x\n", str_posted, strcomp_status, reg, advk_readl(pcie, PIO_ADDR_LS)); + + return -EFAULT; } static int advk_pcie_wait_pio(struct advk_pcie *pcie) @@ -703,8 +747,17 @@ static int advk_pcie_rd_conf(struct pci_bus *bus, u32 devfn, size, val); if (advk_pcie_pio_is_running(pcie)) { - *val = 0xffffffff; - return PCIBIOS_SET_FAILED; + /* + * For PCI_VENDOR_ID register, return Completion Retry Status + * so caller tries to issue the request again insted of failing + */ + if (where == PCI_VENDOR_ID) { + *val = CFG_RD_CRS_VAL; + return PCIBIOS_SUCCESSFUL; + } else { + *val = 0xffffffff; + return PCIBIOS_SET_FAILED; + } } /* Program the control register */ @@ -729,15 +782,27 @@ static int advk_pcie_rd_conf(struct pci_bus *bus, u32 devfn, advk_writel(pcie, 1, PIO_START); ret = advk_pcie_wait_pio(pcie); + if (ret < 0) { + /* + * For PCI_VENDOR_ID register, return Completion Retry Status + * so caller tries to issue the request again instead of failing + */ + if (where == PCI_VENDOR_ID) { + *val = CFG_RD_CRS_VAL; + return PCIBIOS_SUCCESSFUL; + } else { + *val = 0xffffffff; + return PCIBIOS_SET_FAILED; + } + } + + /* Check PIO status and get the read result */ + ret = advk_pcie_check_pio_status(pcie, val); if (ret < 0) { *val = 0xffffffff; return PCIBIOS_SET_FAILED; } - advk_pcie_check_pio_status(pcie); - - /* Get the read result */ - *val = advk_readl(pcie, PIO_RD_DATA); if (size == 1) *val = (*val >> (8 * (where & 3))) & 0xff; else if (size == 2) @@ -801,7 +866,9 @@ static int advk_pcie_wr_conf(struct pci_bus *bus, u32 devfn, if (ret < 0) return PCIBIOS_SET_FAILED; - advk_pcie_check_pio_status(pcie); + ret = advk_pcie_check_pio_status(pcie, NULL); + if (ret < 0) + return PCIBIOS_SET_FAILED; return PCIBIOS_SUCCESSFUL; } From patchwork Thu May 6 15:31:15 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: 12242479 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 CA455C4360C for ; Thu, 6 May 2021 15:34:41 +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 330986109E for ; Thu, 6 May 2021 15:34:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 330986109E 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=oeAqK8bs4WV0eA275lcaHcV3jSOMzl926Eyj0IONHnc=; b=VaHvd5Xd3JyU41CmIw8nR6Tiy pRPdApW5dITP7oBWsDYyuHQ+zxOdR2RArqTlDcQQHquQNQUas35DdqIg47GmgLIxhGiVjDlqDKriG RbvK+8U9u1pPAahalHxBNMdQnbf0hKSvukMFRw8ZLsjSqfa4aI2gr0EMJCavA7Bt6hPHwm9xGRVOK wKemMZS9JdFBdUZCNqWOmn8Zx/PjXG1dfbVgUXAtoKkY26JAy4VteuuPZy2xq+Dl2zVI+uD5Vn0hO 8Rjy1IMy+DmkZ8yxmhSk7jUkZZpshQeR+GgIEnLegA48kwokPfEo8F/ZcGuHnXLV3mGfFB/4IZlFE pbVoF6s9Q==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1leg04-004aCE-69; Thu, 06 May 2021 15:33:16 +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 1lefzg-004a2W-3h for linux-arm-kernel@desiato.infradead.org; Thu, 06 May 2021 15:32:52 +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=SKqy2jVPczMdzntmqoj/cPGbVcXPe6VOfn/BSmJ+br8=; b=qxKeZWO8TAog6y8WP4BwsxV9vY 7qni1q700hzPnCXbCgOAoPoOcnxmCsv4jrBvvTMIM5AcTT/gYlx+Thy9QxS6betIYInCz8HZG8EMb tirIudombVbMClvXQWG10QFjiDNgmGBY16x37OXdOXVmARVjw0zuywKAHtvIGVytTLpMxmAd0xus7 SNl2DgK+Yx6BeqP2+9K2ermmiSbZDB/sXEU5DVmcVvg4XklOTjkw2Ws64xW1SPyFA3KLUh8x9k2Pe D7AWgH79dQMtore3DoNsTY+M7lp9zD+Tv5n+X0U0EktC1GfdVgNmfjpAd+AJwdt1dXyESgOlf3Axc NOcEu8Ww==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lefzb-0069f1-W0 for linux-arm-kernel@lists.infradead.org; Thu, 06 May 2021 15:32:50 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2DA3A611AE; Thu, 6 May 2021 15:32:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620315167; bh=IdVDiP6+1WGD69KpQ4ecO/tfD5bBRFQpZYGTE4VGzkg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FFXKmiEySlP/tZydvoImG/r31EU1UBJOR46SWzqYuKF8d6dwqLioVT282SYuBon16 ZRsbVcR4jXWpUzObLhzWQlTxIRTpuABm6P1jZUKpalx6JkBewu7iPI+OlWWvQjUAUy iTRvMZWwTZz4+yoPs4sr80K+rdlkqMVNnzB1/V9W2ndn/NZOkKf26pSL0JzpzOJE/g aIrhLIf3SU5yM/BkX38DhYt7jHN3IARbpN9tQy/3fYWZZVHn6r9Sm2CfXK0W8a4lax 7WbduU0lKwoswL0nKcjbWNALDQsn9zmiT+jQpUdoNV+AzNSe/KDVWApIczPlRyTctW BG7PP6ZanlpHA== Received: by pali.im (Postfix) id 1E226E79; Thu, 6 May 2021 17:32:45 +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 04/42] PCI: aardvark: Increase polling delay to 1.5s while waiting for PIO response Date: Thu, 6 May 2021 17:31:15 +0200 Message-Id: <20210506153153.30454-5-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_083248_119530_64701AA0 X-CRM114-Status: GOOD ( 13.53 ) 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 Measurements in different conditions showed that aardvark hardware PIO response can take up to 1.44s. Increase wait timeout from 1ms to 1.5s to ensure that we do not miss responses from hardware. After 1.44s hardware returns errors (e.g. Completer abort). The previous two patches fixed checking for PIO status, so now we can use it to also catch errors which are reported by hardware after 1.44s. After applying this patch, kernel can detect and print PIO errors to dmesg: [ 6.879999] advk-pcie d0070000.pcie: Non-posted PIO Response Status: CA, 0xe00 @ 0x100004 [ 6.896436] advk-pcie d0070000.pcie: Posted PIO Response Status: COMP_ERR, 0x804 @ 0x100004 [ 6.913049] advk-pcie d0070000.pcie: Posted PIO Response Status: COMP_ERR, 0x804 @ 0x100010 [ 6.929663] advk-pcie d0070000.pcie: Non-posted PIO Response Status: CA, 0xe00 @ 0x100010 [ 6.953558] advk-pcie d0070000.pcie: Posted PIO Response Status: COMP_ERR, 0x804 @ 0x100014 [ 6.970170] advk-pcie d0070000.pcie: Non-posted PIO Response Status: CA, 0xe00 @ 0x100014 [ 6.994328] advk-pcie d0070000.pcie: Posted PIO Response Status: COMP_ERR, 0x804 @ 0x100004 Without this patch kernel prints only a generic error to dmesg: [ 5.246847] advk-pcie d0070000.pcie: config read/write timed out Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Cc: stable@vger.kernel.org # 7fbcb5da811b ("PCI: aardvark: Don't rely on jiffies while holding spinlock") --- drivers/pci/controller/pci-aardvark.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index a37ba86f1b2d..3f3c72927afb 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -166,7 +166,7 @@ #define PCIE_CONFIG_WR_TYPE0 0xa #define PCIE_CONFIG_WR_TYPE1 0xb -#define PIO_RETRY_CNT 500 +#define PIO_RETRY_CNT 750000 /* 1.5 s */ #define PIO_RETRY_DELAY 2 /* 2 us*/ #define LINK_WAIT_MAX_RETRIES 10 From patchwork Thu May 6 15:31:16 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: 12242489 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 AA86BC433B4 for ; Thu, 6 May 2021 15:37:13 +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 69C55610A1 for ; Thu, 6 May 2021 15:37:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 69C55610A1 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=xtJ8S4lzlqiUqyX9PcznKFLKW9mvanc5s4ePvgf0mbA=; b=BEDSWVUOpaunwfz+WMmojPRU9 g+4cFwkTgFV1yCBsmB16QEd8UI+jB8qPHivCXFonbuMij2WdIYqpMS6KelGeXuUQBaIVab/1+dg1M L1cDkJx36JkqbbZf8oQWXrE3A6nYzJqZH6nByNNiR6zu8LCduf9ZhbzItWNQcOkBqLPYNz6cDTxMM j/TngC/WxKo+bnVt1GnQJm1tR1bXBBmfCFdXNK4uU3jFgRokCboxiMIlk7k1wjEOuGoyIOUqiYMml Ba4W9i8SgMYvD35p9nWlO1hbAgaAaMV6tOU2tHBJk7KMDV/W5FFIlRDKl1FlFm6BY49F8mE1iuvPG MxxJUmvHg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1leg2O-004b1E-TW; Thu, 06 May 2021 15:35:42 +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 1lefzi-004a3m-Ao for linux-arm-kernel@desiato.infradead.org; Thu, 06 May 2021 15:32:54 +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=JXX9Lsljmown3yJfzIRxQwK9FIQ2BX8oEG/lfg7folo=; b=ZBrQsWHn/umrZt3YUWGYLNQJWE lsR03sq8aD41EZzeNE+rcjWv08KQDovVABqgF4xHXUey5OGj46MFJ+GEZ6EtUXrdufz0piEociAnO QAC+pBdbrz2e3VCpn6N9dY8xU8KgTk520pSsA2PVDXtBD/ktDShJyOKIOihZIcqAP+8jI2j8Jl61F 1Tjhd3olFCa8cHssNblSAXKMZm7efilYK8i7JxVBhFMu5cr69rShvTErkhNVNPgyYSFZ70piQlAYE bg3s+n1P2h8rfUbBLwCyN6wIwOzn2bqHnl7M9vsiPJfjzHryq3LVub2481sEq9MLhjws8nfrlDYMC JKEAimiw==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lefzd-0069gb-Jm for linux-arm-kernel@lists.infradead.org; Thu, 06 May 2021 15:32:53 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id BA553613F0; Thu, 6 May 2021 15:32:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620315167; bh=32yCzHDa56snda7ATUWNvJbqe/MsTwnPQCq/ie/OGr8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ErP9yH2LeaLujgtbGKxp68ZDWKMB5jm3IzZKTGPGq57lXpdi1Uz9yB3tuNZI7xzOi 3HWxx5zBi6YrfRWBq2q+lnsOk7FmJJUNqtIYsFivu3f8+CpUdBwfuRgzAb16/QdLbo QLeTQLBUW9dv6MKE8rWczzA8sLjOtSoIYdyCnYmOyruViTgGcqyfr3pVDm00V83Wd+ ZL3xWLWFQFTfcGU+2khFew7h2SITYsJQ9e0FVAhegAkCbD9UDNLn5wiy429Npgzri/ 65iQ5ppEaKjSPwHD4O9goaqCvT1egTE07zyD5v70Esz3kOGhZwBUcC2DqPZsVXARgS NyhFTU5ue79gw== Received: by pali.im (Postfix) id 6A68010CD; Thu, 6 May 2021 17:32:45 +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 05/42] PCI: pci-bridge-emul: Add PCIe Root Capabilities Register Date: Thu, 6 May 2021 17:31:16 +0200 Message-Id: <20210506153153.30454-6-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_083249_732037_EE303FE8 X-CRM114-Status: GOOD ( 10.24 ) 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 This is 16-bit register at offset 0x1E. Rename current 'rsvd' struct member to 'rootcap'. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Fixes: 23a5fba4d941 ("PCI: Introduce PCI bridge emulated config space common logic") Cc: stable@vger.kernel.org # e0d9d30b7354 ("PCI: pci-bridge-emul: Fix big-endian support") --- drivers/pci/pci-bridge-emul.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/pci-bridge-emul.h b/drivers/pci/pci-bridge-emul.h index b31883022a8e..49bbd37ee318 100644 --- a/drivers/pci/pci-bridge-emul.h +++ b/drivers/pci/pci-bridge-emul.h @@ -54,7 +54,7 @@ struct pci_bridge_emul_pcie_conf { __le16 slotctl; __le16 slotsta; __le16 rootctl; - __le16 rsvd; + __le16 rootcap; __le32 rootsta; __le32 devcap2; __le16 devctl2; From patchwork Thu May 6 15:31:17 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: 12242485 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 1EA6AC433ED for ; Thu, 6 May 2021 15:36:03 +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 74EC5610C8 for ; Thu, 6 May 2021 15:36:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 74EC5610C8 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=nw2ZF9dKlW+OYiGYbAYkOM28fZA0su1m0Tu9gSsrx2M=; b=YJoDewqMRsaGmNRhgxTIAuOIm 3LiLmxsv7EkDaIw6z3lwDUurrtYTxxMUp5XhJppkfJX6lAGl+17uZzlKGzKf6zZFKY18w+rxvZ3fC HACpm2NfIyv8lRExF+SYZhW0FabZVn/X0P31Y1ievo4o8JOI6wIah/HOBUNduaftLGU5tMDeZ2Wzd t/CWCWZnGnYakE2cHCjzvcZK47/0T60bacnh6xF37DQqsrffWyB3tqwCk9kiQ5E1/XHBXaM4dgQvS u/DvGtMWG34yibTV4qrXx3m5fbUpOwHRDI04BIvHCy/F5o82FOxTgkm10i8cYAOf969yAwmnkgDRH tXNNg/rNA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1leg1R-004aca-SR; Thu, 06 May 2021 15:34:42 +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 1lefzi-004a3a-25 for linux-arm-kernel@desiato.infradead.org; Thu, 06 May 2021 15:32:54 +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=deWJqWWARCcJDrEXdA9FwIAbum+H/RqXNFR28NaEsnQ=; b=hJ1BAvIlBDubPK1qv3uuSzk5Tp T35/UynrOkIcdA+AJBcfqp/XMRPbDLuunmnad/wl5jo3h+CB2AnQ8jg3/RF9+oTAOh+JSynXq9sfg UCHn7/o/t4ywSXUAz8UQSPqkWqRYFxjzrLV5/4I/4Bz/VJv2OsgIjf/4hlpFg6NKGq0BPk5kLLH44 BGmN7LpJFVOMHVroxBLtPAcU2ziqzuzURCv246bQkmPOxb11yUy9dpvuaBFeJS4sTmEsAyzyAO3pL ceZOaWDAs3zm4RdVVIDz4hjvO6A0FwkX2/dHAT63hmsh5Laa4rz0uWuiJFhLJ/ZoMY0yjIdOHGca7 ejHem5yg==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lefzd-0069ga-Ie for linux-arm-kernel@lists.infradead.org; Thu, 06 May 2021 15:32:52 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id C0C7A613E4; Thu, 6 May 2021 15:32:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620315167; bh=dHsqdNjyH3uEKBJHdSqdXMTYkvi4cwFKXYRKyfqwHMw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hCUkcoTnKQxQXmXSBCd/GlARbvZoU+rw8K89DtIUwxZ9FWx0T2FxmToOoseROJIPt EbMQJwckfLttJTjMmp0CZ5QcCGEUbk7qeSERhshVV9QuEtdJTjUuU58n2bUKWslOKC xKdI8T7nq/whQmzDwIibtK4pP1dcP5mm8Zc+wSH8HSBCVm1Pkp7pIyLmwXlpBBi+4M 9Q0ZiP8oYE7kKsgvHENJz3j1MM455BxNDEzyY7ZWV5jLSYsix3OaxK5z7RWUIRjePk bq8HqOablna25truOZSUKba7UVWnPAqggA6x81wxntVKU7HHCjiMhqHhH37deWQf6P jmhXzwsDzj70w== Received: by pali.im (Postfix) id A824211AB; Thu, 6 May 2021 17:32:45 +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 06/42] PCI: aardvark: Fix reporting CRS Software Visibility on emulated bridge Date: Thu, 6 May 2021 17:31:17 +0200 Message-Id: <20210506153153.30454-7-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_083249_684363_D32D15A2 X-CRM114-Status: GOOD ( 11.80 ) 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 CRS Software Visibility is supported and always enabled by PIO. Correctly report this information via emulated root bridge. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Fixes: 8a3ebd8de328 ("PCI: aardvark: Implement emulated root PCI bridge config space") Cc: stable@vger.kernel.org --- drivers/pci/controller/pci-aardvark.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index 3f3c72927afb..e297ec9ec390 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -578,6 +578,8 @@ advk_pci_bridge_emul_pcie_conf_read(struct pci_bridge_emul *bridge, case PCI_EXP_RTCTL: { u32 val = advk_readl(pcie, PCIE_ISR0_MASK_REG); *value = (val & PCIE_MSG_PM_PME_MASK) ? 0 : PCI_EXP_RTCTL_PMEIE; + *value |= PCI_EXP_RTCTL_CRSSVE; + *value |= PCI_EXP_RTCAP_CRSVIS << 16; return PCI_BRIDGE_EMUL_HANDLED; } @@ -659,6 +661,7 @@ static struct pci_bridge_emul_ops advk_pci_bridge_emul_ops = { static int advk_sw_pci_bridge_init(struct advk_pcie *pcie) { struct pci_bridge_emul *bridge = &pcie->bridge; + int ret; bridge->conf.vendor = cpu_to_le16(advk_readl(pcie, PCIE_CORE_DEV_ID_REG) & 0xffff); @@ -682,7 +685,16 @@ static int advk_sw_pci_bridge_init(struct advk_pcie *pcie) bridge->data = pcie; bridge->ops = &advk_pci_bridge_emul_ops; - return pci_bridge_emul_init(bridge, 0); + /* PCIe config space can be initialized after pci_bridge_emul_init() */ + ret = pci_bridge_emul_init(bridge, 0); + if (ret < 0) + return ret; + + /* Completion Retry Status is supported and always enabled by PIO */ + bridge->pcie_conf.rootctl = cpu_to_le16(PCI_EXP_RTCTL_CRSSVE); + bridge->pcie_conf.rootcap = cpu_to_le16(PCI_EXP_RTCAP_CRSVIS); + + return 0; } static bool advk_pcie_valid_device(struct advk_pcie *pcie, struct pci_bus *bus, From patchwork Thu May 6 15:31:18 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: 12242589 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 A235EC433B4 for ; Thu, 6 May 2021 15:40:35 +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 E47BB61040 for ; Thu, 6 May 2021 15:40:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E47BB61040 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=imQLnkD6vIRaJk83PeaVAthJRvyIOJY6Vfkn6d3/qas=; b=Z890nE66/tAg8n2k8MGnoxoyu OGjDzgK9phySCt4liRKi1fN81Lx6DcpQR1K44i1RaOfVYWdCIRfIncjvly5DYPYXrT+ZN5uLQIToH R5Galq05chXO/FUechSc0XzjOCtFb32NjA6IoIzPWKDCeDKwO/NCBAuRPG3oHYMrhnv4SjuqKXqs8 kHEP1N2qHA0Eh7FdGU6/XSaHIu5A3raSEHe7gc5f7JxBiuCVN+nXC2J79xXPsufJPqP5nFxFjdYug 5Sv6T2nUBHWZ9kNEU4OaV1glRWeAd+CHBf35O+61oHj6a0127t8E+oTup3bpGsldIaXctuJ9iDYJl M436FH0KQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1leg5U-004c9X-Bc; Thu, 06 May 2021 15:38:52 +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 1lefzl-004a55-NZ for linux-arm-kernel@desiato.infradead.org; Thu, 06 May 2021 15:32:58 +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=WLdA42zvI1m5O15q6+bksx80p4jAJwc4hmxqBpr09a0=; b=qh8jbxtfrrYG6bGFj9BWXj5h+V pZmn6YnODm7myvxW0p/sP39o2Ba9DZphd0Gl3YxAeCMF5CnJjwxj4DZj8ZPARYvcGbtt1PtiYsyRO VTs7mt6IEF+eHzTF2QIkWyCSNEI0HcnC7lJQppA6iAUQABnsE04jobnKEarKJm2teS/iM4ld05Fa+ /PXf5g8M+nwN3+EuJloQMCJ52Y6qYE4+B7hqzM6WH8+Zh+QAN4JetFrzQgtFQuezsjr9/XTtDaptf +uGBZryMMl6rL4XLkRYS+T/GmX3oeSJdaVBaKtSqBYKDwYIWCNYjgxO67MWbk0kKN8Bb4nq0Pj40C ihLccfXA==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lefzf-0069hj-Jk for linux-arm-kernel@lists.infradead.org; Thu, 06 May 2021 15:32:56 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id DC524613F2; Thu, 6 May 2021 15:32:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620315168; bh=c7GGuyUtVyL1SLFfZcJF6dkFcBmF/f2vbvmIa4XMBGk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Uk752vva9+3aZbQc1d8zcNpDjPeI8l75tYIslNH6LmoLxAInnItGuzB4Em+wbZZ0/ H/WgaOS8wQgL3J01VyjMoLCvQK7mRJ1IfRNwVY1RL8yN1m8s1/pgtNIOSfa1WeM8KM sCcz3CGju/FSqut+gU+PJJJLNhbP77uY6nFpZQNpTJXnYMIOJ/dVFw4dy6TOQN2i7y EmcIx/4f1B0W8VMdXlphGnGNs44Dq7Vg5/LOgwiQ0Ar/puHsiMO4NWuYZ2gLgXZG8t M7SqWIZMEvhiYt0i7+QmmWva36zdPAxVZIJSUSGfRkWUtU7rE/RjTwk6KRqmv37NmV xu3AkBgCizWfg== Received: by pali.im (Postfix) id 14E4B11DA; Thu, 6 May 2021 17:32:46 +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 07/42] PCI: aardvark: Fix link training Date: Thu, 6 May 2021 17:31:18 +0200 Message-Id: <20210506153153.30454-8-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_083251_845618_7CA01E5A X-CRM114-Status: GOOD ( 38.37 ) 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 Fix multiple link training issues in aardvark driver. The main reason of these issues was misunderstanding of what certain registers do, since their names and comments were misleading: before commit 96be36dbffac ("PCI: aardvark: Replace custom macros by standard linux/pci_regs.h macros"), the pci-aardvark.c driver used custom macros for accessing standard PCIe Root Bridge registers, and misleading comments did not help to understand what the code was really doing. After doing more tests and experiments I've come to the conclusion that the SPEED_GEN register in aardvark sets the PCIe revision / generation compliance and forces maximal link speed. Both GEN3 and GEN2 values set the read-only PCI_EXP_FLAGS_VERS bits (PCIe capabilities version of Root Bridge) to value 2, while GEN1 value sets PCI_EXP_FLAGS_VERS to 1, which matches with PCI Express specifications revision 3, 2 and 1, respectively. Changing SPEED_GEN also sets the read-only bits PCI_EXP_LNKCAP_SLS and PCI_EXP_LNKCAP2_SLS to corresponding speed. Note that PCI Express rev 1 specification does not define PCI_EXP_LNKCAP2 and PCI_EXP_LNKCTL2 registers and when SPEED_GEN is set to GEN1 (which also sets PCI_EXP_FLAGS_VERS set to 1), lspci cannot access PCI_EXP_LNKCAP2 and PCI_EXP_LNKCTL2 registers. Changing PCIe link speed can be done via PCI_EXP_LNKCTL2_TLS bits of PCI_EXP_LNKCTL2 register. Armada 3700 Functional Specifications says that the default value of PCI_EXP_LNKCTL2_TLS is based on SPEED_GEN value, but tests showed that the default value is always 8.0 GT/s, independently of speed set by SPEED_GEN. So after setting SPEED_GEN, we must also set value in PCI_EXP_LNKCTL2 register via PCI_EXP_LNKCTL2_TLS bits. Triggering PCI_EXP_LNKCTL_RL bit immediately after setting LINK_TRAINING_EN bit actually doesn't do anything. Tests have shown that a delay is needed after enabling LINK_TRAINING_EN bit. As triggering PCI_EXP_LNKCTL_RL currently does nothing, remove it. Commit 43fc679ced18 ("PCI: aardvark: Improve link training") introduced code which sets SPEED_GEN register based on negotiated link speed from PCI_EXP_LNKSTA_CLS bits of PCI_EXP_LNKSTA register. This code was added to fix detection of Compex WLE900VX (Atheros QCA9880) WiFi GEN1 PCIe cards, as otherwise these cards were "invisible" on PCIe bus (probably because they crashed). But apparently more people reported the same issues with these cards also with other PCIe controllers [1] and I was able to reproduce this issue also with other "noname" WiFi cards based on Atheros QCA9890 chip (with the same PCI vendor/device ids as Atheros QCA9880). So this is not an issue in aardvark but rather issue in Atheros QCA98xx chips. Also, this issue only exists if the kernel is compiled with PCIe ASPM support, and a generic workaround for this is to change PCIe Bridge to 2.5 GT/s link speed via PCI_EXP_LNKCTL2_TLS_2_5GT bits in PCI_EXP_LNKCTL2 register [2], before triggering PCI_EXP_LNKCTL_RL bit. This workaround also works when SPEED_GEN is set to value GEN2 (5 GT/s). So remove this hack completely in the aardvark driver and always set SPEED_GEN to value from 'max-link-speed' DT property. Fix for Atheros QCA98xx chips is handled separately by patch [2]. These two things (code for triggering PCI_EXP_LNKCTL_RL bit and changing SPEED_GEN value) also explain why commit 6964494582f5 ("PCI: aardvark: Train link immediately after enabling training") somehow fixed detection of those problematic Compex cards with Atheros chips: if triggering link retraining (via PCI_EXP_LNKCTL_RL bit) was done immediately after enabling link training (via LINK_TRAINING_EN), it did nothing. If there was a specific delay, aardvark HW already initialized PCIe link and therefore triggering link retraining caused the above issue. Compex cards triggered link down event and disappeared from the PCIe bus. Commit f4c7d053d7f7 ("PCI: aardvark: Wait for endpoint to be ready before training link") added 100ms sleep before calling 'Start link training' command and explained that it is a requirement of PCI Express specification. But the code after this 100ms sleep was not doing 'Start link training', rather it triggered PCI_EXP_LNKCTL_RL bit via PCIe Root Bridge to put link into Recovery state. The required delay after fundamental reset is already done in function advk_pcie_wait_for_link() which also check when PCIe link is up. So after removing the code which triggers PCI_EXP_LNKCTL_RL bit on PCIe Root Bridge, there is no need to wait 100ms again. Remove the extra msleep() call and update comment about the delay required by the PCI Express specification. According to Marvell Armada 3700 Functional Specifications, Link training should be enabled via aardvark register LINK_TRAINING_EN after selecting PCIe generation and x1 lane. There is no need to disable it prior resetting card via PERST# signal. This disabling code was introduced in commit 5169a9851daa ("PCI: aardvark: Issue PERST via GPIO") as a workaround for some Atheros cards. It turns out that this also is Atheros specific issue and affects any PCIe controller, not only aardvark. Moreover this Atheros issue was triggered by juggling with PCI_EXP_LNKCTL_RL, LINK_TRAINING_EN and SPEED_GEN bits interleaved with sleeps. Now, after removing triggering PCI_EXP_LNKCTL_RL, there is no need to explicitly disable LINK_TRAINING_EN bit. So remove this code too. The problematic Compex cards described in previous git commits are correctly detected in advk_pcie_train_link() function even after applying all these changes. Note that with this patch, and also prior this patch, some NVMe disks which support PCIe GEN3 with 8 GT/s speed are negotiated only at the lowest link speed 2.5 GT/s, independently of SPEED_GEN value. After manually triggering PCI_EXP_LNKCTL_RL bit (e.g. from userspace via setpci), these NVMe disks change link speed to 5 GT/s when SPEED_GEN was configured to GEN2. This issue first needs to be properly investigated. I will send a fix in the future. On the other hand, some other GEN2 PCIe cards with 5 GT/s speed are autonomously by HW autonegotiated at full 5 GT/s speed without need of any software interaction. Armada 3700 Functional Specifications describes the following steps for link training: set SPEED_GEN to GEN2, enable LINK_TRAINING_EN, poll until link training is complete, trigger PCI_EXP_LNKCTL_RL, poll until signal rate is 5 GT/s, poll until link training is complete, enable ASPM L0s. The requirement for triggering PCI_EXP_LNKCTL_RL can be explained by the need to achieve 5 GT/s speed (as changing link speed is done by throw to recovery state entered by PCI_EXP_LNKCTL_RL) or maybe as a part of enabling ASPM L0s (but in this case ASPM L0s should have been enabled prior PCI_EXP_LNKCTL_RL). It is unknown why the original pci-aardvark.c driver was triggering PCI_EXP_LNKCTL_RL bit before waiting for the link to be up. This does not align with neither PCIe base specifications nor with Armada 3700 Functional Specification. (Note that in older versions of aardvark, this bit was called incorrectly PCIE_CORE_LINK_TRAINING, so this may be the reason.) It is also unknown why Armada 3700 Functional Specification says that it is needed to trigger PCI_EXP_LNKCTL_RL for GEN2 mode, as according to PCIe base specification 5 GT/s speed negotiation is supposed to be entirely autonomous, even if initial speed is 2.5 GT/s. [1] - https://lore.kernel.org/linux-pci/87h7l8axqp.fsf@toke.dk/ [2] - https://lore.kernel.org/linux-pci/20210326124326.21163-1-pali@kernel.org/ Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Cc: stable@vger.kernel.org # f4c7d053d7f7 ("PCI: aardvark: Wait for endpoint to be ready before training link") Cc: stable@vger.kernel.org # 6964494582f5 ("PCI: aardvark: Train link immediately after enabling training") Cc: stable@vger.kernel.org # 43fc679ced18 ("PCI: aardvark: Improve link training") Cc: stable@vger.kernel.org # 5169a9851daa ("PCI: aardvark: Issue PERST via GPIO") Cc: stable@vger.kernel.org # 96be36dbffac ("PCI: aardvark: Replace custom macros by standard linux/pci_regs.h macros") Cc: stable@vger.kernel.org # d0c6a3475b03 ("PCI: aardvark: Move PCIe reset card code to advk_pcie_train_link()") Cc: stable@vger.kernel.org # 1d1cd163d0de ("PCI: aardvark: Update comment about disabling link training") --- drivers/pci/controller/pci-aardvark.c | 117 ++++++++------------------ 1 file changed, 34 insertions(+), 83 deletions(-) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index e297ec9ec390..edeacd95297e 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -209,11 +209,6 @@ static inline u32 advk_readl(struct advk_pcie *pcie, u64 reg) return readl(pcie->base + reg); } -static inline u16 advk_read16(struct advk_pcie *pcie, u64 reg) -{ - return advk_readl(pcie, (reg & ~0x3)) >> ((reg & 0x3) * 8); -} - static int advk_pcie_link_up(struct advk_pcie *pcie) { u32 val, ltssm_state; @@ -251,23 +246,9 @@ static void advk_pcie_wait_for_retrain(struct advk_pcie *pcie) static void advk_pcie_issue_perst(struct advk_pcie *pcie) { - u32 reg; - if (!pcie->reset_gpio) return; - /* - * As required by PCI Express spec (PCI Express Base Specification, REV. - * 4.0 PCI Express, February 19 2014, 6.6.1 Conventional Reset) a delay - * for at least 100ms after de-asserting PERST# signal is needed before - * link training is enabled. So ensure that link training is disabled - * prior de-asserting PERST# signal to fulfill that PCI Express spec - * requirement. - */ - reg = advk_readl(pcie, PCIE_CORE_CTRL0_REG); - reg &= ~LINK_TRAINING_EN; - advk_writel(pcie, reg, PCIE_CORE_CTRL0_REG); - /* 10ms delay is needed for some cards */ dev_info(&pcie->pdev->dev, "issuing PERST via reset GPIO for 10ms\n"); gpiod_set_value_cansleep(pcie->reset_gpio, 1); @@ -275,53 +256,46 @@ static void advk_pcie_issue_perst(struct advk_pcie *pcie) gpiod_set_value_cansleep(pcie->reset_gpio, 0); } -static int advk_pcie_train_at_gen(struct advk_pcie *pcie, int gen) +static void advk_pcie_train_link(struct advk_pcie *pcie) { - int ret, neg_gen; + struct device *dev = &pcie->pdev->dev; u32 reg; + int ret; - /* Setup link speed */ + /* + * Setup PCIe rev / gen compliance based on device tree property + * 'max-link-speed' which also forces maximal link speed. + */ reg = advk_readl(pcie, PCIE_CORE_CTRL0_REG); reg &= ~PCIE_GEN_SEL_MSK; - if (gen == 3) + if (pcie->link_gen == 3) reg |= SPEED_GEN_3; - else if (gen == 2) + else if (pcie->link_gen == 2) reg |= SPEED_GEN_2; else reg |= SPEED_GEN_1; advk_writel(pcie, reg, PCIE_CORE_CTRL0_REG); /* - * Enable link training. This is not needed in every call to this - * function, just once suffices, but it does not break anything either. + * Set maximal link speed value also into PCIe Link Control 2 register. + * Armada 3700 Functional Specification says that default value is based + * on SPEED_GEN but tests showed that default value is always 8.0 GT/s. */ + reg = advk_readl(pcie, PCIE_CORE_PCIEXP_CAP + PCI_EXP_LNKCTL2); + reg &= ~PCI_EXP_LNKCTL2_TLS; + if (pcie->link_gen == 3) + reg |= PCI_EXP_LNKCTL2_TLS_8_0GT; + else if (pcie->link_gen == 2) + reg |= PCI_EXP_LNKCTL2_TLS_5_0GT; + else + reg |= PCI_EXP_LNKCTL2_TLS_2_5GT; + advk_writel(pcie, reg, PCIE_CORE_PCIEXP_CAP + PCI_EXP_LNKCTL2); + + /* Enable link training after selecting PCIe generation */ reg = advk_readl(pcie, PCIE_CORE_CTRL0_REG); reg |= LINK_TRAINING_EN; advk_writel(pcie, reg, PCIE_CORE_CTRL0_REG); - /* - * Start link training immediately after enabling it. - * This solves problems for some buggy cards. - */ - reg = advk_readl(pcie, PCIE_CORE_PCIEXP_CAP + PCI_EXP_LNKCTL); - reg |= PCI_EXP_LNKCTL_RL; - advk_writel(pcie, reg, PCIE_CORE_PCIEXP_CAP + PCI_EXP_LNKCTL); - - ret = advk_pcie_wait_for_link(pcie); - if (ret) - return ret; - - reg = advk_read16(pcie, PCIE_CORE_PCIEXP_CAP + PCI_EXP_LNKSTA); - neg_gen = reg & PCI_EXP_LNKSTA_CLS; - - return neg_gen; -} - -static void advk_pcie_train_link(struct advk_pcie *pcie) -{ - struct device *dev = &pcie->pdev->dev; - int neg_gen = -1, gen; - /* * Reset PCIe card via PERST# signal. Some cards are not detected * during link training when they are in some non-initial state. @@ -332,41 +306,18 @@ static void advk_pcie_train_link(struct advk_pcie *pcie) * PERST# signal could have been asserted by pinctrl subsystem before * probe() callback has been called or issued explicitly by reset gpio * function advk_pcie_issue_perst(), making the endpoint going into - * fundamental reset. As required by PCI Express spec a delay for at - * least 100ms after such a reset before link training is needed. - */ - msleep(PCI_PM_D3COLD_WAIT); - - /* - * Try link training at link gen specified by device tree property - * 'max-link-speed'. If this fails, iteratively train at lower gen. - */ - for (gen = pcie->link_gen; gen > 0; --gen) { - neg_gen = advk_pcie_train_at_gen(pcie, gen); - if (neg_gen > 0) - break; - } - - if (neg_gen < 0) - goto err; - - /* - * After successful training if negotiated gen is lower than requested, - * train again on negotiated gen. This solves some stability issues for - * some buggy gen1 cards. + * fundamental reset. As required by PCI Express spec (PCI Express + * Base Specification, REV. 4.0 PCI Express, February 19 2014, 6.6.1 + * Conventional Reset) a delay for at least 100ms after such a reset + * before sending a Configuration Request to the device is needed. + * So wait until PCIe link is up. Function advk_pcie_wait_for_link() + * waits for link at least 900ms. */ - if (neg_gen < gen) { - gen = neg_gen; - neg_gen = advk_pcie_train_at_gen(pcie, gen); - } - - if (neg_gen == gen) { - dev_info(dev, "link up at gen %i\n", gen); - return; - } - -err: - dev_err(dev, "link never came up\n"); + ret = advk_pcie_wait_for_link(pcie); + if (ret < 0) + dev_err(dev, "link never came up\n"); + else + dev_info(dev, "link up\n"); } static void advk_pcie_setup_hw(struct advk_pcie *pcie) From patchwork Thu May 6 15:31:19 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: 12242491 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 63CB2C433B4 for ; Thu, 6 May 2021 15:37:48 +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 BA173610A7 for ; Thu, 6 May 2021 15:37:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BA173610A7 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=yDgTAgfhxQgAITCHUed5A3xTNG1y7CEeOPOB3vWks8I=; b=LHB/0GTmYOGPcWxkMUbUCUCyI 1w+VN7Gs36fFjUJauG/VlvRVN6UXmZgrDGaMwMSbFfnN2CTJzwNMdInz7Co6kngXRBNg2HlVB22Ja TDgB4x9tgv3H6KI9T/YJbqlXeWMEmic/PcwCJ0Y8tCmiyz1bYoJMUWyPvKAB9f4ONjFgjTOIa7ENi /EY3IdyEL3i253GyDguycDfFJpyUspImm3xzF4gSpaHyucA+zWuwVyaS7v19rfjqYkw0EJXREGiD7 p5xaZCQ4NH+/VntFl9egpXWB7k5VfH1JyJ47wK/aqGo3fIOB7gQcHVCme3fU4T5pZ2WEwptL5xo5c j7sGoho0g==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1leg2n-004b9P-Ty; Thu, 06 May 2021 15:36:06 +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 1lefzj-004a43-4b for linux-arm-kernel@desiato.infradead.org; Thu, 06 May 2021 15:32:55 +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=a7oAqRLBBduyA4zBl/G9dUcUcITaSsmHtoA3f2FyUbo=; b=sW/Lg2tKkydo74m3UEcNdPIe5r zo1YdvyBy+8knT+QE5AK3Ny8kixDSWQ60O3pmaG7QIOV82oF09y14R/lFF2ApDcumuXBBDUE5jV2h WnEkDdiSOvIBhQLj/XYRmSSuxDSKtquU04gn44Le+udYBDUrGJQu5jF8Lj6VNzL6bgTcGUceonLxr j1D8DxUSqPUSAc3ohSEaSf4Y47nPr5RYKX1GQBD5mDFRPdPndMDlkhydEDFmWS3Gn+8+gRXdHDHGT 9WEpfv4lWQn3zlQvyQa4m661G3zsex4dq+e8LzMesCT7FsozCBYsv5ZmbdF2WKmWWq2FJSaRlTGJK 4T5uAADg==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lefzf-0069hb-7p for linux-arm-kernel@lists.infradead.org; Thu, 06 May 2021 15:32:53 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id E7C16613F1; Thu, 6 May 2021 15:32:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620315168; bh=bSHnjsAOWAaXk6MagAsbXeDOrNG/Ncxs7ohUVA+0BuE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Lu3gn9NOUBT7/7SrdpU1mDws9aNot/XnGNu0fjUxvHANFgbHn4gXB8fYhrelVusFa 1pEA5vHqN+9XcnaiySPOaNU+e9WaaJj/ga7If4f9jXUIYoez1bWWqo1DG0Yw99juHu P6c2SRhEVglPp83VITcK2MHrHkQvd6cLq6/sGYap+959HFAkG/XsoFc37e1q5JHJkE LBrqmtWlKbQYhiZhiiO8IhGvDrhxHe2jJXz23Ja6ehS+9TeOoSJxu/1HACsLWpPwL3 dMDk2old8ySWch484OOCcBMyF62Q+wXpCKSGl60tCNnu1w7P9R+i1T0QekDJNj1Xag UOHo8CjY/1SXw== Received: by pali.im (Postfix) id 50B861206; Thu, 6 May 2021 17:32:46 +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 08/42] PCI: Add PCI_EXP_DEVCTL_PAYLOAD_* macros Date: Thu, 6 May 2021 17:31:19 +0200 Message-Id: <20210506153153.30454-9-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_083251_385264_2F3423AF X-CRM114-Status: UNSURE ( 8.81 ) X-CRM114-Notice: Please train this message. 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 Define a macro PCI_EXP_DEVCTL_PAYLOAD_* for every possible Max Payload Size in linux/pci_regs.h, in the same style as PCI_EXP_DEVCTL_READRQ_*. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún --- include/uapi/linux/pci_regs.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/uapi/linux/pci_regs.h b/include/uapi/linux/pci_regs.h index e709ae8235e7..ff6ccbc6efe9 100644 --- a/include/uapi/linux/pci_regs.h +++ b/include/uapi/linux/pci_regs.h @@ -504,6 +504,12 @@ #define PCI_EXP_DEVCTL_URRE 0x0008 /* Unsupported Request Reporting En. */ #define PCI_EXP_DEVCTL_RELAX_EN 0x0010 /* Enable relaxed ordering */ #define PCI_EXP_DEVCTL_PAYLOAD 0x00e0 /* Max_Payload_Size */ +#define PCI_EXP_DEVCTL_PAYLOAD_128B 0x0000 /* 128 Bytes */ +#define PCI_EXP_DEVCTL_PAYLOAD_256B 0x0020 /* 256 Bytes */ +#define PCI_EXP_DEVCTL_PAYLOAD_512B 0x0040 /* 512 Bytes */ +#define PCI_EXP_DEVCTL_PAYLOAD_1024B 0x0060 /* 1024 Bytes */ +#define PCI_EXP_DEVCTL_PAYLOAD_2048B 0x0080 /* 2048 Bytes */ +#define PCI_EXP_DEVCTL_PAYLOAD_4096B 0x00a0 /* 4096 Bytes */ #define PCI_EXP_DEVCTL_EXT_TAG 0x0100 /* Extended Tag Field Enable */ #define PCI_EXP_DEVCTL_PHANTOM 0x0200 /* Phantom Functions Enable */ #define PCI_EXP_DEVCTL_AUX_PME 0x0400 /* Auxiliary Power PM Enable */ From patchwork Thu May 6 15:31:20 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: 12242579 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 4A721C433B4 for ; Thu, 6 May 2021 15:38:04 +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 C78C5610A1 for ; Thu, 6 May 2021 15:38:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C78C5610A1 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=Q0F74lVRLDh7fYneuoYAIG+Ul2yAID3/JqNETWh0wBQ=; b=JXwcPL1wSlBW8lnSaJcn4/7hA g7vbSq55ApcAo5YBouznZjvu/f+3NI0ZKkrOroVToBpkEi0/fzFYeZ4WcvPBOoNZJXxS0DAF7frxx tZ7uOqjo8mpeTBTC21ylHLf/OrSsALIT4I3e8f9Wvujx7P5cOsR64ef4KIQU5xwunONvk689YBc+T hFxE6DxleAshAVyCmmqLMnF5Teic+gyzrzl7RWSUM2VAZUBlXULP8LMrsNYtJQPY+r6br/1i6seKD 0uU4vQsUZ1pdYFuQ2qqJSwcLoGnLrMhrjxmy5oll7YGrnS8uMzWMDGZ3FKivFrOvoWLE/Z/kEsSmd KoJJJnakQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1leg3A-004bHd-Ni; Thu, 06 May 2021 15:36:28 +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 1lefzj-004a4J-Dj for linux-arm-kernel@desiato.infradead.org; Thu, 06 May 2021 15:32:55 +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=KQv4wWaGTMgReekL3lhCKOxcCkvUXbzNA+I0qZY8+Cw=; b=g5f0vfur1S361yCjDMNiYp4IAd X2hulA8M8Tjsy4vq9v8pL76/sfvUBFy/7rHgRdp1ncXitYFB+7cOjlFGczgU0swLOIIKGg8MzGl6H HKqtixGrDGZBpVjZst9e0nT7zBx0XNnkiJHgqT69cc261tD6S5VTCex0p0REfGokHvVNbGzLoSWwB DZGMUU/mIQTxBSavIGWp+gvu4Ur+9978Q4InTxmOd2/Sh9WIU3eWE21kHbfUU6/jKpT2MqvKHUuJj 9sIvIrV9NYIw+i7rjuLeKS7591TedEQZm1yihTL4qgDp8MPUgCzRu+ThEnk79s6Xa+a9LY+10kVOh 4rtARMrg==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lefzf-0069ha-7n for linux-arm-kernel@lists.infradead.org; Thu, 06 May 2021 15:32:54 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id EA209613F5; Thu, 6 May 2021 15:32:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620315168; bh=u1gZ4iCJ8EZuBq5+caF8WVSL+jyHUTpCgbqmTBAr8V8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oFxyk95u1LyOsMCxTvvj4v2FldyAmFLbYC+G5ZQUrf/8Oy6C4dBjQRshqVOcaJpa1 klQB3MKtwfzwXlRdVNPPoaWwfgzwpSAw4G70CyI2iDJnlcoe2+6b6eka574kPB8pzV Xx72qrVdMlzTcxcPycxRnXnPTk2Fc5s4V/MbLbQ7qEDTORl+/KEMs26dWYrfoXnds2 o72XlXW3fgi4p5CgxtAMtsYDOYuadBgvTpKNk39zm+GbdPz/QhsilUYN7hLp9J6nDD CKd2cu5Ch49OZbOAbRfSSVDxFSW2ifiT77d9s1eVsc2jmqLm3337CyRns3bRN1MZgX 0V1+ETSGO/hVg== Received: by pali.im (Postfix) id 819311208; Thu, 6 May 2021 17:32:46 +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 09/42] PCI: aardvark: Fix PCIe Max Payload Size setting Date: Thu, 6 May 2021 17:31:20 +0200 Message-Id: <20210506153153.30454-10-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_083251_393800_7BF03C5F X-CRM114-Status: GOOD ( 10.45 ) 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 Change PCIe Max Payload Size setting in PCIe Device Control register to 512 bytes to align with PCIe Link Initialization sequence as defined in Marvell Armada 3700 Functional Specification. According to the specification, maximal Max Payload Size supported by this device is 512 bytes. Without this kernel prints suspicious line: pci 0000:01:00.0: Upstream bridge's Max Payload Size set to 256 (was 16384, max 512) With this change it changes to: pci 0000:01:00.0: Upstream bridge's Max Payload Size set to 256 (was 512, max 512) Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Cc: stable@vger.kernel.org --- drivers/pci/controller/pci-aardvark.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index edeacd95297e..873efd79fffb 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -351,8 +351,9 @@ static void advk_pcie_setup_hw(struct advk_pcie *pcie) reg = advk_readl(pcie, PCIE_CORE_PCIEXP_CAP + PCI_EXP_DEVCTL); reg &= ~PCI_EXP_DEVCTL_RELAX_EN; reg &= ~PCI_EXP_DEVCTL_NOSNOOP_EN; + reg &= ~PCI_EXP_DEVCTL_PAYLOAD; reg &= ~PCI_EXP_DEVCTL_READRQ; - reg |= PCI_EXP_DEVCTL_PAYLOAD; /* Set max payload size */ + reg |= PCI_EXP_DEVCTL_PAYLOAD_512B; reg |= PCI_EXP_DEVCTL_READRQ_512B; advk_writel(pcie, reg, PCIE_CORE_PCIEXP_CAP + PCI_EXP_DEVCTL); From patchwork Thu May 6 15:31:21 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: 12242587 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 02872C433ED for ; Thu, 6 May 2021 15:39:53 +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 5405A610A1 for ; Thu, 6 May 2021 15:39:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5405A610A1 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=p9cz5a/+pcFT5eWX/Sqshio366G3DdHq197APoOkw/M=; b=i/15Qaf6Eq3baA6pLrNSjmmhd 0t0wKY1B1poIf4GQ6Ef/ohc11BVR3Ss8bgBP1SzcWCMi5xFzgFbqEJfnr9di3Iwqzt8iaIVHiXK0X LV8sf3puMg0ZDZLsXKqF8jshV27uKYNEV3KyroB6Zv/K2DNXnxp7rko8onhREY7h0oo2IPCDiEOOC 6URQq29NIv2F+Nd33Oz/BN2SbCAsHlIRrwfTowlzOxSj8kXi7dJjJfS4vw6ZLy3ABkSn2EcH17smo R4bqne0O7YSMflOlbk6LhO1FgT0X6lqSWuHdeeOalA9EPN8E3EHyOySur0n/8ux3BXZQCLkTqJpz0 ixJK6fVLA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1leg52-004bzC-BM; Thu, 06 May 2021 15:38:24 +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 1lefzm-004a5M-5D for linux-arm-kernel@desiato.infradead.org; Thu, 06 May 2021 15:32:58 +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=MhZzT97IOpdui7FFoLPzHHDpbH2IE8lbrMqna+8xIZ4=; b=AR35O8Ndtv25ZyGQDph5Y/YxJP 0VlMCAqOvOwKg9/9S51XXPfA3Lcv0bTW9gG05G/IsY+0+KwMKYT+Dc1t0swFVI+q5zjVxeak856ul /wSMkMpOKeFMuavQ/+GJYOVaUeQckGUzcUwNhBhDCTnTEToSkuaC7+yFs7pQJpcO/Pn1b/8h/0D0X BPOo/106gf7nq+fdMnwLl0B0FYgXGjFJ/z385OuR+wmIm9Kw0VS747GYvCPbfl+TGGyiaREGI89dr 2CyLC2e35BdLYeZgQaUgisHVWj8KPoqZ66yWzpSfy1dTLpiybWuJQNRNPYeXQDEQ6B3BI55qFiu8i bR0Cw5og==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lefzg-0069ga-Qe for linux-arm-kernel@lists.infradead.org; Thu, 06 May 2021 15:32:56 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 88BD66141E; Thu, 6 May 2021 15:32:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620315169; bh=1Bwgi38dM/1NWEIAUJl5SKScRp/ehwbz7KhEc+qYX7U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ei9TKzb/i6/uMehaFPV4MKb3I9fcfI+XdKOhmrmDjnOnNWFoh/BuD9ptcwMLDbtNU bYNDyfeqAN1UBuzqRoKRpWIl56t/SMCSpCHVUEGSS+VbWQqnY/HRwTS50SoUl4yt0R +DsmqLJKpAnoEHdviNqIbqC63IIownNfTvU+xkjBbozXMqwXVpAt8LGE0SHaW5Fsm2 4rtonbnHT7txSHMFc5k3pfYc8ud70LLniC1RZKky/ssw1BqJCvJYSXsUoIbqcuBVMn GmqWQcM/u7AsjErRp+9NpZtwVnm+TQzN0aug3LXYIgZOH3Vehdza5QeTQuU6dWJgcH 6+g9E9q4j33eA== Received: by pali.im (Postfix) id C8C921211; Thu, 6 May 2021 17:32:46 +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 10/42] PCI: aardvark: Implement workaround for the readback value of VEND_ID Date: Thu, 6 May 2021 17:31:21 +0200 Message-Id: <20210506153153.30454-11-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_083252_948137_3BF4EEB7 X-CRM114-Status: GOOD ( 11.86 ) 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 Marvell Armada 3700 Functional Errata, Guidelines, and Restrictions document describes in erratum 4.1 PCIe value of vendor ID (Ref #: 243): The readback value of VEND_ID (RD0070000h [15:0]) is 1B4Bh, while it should read 11ABh. The firmware can write the correct value, 11ABh, through VEND_ID (RD0076044h [15:0]). Implement this workaround in aardvark driver for both PCI vendor id and PCI subsystem vendor id. This change affects and fixes PCI vendor id of emulated PCIe root bridge. After this change emulated PCIe root bridge has correct vendor id. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Fixes: 8a3ebd8de328 ("PCI: aardvark: Implement emulated root PCI bridge config space") Cc: stable@vger.kernel.org --- drivers/pci/controller/pci-aardvark.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index 873efd79fffb..cd4b427d7692 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -126,6 +126,7 @@ #define LTSSM_MASK 0x3f #define LTSSM_L0 0x10 #define RC_BAR_CONFIG 0x300 +#define VENDOR_ID_REG (LMI_BASE_ADDR + 0x44) /* PCIe core controller registers */ #define CTRL_CORE_BASE_ADDR 0x18000 @@ -340,6 +341,16 @@ static void advk_pcie_setup_hw(struct advk_pcie *pcie) reg |= (IS_RC_MSK << IS_RC_SHIFT); advk_writel(pcie, reg, PCIE_CORE_CTRL0_REG); + /* + * Replace incorrect PCI vendor id value 0x1b4b by correct value 0x11ab. + * VENDOR_ID_REG contains vendor id in low 16 bits and subsystem vendor + * id in high 16 bits. Updating this register changes readback value of + * read-only vendor id bits in PCIE_CORE_DEV_ID_REG register. Workaround + * for erratum 4.1: "The value of device and vendor ID is incorrect". + */ + reg = (PCI_VENDOR_ID_MARVELL << 16) | PCI_VENDOR_ID_MARVELL; + advk_writel(pcie, reg, VENDOR_ID_REG); + /* Set Advanced Error Capabilities and Control PF0 register */ reg = PCIE_CORE_ERR_CAPCTL_ECRC_CHK_TX | PCIE_CORE_ERR_CAPCTL_ECRC_CHK_TX_EN | From patchwork Thu May 6 15:31:22 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: 12242593 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 C9D71C433B4 for ; Thu, 6 May 2021 15:41:51 +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 4E351610A1 for ; Thu, 6 May 2021 15:41:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4E351610A1 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=h5idPUV/WKlU+pBYdMKsSunkfTkdySjyqAb6hNyLK1g=; b=G3fZOw0WJdMDgOBig8YX0uk8I 8kiFiQvmk9x4MZChTqNp/e54bnoQfhOQ3tWWAwzIPF6l0SBlTaQPi9r5zYAr9/On7HLbfuijmj0Jv zj2JtxcpX3Z6ZXzXQBH5JcbmatPvocXLINeeGzEMfGLa1kJsF5aQNZ3g7vmxFgJbYlDkhM8JlJdNK QcBVeqS1ZN5ZQuvYtkxxo3M462lavCIhGyfazTcbqsun6g/zd2J5CGRndFSCq0Mam6AW9yxo1MtBQ dkVGdpy3YM88b8KlRpGn/zsvCk2mQttpcv0QwjbQRWAMfF01qVzYTRQ60bgtkhsuIiMHNd7nAuqId mBtsG5D4A==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1leg6W-004cWR-8F; Thu, 06 May 2021 15:39:56 +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 1lefzn-004a69-BV for linux-arm-kernel@desiato.infradead.org; Thu, 06 May 2021 15:32:59 +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=RGBE12MjbTz6qgUS0Xh2ISOBDy/eUXLR/yLc38jRxNk=; b=EJEh63jn47uwKw2Hw/x1ehnpEh 3wGDFSe9EYpq+01GLbo+6wg+A8K6zeo+DHAq+hFVZ3rQMNqvDIcylBCZypsxmRxagiZOw/cWNUHgj mJjtNhLwgcX/gOfaC/rQ4Ln8DVtC0IOBaO5JkR8N7qCM/RqgeKbsmZHokWgN6l1ykwcceqKZhIU3V mtTZwRle+BC2wNC/Ck20pG00t5zJvI/MufxVY/Xqgcm3OBaRrf8u7ZUW6EqbUpBs8RV3YZRZ9L+kh xCk7PBqvDEqFAiHPr6b5QMyzdstr2hLUwTCcKxme3KEC7aQKXB4oCkfBDG9p1RNXSzPC3FDLRKChX sxLDkwlA==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lefzh-0069gb-4y for linux-arm-kernel@lists.infradead.org; Thu, 06 May 2021 15:32:58 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id BD95361432; Thu, 6 May 2021 15:32:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620315169; bh=KvLt43DnzadPpOqnRUdrwzI2CtNEyAwAsOi6GeKBWRI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WU2IKx3lHHR8r6UTGjfQHnZIfj7luYJDfEbfeuvSbQdMku7iYZMM/+feR26Wp2Nox W8Q0rAK3DLiHWr6Kf17dKe10z4NuezdTK16Cz4d2ij3I8M+B/VsL+UE31ZJ+UyyJax AQxL5VjaYeB9TYdmSWvSHxa6UpyBjZxSYv8HiW465hYI8dltXgWQGE2fLViAJtVC+N Fym7Uq+SYDhtbzhL7MGy+PUXdNoLOOZBn/4asHNb4YG3o+H/Wr8+lA3pK4Eh07ejz4 IU5EcWTCI4XKJvwbdOZTVEEPka3J0AesHrqv9agNAG3yfdla8W0R+kr+2l/KlLd3Bb qGTCqi1NeK8BQ== Received: by pali.im (Postfix) id 1D0971250; Thu, 6 May 2021 17:32:47 +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 11/42] PCI: aardvark: Do not touch status bits of masked interrupts in interrupt handler Date: Thu, 6 May 2021 17:31:22 +0200 Message-Id: <20210506153153.30454-12-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_083253_259978_F3A0486A X-CRM114-Status: UNSURE ( 9.82 ) X-CRM114-Notice: Please train this message. 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 It is incorrect to clear status bits of masked interrupts. The aardvark driver clears all status interrupt bits when no unmasked status bit was set. When some unmasked bit was set then masked bits were not cleared. Fix this so that masked bits are never cleared. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Cc: stable@vger.kernel.org --- drivers/pci/controller/pci-aardvark.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index cd4b427d7692..362faddae935 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -1090,11 +1090,8 @@ static void advk_pcie_handle_int(struct advk_pcie *pcie) isr1_mask = advk_readl(pcie, PCIE_ISR1_MASK_REG); isr1_status = isr1_val & ((~isr1_mask) & PCIE_ISR1_ALL_MASK); - if (!isr0_status && !isr1_status) { - advk_writel(pcie, isr0_val, PCIE_ISR0_REG); - advk_writel(pcie, isr1_val, PCIE_ISR1_REG); + if (!isr0_status && !isr1_status) return; - } /* Process MSI interrupts */ if (isr0_status & PCIE_ISR0_MSI_INT_PENDING) From patchwork Thu May 6 15:31:23 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: 12242581 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=-14.9 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,UNWANTED_LANGUAGE_BODY,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 37EE2C433ED for ; Thu, 6 May 2021 15:38:21 +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 ED731610A1 for ; Thu, 6 May 2021 15:38:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ED731610A1 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=dIJgkBDpnmqgLbET3stLAfJY0smI1lvYZquwQ6pt0RQ=; b=SSro6+98cnuYvyxsILcm+rMDH +nb8qkWvu3WC4Utz+AzeOrIFkUT0FLwyuWt3rzpUCis4ShzN7+VfZXWz0fYKJeGbUNvfYMFbh03t2 nILr94xNd2hRNJl5A5REyWxrcr7WkmSD4MRm+O/o+rZIUKvoQHM2A9ZTQu6WiUu4joA+NzRI2/UmJ JuotiMZwEA2r53Brs0DEUhEaygxMVUAhfSbP8CnBRs7xRtA+jcdvi/A4Y2lUI3rCpWcTXEFEFU3mR um/5M2nSzZpS/E/kS4kN8kDszfi1h3o3P6Ydq8sWYRvBk07AVJ/yUPdMy647Zkx7E7sdnLs+WNQyV yJAZ60ZHg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1leg3g-004bSW-50; Thu, 06 May 2021 15:37:00 +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 1lefzj-004a4Q-Pq for linux-arm-kernel@desiato.infradead.org; Thu, 06 May 2021 15:32:56 +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=Jp+mrUc/wGQaU+9p4JknmDbra4B73k7NjEXegSHf2ng=; b=OOU4H4Fm8XgkJfD0NDIfJYl9jN TvtRKaE35qiAReqi4mGMAo72DlP9VqjzgMUzGJ7bh7oQ1HOOcvakyKbsaqquaPo+EHjU2Av2n9son Ut6pkhq9fPC8uY1BF1+zB+m8l3gFI40kzrlcVKnCI3AOdbToIAloeIYk/5b5FsoSBmnirg8RxXiQF X5/yhcPckQMr64epjkf/0ndqpGsWXbQtqtdiOpEymcmpK8M11tvdgMWM/MDKL3t+X+dQzCu3ersh4 sqtb2T4kyg/S14tjDkEOCSCUohNhftEo+9uqc8L26/xhN9MxCo588NmqLpj/Mda4DZO3D8RhAG57E 5LTXcjrw==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lefzf-0069hi-Hp for linux-arm-kernel@lists.infradead.org; Thu, 06 May 2021 15:32:54 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5090E6140C; Thu, 6 May 2021 15:32:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620315168; bh=MTTPn1JuU+d3/eQ+Q7Ef/sfL+sWMGgOEsQXP78mZRIE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kslpnpwNQOUTAzurn5Gss4CnU3SYYP2rwxKtVz9ioqugqtuiH4OXS6sIpxE+JI/xf LMd1ClbrzJlXfcBZYlNaJT0aZlYZSHqjj2X0d2yP9u7/ZF6IL8snkqS76vrVf1fPR+ A5+D8ByYQDrCxORx+Zh22+kxRZzHVGvUhJJv+69M/fjDBpGJk1eFGEwQribgq00DDc vNcuaf3WCZTK4+OskzWUWLSnQiD6tTuGrz4y0U1NgR80opzxy6/HPeATRo4SYTazDW NoFjAcNtH5oYDkBXP35FvAzMFcGCDDCKCwI3mloPLkd2dUeWnUBnCoqknAxPJgjKZ4 bvuh+Ckpfi5fA== Received: by pali.im (Postfix) id 57DF8129A; Thu, 6 May 2021 17:32:47 +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 12/42] PCI: aardvark: Check for virq mapping when processing INTx IRQ Date: Thu, 6 May 2021 17:31:23 +0200 Message-Id: <20210506153153.30454-13-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_083251_660148_E32CCA5B X-CRM114-Status: GOOD ( 10.79 ) 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 It is possible that we receive spurious INTx interrupt. So add needed check before calling generic_handle_irq() function. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Cc: stable@vger.kernel.org --- drivers/pci/controller/pci-aardvark.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index 362faddae935..e7089db11f79 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -1106,7 +1106,10 @@ static void advk_pcie_handle_int(struct advk_pcie *pcie) PCIE_ISR1_REG); virq = irq_find_mapping(pcie->irq_domain, i); - generic_handle_irq(virq); + if (virq) + generic_handle_irq(virq); + else + dev_err(&pcie->pdev->dev, "unexpected INT%c IRQ\n", (char)i+'A'); } } From patchwork Thu May 6 15:31:24 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: 12242583 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 F3578C433ED for ; Thu, 6 May 2021 15:38:42 +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 B8A5061040 for ; Thu, 6 May 2021 15:38:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B8A5061040 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=DpS8dVdIlN/cbHwssAvKIWZqFIHoQjuZ6SSrprKPbMU=; b=W1pxA5V3Nc+brwNr0ETBqfZ/E O7DwVLyWp5Zh0NwWbBmaFqzZtnn3MAKBv1E8jgip32qTKRJOE3vVrvbcFD8F6tTSKGHP5LLS6XD6A kbe5ftnbpXEdCu2wWlP5jsQ+KySGmIvWPVSCwzCQfBtIRGKedqAhL8jumNLgMuM8QBASO6wOSY2fI 3eo4AgKwYRHt1LaO+KwIsO9k7ltjWiMCLpzALpVWOlv5/gYxjb0/t7+xamvfTCU4QrWuqAaY5OXzh Wyl3xabqVoQiywtIn4mGt1DIhO34UF2hXTHUpfu6Ta58ibvw0RvgmqeRzzFkwjx8AObnbV2/pUEmv 5qYfqBcpQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1leg44-004bbH-DU; Thu, 06 May 2021 15:37:25 +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 1lefzk-004a4l-Qk for linux-arm-kernel@desiato.infradead.org; Thu, 06 May 2021 15:32:57 +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=zyIZ05iLVarjNN0Q4XpWlM1rw5tO7oywhTznroxrgP4=; b=OlN3C3vbwzF9Vj12aSDfhynzUK joqVOzhni/sDEI75X5mEaDekkzUyLRrqb1oKk9L6K3yMScRg3s8y/Tl1XA1hNiuTv2c0BBjPouE9o lZzWPqUyzUOB+PKdxqsvuRvTuXwUDrt3zDgN0muulCP/PzPtwfOUVeiqAFLoMRO51vPFKq+EO/a+t BDP7uPBo+P5Mbj419xQa39OvgdEAQnx5UXnOn3GesmF0u7ZDigPW0GnNqPzaMSP78vuAQulGC6XfV fZuzm9iD6tA1MUMefEc7I9tO9FB7f0Zy0aeVCIISxYTYE7XYCOa5jGVelwzMBKLfQ3phaI3HQGuV7 LD0KpRKw==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lefzf-0069iB-Qy for linux-arm-kernel@lists.infradead.org; Thu, 06 May 2021 15:32:55 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5713F61410; Thu, 6 May 2021 15:32:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620315168; bh=MpxK0wPuDd30O+SuegHQ8xNOoI7IRN6DCqL2Bjbkn/w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bVnlrkf0qQBKjo9NL9mPkckQaCA36//4P2zgYDAMHIcMamihuIjFOg1guPhm5e1il ajyTVmIF7L6OsnFhRPAg/LYPZKkh9ZA4+8kWS4A25Fws3YkbLqtM2mxF5MBZ+cwPUt OnGX/U5yadN3/baS288c05N1xgb2qSDlyJ/3+jUDP0hCznirMRB6jJ7PR1n2KdgPB5 4iJQ+oK00Ub/OqmY7pNUFmTq7+kJhQzWj3qi1apH6tHomMsJMaL/+coOkoqReevPTI rG6sfP9b+dBv03GcELuTxDgUngfuiORzWVreR1h4fPPz3b0IhO9esfMqxXtkY1/mRW o5oYpgG+4stpg== Received: by pali.im (Postfix) id B2E11732; Thu, 6 May 2021 17:32:47 +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 13/42] PCI: aardvark: Remove irq_mask_ack callback for INTx interrupts Date: Thu, 6 May 2021 17:31:24 +0200 Message-Id: <20210506153153.30454-14-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_083251_986793_3655D547 X-CRM114-Status: UNSURE ( 9.78 ) X-CRM114-Notice: Please train this message. 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 Callback for irq_mask_ack is the same as for irq_mask. As there is no special handling for irq_ack, there is no need to define irq_mask_ack too. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Acked-by: Marc Zyngier --- drivers/pci/controller/pci-aardvark.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index e7089db11f79..2aced8c9ae9f 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -1032,7 +1032,6 @@ static int advk_pcie_init_irq_domain(struct advk_pcie *pcie) } irq_chip->irq_mask = advk_pcie_irq_mask; - irq_chip->irq_mask_ack = advk_pcie_irq_mask; irq_chip->irq_unmask = advk_pcie_irq_unmask; pcie->irq_domain = From patchwork Thu May 6 15:31:25 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: 12242611 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 E29C8C433B4 for ; Thu, 6 May 2021 15:43:24 +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 963DE610A1 for ; Thu, 6 May 2021 15:43:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 963DE610A1 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=JhUomTRczLPle3+JK2s/EXk08kR65c5kyHedjhh0W0U=; b=gmqbFBx1rxlmr50PkscGxxKil 6svAJBzaGnmVc4SeEgBWIo5egYRa9TVLYnpvWzLbF1FovIPHpzKN4k4pRpLE9k+3GR0/a4cxJqvea 2MlMVg4yK0KSko7DbVMzsZ8aH7bQ1u3Prjf6uoTAr2RuYbCGpHHgq+xsF+MWDzQrPlUDHJ1wBMrDx hQBGqco2fU+91g+gjKrkdXjS7IoJQ0SdEnMuiEcKBnmPJvXw6n8GHHeO7cI37mL3k/tuwLk0sBU0l EhPytEAkv0+ZxCUiY0LXfo7cM+m789gsDYA0bgCqnPf+oALt/miu+IReDJDhOfjdu95kmlspSBXPQ DtHu1CPiw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1leg8P-004dCo-HS; Thu, 06 May 2021 15:41:54 +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 1lefzn-004a6V-Ml for linux-arm-kernel@desiato.infradead.org; Thu, 06 May 2021 15:32:59 +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=RUvMIwhQ4SLMfqzAwd0TBgkljgpO55+PmA4zMgZxlK0=; b=iMdtMDyRFrbcEaYsy9udTy2RYy NdW1O4ptemMUrS5ARvyU3pFGFOlRLo0Y2B6wky83lAMHX0QS0PM09REKJhEXM7wdRdiu2tIcG2Rgu YdVP3L3raH77ENbok9BQH9IVI5fYr72sgEdqnvKgeV1nvsc5xvoTxgpjS7M9pVgWXcBoSTm2J9ifU 83eZZya3jR3yMB+FgawWO61gDM4g+TmQXMv2n+8tZwtQ5VQKrP3Sz2XY2P30LZ+7corkLGRHEBgs8 PwD2I2bAfZD+UUVx21Tp5b7gEZyuoGQ3mMONKPwK3yGaWt++PsrlVnKgvFLLcq85ZPiNJuUXJuGGC l/GLqm7g==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lefzh-0069kO-Ei for linux-arm-kernel@lists.infradead.org; Thu, 06 May 2021 15:32:58 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0797B6144C; Thu, 6 May 2021 15:32:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620315170; bh=oZBRW1urfkXXBJqUlknYvRg4n9R+PwWJMKIKp7WdGLI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TLRgo/bzKb6pxtGTiIRV7bR7HxY1pDTOde57U9sQ9EiLklW/kbKVQigCECUOkCaM8 Z4qvB/d7r62YiXJCMQWgOgu+tiYWrFcHNaEFQsJLeYRcyL2ZgqXIO1TLvqzJZ53cXN 1Y7urItb0D0uSMcraCw8WVLjNE2uK+lizbApLtsMML/6icHGrDvI892SKSEfrqn0Nc U8RZa/EchOaKiMC9W/PxLIwzexzqRfaTub66/MaImmI/ruV3CJWoATOMRFr0V9jYG9 nbwW9S+CQFXtvJ9ZtjrGpJS4JxsVmGE8IXPT0Qq6kDnac2nyiA2l+XUcCiR4Xie9BV JJYwk8Yf5MSzQ== Received: by pali.im (Postfix) id 2957489A; Thu, 6 May 2021 17:32:48 +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 14/42] PCI: aardvark: Don't mask irq when mapping Date: Thu, 6 May 2021 17:31:25 +0200 Message-Id: <20210506153153.30454-15-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_083253_547425_47606519 X-CRM114-Status: UNSURE ( 9.66 ) X-CRM114-Notice: Please train this message. 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 By default, all Legacy INTx interrupts are masked, so there is no need to mask this interrupt during irq_map callback. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún --- drivers/pci/controller/pci-aardvark.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index 2aced8c9ae9f..08f1157e1c5e 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -940,7 +940,6 @@ static int advk_pcie_irq_map(struct irq_domain *h, { struct advk_pcie *pcie = h->host_data; - advk_pcie_irq_mask(irq_get_irq_data(virq)); irq_set_status_flags(virq, IRQ_LEVEL); irq_set_chip_and_handler(virq, &pcie->irq_chip, handle_level_irq); From patchwork Thu May 6 15:31:26 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: 12242585 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 A2704C433B4 for ; Thu, 6 May 2021 15:39:25 +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 56449610A1 for ; Thu, 6 May 2021 15:39:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 56449610A1 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=3oaK5jkexc0u/OTxYd/2yyR+eISvbWGzzDD3kl/WkIY=; b=NFmalN2yytTYnabR2gOVzfJRe m6Sev/mAGkAKzGRMSSFJp8dOWw7QuGoJDNfdQweFmNYNFP3snmyiOhgd1ct6bV88SwPqTkQQGMZD4 TMJsZMzl+b4Kze1eueZE+93TIJ8/kuqqVKoxd3s55yC6tF5C6uZsovZOImfarFiUi6uGo2q2rA4HI EAsJ/rngHOGt9U4np/bZL9nLfDzEDxE2yFWAKzO63HksoBraiZtjceuGWq3PEVdp7/BIzH+eNDlXW sQtlZkogpfrb9T5XuL1j/TQYovQMarYVeemD3b54g01jeWCYRLUFokpFGDBOxTmYVVE3LKKf+8tHH /FAz/3Wag==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1leg4X-004bm1-Ea; Thu, 06 May 2021 15:37:55 +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 1lefzl-004a58-RC for linux-arm-kernel@desiato.infradead.org; Thu, 06 May 2021 15:32:58 +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=/OJRZ1Bl7p7tGJShkPLHTGnIWIyLBhcE19DqCn8zrpw=; b=zfyg7EzRNWCw85Xf9Qku/BcQln NXk2SQF2+9tYl2l1QjT5lXAa+J1TEmLMOLyR0d3f+dXIIBtX3fMK5O2YaafMkR/ho6NRIR+3u/B3s rr+KmABTpAhUb77UVtEDd0StLJM39uI+yObL5/jFXnmr+fnINg5PXS7VURA1+IDlH+6vS1TP5XALZ A1oZLg21lVd3QheA6E5++o8eMVuc+uz0OiSc2W941lQjclBLxNyq9/+1iqLdMGKlMnUxum2F+IzgI Ejanl+kL8bK87d97bJoiJKqaGyb5oqWLsowGxbfslYGcSlme7SKcGDH4WIBQkIE9dfdrzLKgTITj7 CAdpzv2Q==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lefzf-0069iC-QZ for linux-arm-kernel@lists.infradead.org; Thu, 06 May 2021 15:32:56 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id C4FA4613EE; Thu, 6 May 2021 15:32:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620315168; bh=zoiVY2XI6nExpUKOXT9A0hPboS1rFrKCjUz6eR0Qm/M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iWR1wIeo72aTtyzz5OLdJt76iqVyuXbceGj5Q/uy61i57HtsZ+9M/68WFGLZVmVdL lP6mcXCe/m7gYGy7wPMO/0uGwUM3eWPvwFi8Bvvqo5kOYIN8n/2OFZr/yrF8ykeLf6 rFcq87GBCQzC7jqHlwRwGhQ9ejlGRq8hzt6BI9R9s2XCVZy+jBl78cTAgE2uiBsICa 9OPd4hsI5zUrA/P7U4JWDEpfku/xLArJrGEnRUIyysATpQ8hbiAkHJC/wWEGVqFqHQ 9X2W8YwGV4iKY0ApEIqMLY0vyw3jVWpXBwFGhgIg9MDP7m7JmkDOj/JOQxXg8O2Ys2 WDlvbGFWcNYlw== Received: by pali.im (Postfix) id 7BDF98A1; Thu, 6 May 2021 17:32:48 +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 15/42] PCI: aardvark: Change name of INTx irq_chip to advk-INT Date: Thu, 6 May 2021 17:31:26 +0200 Message-Id: <20210506153153.30454-16-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_083251_963751_CAB06C1D X-CRM114-Status: GOOD ( 10.87 ) 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 This name is visible in /proc/interrupts file and for better reading it should have at most 8 characters. Also there is no need to allocate this name dynamically, since there is only one PCIe controller on Armada 37xx. This aligns with how the MSI irq_chip in this driver names it's interrupt ("advk-MSI"). Signed-off-by: Pali Rohár Reviewed-by: Marek Behún --- drivers/pci/controller/pci-aardvark.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index 08f1157e1c5e..c50421af9d06 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -1022,14 +1022,7 @@ static int advk_pcie_init_irq_domain(struct advk_pcie *pcie) } irq_chip = &pcie->irq_chip; - - irq_chip->name = devm_kasprintf(dev, GFP_KERNEL, "%s-irq", - dev_name(dev)); - if (!irq_chip->name) { - ret = -ENOMEM; - goto out_put_node; - } - + irq_chip->name = "advk-INT"; irq_chip->irq_mask = advk_pcie_irq_mask; irq_chip->irq_unmask = advk_pcie_irq_unmask; From patchwork Thu May 6 15:31:27 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: 12242591 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 A3B8EC433ED for ; Thu, 6 May 2021 15:41:06 +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 263D161040 for ; Thu, 6 May 2021 15:41:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 263D161040 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=SnG1sOK5UgdtX0hdYycga+V+gbfADqjUO3kIvtWyIy0=; b=fh0S8nxaXKr1+TehuVRp1zduy ASJ5zvm0aILqeyhJ758Cl+NWBwmaGsJ3T47YugNj9EQNYu2l+JGv9E1s7ITwcBvHT6WgJFYS2Qj5J c1eXVOQaSLQtZqTw0iSXqIHPsRJm2psdREuuwXAC2kQk/xyz/A0/ccInr3nKHh2njGoHwC/xrEzRE 1voyfocpQzfyB7q7qi+qxHetg/uM4b4Yl/hcO+VIowxWGbyrxQ1W/bP107OElE/0h5ZTbjV9YAkVX S7FpaG+ebB5O6oKj1a2Vv5HbPietVvMn4UfFTA+BiYsqYuyzcsbB5zbsGQ+XLhpeSDNLtaZIbP7t0 uFoLY6LSQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1leg5z-004cKf-Qj; Thu, 06 May 2021 15:39:24 +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 1lefzm-004a5e-Ti for linux-arm-kernel@desiato.infradead.org; Thu, 06 May 2021 15:32:59 +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=isWSgWpy4VxIsl7WjbL3aV/x7lVqktXY2l5rzCrHqBs=; b=33Mxnec8KoTR+oH6d9EqwOeUHg Cwco0ptKyoqvsOUUzbCxR2rc7UgAYVtVv4Sgvr37tNLOYmePFUUam6k/9lb58dd0rYPn2+QQTumqo rref6VdjhaMZsyxbZM2nCEA427A1Qj7/bZneJiRLeRkMVI6/pj4hNboqcljIgzdZRdLbY0YFGl9wp FRAGL2OBapFxudcYZgonI2RvJ1Rj90/tjD+KsFI80D7gLKSX4TEHNXMk2Rc9fL+wgKeUOMXm17XLb p2h1fH5AetWWPEwe1boAPEI+1+86zG6I2DH9cnkAcXjLe3dt3mnV8yfhBgQRaEezrgKlAH/wAsH6y us/OW3rA==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lefzh-0069jn-0I for linux-arm-kernel@lists.infradead.org; Thu, 06 May 2021 15:32:57 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 15D12613E3; Thu, 6 May 2021 15:32:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620315169; bh=qGv5xT5gD11qmr1DVmxcsAYsbpUCl4ZOEgFpdd7GuZ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IcczHnvLIHF6Yfx/K/MGhuGZyKTj2egYnSsbv/FT+g6FvPAVLwvBljubTWSu0MLC/ 8cJ5tvUC4mbyvkJlm76qAUB8QGJ6/Eudcc3qTnBMBkv/HRuGb1c3DlG5vGWR1ludqo uLZDbsTHo8YXU9pMepGBdLgGHvji8yxuge/lIi57C24hDVnOadn9S0A2FtuiC67Tk7 H1nnRear0F2QjTLUDwPcBS7Dqd2hqNSIB8+N8z/Y2DAJxvJJDzU/2ZzOvglFPBvDt8 ouxkk52VzJ33d3sj67QQtdVtGTZmuXMyPAmLYGsv/VaFcJn/pbqrcsKjsberwgqd2w RuPj0zexOE0NQ== Received: by pali.im (Postfix) id C357A732; Thu, 6 May 2021 17:32:48 +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 16/42] PCI: aardvark: Remove unneeded goto Date: Thu, 6 May 2021 17:31:27 +0200 Message-Id: <20210506153153.30454-17-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_083253_115969_3E5FB554 X-CRM114-Status: GOOD ( 11.22 ) 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 Simplify advk_pcie_init_irq_domain() function. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún --- drivers/pci/controller/pci-aardvark.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index c50421af9d06..366d7480bc1b 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -1013,7 +1013,6 @@ static int advk_pcie_init_irq_domain(struct advk_pcie *pcie) struct device_node *node = dev->of_node; struct device_node *pcie_intc_node; struct irq_chip *irq_chip; - int ret = 0; pcie_intc_node = of_get_next_child(node, NULL); if (!pcie_intc_node) { @@ -1029,15 +1028,15 @@ static int advk_pcie_init_irq_domain(struct advk_pcie *pcie) pcie->irq_domain = irq_domain_add_linear(pcie_intc_node, PCI_NUM_INTX, &advk_pcie_irq_domain_ops, pcie); + + of_node_put(pcie_intc_node); + if (!pcie->irq_domain) { dev_err(dev, "Failed to get a INTx IRQ domain\n"); - ret = -ENOMEM; - goto out_put_node; + return -ENOMEM; } -out_put_node: - of_node_put(pcie_intc_node); - return ret; + return 0; } static void advk_pcie_remove_irq_domain(struct advk_pcie *pcie) From patchwork Thu May 6 15:31:28 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: 12242595 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 23580C433ED for ; Thu, 6 May 2021 15:42:23 +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 7FEAE6101A for ; Thu, 6 May 2021 15:42:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7FEAE6101A 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=h61LW2N4Ohb5BqMspQTMFToWKI98Cm33tQqwh4wxMZ8=; b=SMNWfpfV7bdDHIS/H984+S0ZD 5HR4bDIXo5Kipc/yYtBxqGZ4eNK1pzyFRaU/CXgabw3dWagUW4GX28dD4VuYX2hpcsmgVbCAsgKe4 S2IMCn1967qzYgqGRd02Kp21tK6yxNPONXpFDcZWMcbjGiAbe3/SrQ6W11E1J5QhRlWsOLCm4XbCA Fhmd145Is4cRvHB6kDCo12HMI2qGI58S64olxgPbu7PmzQi/p25Ca7twcFOyX1Mdl9LxkHOd8G//l rjyidr7CH4JKraR2H25nyjKGJFlHEAuN7zoNKMeNl2xnYIGtsMlTRaPT5hIbvz4Anx+OxTbgoJveU 9aMS+lZSA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1leg77-004cid-46; Thu, 06 May 2021 15:40:34 +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 1lefzn-004a5x-8M for linux-arm-kernel@desiato.infradead.org; Thu, 06 May 2021 15:32:59 +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=WCXCSMlLju+RVMt1dqMxOrA+GhhtjeZ2xOqd4EhD97U=; b=mZ5OExcgnrfzJVBI2es8H/TVOO MFEKwO1nXv8hg6v1PO8DCbnyhjh3plAbsuZQemVls5slmcfuOrQtDcjg5YWSxoZEHbQDp8vBOj0ug 1mdmeU0PRYp0Hwljqa+hXIYE9i7UZfgHljrjM0u2O46bbZVuOmm2zjJZMxqbVHUj+wKDX0Pn/ETtN P/sQwGiRP36EsEkOhzc3f+bYtxaxrFmofJl0U1O00poApI+/miDcKAjv1UCcfM4KnpA1PMk6lOqLz e7fs1ScQWtEM0fTXyQyOp7cbiqUU1CRl7B9xLW0nctfnmWcweoiaixSr6vxfGoPm8FNLLAj0fSXTw UoUl+B6Q==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lefzh-0069jp-1F for linux-arm-kernel@lists.infradead.org; Thu, 06 May 2021 15:32:57 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5AEF5613F6; Thu, 6 May 2021 15:32:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620315169; bh=yN1GVDsVClOczJBW/hcMrhTyF36UkgV7hMJV2qJoxrY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pxrXFrmgOLLG5cl31a3HZDuTj2XGD0N78K9/16eUsDSmLqb6edR911/rRpLPEtCKA NUdpDhPM0L4hVdUuTHkelRXUtS0myrC7wECtiYkKeKmZZwLJLGKQYMK/5qOIisBNKh 49hoh9odMpOUA6GnACS1dKV4kx50V4eDtoBo8wpSb1rxpT/fvESvS/zXQYlgdZpo9j AdVS62Rug9qBYXPZ2YzDcKcyuE7+7UHSmF2wJLBrjRE6KHOCU+Ul7VNl+SBby66YQP ellsp8wawVYmHN1+oySrX4HBSZox+iQ8y0NbOYFUaZ3AUEkg+T1efLtbRehf/zbSC9 m8tpKEYfSeKrg== Received: by pali.im (Postfix) id 120E5BF9; Thu, 6 May 2021 17:32:49 +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 17/42] PCI: aardvark: Fix support for MSI interrupts Date: Thu, 6 May 2021 17:31:28 +0200 Message-Id: <20210506153153.30454-18-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_083253_220800_C5D7229F X-CRM114-Status: GOOD ( 19.11 ) 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 MSI domain callback .alloc (implemented by advk_msi_irq_domain_alloc() function) should return zero on success. Returning non-zero value indicates failure. Fix return value of this function as in many cases it now returns failure while allocating IRQs. Aardvark hardware supports Multi-MSI and MSI_FLAG_MULTI_PCI_MSI is already set. But when allocating MSI interrupt numbers for Multi-MSI, they need to be properly aligned, otherwise endpoint devices send MSI interrupt with incorrect numbers. Fix this issue by using function bitmap_find_free_region() instead of bitmap_find_next_zero_area(). To ensure that aligned MSI interrupt numbers are used by endpoint devices, we cannot use Linux virtual irq numbers (as they are random and not properly aligned). So use hwirq numbers allocated by the function bitmap_find_free_region(), which are aligned. This needs an update in advk_msi_irq_compose_msi_msg() and advk_pcie_handle_msi() functions to do proper mapping between Linux virtual irq numbers and hwirq MSI inner domain numbers. Also the whole 16-bit MSI number is stored in the PCIE_MSI_PAYLOAD_REG register, not only lower 8 bits. Fix reading content of this register. This change fixes receiving MSI interrupts on Armada 3720 boards and allows using NVMe disks which use Multi-MSI feature with 3 interrupts. Without this change, NVMe disks just freeze booting Linux on Armada 3720 boards as linux nvme-core.c driver is waiting 60s for an interrupt. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Cc: stable@vger.kernel.org # f21a8b1b6837 ("PCI: aardvark: Move to MSI handling using generic MSI support") --- drivers/pci/controller/pci-aardvark.c | 32 ++++++++++++++++----------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index 366d7480bc1b..498810c00b6d 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -118,6 +118,7 @@ #define PCIE_MSI_STATUS_REG (CONTROL_BASE_ADDR + 0x58) #define PCIE_MSI_MASK_REG (CONTROL_BASE_ADDR + 0x5C) #define PCIE_MSI_PAYLOAD_REG (CONTROL_BASE_ADDR + 0x9C) +#define PCIE_MSI_DATA_MASK GENMASK(15, 0) /* LMI registers base address and register offsets */ #define LMI_BASE_ADDR 0x6000 @@ -861,7 +862,7 @@ static void advk_msi_irq_compose_msi_msg(struct irq_data *data, msg->address_lo = lower_32_bits(msi_msg); msg->address_hi = upper_32_bits(msi_msg); - msg->data = data->irq; + msg->data = data->hwirq; } static int advk_msi_set_affinity(struct irq_data *irq_data, @@ -878,15 +879,11 @@ static int advk_msi_irq_domain_alloc(struct irq_domain *domain, int hwirq, i; mutex_lock(&pcie->msi_used_lock); - hwirq = bitmap_find_next_zero_area(pcie->msi_used, MSI_IRQ_NUM, - 0, nr_irqs, 0); - if (hwirq >= MSI_IRQ_NUM) { - mutex_unlock(&pcie->msi_used_lock); - return -ENOSPC; - } - - bitmap_set(pcie->msi_used, hwirq, nr_irqs); + hwirq = bitmap_find_free_region(pcie->msi_used, MSI_IRQ_NUM, + order_base_2(nr_irqs)); mutex_unlock(&pcie->msi_used_lock); + if (hwirq < 0) + return -ENOSPC; for (i = 0; i < nr_irqs; i++) irq_domain_set_info(domain, virq + i, hwirq + i, @@ -894,7 +891,7 @@ static int advk_msi_irq_domain_alloc(struct irq_domain *domain, domain->host_data, handle_simple_irq, NULL, NULL); - return hwirq; + return 0; } static void advk_msi_irq_domain_free(struct irq_domain *domain, @@ -904,7 +901,7 @@ static void advk_msi_irq_domain_free(struct irq_domain *domain, struct advk_pcie *pcie = domain->host_data; mutex_lock(&pcie->msi_used_lock); - bitmap_clear(pcie->msi_used, d->hwirq, nr_irqs); + bitmap_release_region(pcie->msi_used, d->hwirq, order_base_2(nr_irqs)); mutex_unlock(&pcie->msi_used_lock); } @@ -1048,6 +1045,7 @@ static void advk_pcie_handle_msi(struct advk_pcie *pcie) { u32 msi_val, msi_mask, msi_status, msi_idx; u16 msi_data; + int virq; msi_mask = advk_readl(pcie, PCIE_MSI_MASK_REG); msi_val = advk_readl(pcie, PCIE_MSI_STATUS_REG); @@ -1057,9 +1055,17 @@ static void advk_pcie_handle_msi(struct advk_pcie *pcie) if (!(BIT(msi_idx) & msi_status)) continue; + /* + * msi_idx contains bits [4:0] of the msi_data and msi_data + * contains 16bit MSI interrupt number from MSI inner domain + */ advk_writel(pcie, BIT(msi_idx), PCIE_MSI_STATUS_REG); - msi_data = advk_readl(pcie, PCIE_MSI_PAYLOAD_REG) & 0xFF; - generic_handle_irq(msi_data); + msi_data = advk_readl(pcie, PCIE_MSI_PAYLOAD_REG) & PCIE_MSI_DATA_MASK; + virq = irq_find_mapping(pcie->msi_inner_domain, msi_data); + if (virq) + generic_handle_irq(virq); + else + dev_err(&pcie->pdev->dev, "unexpected MSI 0x%04hx\n", msi_data); } advk_writel(pcie, PCIE_ISR0_MSI_INT_PENDING, From patchwork Thu May 6 15:31:29 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: 12242597 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 D573EC433ED for ; Thu, 6 May 2021 15:42: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 5B590610A7 for ; Thu, 6 May 2021 15:42:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5B590610A7 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=3JfnG4xIYW+793Srv6DKWyr7DyvitWQ7k2j7yz+YKsk=; b=J/8SEgD4P3NIYtR/u57DBVUxW cDzTeQz0XqEjq0iR/exEXaUTGBtOMG+U2Xx2wpuoLk4+GTEuqrC8F8M/Hi/RxWDAA3A4EImQJjFw7 AhmV5WoHk++sLEwX+JjJEU+Oz5zx+fGuwRikl9bhnANi+VSbIlOQ+8YrwYL+ZVvEWP+Idra8rt9iQ SbbQ3qxjHLYxOUw8cAEwBi71ESZczUlsjCUcaxXE7mBrvRhVwXugAeX2lLyXeBv3nF1eDNZ3E6+6n sQNY1HJagWOdLKYO8LdudQ0gD/Afb9HOtz7IBBG7e3g+yIehM9rFOp7ieyWtFodPmsD1vOgcN3rKm fx3DOTdYA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1leg7k-004cyI-AX; Thu, 06 May 2021 15:41:12 +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 1lefzn-004a6S-Jp for linux-arm-kernel@desiato.infradead.org; Thu, 06 May 2021 15:32:59 +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=A9CNB0L5s5+H//IUtgx/uDHXuNSyeoOxqlS2FgW4jwo=; b=BVc7vCWo3kAPPmd5MRpo4B2FSn KzTlG1HL+KFEPRENuIOZoz3xSyxMaJX7jEbUXkm0/qG2JsGlNSGCliXcweC+w1JfoiSbiTEZ2FHdD 6+rZIC+PpP+MRffm3uZoWQUTBd8eXSze2vtpMn/z8cRvXW5AcE/Z7cOTfV5ijmroYq5GQUOJsur5A 7j/umrt9G3uSL+/bupFWumLYt/q1CBGb3lkBz3XaJoYvEC6V4dJI1BhVj03qnl0qn+oGiWiSmlM7O XpuHlj3+iYFLoZ0/hexUHcBg4iU2tLdvw34ZXL0cdvX/C5kDyjOf52nZ8vTBv6sr673dyyF2zK/4Z PWRG3hRw==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lefzh-0069jr-61 for linux-arm-kernel@lists.infradead.org; Thu, 06 May 2021 15:32:58 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id A474961439; Thu, 6 May 2021 15:32:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620315169; bh=AxtlbVze2/56soOpmOZjWWVJpGnSFZmHfFNbsihLoxI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aKpwx1CoP71JDjHNRDbH+3h6wN2p7jbAI/JP5RUUzSkxEaiHAsx6ovSiOuVl4e1qH pLUe24gdAwSbGU2MEi8Tmp/GPzMKGH05M9LuO0b2DQCxnyVPc2cFpLA062kk/0HkO9 songOon0mZo2YlLiL8FSnN1uePXX6w2N6UnGv0PhvfwY/+HQHxcMgcjEZXHm9PC08Y VmCYh/R4UBp7e66goyLmgOQVOiZPVYFgXF/Vfzk5V77tho2W6m+XpTY0e2PtHfGgER 5T6bIe7B1GijDTBzYhzqhV2r9OuNQVIr7S6VKcQkQiZERk39PxTU0C8sbdoGnGggRQ vd9W1qCxtIGtw== Received: by pali.im (Postfix) id 5DE678A1; Thu, 6 May 2021 17:32:49 +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 18/42] PCI: aardvark: Correctly clear and unmask all MSI interrupts Date: Thu, 6 May 2021 17:31:29 +0200 Message-Id: <20210506153153.30454-19-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_083253_335840_3B070426 X-CRM114-Status: GOOD ( 11.19 ) 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 Define a new macro PCIE_MSI_ALL_MASK and use it for masking, unmasking and clearing all MSI interrupts. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Cc: stable@vger.kernel.org --- drivers/pci/controller/pci-aardvark.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index 498810c00b6d..5e0243b2c473 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -117,6 +117,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) @@ -386,19 +387,22 @@ 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); /* Disable All ISR0/1 Sources */ - reg = PCIE_ISR0_ALL_MASK; - reg &= ~PCIE_ISR0_MSI_INT_PENDING; - advk_writel(pcie, reg, PCIE_ISR0_MASK_REG); - + advk_writel(pcie, PCIE_ISR0_ALL_MASK, PCIE_ISR0_MASK_REG); 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); + + /* Unmask summary MSI interrupt */ + reg = advk_readl(pcie, PCIE_ISR0_MASK_REG); + reg &= ~PCIE_ISR0_MSI_INT_PENDING; + advk_writel(pcie, reg, PCIE_ISR0_MASK_REG); /* Enable summary interrupt for GIC SPI source */ reg = PCIE_IRQ_ALL_MASK & (~PCIE_IRQ_ENABLE_INTS_MASK); @@ -1049,7 +1053,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 Thu May 6 15:31:30 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: 12242613 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 7B125C433ED for ; Thu, 6 May 2021 15:44:14 +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 BDF07610A7 for ; Thu, 6 May 2021 15:44:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BDF07610A7 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=m+WqY3m+LOr6KbjGKhzsY2mI+5zQjmIGXM/UNdqz6eE=; b=V1jYLIei4s2m9p9ITE1Pjx5rH 30A80C5H5PbCVN+ACFuqPHTwYTac7WFVkE1mdwON0XRvGTh/eVg7LIYc+rqPPvQerLwaC44S+MnhU LJaVrayuTi+am58C5zUZ5BKosoUDfuUJN6xrFOuefezMoAijT+/5GLqBhUBXADIiG/QqecqqPk783 0HuNJ2i98G+AzYRr0zvxEndRJnTFm/A5iGcHUko08yoGgQcDS50TV3ESoxdF8qhQ3Carc7wuYMS1g UmT9BIH0MtitVNZk7Tv2Zbg1eWoX4tT84hTp4NVRl4hMXMNrICajdvZNv6Lz+ReuWn0PWhCc7sUxL nL2t03e3Q==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1leg90-004dR1-5Q; Thu, 06 May 2021 15:42:30 +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 1lefzo-004a6k-7I for linux-arm-kernel@desiato.infradead.org; Thu, 06 May 2021 15:33:00 +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=WucDlhhbGTYM2psFHzQSfqvBA5mNXenKaby7mqQgJ9Y=; b=2XA7Eddk/hQx+oP8cuycruelA0 yMMCp5Z+j0FxbEKQO5jzs8uUtkhL06j447Cx7iXuSq+AOIu4AhLu9Z3SGA4k2cBVNSxs81cUk37dA 7SkNUu+3WZayvUNoA3gcfD7Zw72ZcWQQXS/jgtqkaaA8e3iwUkBIbMScRlqhJrM54b8uFLNCQAOZg 5aMIGHHFkz4fsK60o+309MFvO3HgC+IvHNkHpS7q+tkNbqsgjIuuUpMkXtn6j2zTib41tX0Otno3E 8DGJ/P0IvwkU1dTsz0kWOk86nZAhs64xJTAfBPyl6qqbzQjXBOomV7zdy3kxEQGeHtJ5ZbtA4NFN0 KxjkTMMw==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lefzh-0069hb-VR for linux-arm-kernel@lists.infradead.org; Thu, 06 May 2021 15:32:58 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id E928E61448; Thu, 6 May 2021 15:32:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620315170; bh=NhWFiT9mS26VGMqexxlpc1KWY2pibRPWZ7Iothabwro=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X4HqXv5Fl3bn1sgm2DgGNCqnCa4vXQpacap8ZrEH9+w+rgSIDq6zonuTS3ecUClg4 B6Q7Q1f6flHxARIDFesxi8vL+H0ovy84kZbaMhcFEA2863B4FOf+ReICL4Vaao/Cj1 MqkzMZv8XJ6c7EI7bAQHNOaCljmB3PULSrr2J8sjZVZ4B8bmlCKXjyeufdCy5lkn4w GIVFUuQ/RQWkygOJXO9bVPC/WXrSB75SRqco8K/EYOm24f8eAP7FJw7qeFOiG1/EmA 362kkX6KNVlK4tH/nIM11KnX4W/jFyPGlVUE0qjzSNYWJzMqSaOKm5a70vGMLd4zBJ gSlj9G5zZLHLw== Received: by pali.im (Postfix) id A23D5732; Thu, 6 May 2021 17:32:49 +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 19/42] PCI: aardvark: Fix setting MSI address Date: Thu, 6 May 2021 17:31:30 +0200 Message-Id: <20210506153153.30454-20-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_083254_099906_B022D763 X-CRM114-Status: GOOD ( 12.54 ) 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 MSI address for receiving MSI interrupts needs to be correctly set before enabling processing of MSI interrupts. Move code for setting PCIE_MSI_ADDR_LOW_REG and PCIE_MSI_ADDR_HIGH_REG registers with MSI address from advk_pcie_init_msi_irq_domain() function to advk_pcie_setup_hw() function before enabling PCIE_CORE_CTRL2_MSI_ENABLE. As part of this change, also remove unused variable msi_msg, which was used only for MSI doorbell address. MSI address can be any address which does not conflict with PCI space. So change it to the address of the main struct advk_pcie. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Cc: stable@vger.kernel.org # f21a8b1b6837 ("PCI: aardvark: Move to MSI handling using generic MSI support") Acked-by: Marc Zyngier --- drivers/pci/controller/pci-aardvark.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index 5e0243b2c473..199015215779 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -195,7 +195,6 @@ struct advk_pcie { struct msi_domain_info msi_domain_info; DECLARE_BITMAP(msi_used, MSI_IRQ_NUM); struct mutex msi_used_lock; - u16 msi_msg; int link_gen; struct pci_bridge_emul bridge; struct gpio_desc *reset_gpio; @@ -325,6 +324,7 @@ static void advk_pcie_train_link(struct advk_pcie *pcie) static void advk_pcie_setup_hw(struct advk_pcie *pcie) { + phys_addr_t msi_addr; u32 reg; /* Enable TX */ @@ -381,6 +381,11 @@ static void advk_pcie_setup_hw(struct advk_pcie *pcie) reg |= LANE_COUNT_1; advk_writel(pcie, reg, PCIE_CORE_CTRL0_REG); + /* Set MSI address */ + msi_addr = virt_to_phys(pcie); + advk_writel(pcie, lower_32_bits(msi_addr), PCIE_MSI_ADDR_LOW_REG); + advk_writel(pcie, upper_32_bits(msi_addr), PCIE_MSI_ADDR_HIGH_REG); + /* Enable MSI */ reg = advk_readl(pcie, PCIE_CORE_CTRL2_REG); reg |= PCIE_CORE_CTRL2_MSI_ENABLE; @@ -862,10 +867,10 @@ static void advk_msi_irq_compose_msi_msg(struct irq_data *data, struct msi_msg *msg) { struct advk_pcie *pcie = irq_data_get_irq_chip_data(data); - phys_addr_t msi_msg = virt_to_phys(&pcie->msi_msg); + phys_addr_t msi_addr = virt_to_phys(pcie); - msg->address_lo = lower_32_bits(msi_msg); - msg->address_hi = upper_32_bits(msi_msg); + msg->address_lo = lower_32_bits(msi_addr); + msg->address_hi = upper_32_bits(msi_addr); msg->data = data->hwirq; } @@ -960,7 +965,6 @@ static int advk_pcie_init_msi_irq_domain(struct advk_pcie *pcie) struct device_node *node = dev->of_node; struct irq_chip *bottom_ic, *msi_ic; struct msi_domain_info *msi_di; - phys_addr_t msi_msg_phys; mutex_init(&pcie->msi_used_lock); @@ -978,13 +982,6 @@ static int advk_pcie_init_msi_irq_domain(struct advk_pcie *pcie) MSI_FLAG_MULTI_PCI_MSI; msi_di->chip = msi_ic; - msi_msg_phys = virt_to_phys(&pcie->msi_msg); - - advk_writel(pcie, lower_32_bits(msi_msg_phys), - PCIE_MSI_ADDR_LOW_REG); - advk_writel(pcie, upper_32_bits(msi_msg_phys), - PCIE_MSI_ADDR_HIGH_REG); - pcie->msi_inner_domain = irq_domain_add_linear(NULL, MSI_IRQ_NUM, &advk_msi_domain_ops, pcie); From patchwork Thu May 6 15:31:31 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: 12242617 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 4ACD0C433B4 for ; Thu, 6 May 2021 15:46:49 +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 D4765610A1 for ; Thu, 6 May 2021 15:46:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D4765610A1 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=AwNqxR0XVGQKOMGeAndpaKM6EEMccyjbALti7o0+tAY=; b=Ysa9DTgDt6qgY2iB5mM1je2Oo 4I7j5UTnw4rJ7820/cuhEbwh/T1VK9PToNW2H2r79VUus9MXrlXOIL4bmwXv8OZ7sepGlKz/idS8t tHyV1e+F5h2ld0roB4HCyxeLtTeNQ49YeGoqUFt2y/w/cb97b1MDOf6s28AH2Zhg02FnzXy/Z0C4S w6yeCoRAy070njbmM2KcaF6sbXLxaMw2xxGiR27gM3YIp9kO3RZ2lD9wJTBFd2DlW8dSwSOVXskXA rgaDMpvjrZsA/5YNws4nasyh4RVNVmZhrYR1SPJevnU2rln/YZ4Wht4pGngf6Hsp7UCsqV8JS+E2m 6534qHR5w==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1legAm-004dyn-IC; Thu, 06 May 2021 15:44:21 +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 1lefzp-004a7F-0r 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=UDcVYQTqbz9OseTq0S0QydX4WFu/9YqW2MhPwXkVW/I=; b=VO3z1+vNWoxQ7OUL4AwXcd/ihp jroZ/QJzvaXlTOFLj3MCnbwQsL5L7w0cizJ3tWWwXtDFz/CFAuPNeQ0Mrw0msgxnWj6m9jbqFmsyo t6+527QZ2OaUVMWAmSs5eYUUWQkOX8uf/evEJ4D22ou9uUA3uyf8e+2+CAnkQHKAlENRP4F5tApp7 DKooVYaC32v9M3AQQ2dhF1x1iHdg5NxM51SP7U9pbFDXaqVf+pRKZQkS0XwPmx7C8fXlOC2yPLrKM sO6SIA+oJOQAEIF27oNhvwetvGoxp4k5t/0RJ8VMm0pZgYPa5ft74PFHZzuQK1Urum37tGi0fa/XM QHMIxqIQ==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lefzi-0069lK-8A for linux-arm-kernel@lists.infradead.org; Thu, 06 May 2021 15:32:59 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4E8C461434; Thu, 6 May 2021 15:32:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620315170; bh=1sKdRSDWZQDgd5KUeWJnyAld8807tC29lRbcEtY4HEA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UtD+5ok6KQaP3oZRK5I7CcxMyHMmBrBNWE1KRjfI+AKAaCu6riOACR2lQSooforV2 gU9Y7z2NUCjHFzIFvO2Xg+y697IoSWcxnLQZmSxeL1G5JBIG5W1FsH+afh4EzZc35x cJfVjZfzhbCL/VEvws1f9eG/vI6wycpWFbogUWxE+ErHS5BP7mqYy1WbeWppOlrrU2 cHDXRZpllZUTLswV6VuPVLeXQe3qBvEMdKpExhmZwrG2y7Lp7xJ05zGvsHkvrrZzzY SIrSLnqlsiSSHfd/VQTv79uYzRfEWLxpjbzpxC8+nmufhEE5AQIKTWnCnZVbzmS39o QseH1/RE0B01A== Received: by pali.im (Postfix) id 083448A1; Thu, 6 May 2021 17:32:50 +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 20/42] PCI: aardvark: Add support for more than 32 MSI interrupts Date: Thu, 6 May 2021 17:31:31 +0200 Message-Id: <20210506153153.30454-21-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_083254_409640_86A55C66 X-CRM114-Status: GOOD ( 18.81 ) 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 Aardvark HW can handle MSI interrupt with any 16-bit number. Received MSI interrupt number is visible in PCIE_MSI_PAYLOAD_REG register after clearing corresponding bit in PCIE_MSI_STATUS_REG register. The first 32 interrupt numbers are currently stored in linear map in MSI inner domain. Store the rest in dynamic radix tree for space efficiency. Free interrupt numbers (available for MSI inner domain allocation) for the first 32 interrupts are currently stored in a bitmap. For the rest, introduce a linked list of allocated regions. In the most common scenario there is only one PCIe card connected on boards with Armada 3720 SoC. Since in Multi-MSI mode the PCIe device can use at most 32 interrupts, all these interrupts are allocated in the linear map of MSI inner domain and marked as used in the bitmap. For less common scenarios with PCIe devices with multiple functions or with a PCIe Bridge with packet switches with more connected PCIe devices more than 32 interrupts are requested. In this case, store each interrupt range from each interrupt request into the linked list as one node. In the worst case every PCIe function will occupy one node in this linked list. This change allows to use all 32 Multi-MSI interrupts on every connected PCIe card on the Turris Mox router with Mox G module. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún --- drivers/pci/controller/pci-aardvark.c | 71 ++++++++++++++++++++++++--- 1 file changed, 64 insertions(+), 7 deletions(-) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index 199015215779..d74e84b0e689 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -178,11 +178,18 @@ #define RETRAIN_WAIT_MAX_RETRIES 10 #define RETRAIN_WAIT_USLEEP_US 2000 -#define MSI_IRQ_NUM 32 +#define MSI_IRQ_LINEAR_COUNT 32 +#define MSI_IRQ_TOTAL_COUNT 65536 #define CFG_RD_UR_VAL 0xffffffff #define CFG_RD_CRS_VAL 0xffff0001 +struct advk_msi_range { + struct list_head list; + u16 first; + u16 count; +}; + struct advk_pcie { struct platform_device *pdev; void __iomem *base; @@ -193,7 +200,8 @@ struct advk_pcie { struct irq_chip msi_bottom_irq_chip; struct irq_chip msi_irq_chip; struct msi_domain_info msi_domain_info; - DECLARE_BITMAP(msi_used, MSI_IRQ_NUM); + DECLARE_BITMAP(msi_used_linear, MSI_IRQ_LINEAR_COUNT); + struct list_head msi_used_radix; struct mutex msi_used_lock; int link_gen; struct pci_bridge_emul bridge; @@ -885,12 +893,44 @@ static int advk_msi_irq_domain_alloc(struct irq_domain *domain, unsigned int nr_irqs, void *args) { struct advk_pcie *pcie = domain->host_data; + struct advk_msi_range *msi_range, *msi_range_prev, *msi_range_next; + unsigned int first, count, last; int hwirq, i; mutex_lock(&pcie->msi_used_lock); - hwirq = bitmap_find_free_region(pcie->msi_used, MSI_IRQ_NUM, + + /* First few used interrupt numbers are marked in bitmap (the most common) */ + hwirq = bitmap_find_free_region(pcie->msi_used_linear, MSI_IRQ_LINEAR_COUNT, order_base_2(nr_irqs)); + + /* And rest used interrupt numbers are stored in linked list as ranges */ + if (hwirq < 0) { + count = 1 << order_base_2(nr_irqs); + msi_range_prev = list_entry(&pcie->msi_used_radix, typeof(*msi_range), list); + do { + msi_range_next = list_next_entry(msi_range_prev, list); + last = list_entry_is_head(msi_range_next, &pcie->msi_used_radix, list) + ? MSI_IRQ_TOTAL_COUNT : msi_range_next->first; + first = list_entry_is_head(msi_range_prev, &pcie->msi_used_radix, list) + ? MSI_IRQ_LINEAR_COUNT : round_up(msi_range_prev->first + + msi_range_prev->count, count); + if (first + count > last) { + msi_range_prev = msi_range_next; + continue; + } + msi_range = kzalloc(sizeof(*msi_range), GFP_KERNEL); + if (msi_range) { + hwirq = first; + msi_range->first = first; + msi_range->count = count; + list_add(&msi_range->list, &msi_range_prev->list); + } + break; + } while (!list_entry_is_head(msi_range_next, &pcie->msi_used_radix, list)); + } + mutex_unlock(&pcie->msi_used_lock); + if (hwirq < 0) return -ENOSPC; @@ -908,9 +948,20 @@ static void advk_msi_irq_domain_free(struct irq_domain *domain, { struct irq_data *d = irq_domain_get_irq_data(domain, virq); struct advk_pcie *pcie = domain->host_data; + struct advk_msi_range *msi_range; mutex_lock(&pcie->msi_used_lock); - bitmap_release_region(pcie->msi_used, d->hwirq, order_base_2(nr_irqs)); + if (d->hwirq < MSI_IRQ_LINEAR_COUNT) { + bitmap_release_region(pcie->msi_used_linear, d->hwirq, order_base_2(nr_irqs)); + } else { + list_for_each_entry(msi_range, &pcie->msi_used_radix, list) { + if (msi_range->first != d->hwirq) + continue; + list_del(&msi_range->list); + kfree(msi_range); + break; + } + } mutex_unlock(&pcie->msi_used_lock); } @@ -967,6 +1018,7 @@ static int advk_pcie_init_msi_irq_domain(struct advk_pcie *pcie) struct msi_domain_info *msi_di; mutex_init(&pcie->msi_used_lock); + INIT_LIST_HEAD(&pcie->msi_used_radix); bottom_ic = &pcie->msi_bottom_irq_chip; @@ -982,9 +1034,14 @@ static int advk_pcie_init_msi_irq_domain(struct advk_pcie *pcie) MSI_FLAG_MULTI_PCI_MSI; msi_di->chip = msi_ic; + /* + * Aardvark HW can handle MSI interrupt with any 16bit number. + * For optimization first few interrupts are allocated in linear map + * (which is common scenario) and rest are allocated in radix tree. + */ pcie->msi_inner_domain = - irq_domain_add_linear(NULL, MSI_IRQ_NUM, - &advk_msi_domain_ops, pcie); + __irq_domain_add(NULL, MSI_IRQ_LINEAR_COUNT, MSI_IRQ_TOTAL_COUNT, 0, + &advk_msi_domain_ops, pcie); if (!pcie->msi_inner_domain) return -ENOMEM; @@ -1052,7 +1109,7 @@ static void advk_pcie_handle_msi(struct advk_pcie *pcie) msi_val = advk_readl(pcie, PCIE_MSI_STATUS_REG); msi_status = msi_val & ((~msi_mask) & PCIE_MSI_ALL_MASK); - for (msi_idx = 0; msi_idx < MSI_IRQ_NUM; msi_idx++) { + for (msi_idx = 0; msi_idx < BITS_PER_TYPE(msi_status); msi_idx++) { if (!(BIT(msi_idx) & msi_status)) continue; From patchwork Thu May 6 15:31:32 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: 12242615 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 DCEF7C433B4 for ; Thu, 6 May 2021 15:46:02 +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 3544C610A1 for ; Thu, 6 May 2021 15:46:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3544C610A1 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=pSVQglUGKI0rekMQnzwaYF57LrruMa30KoqTl4zRsts=; b=a65iIOfu5+Um1a80Flm08Afkq 5k2hIcODtX3gL5BnrtALB/LtvWlG3Et3PxqDVugF2YEpRAqAneTC0B7uyAxfez+uCuuNep8FXGfjX G+jwgclH9M6iXZxbIK4Vau3FSmASKbRxaySgdRMY0pjb39CJkgUNMMQptfT55ZtV9N/mwfXe8LYxj nhuqiDAENwvc83Hbi6hQd26qEYyYhxtvJ09OsVJOQIOK+UynRpsOTxo/QD+yYdeRhQTYQSqCDSzL9 0XOrbR4c6rFl+aFzuXfzJ3qMHV9emrEin7GwCQHEZfo08w+D8GMXRxuBM2XcgunlpdkgA2i4pDGS5 zQcX6OzYQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1leg9Y-004dbO-5n; Thu, 06 May 2021 15:43:04 +0000 Received: from mail.kernel.org ([198.145.29.99]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lefzl-004a48-OZ for linux-arm-kernel@lists.infradead.org; Thu, 06 May 2021 15:33:00 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9EF3D6141A; Thu, 6 May 2021 15:32:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620315171; bh=yxzpn2O/vp9ZZpPVLIJ+HQxJFsDjVUX2z2EPhOuwt1k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KEyqYxHdE7ZKmqjuMa/tEldb+IFNCvdsnbMTcFJDpDGF7POsd9s6fhKcJUwDgPT/C 3f0Z+T0MNS32RTBEk0NTQvVoHdkQloqQxVrw05z3izZJJENXMswtI+eUYPmcgduWNS QywErnFwoTp2UfCkgt0j2HApyfl+hDCBrh3gqnwNbgAyQ/m3Wb+YSUO5HiWGd1YPtH oi+4BaBU1AKU3EISacHwGauI0j3g8fUx9d+C/AjaUBbUJRDKnu8jnwHpD/N48j6uWT usMapfP502CQ3KBtQyqsxnP4N/7Q1w3DhggOMHQxw70zNll/qekFxqJ2zeidVorYDL KlHt+MTfZ2q1g== Received: by pali.im (Postfix) id 56A2A89A; Thu, 6 May 2021 17:32:50 +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 21/42] PCI: aardvark: Add support for masking MSI interrupts Date: Thu, 6 May 2021 17:31:32 +0200 Message-Id: <20210506153153.30454-22-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_163258_402206_BAB834D3 X-CRM114-Status: GOOD ( 17.43 ) 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 Aardvark HW does not support masking individual MSI interrupts. It supports masking only whole equivalence classes which consist of MSI interrupts with same lower 5 bits. So mask a whole equivalence class only if all interrupts in this class are masked. For each equivalence class store a reference counter to indicate how many unmasked interrupts are in this class. Use this counter to decide when this class of MSI interrupts can be masked. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún --- drivers/pci/controller/pci-aardvark.c | 77 ++++++++++++++++++++++++--- 1 file changed, 69 insertions(+), 8 deletions(-) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index d74e84b0e689..376f0666becc 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -202,6 +202,7 @@ struct advk_pcie { struct msi_domain_info msi_domain_info; DECLARE_BITMAP(msi_used_linear, MSI_IRQ_LINEAR_COUNT); struct list_head msi_used_radix; + u16 msi_used_ec_refcnt[32]; struct mutex msi_used_lock; int link_gen; struct pci_bridge_emul bridge; @@ -405,12 +406,10 @@ static void advk_pcie_setup_hw(struct advk_pcie *pcie) advk_writel(pcie, PCIE_ISR1_ALL_MASK, PCIE_ISR1_REG); advk_writel(pcie, PCIE_IRQ_ALL_MASK, HOST_CTRL_INT_STATUS_REG); - /* Disable All ISR0/1 Sources */ + /* Disable All ISR0/1 and MSI Sources */ advk_writel(pcie, PCIE_ISR0_ALL_MASK, PCIE_ISR0_MASK_REG); advk_writel(pcie, PCIE_ISR1_ALL_MASK, PCIE_ISR1_MASK_REG); - - /* Unmask all MSIs */ - advk_writel(pcie, ~(u32)PCIE_MSI_ALL_MASK, PCIE_MSI_MASK_REG); + advk_writel(pcie, PCIE_MSI_ALL_MASK, PCIE_MSI_MASK_REG); /* Unmask summary MSI interrupt */ reg = advk_readl(pcie, PCIE_ISR0_MASK_REG); @@ -888,6 +887,54 @@ static int advk_msi_set_affinity(struct irq_data *irq_data, return -EINVAL; } +static void advk_msi_irq_mask(struct irq_data *d) +{ + struct advk_pcie *pcie = d->domain->host_data; + irq_hw_number_t hwirq = irqd_to_hwirq(d); + u8 idx = hwirq & 31; + u32 mask; + + /* + * Aardvark HW does not support masking individual MSI interrupts. It + * supports masking only whole equivalence class idx which consist of + * MSI interrupts with same low 5 bits. So mask equivalence class idx + * only in case there is no used (unmasked) interrupt in this class. + */ + + if (--pcie->msi_used_ec_refcnt[idx] > 0) + return; + + mask = advk_readl(pcie, PCIE_MSI_MASK_REG); + mask |= BIT(idx); + advk_writel(pcie, mask, PCIE_MSI_MASK_REG); +} + +static void advk_msi_irq_unmask(struct irq_data *d) +{ + struct advk_pcie *pcie = d->domain->host_data; + irq_hw_number_t hwirq = irqd_to_hwirq(d); + u8 idx = hwirq & 31; + u32 mask; + + pcie->msi_used_ec_refcnt[idx]++; + + mask = advk_readl(pcie, PCIE_MSI_MASK_REG); + mask &= ~BIT(idx); + advk_writel(pcie, mask, PCIE_MSI_MASK_REG); +} + +static void advk_msi_top_irq_mask(struct irq_data *d) +{ + pci_msi_mask_irq(d); + irq_chip_mask_parent(d); +} + +static void advk_msi_top_irq_unmask(struct irq_data *d) +{ + pci_msi_unmask_irq(d); + irq_chip_unmask_parent(d); +} + static int advk_msi_irq_domain_alloc(struct irq_domain *domain, unsigned int virq, unsigned int nr_irqs, void *args) @@ -1025,9 +1072,13 @@ static int advk_pcie_init_msi_irq_domain(struct advk_pcie *pcie) bottom_ic->name = "MSI"; bottom_ic->irq_compose_msi_msg = advk_msi_irq_compose_msi_msg; bottom_ic->irq_set_affinity = advk_msi_set_affinity; + bottom_ic->irq_mask = advk_msi_irq_mask; + bottom_ic->irq_unmask = advk_msi_irq_unmask; msi_ic = &pcie->msi_irq_chip; msi_ic->name = "advk-MSI"; + msi_ic->irq_mask = advk_msi_top_irq_mask; + msi_ic->irq_unmask = advk_msi_top_irq_unmask; msi_di = &pcie->msi_domain_info; msi_di->flags = MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS | @@ -1101,8 +1152,10 @@ static void advk_pcie_remove_irq_domain(struct advk_pcie *pcie) static void advk_pcie_handle_msi(struct advk_pcie *pcie) { - u32 msi_val, msi_mask, msi_status, msi_idx; + struct irq_data *irq_data; + u32 msi_val, msi_mask, msi_status; u16 msi_data; + u8 msi_idx; int virq; msi_mask = advk_readl(pcie, PCIE_MSI_MASK_REG); @@ -1119,11 +1172,19 @@ static void advk_pcie_handle_msi(struct advk_pcie *pcie) */ advk_writel(pcie, BIT(msi_idx), PCIE_MSI_STATUS_REG); msi_data = advk_readl(pcie, PCIE_MSI_PAYLOAD_REG) & PCIE_MSI_DATA_MASK; + + /* + * Aardvark HW does not support masking individual MSI interrupts. + * So call generic_handle_irq() only in case kernel has not masked + * received MSI interrupt. + */ virq = irq_find_mapping(pcie->msi_inner_domain, msi_data); - if (virq) - generic_handle_irq(virq); - else + irq_data = virq ? irq_get_irq_data(virq) : NULL; + + if (!irq_data) dev_err(&pcie->pdev->dev, "unexpected MSI 0x%04hx\n", msi_data); + else if (!irqd_irq_masked(irq_data)) + generic_handle_irq(virq); } advk_writel(pcie, PCIE_ISR0_MSI_INT_PENDING, From patchwork Thu May 6 15:31:33 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: 12242683 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 DABE0C43460 for ; Thu, 6 May 2021 16:03:53 +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 72FB461168 for ; Thu, 6 May 2021 16:03:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 72FB461168 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=xYj/YKnvW1dqrDj/I8Y+H4YDOaNETwqbTfJKutxyFoM=; b=hP60xjFXlqJG+efu+UKBi3H3d bWiZ+xsy7XFw394pbwzOxoylHYvlOsi+0Sa9Wr2c3aaCuEs2N0X4+/iAY1M71im11LtBXGDGw4+k5 YUpwK805vecrPXLlZL5S+/nE6thXL3W0CQoQBUKqoObf5fqe1KwdAeo4xfvGBUZxIW0FCoUqwMMCf ze0jdKxpqqL8Ez53bQKbUQh1Yboh+fJf1EAPXS79qIfZ/2t3s0lqh8zYZHnfYt1XE66zLaNyfSXRq Cn+leWZafwPxxJ0gOakll+G/h6nNoCmJcEYpluGl1CeKH7p3KQPF6bfftP8IqrULlx4Kj0ND6vCrZ AlDhFrY1g==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1legAD-004doo-2F; Thu, 06 May 2021 15:43:45 +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 1lefzo-004a6w-Lq for linux-arm-kernel@desiato.infradead.org; Thu, 06 May 2021 15:33:00 +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=wJrO+Jr0mRZaQuGgZMDRCb5XKmjeGp6M8yxovuwQXHk=; b=zNYaK6QPAvPWy4MK4ptI5jaUNJ FU+s/hl45LXuGGfiOjIe5oEl+BCR8CDzU9FioVMsznY7VP+nKaEgWprHufBg2p/+yVsuIqIRqKBAU F57N3Eyp27kGPuHFiPhcaAHQnV4qFx/fY0tSquq3tFIonna8DI1Vz+B4MkHRGsvMW74wgQuk65Y+a cjsWBZKlcxmCZ+B5L5kS06JVjIlOBgenmbhHr3g5V9fcScokAsCKLJgOcqKifgZaHH/UN0cBkGh6Z 9SkH35URcb/WVNx3sm5VNyzY1sNvGx/OLLVrUXKNwtZAd6oDdUCeYvAGXqyJr0XQVlwvknHf820Qv HpH+ZGKw==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lefzi-0069ha-9j for linux-arm-kernel@lists.infradead.org; Thu, 06 May 2021 15:32:59 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id E5B4C61492; Thu, 6 May 2021 15:32:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620315171; bh=aFz0PFRzNP3wjEbTBW+rHPZjGLu0vSW7VtIiwAyNHNc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OxYRibS40Y+CZI4MoUELH9lWQ8j2mwyO/xAYa5r57x9HG7QjwBnWqqgF571Cj2Qh3 pO73bc6cDOzKIfndLOMgGZLgyXOHNDDGbsh6qod1XC1kgAouWp+b6kr4Qz52QMXO+o EOWfiBlZriNhtdAHZYOEMyCZdrP0nk0SHT3cCskKdv7xSeEUOy13iMNND+vJQN3P3X xrEzr93HeKB/krSkh3etvcp/xvgyhf8S+DmRHDhsenNWMsQ5pJoM4uYYMc4OEKE/No RcNqBH11zYEfdzz0dqTSatu4eBcLTS0RFw2Zdoc88+LulQSS0LFXEXY6GDY415sxei UAzv7yVZ9CfPA== Received: by pali.im (Postfix) id 9F939732; Thu, 6 May 2021 17:32:50 +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 22/42] PCI: aardvark: Enable MSI-X support Date: Thu, 6 May 2021 17:31:33 +0200 Message-Id: <20210506153153.30454-23-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_083254_420915_33BD301B X-CRM114-Status: GOOD ( 14.05 ) 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 According to PCI 3.0 specification, sending both MSI and MSI-X interrupts is done by DWORD memory write operation to doorbell message address. The write operation for MSI has zero upper 16 bits and the MSI interrupt number in the lower 16 bits. The write operation for MSI-X contains a 32-bit value from MSI-X table. This means that when MSI-X uses only a 16-bit value, the MSI-X message can be captured by aardvark MSI doorbell address processing. Therefore aardvark HW should also support MSI-X interrupts, despite Armada 3700 Functional Specification not mentioning anything about how to configure PCIe for MSI-X interrupts. (Note that the specification says that MSI-X is supported, it just does not say explicitly how to enable it.) Since pci-aardvark.c driver now supports receiving MSI interrupt with any 16-bit number, enable also MSI-X support. Testing proved that kernel can correctly receive MSI-X interrupts from PCIe cards which supports both MSI and MSI-X interrupts. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún --- drivers/pci/controller/pci-aardvark.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index 376f0666becc..8a5133226e41 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -1082,7 +1082,7 @@ static int advk_pcie_init_msi_irq_domain(struct advk_pcie *pcie) msi_di = &pcie->msi_domain_info; msi_di->flags = MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS | - MSI_FLAG_MULTI_PCI_MSI; + MSI_FLAG_MULTI_PCI_MSI | MSI_FLAG_PCI_MSIX; msi_di->chip = msi_ic; /* From patchwork Thu May 6 15:31:34 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: 12242679 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 68673C43470 for ; Thu, 6 May 2021 16:03:53 +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 E81856113E for ; Thu, 6 May 2021 16:03:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E81856113E 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=BWlstWbWcFTScFfISqW9hZKsXIICLj/lcm1MZ2nSELA=; b=JIV+wexv2h7nKEkRTNnRQwtOx SsAaxfvhpP50d96N/XbLWyer2uIkeg8Gr7NUsvLSGMkBMmZ9xFr7Ny75XsX6oLX13r2Sj5FjwOm4N 3s+QC8RKEgsLWwtB6nAIJwQPpDyo5ilJZtCWk6PSd+c0hc+ZNZyMv0LzmI4sk/JTDnjpuefndHW7a G8gR15frHeh4EWYZwadwqGQSlXW9tzc9WDAIs2E0+jjALDru6iBb5OwlBsaxqlqpEh9XXCbHEQ0fT bQR2lMivfa8H2AW28bGuxwhtZvtWD/Q6SqudTNvwMdV73uqCMxh7lwRVNs/bGfHCvExllgZAsXb2o q0JygNX0A==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1legDO-004ekN-12; Thu, 06 May 2021 15:47:02 +0000 Received: from mail.kernel.org ([198.145.29.99]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lefzl-004a4K-Qk for linux-arm-kernel@lists.infradead.org; Thu, 06 May 2021 15:33:03 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3FFB261444; Thu, 6 May 2021 15:32:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620315171; bh=BNybo/imm7XJtoxFMKGPLmZE6NxN+kmKnZtaTUumbOU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VwIB4YyNY1qalXOuifdY/OX5Lr5ZidlVIaCsWkaCvH96DGZoQbfGYIf5ISVob5+KE pN5GegVfTHQ1KT+VK+tlRGJMH8onCaGV4sPkRiymB1JxdF2H12vBvuw8IyfyNhFnWK QQ1/Bq9NXvpvj3yTVBhL1YsuZoK3IFcSTj+QDJuiKxl5qfBxrGd0ezg4Pu0T1tgbZz ROZm4n41SXYyFFZKCXb+TobGeOc3oPmtIGKt1TT4TGXxWT/2XYAlY9+rQU/gaKm/Kf kodHF+9TrPMtie4G61xkoDnbSsIrBWB2+yeujXWJKQrX4r6MSm4hwczG3Zem8DCd2f JvTrdf6qptqMQ== Received: by pali.im (Postfix) id E76C08A1; Thu, 6 May 2021 17:32:50 +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 23/42] PCI: aardvark: Fix support for ERR interrupt on emulated bridge Date: Thu, 6 May 2021 17:31:34 +0200 Message-Id: <20210506153153.30454-24-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_163258_610904_ED78B66F X-CRM114-Status: GOOD ( 13.76 ) 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 ERR interrupt is triggered when corresponding bit is unmasked in both ISR0 and PCI_EXP_DEVCTL registers. Unmasking ERR bits in PCI_EXP_DEVCTL register is not enough. This means that currently the ERR interrupt is never triggered. Unmask ERR bits in ISR0 register at driver probe time. ERR interrupt is not triggered until ERR bits are unmasked also in PCI_EXP_DEVCTL register, which is done by AER driver. So it is safe to unconditionally unmask all ERR bits in aardvark probe. Aardvark HW sets PCI_ERR_ROOT_AER_IRQ to zero and when corresponding bits in ISR0 and PCI_EXP_DEVCTL are enabled, the HW triggers a generic interrupt on GIC. Chain this interrupt to PCIe interrupt 0 with generic_handle_irq() to allow processing of ERR interrupts. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Fixes: 8a3ebd8de328 ("PCI: aardvark: Implement emulated root PCI bridge config space") Cc: stable@vger.kernel.org --- drivers/pci/controller/pci-aardvark.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index 8a5133226e41..2ea58ba10a97 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -104,6 +104,9 @@ #define PCIE_MSG_PM_PME_MASK BIT(7) #define PCIE_ISR0_MASK_REG (CONTROL_BASE_ADDR + 0x44) #define PCIE_ISR0_MSI_INT_PENDING BIT(24) +#define PCIE_ISR0_CORR_ERR BIT(11) +#define PCIE_ISR0_NFAT_ERR BIT(12) +#define PCIE_ISR0_FAT_ERR BIT(13) #define PCIE_ISR0_INTX_ASSERT(val) BIT(16 + (val)) #define PCIE_ISR0_INTX_DEASSERT(val) BIT(20 + (val)) #define PCIE_ISR0_ALL_MASK GENMASK(26, 0) @@ -416,6 +419,11 @@ static void advk_pcie_setup_hw(struct advk_pcie *pcie) reg &= ~PCIE_ISR0_MSI_INT_PENDING; advk_writel(pcie, reg, PCIE_ISR0_MASK_REG); + /* Unmask bits for ERR interrupt */ + reg = advk_readl(pcie, PCIE_ISR0_MASK_REG); + reg &= ~(PCIE_ISR0_FAT_ERR | PCIE_ISR0_NFAT_ERR | PCIE_ISR0_CORR_ERR); + advk_writel(pcie, reg, PCIE_ISR0_MASK_REG); + /* Enable summary interrupt for GIC SPI source */ reg = PCIE_IRQ_ALL_MASK & (~PCIE_IRQ_ENABLE_INTS_MASK); advk_writel(pcie, reg, HOST_CTRL_INT_MASK_REG); @@ -1195,6 +1203,7 @@ static void advk_pcie_handle_int(struct advk_pcie *pcie) { u32 isr0_val, isr0_mask, isr0_status; u32 isr1_val, isr1_mask, isr1_status; + u32 err_bits; int i, virq; isr0_val = advk_readl(pcie, PCIE_ISR0_REG); @@ -1205,9 +1214,22 @@ static void advk_pcie_handle_int(struct advk_pcie *pcie) isr1_mask = advk_readl(pcie, PCIE_ISR1_MASK_REG); isr1_status = isr1_val & ((~isr1_mask) & PCIE_ISR1_ALL_MASK); + err_bits = isr0_status & (PCIE_ISR0_FAT_ERR | PCIE_ISR0_NFAT_ERR | PCIE_ISR0_CORR_ERR); + if (!isr0_status && !isr1_status) return; + /* Process ERR interrupt */ + if (err_bits) { + advk_writel(pcie, err_bits, PCIE_ISR0_REG); + /* Aardvark HW returns zero for PCI_ERR_ROOT_AER_IRQ, so use PCIe interrupt 0 */ + virq = irq_find_mapping(pcie->irq_domain, 0); + if (virq) + generic_handle_irq(virq); + else + dev_err(&pcie->pdev->dev, "unexpected ERR IRQ\n"); + } + /* Process MSI interrupts */ if (isr0_status & PCIE_ISR0_MSI_INT_PENDING) advk_pcie_handle_msi(pcie); From patchwork Thu May 6 15:31:35 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: 12242675 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 EA8E6C433ED for ; Thu, 6 May 2021 16:03:51 +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 71EF3610E9 for ; Thu, 6 May 2021 16:03:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 71EF3610E9 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=JG652WgyqmTkchdhJQTIqEPWXKRyivSc34jGG+S8XyI=; b=SRLeXy0rR2/geIxLG2pjuuHny Qd2z74CSlOCD+8qbLh/ZJBkp6s4pUiCZz9Kfi6p+/ZcESf8ITcpLL1mfuuoL9zbBydxVb80VDxwmc BDbRX/ho7dWyr/roHACgXnxvRyRo7pmB0qtFJWhynfJyXkxKbCDDPCnNwppwGB3ZiPvK9237CIHov uc1obnJLCzj7Qk+sbEh13hRifTsp2ueOOLitwpOOFIJq0j27cK8iQHeo2XFf84lLMCffAPfGcA+84 GDQfWtAs/T3SHTp+e7AuPTFjcT0o5DyC0HXSb+qKMUCc1knzEGeTS2pa26uBtM/xbrWp/ncBwEWLR JUdGDBxxA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1legEP-004f4o-5a; Thu, 06 May 2021 15:48:05 +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 1lefzo-004a7A-Vv 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=HvVVH0N1OL4pB67bmpFUEL2AYtVVC8SRgWwWRKZT2bY=; b=rMkt7a0AxPHOo2IZAWvNyKoHFY aj837Ucpiax0uorfpXPOL8UevlQBCbIXRm3wwFjF6HESasPu/IBXNoiSjuT6FvE3wXlKMJqCrGl+B pRZcyn1Kd7V57/RSq/Mzmy8JkjqWTCr+QwRCrRHm6pgmxjHt2O1JJdGq4DsrfoJAO8ZqaZF22H8Em fJ9PIJvkFQfCmoxi/7c8aKFhUHnEGfua2mF7zFab4MYIPqrYUxb1DQB+kUYhbFgrgcWIYHd6nNgtA IwFjdKIStZ8Gg8jeVWNgcMVfCaXT8oiJx32m/sHb639/sp+bY7xDsy3sRbPN6P/CdnYapa2auP+3d XcEAGmsg==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lefzi-0069hi-Fd for linux-arm-kernel@lists.infradead.org; Thu, 06 May 2021 15:32:59 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 87A2861466; Thu, 6 May 2021 15:32:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620315171; bh=urrwtdifV1fz+XQqM6L88XpER1LnRW6X4GCyTMrByDI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IAhpZGoDLMr/XM36LpXnUhmpuYoUZemfa69scs/apqACQh8Asvic7XO+S0i337uGG DK1TdARfwbJny6lEsfYGdy1RdSSEhR/bw7uHhwcC8KpAek/F3+Tku2/6MhxRgl5E9S B2JbMXxo+u6kSPTDkEXBYaK8lAsaPQ5TsrFofh5JOjKvaeZHzMFcaofoc611m/+MgC FelmH4b66mUm0cvRU94SCd/dnm3n+yYWLC4APmCYOplQps7e7PJ9tDL6xaV0TWHElc B/rQ+nPd5mK4m2ElrKyiO7kmvRnJJhGjVbabnGOWKFIesVYwP6T/MZdI2lVk0UTSRm NbDcjjm9Jmy4g== Received: by pali.im (Postfix) id 3DA1589A; Thu, 6 May 2021 17:32:51 +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 24/42] PCI: aardvark: Fix support for PME on emulated bridge Date: Thu, 6 May 2021 17:31:35 +0200 Message-Id: <20210506153153.30454-25-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_083254_622287_4A478E7B X-CRM114-Status: GOOD ( 14.71 ) 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 The emulated bridge returns incorrect value for PCI_EXP_RTSTA register during readout in advk_pci_bridge_emul_pcie_conf_read() function. Fix it by setting correct bit PCI_EXP_RTSTA_PME based on PCIE_MSG_PM_PME_MASK. Currently enabling PCI_EXP_RTSTA_PME bit in PCI_EXP_RTCTL register does nothing. This is because PCIe PME driver expects to receive PCIe interrupt defined in PCI_EXP_FLAGS_IRQ register. But aardvark hardware does not trigger PCIe INTx/MSI interrupt for PME event, rather it triggers custom aardvark interrupt which this driver is not processing yet. Fix this issue by handling PME interrupt in advk_pcie_handle_int() and chaining it to PCIe interrupt 0 with generic_handle_irq() (since aardvark hardware sets PCI_EXP_FLAGS_IRQ to zero). With this change PCIe PME driver finally starts receiving PME interrupt. To optimize advk_pci_bridge_emul_pcie_conf_write() code, touch PCIE_ISR0_REG and PCIE_ISR0_MASK_REG registers only when it is really needed, when processing PCI_EXP_RTCTL_PMEIE and PCI_EXP_RTSTA_PME bits. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Fixes: 8a3ebd8de328 ("PCI: aardvark: Implement emulated root PCI bridge config space") Cc: stable@vger.kernel.org # c0f05a6ab525 ("PCI: aardvark: Fix PCI_EXP_RTCTL register configuration") --- drivers/pci/controller/pci-aardvark.c | 40 ++++++++++++++++++++------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index 2ea58ba10a97..fac48797d922 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -574,7 +574,10 @@ advk_pci_bridge_emul_pcie_conf_read(struct pci_bridge_emul *bridge, case PCI_EXP_RTSTA: { u32 isr0 = advk_readl(pcie, PCIE_ISR0_REG); u32 msglog = advk_readl(pcie, PCIE_MSG_LOG_REG); - *value = (isr0 & PCIE_MSG_PM_PME_MASK) << 16 | (msglog >> 16); + u32 val = msglog >> 16; + if (isr0 & PCIE_MSG_PM_PME_MASK) + val |= PCI_EXP_RTSTA_PME; + *value = val; return PCI_BRIDGE_EMUL_HANDLED; } @@ -617,19 +620,21 @@ advk_pci_bridge_emul_pcie_conf_write(struct pci_bridge_emul *bridge, advk_pcie_wait_for_retrain(pcie); break; - case PCI_EXP_RTCTL: { + case PCI_EXP_RTCTL: /* Only mask/unmask PME interrupt */ - u32 val = advk_readl(pcie, PCIE_ISR0_MASK_REG) & - ~PCIE_MSG_PM_PME_MASK; - if ((new & PCI_EXP_RTCTL_PMEIE) == 0) - val |= PCIE_MSG_PM_PME_MASK; - advk_writel(pcie, val, PCIE_ISR0_MASK_REG); + if (mask & PCI_EXP_RTCTL_PMEIE) { + u32 val = advk_readl(pcie, PCIE_ISR0_MASK_REG); + if ((new & PCI_EXP_RTCTL_PMEIE) == 0) + val |= PCIE_MSG_PM_PME_MASK; + else + val &= ~PCIE_MSG_PM_PME_MASK; + advk_writel(pcie, val, PCIE_ISR0_MASK_REG); + } break; - } case PCI_EXP_RTSTA: - new = (new & PCI_EXP_RTSTA_PME) >> 9; - advk_writel(pcie, new, PCIE_ISR0_REG); + if (new & PCI_EXP_RTSTA_PME) + advk_writel(pcie, PCIE_MSG_PM_PME_MASK, PCIE_ISR0_REG); break; default: @@ -1219,6 +1224,21 @@ static void advk_pcie_handle_int(struct advk_pcie *pcie) if (!isr0_status && !isr1_status) return; + /* Process PME interrupt */ + if (isr0_status & PCIE_MSG_PM_PME_MASK) { + /* + * Do not clear PME interrupt bit in ISR0, it is cleared by IRQ + * receiver by writing to the PCI_EXP_RTSTA register of emulated + * root bridge. Aardvark HW returns zero for PCI_EXP_FLAGS_IRQ, + * so use PCIe interrupt 0. + */ + virq = irq_find_mapping(pcie->irq_domain, 0); + if (virq) + generic_handle_irq(virq); + else + dev_err(&pcie->pdev->dev, "unexpected PME IRQ\n"); + } + /* Process ERR interrupt */ if (err_bits) { advk_writel(pcie, err_bits, PCIE_ISR0_REG); From patchwork Thu May 6 15:31:36 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: 12242673 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,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 ED36EC433B4 for ; Thu, 6 May 2021 16:03:50 +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 5E39B610E7 for ; Thu, 6 May 2021 16:03:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5E39B610E7 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=K321nz/Z5Ei5ZKYAUFnqlnC5ylBViURN+vJUQtwxEJ4=; b=VdGRVMKbEM1rPj5GjJMODQA+/ t32cOI5HzXH3Gw4OPWLwRDAnOCpIXoGG2wQGgWkIhZDinJuzIMdifJrSWW+lNhaXBVvNdWQazbSjz 6fpe9knNq5DQqmzu9Qy8P1L3T6nzgeKdzVDlNyGKMZv0H2AoR1Ijm1L7VDKSWZTer7uSMG0NATmgy Z9N1CVgSCFDdPakM01d3j+xPrAuvvisC5KCPs29455GOZQNUtP36nB+0LVWGq70z9ONuL80aX/o5G 1odJ2vhDGh1kM45rN6qzfAex+mZLr+xwmQXdQp4e6KuBCieCx8UX3uanv1XkgoBHEaUxWw0hXLCLh /QF8y+RKw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1legCO-004eRW-Dy; Thu, 06 May 2021 15:46:00 +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 1lefzp-004a7P-8N 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=MAfiwxPXiTcVReKuiDU0ylh4F8AkeEl+yJDvpG7eQrI=; b=1w0ziChgfxQhGH20axEWgwceLt Vs+7VYFhkeB1zR5fRef1VDgM7ZLy62Sk71+BVT7qRuM58q0K+uWYAAnUAzWifI6gKeNcFcKVV2Iit vGZLe407v0qLK0einhuURzHIeXVYJWKMqnhMwduwFWXm95W6zMeZdrxj75mMQR6ztseMFPjvtFCiX PNEG9ti2A27dDWNutRqWi0QgwetY43LTVdFzUbrjuP83kCyISKZZHhRQh307hMtqh6/imR8eyL2Rk VBN3oBYSfy1VVZK6dQyIiRts1lu00KhM9BEi1pyrCJwXjJor85SwL7gcAC2n9BursuvWx1yUITuYg cBlyrG1A==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lefzj-0069iB-Mm for linux-arm-kernel@lists.infradead.org; Thu, 06 May 2021 15:33:00 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id D4DD86147E; Thu, 6 May 2021 15:32:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620315172; bh=XSMv0I/QDrKbiP+dMRWG7vUJ6CvFhsuNwavmAeULpqY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W0WyADJSXGoh3a/vZpkVZmGTpx4WLbcZqMo/v639+04vX8rWMvDQXbYkg0TXzAUBn B15MK53F7ZuNJCOEI5a081bbpsPLqGA4Oq6uM3RjF+2ONctil1h8eQJINed8lIdr5F xDhbeV7ccDSas1j5+F5Wn6RA4B8VLo+q8SjQuP0xzzuWIS927jct2O6HGjfkrk39SR PPgUh1GbhdCDHLGrCXaRzBt+YM/eRBGskj9068CfMqDxCQYWDhB5Gt6sMttrz2Uf5U eNXArkP/BtiIab3AHvXOcUCLNpianEY3PmEZePpNH+fQtuJPtPee8cQqE8L+iN1hCz bop5pwirNZi9Q== Received: by pali.im (Postfix) id 8A6CA732; Thu, 6 May 2021 17:32:51 +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 25/42] PCI: aardvark: Fix support for PME requester on emulated bridge Date: Thu, 6 May 2021 17:31:36 +0200 Message-Id: <20210506153153.30454-26-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_083255_841563_9CFDB691 X-CRM114-Status: GOOD ( 20.05 ) 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 PME requester id is stored in the PCIE_MSG_LOG_REG register, which contains the last inbound message. So when new inbound message is received by HW (including non-PM), the content in PCIE_MSG_LOG_REG register is replaced by a new value. PCIe specification mandates that subsequent PMEs are kept pending until the PME Status Register bit is cleared by software by writing a 1b. Enable aardvark PME interrupt unconditionally by unmasking it and read PME requester id from PCIE_MSG_LOG_REG register to emulated bridge config space immediately after receiving interrupt. Support for masking/unmasking PME interrupt on emulated bridge via PCI_EXP_RTCTL_PMEIE bit is now implemented only in emulated bridge config space, to ensure that we do not miss any aardvark PME interrupt. Reading of PCI_EXP_RTCAP and PCI_EXP_RTSTA registers is simplified as final value is now always stored into emulated bridge config space by the interrupt handler, so there is no need to implement support for these registers in read_pcie callback. Clearing of W1C bit PCI_EXP_RTSTA_PME is now also simplified as it is done by pci-bridge-emul.c code for emulated bridge config space. So there is no need to implement support for clearing this bit in write_pcie callback. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Fixes: 8a3ebd8de328 ("PCI: aardvark: Implement emulated root PCI bridge config space") Cc: stable@vger.kernel.org # c0f05a6ab525 ("PCI: aardvark: Fix PCI_EXP_RTCTL register configuration") --- drivers/pci/controller/pci-aardvark.c | 81 ++++++++++++--------------- 1 file changed, 36 insertions(+), 45 deletions(-) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index fac48797d922..6c860e67e5a2 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -424,6 +424,11 @@ static void advk_pcie_setup_hw(struct advk_pcie *pcie) reg &= ~(PCIE_ISR0_FAT_ERR | PCIE_ISR0_NFAT_ERR | PCIE_ISR0_CORR_ERR); advk_writel(pcie, reg, PCIE_ISR0_MASK_REG); + /* Unmask PME interrupt for processing of PME requester */ + reg = advk_readl(pcie, PCIE_ISR0_MASK_REG); + reg &= ~PCIE_MSG_PM_PME_MASK; + advk_writel(pcie, reg, PCIE_ISR0_MASK_REG); + /* Enable summary interrupt for GIC SPI source */ reg = PCIE_IRQ_ALL_MASK & (~PCIE_IRQ_ENABLE_INTS_MASK); advk_writel(pcie, reg, HOST_CTRL_INT_MASK_REG); @@ -557,30 +562,17 @@ advk_pci_bridge_emul_pcie_conf_read(struct pci_bridge_emul *bridge, { struct advk_pcie *pcie = bridge->data; + /* + * PCI_EXP_RTCTL and PCI_EXP_RTSTA registers are fully supported + * but their values are stored only in emulated config space buffer. + * So there is no need to handle them in read_pcie callback. + */ switch (reg) { case PCI_EXP_SLTCTL: *value = PCI_EXP_SLTSTA_PDS << 16; return PCI_BRIDGE_EMUL_HANDLED; - case PCI_EXP_RTCTL: { - u32 val = advk_readl(pcie, PCIE_ISR0_MASK_REG); - *value = (val & PCIE_MSG_PM_PME_MASK) ? 0 : PCI_EXP_RTCTL_PMEIE; - *value |= PCI_EXP_RTCTL_CRSSVE; - *value |= PCI_EXP_RTCAP_CRSVIS << 16; - return PCI_BRIDGE_EMUL_HANDLED; - } - - case PCI_EXP_RTSTA: { - u32 isr0 = advk_readl(pcie, PCIE_ISR0_REG); - u32 msglog = advk_readl(pcie, PCIE_MSG_LOG_REG); - u32 val = msglog >> 16; - if (isr0 & PCIE_MSG_PM_PME_MASK) - val |= PCI_EXP_RTSTA_PME; - *value = val; - return PCI_BRIDGE_EMUL_HANDLED; - } - case PCI_EXP_LNKCTL: { /* u32 contains both PCI_EXP_LNKCTL and PCI_EXP_LNKSTA */ u32 val = advk_readl(pcie, PCIE_CORE_PCIEXP_CAP + reg) & @@ -609,6 +601,12 @@ advk_pci_bridge_emul_pcie_conf_write(struct pci_bridge_emul *bridge, { struct advk_pcie *pcie = bridge->data; + /* + * PCI_EXP_RTCTL and PCI_EXP_RTSTA registers are fully supported + * but their values are stored only in emulated config space buffer. + * So there is no need to handle them in write_pcie callback. + */ + switch (reg) { case PCI_EXP_DEVCTL: advk_writel(pcie, new, PCIE_CORE_PCIEXP_CAP + reg); @@ -620,23 +618,6 @@ advk_pci_bridge_emul_pcie_conf_write(struct pci_bridge_emul *bridge, advk_pcie_wait_for_retrain(pcie); break; - case PCI_EXP_RTCTL: - /* Only mask/unmask PME interrupt */ - if (mask & PCI_EXP_RTCTL_PMEIE) { - u32 val = advk_readl(pcie, PCIE_ISR0_MASK_REG); - if ((new & PCI_EXP_RTCTL_PMEIE) == 0) - val |= PCIE_MSG_PM_PME_MASK; - else - val &= ~PCIE_MSG_PM_PME_MASK; - advk_writel(pcie, val, PCIE_ISR0_MASK_REG); - } - break; - - case PCI_EXP_RTSTA: - if (new & PCI_EXP_RTSTA_PME) - advk_writel(pcie, PCIE_MSG_PM_PME_MASK, PCIE_ISR0_REG); - break; - default: break; } @@ -1224,19 +1205,29 @@ static void advk_pcie_handle_int(struct advk_pcie *pcie) if (!isr0_status && !isr1_status) return; - /* Process PME interrupt */ + /* Process PME interrupt as the first one to do not miss PME requester id */ if (isr0_status & PCIE_MSG_PM_PME_MASK) { + advk_writel(pcie, PCIE_MSG_PM_PME_MASK, PCIE_ISR0_REG); /* - * Do not clear PME interrupt bit in ISR0, it is cleared by IRQ - * receiver by writing to the PCI_EXP_RTSTA register of emulated - * root bridge. Aardvark HW returns zero for PCI_EXP_FLAGS_IRQ, - * so use PCIe interrupt 0. + * PCIE_MSG_LOG_REG contains the last inbound message, + * so store requester id only when PME was not asserted yet. + * Also do not trigger PME interrupt when PME is still asserted. */ - virq = irq_find_mapping(pcie->irq_domain, 0); - if (virq) - generic_handle_irq(virq); - else - dev_err(&pcie->pdev->dev, "unexpected PME IRQ\n"); + if (!(le32_to_cpu(pcie->bridge.pcie_conf.rootsta) & PCI_EXP_RTSTA_PME)) { + u32 requester = advk_readl(pcie, PCIE_MSG_LOG_REG) >> 16; + pcie->bridge.pcie_conf.rootsta = cpu_to_le32(requester | PCI_EXP_RTSTA_PME); + /* + * Trigger PME interrupt only in case when PMEIE bit in Root Control is set. + * Aardvark HW returns zero for PCI_EXP_FLAGS_IRQ, so use PCIe interrupt 0. + */ + if (le16_to_cpu(pcie->bridge.pcie_conf.rootctl) & PCI_EXP_RTCTL_PMEIE) { + virq = irq_find_mapping(pcie->irq_domain, 0); + if (virq) + generic_handle_irq(virq); + else + dev_err(&pcie->pdev->dev, "unexpected PME IRQ\n"); + } + } } /* Process ERR interrupt */ From patchwork Thu May 6 15:31:37 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: 12242619 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 53859C43460 for ; Thu, 6 May 2021 15:46:50 +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 CFC9C610C8 for ; Thu, 6 May 2021 15:46:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CFC9C610C8 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=C4ndqhq2E7nENMcIDUQb7ffKbNF6DoHsICM7UmaAhC4=; b=UBSl4dSIK6L8OVrGcU//rZ/RQ /q8gJCprwiVbyZZGHm6BXGhlc+fE04EqedLXra6P2dBDR7O5OcRuTcsnzF6mr84yfL7IFpWKtcftf JGj8GzSte30u5UYKOcZjttcQVofCzjU78GXvM1MyktYohyam4tKFh2uufFH+cGtLsxH9mOyzYcyeh qanKxTNFgAqo5Sn+Iby/Jy4/LBHDgIXOGwSvREMpj7baReOomX6tlLjGrfqPGaBPueCtcyNptWQOk vFQVndsTq6WHuzgEisaw/KN/PiL3EHU4sbEFaQZCQyvJMp5+Drb5nu2AMUeexZFcB+Kh7gHEOwIXo p5/zaj0KA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1legBN-004e9Q-7H; Thu, 06 May 2021 15:44:57 +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 1lefzp-004a7V-G1 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=NlPdLa0mFoh+Y1pq7/6fZEnNWdOCnsGrlu1byzl595k=; b=vT/k+7g8Qi2YUfAja5N0fix57s pe7MbWpqUqhtjLE/vCyGohKstQYavUREFPsp+sm6hvt+hjHcKvBtM/v7aFbvmAHdfeCYUIZEBZ1U4 gkldRTyYAnmob/vXEprj0MToPycr73sWNNyEVACUVxk0TXkoFSJyoU8mPHPr++0f+YMBdjb/IL3Ma 4j08YDbXofOsITXOVwiNtLh4QY3pTmD8uyCkYYJ1dy97QCxU/77B/6N1dv3JKOqzs0VxTeqBnm70b 5mdj2h8CnGsLnBQknGXQ3t2zJc/QnCr41oCQRvX9dsfw06Tzn4IXIZGVAB6ABvZJ49REPw4QY8tTx CLpQ8yfw==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lefzj-0069mX-UK for linux-arm-kernel@lists.infradead.org; Thu, 06 May 2021 15:33:00 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2E94961480; 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=/uVqlvC9txwPNmX/K1BcG3NATkDFNCdhia5CIYift7Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dBuxXdS0DcNxAUVlQGA8WlWK2UBZKsMVW+M9m1tAYBBL2XUeymhG+EmZ0SGdP4aMt 2Q28Xl640HLK+GktyhLOmLI/N5wnXZSW1JdFv6kfEvXYObYgu76dQDufTc1H0Zpthe 24O/VGYlsz605MqNLxeqeE+kEq6iRm52b1VZvRCssS73mp29n07mL2H5cGv0IOlpdi f5TmoaJ7A1CUdev0lAVHoCq0TMQN5VktfylGYIlPJEtae0sD6QUjhs7twWt/Dq6WjY QUCp0PiXKGsiIw/m74+NDw4480jXJtvEckew4cZpO+9IuJUCHfxX366gQhn4328IZ4 AIJ/NArF3yY4g== Received: by pali.im (Postfix) id D67758A1; Thu, 6 May 2021 17:32:51 +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 26/42] PCI: aardvark: Fix support for bus mastering and PCI_COMMAND on emulated bridge Date: Thu, 6 May 2021 17:31:37 +0200 Message-Id: <20210506153153.30454-27-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_071552_9C4278F6 X-CRM114-Status: GOOD ( 17.67 ) 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 From very vague, ambiguous and incomplete information from Marvell we deduced that the 32-bit aardvark register 0x4 (PCIE_CORE_CMD_STATUS_REG), which is not documented in Armada 3700 Functional Specifications for PCIe Root Complex mode, should control two 16-bit PCIe registers: Command Register and Status Registers of virtual PCIe Root Bridge. This means that bit 2 controls bus mastering and forwarding of memory and I/O requests in the upstream direction. According to PCI specifications bits [0:2] of Command Register, this should be by default disabled on reset. So explicitly disable these bits at early beginning of aardvark initialization. Also remove code which unconditionally enables all 3 bits and let kernel code (via pci_set_master() function) to handle bus mastering of Root PCIe Bridge via emulated PCI_COMMAND on emulated bridge. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Fixes: 8a3ebd8de328 ("PCI: aardvark: Implement emulated root PCI bridge config space") Cc: stable@vger.kernel.org # b2a56469d550 ("PCI: aardvark: Add FIXME comment for PCIE_CORE_CMD_STATUS_REG access") --- drivers/pci/controller/pci-aardvark.c | 54 +++++++++++++++++++-------- 1 file changed, 38 insertions(+), 16 deletions(-) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index 6c860e67e5a2..92f93ec48d6b 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -31,9 +31,6 @@ /* PCIe core registers */ #define PCIE_CORE_DEV_ID_REG 0x0 #define PCIE_CORE_CMD_STATUS_REG 0x4 -#define PCIE_CORE_CMD_IO_ACCESS_EN BIT(0) -#define PCIE_CORE_CMD_MEM_ACCESS_EN BIT(1) -#define PCIE_CORE_CMD_MEM_IO_REQ_EN BIT(2) #define PCIE_CORE_DEV_REV_REG 0x8 #define PCIE_CORE_PCIEXP_CAP 0xc0 #define PCIE_CORE_ERR_CAPCTL_REG 0x118 @@ -365,6 +362,11 @@ static void advk_pcie_setup_hw(struct advk_pcie *pcie) reg = (PCI_VENDOR_ID_MARVELL << 16) | PCI_VENDOR_ID_MARVELL; advk_writel(pcie, reg, VENDOR_ID_REG); + /* Disable Root Bridge I/O space, memory space and bus mastering */ + reg = advk_readl(pcie, PCIE_CORE_CMD_STATUS_REG); + reg &= ~(PCI_COMMAND_IO | PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER); + advk_writel(pcie, reg, PCIE_CORE_CMD_STATUS_REG); + /* Set Advanced Error Capabilities and Control PF0 register */ reg = PCIE_CORE_ERR_CAPCTL_ECRC_CHK_TX | PCIE_CORE_ERR_CAPCTL_ECRC_CHK_TX_EN | @@ -443,19 +445,6 @@ static void advk_pcie_setup_hw(struct advk_pcie *pcie) advk_writel(pcie, reg, PIO_CTRL); advk_pcie_train_link(pcie); - - /* - * FIXME: The following register update is suspicious. This register is - * applicable only when the PCI controller is configured for Endpoint - * mode, not as a Root Complex. But apparently when this code is - * removed, some cards stop working. This should be investigated and - * a comment explaining this should be put here. - */ - reg = advk_readl(pcie, PCIE_CORE_CMD_STATUS_REG); - reg |= PCIE_CORE_CMD_MEM_ACCESS_EN | - PCIE_CORE_CMD_IO_ACCESS_EN | - PCIE_CORE_CMD_MEM_IO_REQ_EN; - advk_writel(pcie, reg, PCIE_CORE_CMD_STATUS_REG); } static int advk_pcie_check_pio_status(struct advk_pcie *pcie, u32 *val) @@ -555,6 +544,37 @@ static int advk_pcie_wait_pio(struct advk_pcie *pcie) return -ETIMEDOUT; } +static pci_bridge_emul_read_status_t +advk_pci_bridge_emul_base_conf_read(struct pci_bridge_emul *bridge, + int reg, u32 *value) +{ + struct advk_pcie *pcie = bridge->data; + + switch (reg) { + case PCI_COMMAND: + *value = advk_readl(pcie, PCIE_CORE_CMD_STATUS_REG); + return PCI_BRIDGE_EMUL_HANDLED; + + default: + return PCI_BRIDGE_EMUL_NOT_HANDLED; + } +} + +static void +advk_pci_bridge_emul_base_conf_write(struct pci_bridge_emul *bridge, + int reg, u32 old, u32 new, u32 mask) +{ + struct advk_pcie *pcie = bridge->data; + + switch (reg) { + case PCI_COMMAND: + advk_writel(pcie, new, PCIE_CORE_CMD_STATUS_REG); + break; + + default: + break; + } +} static pci_bridge_emul_read_status_t advk_pci_bridge_emul_pcie_conf_read(struct pci_bridge_emul *bridge, @@ -624,6 +644,8 @@ advk_pci_bridge_emul_pcie_conf_write(struct pci_bridge_emul *bridge, } static struct pci_bridge_emul_ops advk_pci_bridge_emul_ops = { + .read_base = advk_pci_bridge_emul_base_conf_read, + .write_base = advk_pci_bridge_emul_base_conf_write, .read_pcie = advk_pci_bridge_emul_pcie_conf_read, .write_pcie = advk_pci_bridge_emul_pcie_conf_write, }; 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); From patchwork Thu May 6 15:31:39 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: 12242621 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 9F76CC433ED for ; Thu, 6 May 2021 15:47:04 +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 0754C610A7 for ; Thu, 6 May 2021 15:47:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0754C610A7 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=GYNzDvaaiOoFNNX7aiWxgDOwNJNU+ToyQYsluvBWAXc=; b=LtQDNsa2FchpGXyIUCjMOCerd NitnR8iWxWhtnXhFZ2ATKWxrZGgOreJpE+ZWiw+1zykjdGrluexBpEX9D5q8PMR1lIhJADACAQwRA kE4AUXTRht6AqgzfmuZr5s5GGnFQLp/RjM96OzvcPWGVaX1gb5quYf2nCSR4UuG8t7sYWKicDOw6b iglftOFYY9OQPGdLi6m8q6KwEjvOsPKT5V91PvG98mEpGtQV7pLD/NOg+1/0g1A5XSc4vx7nrxG7W zjyL9H0lE6cr9X63NUXOdAwI5ScNXMLrGSMmBmJK2ArnQYpb2NyRz9ytdEF+ZWBtNuMbPd47limZI 4YuNXdLMA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1legBt-004eIs-8E; Thu, 06 May 2021 15:45:29 +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 1lefzp-004a7c-Jy 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=UoJHvQ3vzZm1pLq2/c8ra9MFqNWXd94mGHvDIeHwYck=; b=3OL5YqPnqcC+KAbDF3LCE1dTvp A94H48s9UuvfRcnnMEjztk+gtvk88O/4C2ZCIyNh5tDcm5dvHWSCmmOHjhDSqN2CIMBVOXUg8ob8l /raWGAa7iJi2v0e78xGlT1ZYMiWPihakbOLewv0aILzF8nVSC4h0Q9ziUo0N2+2sEpT4ANPI4oVq5 B/2t1mQeAcP57gCKk+CMvjt+2gf4VGm/D7EV59AgY5aJHXwsWQzHWmHygo0k2JqwuRtKwh/5HRzsY j+it3cRgMZ2Q9+QNcznIS/RslnYCnKAPDw5z0VymlrAwHHO5j48nhXW/TirFvntdpyU/WGYbRl4/j ASRFHKtQ==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lefzk-0069hj-FH for linux-arm-kernel@lists.infradead.org; Thu, 06 May 2021 15:33:00 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id BADBA61623; 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=cukb1RYa3CPOxDWIDu0hDutwDBoEWduM1fL88dBLs4Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rb7tDkFKtE7FRK/k2f18pwsTzXMm4bFr0ttYvQCxLMbM0iCF2+0X0LTMMu/W+35Bv 1bGFBql7WyK/hns70U+rXulXmJfFeSf1IIt2cGtGPsm35j+wwc5XMgnAK/S+8CH9S4 ztvPfN/aLjjZe2/eOgQ9kYRU1lZWRMEe4wOIqLt6Z7+mQxQD/FiqW8ZZmUBR9nU6ar WNy338Xp7JpoE7JWFLqF7Bn88bz06Wdd4FzWlbcf/m52H61F1ptY2m0kUqRm9zOtRL 1Gy71CSqQ6o0VX8jo5pWsoDgCuNUnbw9LTkYbsqfSXH86MnjtAxxaRE6qaerkiWrJS WPXN5vwBOKroA== Received: by pali.im (Postfix) id 7499B732; 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 28/42] PCI: aardvark: Free config space for emulated root bridge when unbinding driver to fix memory leak Date: Thu, 6 May 2021 17:31:39 +0200 Message-Id: <20210506153153.30454-29-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_606282_CDBC1220 X-CRM114-Status: GOOD ( 10.95 ) 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 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 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 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index 28ddffce1bec..4b531675db81 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -1491,6 +1491,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); + return 0; } From patchwork Thu May 6 15:31:40 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: 12242677 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 89210C43462 for ; Thu, 6 May 2021 16:03:52 +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 0515D610E9 for ; Thu, 6 May 2021 16:03:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0515D610E9 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=y+NPTl/McCzvDO5784roiv19GjqSUxj/aJeJH762IcA=; b=q2ALStW5+ZkupmcQvVOCD1sjL GnJ2CJN36o0jyaHMm3EHpyFb/3b8o/COT+Yr3b0SvMjdGbjgvSrBdwSvePBCvP5GYI47U+1QWsca5 UNYjSxpd4veL2Tuv8R22B42M1V6xkIz2CVJjicAuOzZDBTSZkz6uam++aVEaQmrh7NXr+mjWUfMZ/ 50rrEyPJ27oCHTsDK0oekE7rx+FO1NzH4uXuKNqPR+6+WNbsKgAXTquiTrAczWoEBtlzW0p92zFkI 7Wzl7SMN4rKjQBqxS/Kz+iegUvTgA473jW/yLf/OzfMa+rqp8O3W1SVoK1Edwfr/uCUuydwTogye1 XnmDmPldA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1legDw-004evM-Qy; Thu, 06 May 2021 15:47:37 +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-004a7g-2K 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=aVhISHuU40y41hcPh9Ge1wnwQ2NdiyDHU1IMjZf7E94=; b=FYd7jh7udiWZG3PHpk3Zb4H8Wq ikQI//uZOFIMu6nTHSPRaBq/n+X/HtgcZ/W+CN5PZIgdOL78TDePgFCJTfzm8jkdxSyXa8TBgBk0f KO6cAs8F1/VrnWxoXJRs+SD7JX3nS9RTNRfDvcl0h2/cCXJypyVSNB6eKsbTPqWklb4B7zS1ILdYp T7gHURQnNDLa5VEfZiGmeWK69STZsvVWTLXc+JZxzqyHGzn6sLykXPLVVYTRZQkuMyTdkVkoI/h1Q nAK0QkYUkydFqMCSRjYiOxcz4urGIUKdnu3K66jN2V4aQBzSp0g1NPMTqUzvjgFFTWNer73Pb06SD WYLXTPLA==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lefzk-0069iC-JT for linux-arm-kernel@lists.infradead.org; Thu, 06 May 2021 15:33:00 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0A13B613ED; Thu, 6 May 2021 15:32:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620315173; bh=/5yIPTKEkWgY56kimWV9XM50Ciagid7BtB2KRODStO4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jseQYHW2AX00bNRe4SOUilGmTtv0OoLzecty/ZBtsQrArq/n3dhHzEcZfvSA+gPif iHOqLDm6J+2aOTGDbqYAIrfFpc/XcU/II14gWpEwtfQwkH9UF/J6nvTUBgmCEfPcbD UuRFMWAAmRX/SFOWU64K2XBs6Rwl7Qz+6MZRECtaxK8yhydg5Thl05xxzhYaS/cte6 YnE5NL/8gkuNchVcP2Zy8gfHIovErlfDfcPHGi89LhuDmzdh5uU1F8848BwX3BpeeS ysxAF3/7oMREC+Q3OVnye88vOnSLag9o+iFbaZHOEidJyIBAUhLePcWaZdIE5dGeG4 QE5XnJ5JSHehA== Received: by pali.im (Postfix) id B56988A1; 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 29/42] PCI: aardvark: Reset PCIe card and disable PHY when unbinding driver Date: Thu, 6 May 2021 17:31:40 +0200 Message-Id: <20210506153153.30454-30-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_708946_E8E4B959 X-CRM114-Status: GOOD ( 11.11 ) 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 When unbinding driver, assert PERST# signal which prepares PCIe card for power down. Then disable link training and PHY. 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 | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index 4b531675db81..b1e6a8a839e0 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -1494,6 +1494,18 @@ 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 link training */ + val = advk_readl(pcie, PCIE_CORE_CTRL0_REG); + val &= ~LINK_TRAINING_EN; + advk_writel(pcie, val, PCIE_CORE_CTRL0_REG); + + /* Disable phy */ + advk_pcie_disable_phy(pcie); + return 0; } From patchwork Thu May 6 15:31:41 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: 12242667 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,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 0F9DFC433ED for ; Thu, 6 May 2021 16:03:43 +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 89C2A610C8 for ; Thu, 6 May 2021 16:03:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 89C2A610C8 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=m8UIbJBzQGCj4L4nDtwsubKgM967t8ZE9D2FAQgg2hQ=; b=A+rMZFfdW6zo43/8HLLXeiegb MLVFTUQ9jahHGdbj3liCTPuEew3TW25xMT3xEVm9el12kx+lEQseseSAsZ/sKJcP5OivqsssmETfZ mREtQEYmueb7deswQFO1uwDxxArYGMFvlt0/kSGUKsr6s735bM/AGUmcs+8foS6SJQTpm2pMhIrb2 2Dqgo2mNhpl0q305isbsjecbfsp1BoNDtbL1iimNA4gy0MZ+3jaQwIy25YPxl8tdrDD2ntUWYckTj e2eDnzIo+OKDIqfTb/eLdC4u7de2lMpchv+UBgQXPUMmb8YJMzbIQvHk0IBmaBE9cY65KKUNM0oqg AGGDUWL0g==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1legFv-004fbY-KV; Thu, 06 May 2021 15:49:39 +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-004a7k-Jw for linux-arm-kernel@desiato.infradead.org; Thu, 06 May 2021 15:33:04 +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=XN5P0Jr5SMPqOA1GByin624XEdhPexT8QyIAZSBXijM=; b=dmL9326GtPsV/HbsdDv+3+JBQG vue46B1gJD92xIQWVNQbF4qM1Z82FKwIAA2k3jUK5U7Z9nAyFcqIVUKZUvBxDxoyUPIz87RCtpM5N jIygF52huuB6LMZZuEiQlnvvW7j2ds8L4xUc+h3lUjUCn1sweoZG+CEiUqnfTGpfhKohxLLYKcLAn ZwVjqNQTrSruoPB660j3LJWwtlkiowASH3k8HhFm7R/68UBDjPQ6I2n8mRBTftjauMfNQalte6uAr MS6tP5WmSfo+z3q7g3qgI2IJ0IibXWlg/UgQs4inAGRjuVWxUFHGejJq/gxci87jJkj/vmciUpH8b zdIwkdDQ==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lefzk-0069nK-RG for linux-arm-kernel@lists.infradead.org; Thu, 06 May 2021 15:33:01 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6416261468; Thu, 6 May 2021 15:32:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620315173; bh=OEaFaYCn4Fs+blLV4e+MvHGsjsrcVg0+nuuN5Mw4ZwM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ng9dDMo+LuMGAj/2YXtZTh6SPrG+ul3sPkewAKWkEgoOK55x6JPqyE0Vd8rPRrO5R ht7cgzBqxZQ5jZonBDQ5N0ZS8T9BYgN7V4KXM9ZrP7JMpOooHqSgg8Ny9ErH7JNa3E sDpFUF8d1zcSHwp12X8SfAA4s2IuTlu72U/KekZ3gQnATCr+zC+JqpPfjMTucepPhU F1r7b70iPbttT9N5TtGleguUlZLFlU/WVdtPgN12r6dA4H3kg7IH4Fh17evA20PLQ3 GNR5xgAqSzZyw2U+3Xg7HJ4UPcuIVslBgh7FpBPof/9kWFTa+Q6rt607ni5Nxflczt 54XN5UpBn3aVw== Received: by pali.im (Postfix) id 1B9FC732; Thu, 6 May 2021 17:32:53 +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 30/42] PCI: aardvark: Rewrite irq code to chained irq handler Date: Thu, 6 May 2021 17:31:41 +0200 Message-Id: <20210506153153.30454-31-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_965306_60375D9A X-CRM114-Status: GOOD ( 16.38 ) 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 advk_pcie_irq_handler() reads irq status bits and calls other functions based on which bits are set. These function then reads its own irq status bits and calls other aardvark functions based on these bits. Finally generic_handle_irq() with translated linux irq numbers are called. Rewrite the code to use irq_set_chained_handler_and_data() handler with chained_irq_enter() and chained_irq_exit() processing instead of using devm_request_irq(). Signed-off-by: Pali Rohár Reviewed-by: Marek Behún --- drivers/pci/controller/pci-aardvark.c | 45 ++++++++++++++------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index b1e6a8a839e0..f2ed276b7e18 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -193,6 +193,7 @@ struct advk_msi_range { struct advk_pcie { struct platform_device *pdev; void __iomem *base; + int irq; struct irq_domain *irq_domain; struct irq_chip irq_chip; struct irq_domain *msi_domain; @@ -1283,21 +1284,24 @@ static void advk_pcie_handle_int(struct advk_pcie *pcie) } } -static irqreturn_t advk_pcie_irq_handler(int irq, void *arg) +static void advk_pcie_irq_handler(struct irq_desc *desc) { - struct advk_pcie *pcie = arg; - u32 status; + struct advk_pcie *pcie = irq_desc_get_handler_data(desc); + struct irq_chip *chip = irq_desc_get_chip(desc); + u32 val, mask, status; - status = advk_readl(pcie, HOST_CTRL_INT_STATUS_REG); - if (!(status & PCIE_IRQ_CORE_INT)) - return IRQ_NONE; + chained_irq_enter(chip, desc); - advk_pcie_handle_int(pcie); + val = advk_readl(pcie, HOST_CTRL_INT_STATUS_REG); + mask = advk_readl(pcie, HOST_CTRL_INT_MASK_REG); + status = val & ((~mask) & PCIE_IRQ_ALL_MASK); - /* Clear interrupt */ - advk_writel(pcie, PCIE_IRQ_CORE_INT, HOST_CTRL_INT_STATUS_REG); + if (status & PCIE_IRQ_CORE_INT) { + advk_pcie_handle_int(pcie); + advk_writel(pcie, PCIE_IRQ_CORE_INT, HOST_CTRL_INT_STATUS_REG); + } - return IRQ_HANDLED; + chained_irq_exit(chip, desc); } static void __maybe_unused advk_pcie_disable_phy(struct advk_pcie *pcie) @@ -1363,7 +1367,7 @@ static int advk_pcie_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct advk_pcie *pcie; struct pci_host_bridge *bridge; - int ret, irq; + int ret; bridge = devm_pci_alloc_host_bridge(dev, sizeof(struct advk_pcie)); if (!bridge) @@ -1377,17 +1381,9 @@ static int advk_pcie_probe(struct platform_device *pdev) if (IS_ERR(pcie->base)) return PTR_ERR(pcie->base); - irq = platform_get_irq(pdev, 0); - if (irq < 0) - return irq; - - ret = devm_request_irq(dev, irq, advk_pcie_irq_handler, - IRQF_SHARED | IRQF_NO_THREAD, "advk-pcie", - pcie); - if (ret) { - dev_err(dev, "Failed to register interrupt\n"); - return ret; - } + pcie->irq = platform_get_irq(pdev, 0); + if (pcie->irq < 0) + return pcie->irq; pcie->reset_gpio = devm_gpiod_get_from_of_node(dev, dev->of_node, "reset-gpios", 0, @@ -1436,6 +1432,8 @@ static int advk_pcie_probe(struct platform_device *pdev) return ret; } + irq_set_chained_handler_and_data(pcie->irq, advk_pcie_irq_handler, pcie); + bridge->sysdata = pcie; bridge->ops = &advk_pcie_ops; @@ -1443,6 +1441,7 @@ static int advk_pcie_probe(struct platform_device *pdev) if (ret < 0) { advk_pcie_remove_msi_irq_domain(pcie); advk_pcie_remove_irq_domain(pcie); + irq_set_chained_handler_and_data(pcie->irq, NULL, NULL); return ret; } @@ -1491,6 +1490,8 @@ static int advk_pcie_remove(struct platform_device *pdev) advk_pcie_remove_msi_irq_domain(pcie); advk_pcie_remove_irq_domain(pcie); + irq_set_chained_handler_and_data(pcie->irq, NULL, NULL); + /* Free config space for emulated root bridge */ pci_bridge_emul_cleanup(&pcie->bridge); From patchwork Thu May 6 15:31:42 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: 12242671 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 3B38EC43461 for ; Thu, 6 May 2021 16:03:48 +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 ADDCB61073 for ; Thu, 6 May 2021 16:03:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ADDCB61073 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=zJ4Qt/zwFXDPeo3ymsvfNExNj42XxXauWk2txAnbb5s=; b=OeJWSFhgYnZtBLx3Bh5w61tez FZlzRw5eGrC1IhYpMGk2vwMU7fEldQ+UQUi8Hean8hkmVrZdHz7Cg0A2rf7+wiiukzrAwDTKNahB8 CfOjUHq96hF2Dqwc8axpvQbKzE1aeKyF29QxsyqYMUzBVhK+ui0Drhb/1NWO66ZvMbYSKrf7bP4RU G0iQYWfSARpAvhvePuiDmqzLI8yIdRhc2cJN6tyZFPx6lPfNaR4sxAp25Ggj3jFFD6qgs8Yvs14vb w3qXOlJrj6wiWTHMqm2Y/Qi/lS7h6ia/CqSR0Ym50kPMD2sM2QTpk7B16/L7kQhzHJkQ0vOTAtRIt 7HlG0rstg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1legEp-004fES-Gd; Thu, 06 May 2021 15:48:32 +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-004a7t-TP for linux-arm-kernel@desiato.infradead.org; Thu, 06 May 2021 15:33:04 +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=eOfjyVnowt166Ky7AsOxTOxN3CESr/UCj+2gvgaZq7A=; b=jjRrA9Yji827K+8ntg/sh7iI2i xjsq1QIq/bYRSDtqO8tvLMSo+b/IluIS2uPsx19pGphEuEiyTX5oMnxpdceLg96wda7Idf4bTakJk AAtPxTnQyo4JruWJgTgodvpavmd298b7oZuF0yG5wQpG3bh0wzw5EDNVTHdQI+CCoNXUMV8lIWFYx G7UouE1PIvn/a929Udzi6QepPp/WFL6BRej47jAEQAO/opbTBmEJ04pAS5okOg8t7Yu3x6GXsV1WD d33arsA3nrRUmjnfTcCMj87z8/a7Zz8Dv866dtrXmkehZULf7xnB2izbrezNmkrJUon0Z0VDeXpYG FpVxVFeQ==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lefzl-0069ga-7N for linux-arm-kernel@lists.infradead.org; Thu, 06 May 2021 15:33:01 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id B6214613B5; Thu, 6 May 2021 15:32:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620315174; bh=JtpzxROGnZVDcJeZYzWfrsnJEYa+UhigCuLwKzPz8pI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q7xwc5ANNXpJa4sYpgJ9cScgGOgl2KJRynZD6qVxsvTciEAhMSEZY9Rw/gOM1dJKR YRhUlLxjn6KcSeiB6BFwCKxYxrndvvlneMqpRA/sDRPcWTX+Gy+cex9e+jaPjApjID 8M4Ep7ErS7+tGRKkm+MC9lhABLkBxjnM28NJCrR1vPOlIavw8lZdlwTRFt1RDXC2IT FKLA0eSQkU6/MT+bkR4XTE8Rfmh8bPU/9nwWKsvQjQpJkuZDnwh2J/X+lRWhzOIPVj YBhFanaOYqNc9ouWufijbUX/F22Qx27TkFLV6yxfNek2rwcHUO7upf1nVS1J12uBE1 BD5jRGzIsD4KA== Received: by pali.im (Postfix) id 6A75189A; Thu, 6 May 2021 17:32:53 +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 31/42] PCI: aardvark: Use separate INTA interrupt for emulated root bridge Date: Thu, 6 May 2021 17:31:42 +0200 Message-Id: <20210506153153.30454-32-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_083257_370241_E3D742D6 X-CRM114-Status: GOOD ( 19.33 ) 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 Emulated root bridge currently provides only one Legacy INTA interrupt which is used for reporting PCIe PME and ERR events and handled by kernel PCIe PME and AER drivers. Aardvark HW reports these PME and ERR events separately, so there is no need to mix real INTA interrupt and emulated INTA interrupt for PCIe PME and AER drivers. Register a new advk-EMU irq chip and a new irq domain for emulated root bridge and use this new separate irq domain for providing INTA interrupt from emulated root bridge for PME and ERR events. The real INTA interrupt from real devices is now separate. A custom map_irq callback function on PCI host bridge structure is used to allocate IRQ mapping for emulated root bridge from new irq domain. Original callback of_irq_parse_and_map_pci() is used for all other devices as before. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún --- drivers/pci/controller/pci-aardvark.c | 66 ++++++++++++++++++++++++++- 1 file changed, 64 insertions(+), 2 deletions(-) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index f2ed276b7e18..e724d05a61a8 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -194,6 +194,8 @@ struct advk_pcie { struct platform_device *pdev; void __iomem *base; int irq; + struct irq_domain *emul_irq_domain; + struct irq_chip emul_irq_chip; struct irq_domain *irq_domain; struct irq_chip irq_chip; struct irq_domain *msi_domain; @@ -1074,6 +1076,22 @@ static const struct irq_domain_ops advk_pcie_irq_domain_ops = { .xlate = irq_domain_xlate_onecell, }; +static int advk_pcie_emul_irq_map(struct irq_domain *h, + unsigned int virq, irq_hw_number_t hwirq) +{ + struct advk_pcie *pcie = h->host_data; + + irq_set_chip_and_handler(virq, &pcie->emul_irq_chip, handle_simple_irq); + irq_set_chip_data(virq, pcie); + + return 0; +} + +static const struct irq_domain_ops advk_pcie_emul_irq_domain_ops = { + .map = advk_pcie_emul_irq_map, + .xlate = irq_domain_xlate_onecell, +}; + static int advk_pcie_init_msi_irq_domain(struct advk_pcie *pcie) { struct device *dev = &pcie->pdev->dev; @@ -1167,6 +1185,24 @@ static void advk_pcie_remove_irq_domain(struct advk_pcie *pcie) irq_domain_remove(pcie->irq_domain); } +static int advk_pcie_init_emul_irq_domain(struct advk_pcie *pcie) +{ + pcie->emul_irq_chip.name = "advk-EMU"; + pcie->emul_irq_domain = irq_domain_add_linear(NULL, 1, + &advk_pcie_emul_irq_domain_ops, pcie); + if (!pcie->emul_irq_domain) { + dev_err(&pcie->pdev->dev, "Failed to add emul IRQ domain\n"); + return -ENOMEM; + } + + return 0; +} + +static void advk_pcie_remove_emul_irq_domain(struct advk_pcie *pcie) +{ + irq_domain_remove(pcie->emul_irq_domain); +} + static void advk_pcie_handle_msi(struct advk_pcie *pcie) { struct irq_data *irq_data; @@ -1244,7 +1280,7 @@ static void advk_pcie_handle_int(struct advk_pcie *pcie) * Aardvark HW returns zero for PCI_EXP_FLAGS_IRQ, so use PCIe interrupt 0. */ if (le16_to_cpu(pcie->bridge.pcie_conf.rootctl) & PCI_EXP_RTCTL_PMEIE) { - virq = irq_find_mapping(pcie->irq_domain, 0); + virq = irq_find_mapping(pcie->emul_irq_domain, 0); if (virq) generic_handle_irq(virq); else @@ -1257,7 +1293,7 @@ static void advk_pcie_handle_int(struct advk_pcie *pcie) if (err_bits) { advk_writel(pcie, err_bits, PCIE_ISR0_REG); /* Aardvark HW returns zero for PCI_ERR_ROOT_AER_IRQ, so use PCIe interrupt 0 */ - virq = irq_find_mapping(pcie->irq_domain, 0); + virq = irq_find_mapping(pcie->emul_irq_domain, 0); if (virq) generic_handle_irq(virq); else @@ -1304,6 +1340,21 @@ static void advk_pcie_irq_handler(struct irq_desc *desc) chained_irq_exit(chip, desc); } +static int advk_pcie_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) +{ + struct advk_pcie *pcie = dev->bus->sysdata; + + /* + * Emulated root bridge has itw own emulated irq chip and irq domain. + * Variable pin is the INTx pin (1=INTA, 2=INTB, 3=INTC, 4=INTD) and + * hwirq for irq_create_mapping() is indexed from zero. + */ + if (pci_is_root_bus(dev->bus)) + return irq_create_mapping(pcie->emul_irq_domain, pin-1); + else + return of_irq_parse_and_map_pci(dev, slot, pin); +} + static void __maybe_unused advk_pcie_disable_phy(struct advk_pcie *pcie) { phy_power_off(pcie->phy); @@ -1432,13 +1483,23 @@ static int advk_pcie_probe(struct platform_device *pdev) return ret; } + ret = advk_pcie_init_emul_irq_domain(pcie); + if (ret) { + dev_err(dev, "Failed to initialize irq\n"); + advk_pcie_remove_irq_domain(pcie); + advk_pcie_remove_msi_irq_domain(pcie); + return ret; + } + irq_set_chained_handler_and_data(pcie->irq, advk_pcie_irq_handler, pcie); bridge->sysdata = pcie; bridge->ops = &advk_pcie_ops; + bridge->map_irq = advk_pcie_map_irq; ret = pci_host_probe(bridge); if (ret < 0) { + advk_pcie_remove_emul_irq_domain(pcie); advk_pcie_remove_msi_irq_domain(pcie); advk_pcie_remove_irq_domain(pcie); irq_set_chained_handler_and_data(pcie->irq, NULL, NULL); @@ -1487,6 +1548,7 @@ static int advk_pcie_remove(struct platform_device *pdev) advk_writel(pcie, PCIE_IRQ_ALL_MASK, HOST_CTRL_INT_STATUS_REG); /* Remove IRQ domains */ + advk_pcie_remove_emul_irq_domain(pcie); advk_pcie_remove_msi_irq_domain(pcie); advk_pcie_remove_irq_domain(pcie); From patchwork Thu May 6 15:31:43 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: 12242681 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 9CE49C43600 for ; Thu, 6 May 2021 16:03:54 +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 3C8E5610FC for ; Thu, 6 May 2021 16:03:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3C8E5610FC 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=7+Uy95AfoN1Ayl/sGeeOSk0EJFHRv5bA6FsYlHUorJU=; b=nju9QGpfZ0t+TXmWIfd92NSMj tT1w4m4zFbK87ZddHh1fwc5s8Bs+K2Nk/ElCIg2Dg3gSyK91YK+e4XPWD74dEyGQRpRtfoLfF3pyu Nn4Z7iuje3ld31V6q70CEzIasMiGoIzzq/tbmXeZ7qZQ2y5+DyOyBdintagZsNb0PFWEENLCszT3I w6q52LqxJMlR1pq8WSOAlTw/G4kX6yKh9rcAGoFSVKIEN3STzM1ObSH6ZWNOiHkkFJnkv+QHw/jjK pOK3zTrNGWHsuqBbOLdA6KCYBhlrjRcp1mYu0w1I15AHUGa7lFF8N/UDR7veF5pUjqIKzmuOP+Xn3 Cqs7SfIdg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1legCr-004ea0-53; Thu, 06 May 2021 15:46:29 +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-004a7r-O9 for linux-arm-kernel@desiato.infradead.org; Thu, 06 May 2021 15:33:03 +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=5QnKiVvlMGggt+u+Rbfh/wgi8B39h3AKsBB/TYS2YXE=; b=m208AWT8XqCP7mQ16Tl1xKS76L PgA8dry56HbPuvmSMBLYrQye61Zg2Jk2ti0VTe2UzrQkbQVC0k5tkJjybW98Seq1CJ9c/xJdXuqdR OP0sN33s8nZbXVQgHPMTUuA2Egc88SxgUJsDNjvatIJXkVDUDPYc0XuAQNeuR8M9X9BiqilXEMYEP j85IYNA+4ScYvu7PzWwPS+uxHpLhFk+nv0wz0wSJ2tBHHfekg35ahIcYJDPiR2+dyUfmNzoe+MHdL AmtmQ2G6Fz6dmbYZAHb9rQ/SWLJifme86xfCWbj3JVu75qjhk34RCjJrsxxa74oVNkA57j6meWXuS u4UQRThA==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lefzl-0069o6-GR for linux-arm-kernel@lists.infradead.org; Thu, 06 May 2021 15:33:01 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0526E61469; Thu, 6 May 2021 15:32:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620315174; bh=zi+PML1cWSulO/GYWf9yak7a3W+RSD4MegJIQ/xyX/0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EqDJhLO1Hbf8GkvCKJD0Nzd3ZOEPegQ4Ex2n1YeJtatlQl6Tr4bvmFR9YYqpgSfqb BX4/PEJZLywUrkQrde7yaSPg/j5lrsNr8UlJ44x1jVDO5GS4GPG+/eJo+sGYb+OKro GQHHh13UH+UCZ2TOlXFdq696tTnU9DaAsE3hhTnwH33W047YxWZ2ZixmzjtoF4AoqO N7q6gFcsJOkOEEnUjLywFP7y/SJT+kIm4jDnurpRFmXqfb9+XYfe2YcR6Z/vsTru6I lz+ngyp3uxxpZmbe5h7lWGZT1u1XE1WJLPaklxoistVSrSAkZsUXFwxF7xmFgyJC2U GtL62ZeX3tDUA== Received: by pali.im (Postfix) id B509A8A1; Thu, 6 May 2021 17:32:53 +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 32/42] PCI: pci-bridge-emul: Add description for class_revision field Date: Thu, 6 May 2021 17:31:43 +0200 Message-Id: <20210506153153.30454-33-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_083257_596485_3934D2ED X-CRM114-Status: GOOD ( 10.22 ) 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 Make it clear why there is bitshift by 16 and rewrite the code to align with the new description. Signed-off-by: Pali Rohár Reviewed-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 fdaf86a888b7..2b6ea84f25af 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 24bits and revision is low 8bit + * Class for PCI Bridge Normal Decode has 24bit 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 Thu May 6 15:31:44 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: 12242657 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 8A0D2C43462 for ; Thu, 6 May 2021 16:03:31 +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 1D33C61078 for ; Thu, 6 May 2021 16:03:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1D33C61078 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=r6ZrnzBTngXAiAqc6WhsHCEPJMesSvpIX6rdrjKA9qM=; b=bhE/1YcA804PA4tL1lvxakGUH 8/DxMSi2RXK/1GMZTDLi0IIJdz4ga+r0O0hLPbz8qQ6WLMPAf55DyQ+HCyzz9BIJZToAdu3heyMTq DqxhYUoU+AtdS9vWK+csqyXcxJS9wu6PtW6Z6tCiVxPoHOpKcMI4TH9k29l2N+PFdUdy3p8+JYny5 bNbH94pB9abjj7z6jMgr054rCJtoqAtklqwhVHXPwKQUcDexVFm0rk0Z0gjLwfsOM51sZwjLhR7BP SAfupaQO2UlINsDv0ZqxE47y/QkFWdRa0T6+tLWa6b0/pPOZEaJWOI9O39xN38CULDewNv2bDwWBA tJhi8M1Ig==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1legIK-004gMv-5G; Thu, 06 May 2021 15:52:08 +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 1lefzt-004a7g-3U for linux-arm-kernel@desiato.infradead.org; Thu, 06 May 2021 15:33:05 +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=YIw8yszMwbjw+oJPwpNAYSdMmkV96s/dYdlX6MksGOg=; b=vVyCtP0LLvHGohhpDM9bN8VqOv F526butivp8YuZ44zrK2xxLqJjOSVF8nuwX1PJm2dWWsaaLgOpP4mvkmDSk7M3A2UsJyz5zekAuuy NSjNHy1AYN5I18nJHRgSg3LzOlA+Pz1t9KoeQ1MbwtkSXVW6kK4xaji4T4IE3KOL9SqTXiMUFVNfv 9UR2euZqvU/arXNPHZWtlYykV2Pc95ngNmFnE4cGt2nnL+8aQuKdwj5Aw0g+YHc2Fvc+ZO64q2eaf jaV/ofUCQMBOTnT7hUFT2/f3/gQ1Q1CRcQy5FQ2GZrWfpBtf63TWKolwOZLmHKpNwWKHljtU4XZ1i jHXQulUg==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lefzl-0069jn-NX for linux-arm-kernel@lists.infradead.org; Thu, 06 May 2021 15:33:02 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 50EAF61481; Thu, 6 May 2021 15:32:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620315174; bh=jDjvYmJ9QZ5eFWkjBBpJHdBeKaOXh+IEdL5qMvJJIWY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ngm8BGD8/2QMRyvGZYPTTe0KnFEj+I3VakCN5h9NX97TEr9LV0LzIZ9JGjnjfcu7D YnCNEXpvnld6/Y8lHpvxt5sJSIp7ZZouxyrTLCWDmJRvE2K+TrFYxjfOxkwlLXGGO/ dVMsAokKeBAPHN6KL3ELgw4VnlIm3HyvVZsiE42u+605QrAwmwUSFh890Q9o9ACjX6 BgWbgX30Ynmn6rRDqUVRO/L6gHiWg8fYQ2OL0ESL/9ynHM1fDRcZntS+2fNpRralw9 SJy8reiyQWnBrwExdV7Ep596diKG/UDm7ujNk/hCGbqYqS1+IO5DvGFWuDJ6PFuVeQ SKCCuMDj1hugw== Received: by pali.im (Postfix) id 081C2732; Thu, 6 May 2021 17:32:54 +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 33/42] PCI: pci-bridge-emul: Add definitions for missing capabilities registers Date: Thu, 6 May 2021 17:31:44 +0200 Message-Id: <20210506153153.30454-34-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_083257_822245_D9EBE427 X-CRM114-Status: GOOD ( 10.08 ) 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 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. Fix it by adding missing definitions. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Fixes: 23a5fba4d941 ("PCI: Introduce PCI bridge emulated config space common logic") --- drivers/pci/pci-bridge-emul.c | 38 +++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/drivers/pci/pci-bridge-emul.c b/drivers/pci/pci-bridge-emul.c index 2b6ea84f25af..5f8398f8d039 100644 --- a/drivers/pci/pci-bridge-emul.c +++ b/drivers/pci/pci-bridge-emul.c @@ -251,6 +251,44 @@ 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:24] and [17:16]. */ + .ro = BIT(31) | GENMASK(23, 18) | GENMASK(15, 0), + }, + + [PCI_EXP_DEVCTL2 / 4] = { + /* + * Device control 2 register is RW but has reserved bits [12:11]. + * + * Device status 2 register is reserved. + */ + .rw = GENMASK(15, 13) | GENMASK(10, 0), + }, + + [PCI_EXP_LNKCAP2 / 4] = { + /* Link capabilities 2 register has reserved bits [30:23] and 0. */ + .ro = BIT(31) | GENMASK(22, 1), + }, + + [PCI_EXP_LNKCTL2 / 4] = { + /* + * Link control 2 register is RW. + * + * Link status 2 register has bits 5, 10, 15 W1C; bit 11 reserved and others are RO. + */ + .rw = GENMASK(15, 0), + .w1c = (BIT(15) | BIT(10) | 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 Thu May 6 15:31:45 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: 12242649 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 843B0C43460 for ; Thu, 6 May 2021 16:03:20 +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 09C32610E9 for ; Thu, 6 May 2021 16:03:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 09C32610E9 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=KGheF1yFVDgifIZzn1COKDnuFhT854RXPLnmNuZpSxw=; b=BObhM+ZYnEmBvPSMhYVme1/hv ClkyJ2hIeTijZoTSPFsmVL+pqjAKwSMrFZDFD3tZYFQuVSSxlfn+lVwRkv1LrH1SpLrWKJblk8OEU Rk3D52jn975hj5zYakQDGPH38IV7ojT+TR+HyTiU0Tc8XvT4njscS4xGueYB6hS8j2rdCOvnXjA7Q ei6k9AoTOzPPBDNxN0AYlMUzuaisZ0MODYir38qMNfcolcU0YNHj09OxP9zS3uu5FATnc07nQ3Jqi 8kR4U95FVJChQLHrvYu9QWpnDuRzsj3wKgF3ExchO1RuXGmB6MiTqrd7urw0mfMdZy5hCs/QUiGUA vdb2alzxg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1legKi-004h6b-VE; Thu, 06 May 2021 15:54:37 +0000 Received: from mail.kernel.org ([198.145.29.99]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lefzn-004a5b-1M for linux-arm-kernel@lists.infradead.org; Thu, 06 May 2021 15:33:06 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 97FDC61625; Thu, 6 May 2021 15:32:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620315174; bh=0YkTEBWISevDvHgokN8XUsGMwtVKvfnG9KGkSIjT5Co=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OMXkbHyayU7EJ06iuIZVStBfcPs+TIdvxPzRYPg8sKF16YEUQphEicjVbabUnZ6we zAsro4QRH2vBWa45bDxXDGF8qn3RmOoKKofVmkL1CO1n1i9FIUeMaGEVca5rVP1V1V R124NrK+EXSGLJDgSlFbliWaAJzrvsyuKjgHA+F8yYMmOVtkeAn+DnKZy5NUnjyKJZ DT4AMkYg7Pun4Jz5Bln0vhpx1XjEOIhQqV75+fGsZUITSupwc8uY++tv8j1gJBlM5X 8RA2AW+hhHx8xJ+BtgdO18m9vakQXjItJtF6f2Rd9RI9Zpqpo2SB3w/26Bt7AH+cqe aRxXLoC6NVivw== Received: by pali.im (Postfix) id 535E389A; Thu, 6 May 2021 17:32:54 +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 34/42] PCI: aardvark: Add support for DEVCAP2, DEVCTL2, LNKCAP2 and LNKCTL2 registers on emulated bridge Date: Thu, 6 May 2021 17:31:45 +0200 Message-Id: <20210506153153.30454-35-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_163259_418650_21AAEA98 X-CRM114-Status: UNSURE ( 9.50 ) X-CRM114-Notice: Please train this message. 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 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 Reviewed-by: Marek Behún Fixes: 8a3ebd8de328 ("PCI: aardvark: Implement emulated root PCI bridge config space") --- 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 e724d05a61a8..13bbc0b5134d 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -610,8 +610,13 @@ advk_pci_bridge_emul_pcie_conf_read(struct pci_bridge_emul *bridge, case PCI_EXP_DEVCAP: case PCI_EXP_DEVCTL: case PCI_EXP_LNKCAP: + 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; } @@ -631,16 +636,18 @@ advk_pci_bridge_emul_pcie_conf_write(struct pci_bridge_emul *bridge, */ 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) advk_pcie_wait_for_retrain(pcie); 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 Thu May 6 15:31:46 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: 12242665 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 D80F6C43600 for ; Thu, 6 May 2021 16:03:39 +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 65FBB610FC for ; Thu, 6 May 2021 16:03:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 65FBB610FC 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=YIgVXmriWhy1rbcfqLDqn90mzW8Qb+Vm7QqnevfS1lQ=; b=ftFlRWJRvajLWJE4SHWks0RA9 u87fkGWbaYJ03ofa4vmTNOUDqTlfwtGODhsycE8efQApTPxNq0WM7jM2Sv2gObNWte88ZEa+OlbjD tvC7wgeVYIQI0u0yUejnukdm2bGjpzxXnQTCdltSF4ncPyH9pabePLMiKLizjw48RhxLbLQj6UFr7 sF9xE9MkmT6Abj2Mpor10BR2X2IH+uiVMlhZqsNxQjYkNOkV/qNFltZbZbHnEdeFND+qCNW84MPHN IVNkXSLhtCVdhKyTYJxbcW42EHMCpsNL9r9NLkwm40AwilYwa3MiBwKekf2aXar6hvWJop584njmh SN7hFsDXA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1legGN-004fkB-GU; Thu, 06 May 2021 15:50:07 +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 1lefzr-004a8J-Mu for linux-arm-kernel@desiato.infradead.org; Thu, 06 May 2021 15:33:04 +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=KThAGEyW1L6fXxTgkierDuZV4eaLG1moSHpSh35QXKY=; b=Y9Am5/n2fMKJAeSacwDv2W+s61 FJFsOV2W4Pq/66FxNqPeW5mgD7rpZE0jwfS5uqrg5d/IyoNyoaaYUxFOs+ElZKyjrCCYPadHP/u/G jCxtD50po7hxHa2iqVuwaTgmnWWcV3rArDs6PKJzHhbBIC8o3CBO3fDI80o/uVpKMBLBMg4JlwFnM Yz1aB9P1RvmQe2ZPIV0E+JfuBdiDiTI/azOaR+ZKTYg6rI5IqStvLo7Oq4+cu1joStsJLtr3uXnyJ ZWjsbaPCQQh7z5NzVNQuvlHkuKprPqHnz8T9lipitD6NTSILVJuILxWESX1BundPj8G1qMOg++eeK RYqZXTUw==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lefzm-0069jp-1i for linux-arm-kernel@lists.infradead.org; Thu, 06 May 2021 15:33:02 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id DCD8161926; Thu, 6 May 2021 15:32:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620315175; bh=75Ia8fDMMjN9738pBwL6dSeC+rSyhLtGbCVaSNAnl5E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V7oZZZvz8KrPf3MxbDZcnpDiHlR3yQJiWXA7OBbCD8ij4wLxeJYntqob3tH3S8LIX h/e6DaMEKIb3ov5GmP2FT6mrXCQXDvjzLZf6p61LeAqhBuVC0FtVbNJfeZIRe9uXPD vyqgR6Mulfk4+fWddU0mnzDk1KYYyaZ56PwP+j8X7en+sg7GSCa5hLSbjWBJrzf8CL 9wbVeKuWz0+iP4FzOyMT7mdGOHf5EziHK9zAgvexO9wIerOp22dg33hISIBo8vZWs5 2bB7OniF2FMB8UVSUMf21LstrYByFi/HDk0uMEno+B7PLJDQz7mcW4wNd/n6SH505g l54NAeaBeX+HA== Received: by pali.im (Postfix) id 95D418A1; Thu, 6 May 2021 17:32:54 +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 35/42] PCI: aardvark: Add support for PCI_BRIDGE_CTL_BUS_RESET on emulated bridge Date: Thu, 6 May 2021 17:31:46 +0200 Message-Id: <20210506153153.30454-36-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_083258_148840_B2069B6B X-CRM114-Status: GOOD ( 11.86 ) 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 PCI aardvark hardware supports PCIe Hot Reset via PCIE_CORE_CTRL1_REG register. Use it for implementing PCI_BRIDGE_CTL_BUS_RESET bit of PCI_BRIDGE_CONTROL register on emulated bridge. With this change the function pci_reset_secondary_bus() starts working and can reset connected PCIe card. Also custom userspace script [1] which uses setpci can trigger PCIe Hot Reset and reset the card manually. [1] - https://alexforencich.com/wiki/en/pcie/hot-reset-linux Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Fixes: 8a3ebd8de328 ("PCI: aardvark: Implement emulated root PCI bridge config space") --- drivers/pci/controller/pci-aardvark.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index 13bbc0b5134d..d8fb43604154 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -558,6 +558,22 @@ advk_pci_bridge_emul_base_conf_read(struct pci_bridge_emul *bridge, *value = advk_readl(pcie, PCIE_CORE_CMD_STATUS_REG); return PCI_BRIDGE_EMUL_HANDLED; + case PCI_INTERRUPT_LINE: { + /* + * From the whole 32bit register we support propagating to HW + * only one bit: PCI_BRIDGE_CTL_BUS_RESET. Other bits are + * retrieved only from emulated config space buffer. + */ + __le32 *cfgspace = (__le32 *)&bridge->conf; + u32 val = le32_to_cpu(cfgspace[PCI_INTERRUPT_LINE / 4]); + if (advk_readl(pcie, PCIE_CORE_CTRL1_REG) & HOT_RESET_GEN) + val |= PCI_BRIDGE_CTL_BUS_RESET << 16; + else + val &= ~(PCI_BRIDGE_CTL_BUS_RESET << 16); + *value = val; + return PCI_BRIDGE_EMUL_HANDLED; + } + default: return PCI_BRIDGE_EMUL_NOT_HANDLED; } @@ -574,6 +590,17 @@ advk_pci_bridge_emul_base_conf_write(struct pci_bridge_emul *bridge, advk_writel(pcie, new, PCIE_CORE_CMD_STATUS_REG); break; + case PCI_INTERRUPT_LINE: + if (mask & (PCI_BRIDGE_CTL_BUS_RESET << 16)) { + u32 val = advk_readl(pcie, PCIE_CORE_CTRL1_REG); + if (new & (PCI_BRIDGE_CTL_BUS_RESET << 16)) + val |= HOT_RESET_GEN; + else + val &= ~HOT_RESET_GEN; + advk_writel(pcie, val, PCIE_CORE_CTRL1_REG); + } + break; + default: break; } From patchwork Thu May 6 15:31:47 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: 12242647 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 31592C433B4 for ; Thu, 6 May 2021 16:03:20 +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 B19AA61154 for ; Thu, 6 May 2021 16:03:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B19AA61154 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=2CA/O18WlsOcSSl2di0K0zMnHzeV+uSQtNGEbyIMXRw=; b=RvHv+HUvV80j9dqu79KtTiM87 CIpWodPNb5+dYU9gzcbrLPpW7hp63DqpkC0/wpppO3iBTclt5i0I/Ht6nw7mKQ64clTg4BJBvjBsd Z5u7OUmCdXpTRRyyrA8poPAxlJYo4E1nd5hf9aa6NGAgptxghJwZIFrip0BIvV/ICaGNEeDwbvLgc qwZsl47ICsPApnQ0HMNzhZoFRFgU8+HwPbH5oBJNowXm4P66lCJ20uXkQmB1EPkL4En8Hr9q7exIs N0w4dTz0sCdCtXkf3Sjn+1tQdbyM3wrbZY3nsDJ7ZmjDda6T5KdfgOpZaJU5rHvA/Ayn1f1sHUmP0 9lJ7ldZvA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1legLK-004hHG-Vc; Thu, 06 May 2021 15:55:15 +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 1lefzs-004a7P-Ti for linux-arm-kernel@desiato.infradead.org; Thu, 06 May 2021 15:33:05 +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=MYns9vLon5kpIG8iRb4tqZhdZpmmL/xEa1X3k1ybeUM=; b=kiyvAtAct0GwrHKA2vaUtWWTYD dfFmAQCjo19xV1hEvXTUPSwiKHkI/M5DM0XHfJnVJCn+EGtoQOs8Pu+xlB53bv3yqCBbpaTIMcZUw x6G5AczAGUtTMcZfCOv63iDZv5f265XDiYE/YEl++sdL7KriWc9cf01ULu/RzxkwmDA8h4tjDq4ff y0KN0HeevVHGy/XY6M2YNxeUiyH102dMODn8Ev30LVX1eEERrLgv651Od3dEgnCBw5/lyIEz78i8i mR4sDr/09ncLBrQwRJn80sO+OlQdPk+fHSXBNcZIQOPOXQWW8PRvW91PpG9z53wtoCzJvTDI0cYUr TwFR19Uw==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lefzm-0069gb-4i for linux-arm-kernel@lists.infradead.org; Thu, 06 May 2021 15:33:02 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2DE07616EA; Thu, 6 May 2021 15:32:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620315175; bh=ghapb+8oJP9gj5A73iBbcuKAnKFz+Keg3CDg5iz9MEU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D8P8TDdbEUPvkU0OkVC6L2OvsSvneY0lKfmp3NdonzS4GBLtOK40hdUSJqwRsoZF1 waa8XISVltL1qDT0+U+GlKRFNhSnOZGVjHC8xpsUVuuSI95c0QZe5hrCaG//WjGT5L RgAcsHSZiiGY4Mbf7SzININ6+VCiDiUwZiHoVeo7xREGbnOGNrXV5kkavHwGMiXMKO +039AZJTln4dFqABX5ocSY2GZk76BfON4BAbQgeBTUzIhbMEcqL9ZkbAtO3rQK/NGe xVYnLrHGEqN/+zHJT/Y6UvpFb1lF5hwgHRqve1v1yFVNf0iR3QDJM9BjVV/S3v3a9E 2CS0t3hZym7pw== Received: by pali.im (Postfix) id D94B0732; Thu, 6 May 2021 17:32:54 +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 36/42] PCI: aardvark: Replace custom PCIE_CORE_ERR_CAPCTL_* macros by linux/pci_regs.h macros Date: Thu, 6 May 2021 17:31:47 +0200 Message-Id: <20210506153153.30454-37-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_083258_276034_1CBE9312 X-CRM114-Status: GOOD ( 10.54 ) 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 Advanced Error Reporting Capability registers start at aardvark offset 0x100. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún --- drivers/pci/controller/pci-aardvark.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index d8fb43604154..d99462d99ed8 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -33,11 +33,7 @@ #define PCIE_CORE_CMD_STATUS_REG 0x4 #define PCIE_CORE_DEV_REV_REG 0x8 #define PCIE_CORE_PCIEXP_CAP 0xc0 -#define PCIE_CORE_ERR_CAPCTL_REG 0x118 -#define PCIE_CORE_ERR_CAPCTL_ECRC_CHK_TX BIT(5) -#define PCIE_CORE_ERR_CAPCTL_ECRC_CHK_TX_EN BIT(6) -#define PCIE_CORE_ERR_CAPCTL_ECRC_CHCK BIT(7) -#define PCIE_CORE_ERR_CAPCTL_ECRC_CHCK_RCV BIT(8) +#define PCIE_CORE_PCIERR_CAP 0x100 #define PCIE_CORE_INT_A_ASSERT_ENABLE 1 #define PCIE_CORE_INT_B_ASSERT_ENABLE 2 #define PCIE_CORE_INT_C_ASSERT_ENABLE 3 @@ -370,12 +366,10 @@ static void advk_pcie_setup_hw(struct advk_pcie *pcie) reg &= ~(PCI_COMMAND_IO | PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER); advk_writel(pcie, reg, PCIE_CORE_CMD_STATUS_REG); - /* Set Advanced Error Capabilities and Control PF0 register */ - reg = PCIE_CORE_ERR_CAPCTL_ECRC_CHK_TX | - PCIE_CORE_ERR_CAPCTL_ECRC_CHK_TX_EN | - PCIE_CORE_ERR_CAPCTL_ECRC_CHCK | - PCIE_CORE_ERR_CAPCTL_ECRC_CHCK_RCV; - advk_writel(pcie, reg, PCIE_CORE_ERR_CAPCTL_REG); + /* Enable generation and checking of ECRC on Root Bridge */ + reg = advk_readl(pcie, PCIE_CORE_PCIERR_CAP + PCI_ERR_CAP); + reg |= PCI_ERR_CAP_ECRC_GENE | PCI_ERR_CAP_ECRC_CHKE; + advk_writel(pcie, reg, PCIE_CORE_PCIERR_CAP + PCI_ERR_CAP); /* Set PCIe Device Control register */ reg = advk_readl(pcie, PCIE_CORE_PCIEXP_CAP + PCI_EXP_DEVCTL); From patchwork Thu May 6 15:31:48 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: 12242663 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 78FC3C43460 for ; Thu, 6 May 2021 16:03:39 +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 0496661073 for ; Thu, 6 May 2021 16:03:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0496661073 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=L/O9xWOO0RGJ8oBfG1ivSnRqnbneOAcigckRWvNezjY=; b=WaSUjT1ZMUG7ZvQEvlW16V2Pt rZct1oYB+7DN8l6l2/cevQVGa+aC1tb9aa1k3r1fjeJGevhFIVwcnjf+9ho5Fl0zNzz3jgztmFE70 KLB9092O1KtmIT5/OEfXeOY58lOxEb1zTKYZKgGX2lMc8ZLvFpf6g7UZ8QRp8+Jwx+31E0zD5/C1p f9F2HP6bUGblgmeagyl6GS2665a0TSdbyJsxlKLBlJAFEO9lnOjH7iEax+OOiwi1940oJyPG2YXVK 4vceaYa7CNqr6C8U5gqm6iXpjjak3JWJIi/orZEYszWYuSpd2XV8g5tQj+RmF6QWLiGMJ2D7wgT9B Frki4AD/Q==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1legGl-004frF-1V; Thu, 06 May 2021 15:50:31 +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 1lefzs-004a8l-8g for linux-arm-kernel@desiato.infradead.org; Thu, 06 May 2021 15:33:04 +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=u2GlacQLlZDdLwGJ7V5cF4MYqzhtpb3drIPH2wzcxXA=; b=SbPmsYKykpB16bBF+XfrP6Sr3z isI9I8LDAxEBzJ9rq3RTa1v//agiXlkXUwBCGpZCS+vsUUppdb0pUmecyA1X5IDnH4N0L5Cm+6xYY WpEfv5Y8JC8DPAQRdrzNXH6OKSjxBrOf53arZbCzpoimUaCU+P2S8GFjPzIp6PRnXQ5ydai3LeNrU 2Z+lkPXLkRMHCugqbgWsYqbsYMYxDQy8ypa47yvLCORDKlhaW06iBA379HSktzV8Wgo4aLutu2Gnb qweWbCMQHdzaVHsyvD7cduu9Vw1CLW1KWXarOLU0kGb1/icDUcuyLlBiH6WJr+bh2O93LPmxrL5+Y vFexPf+w==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lefzm-0069jr-CT for linux-arm-kernel@lists.infradead.org; Thu, 06 May 2021 15:33:02 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6239A616EB; Thu, 6 May 2021 15:32:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620315175; bh=OfK0Hzd2grREpBUN2tgkKBXXxq0n8pt4CmtN6wgcHqk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oxvXQjeGDG52+9/+e+/YCQVhh/+CyB4udA90afhFAk4JgSh0rlqlReB/76rR29MGv vBDOcLPuyYji99nUxMGs8MAQUs/CfjqBrFQOGlyZhzlOYCbPzRbIry4N7MjK2vm/EA JDVDfKK2dnc+LAB+qDx1EgUc5Nu5xKxITmadGS5S3KfVwke50Ng+RcNJ76OIlu8ng+ bsDkyoCFMHt7GefKFLcuvZFd2rL7DeKWVGppdOPLgzBioxhdc3kvTAHwnh/ixTsL+q mlNpCgHwVaJ/7x95QkS4aPN7lMjXKeOqXlDAdoi1F2WtQB8TMYpLxd4lC2R4msPxx8 cfmoxHdbeaqRA== Received: by pali.im (Postfix) id 1AC5E89A; Thu, 6 May 2021 17:32:55 +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 37/42] PCI: aardvark: Replace custom PCIE_CORE_INT_* macros by linux PCI_INTERRUPT_* values Date: Thu, 6 May 2021 17:31:48 +0200 Message-Id: <20210506153153.30454-38-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_083258_493486_650FD4AC X-CRM114-Status: GOOD ( 10.28 ) 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 Header file linux/pci.h defines enum pci_interrupt_pin with corresponding interrupt PCI_INTERRUPT_* values. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún --- drivers/pci/controller/pci-aardvark.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index d99462d99ed8..2258b9ae1084 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -34,10 +34,7 @@ #define PCIE_CORE_DEV_REV_REG 0x8 #define PCIE_CORE_PCIEXP_CAP 0xc0 #define PCIE_CORE_PCIERR_CAP 0x100 -#define PCIE_CORE_INT_A_ASSERT_ENABLE 1 -#define PCIE_CORE_INT_B_ASSERT_ENABLE 2 -#define PCIE_CORE_INT_C_ASSERT_ENABLE 3 -#define PCIE_CORE_INT_D_ASSERT_ENABLE 4 + /* PIO registers base address and register offsets */ #define PIO_BASE_ADDR 0x4000 #define PIO_CTRL (PIO_BASE_ADDR + 0x0) @@ -706,7 +703,7 @@ static int advk_sw_pci_bridge_init(struct advk_pcie *pcie) bridge->conf.pref_mem_limit = cpu_to_le16(PCI_PREF_RANGE_TYPE_64); /* Support interrupt A for MSI feature */ - bridge->conf.intpin = PCIE_CORE_INT_A_ASSERT_ENABLE; + bridge->conf.intpin = PCI_INTERRUPT_INTA; bridge->has_pcie = true; bridge->data = pcie; From patchwork Thu May 6 15:31:49 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: 12242659 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 C7A78C43470 for ; Thu, 6 May 2021 16:03:35 +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 556246113E for ; Thu, 6 May 2021 16:03:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 556246113E 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=+10msG/TT+pKeRq48P2/6/ThaPcrQBBdBkxUVZW+SJE=; b=gUL7Gz7zrQsdh5QXFvgvdQaLr MIV2rLRswvzN1YW0BuARzglct37i5to1Y2GVh1GIAEnnueKCk++FPhXgS0bhC6HaQu5b5D0Zw5rbj oUkPwPQrMmk80BoPl1srwPLAet5G/ez7P0R3hOQNqD7xqIntoiTTwwojVm+fmPjdQaMajlbjsnrSt n6/rQwSeNOENYWRp8bWgVcmpNkBQnpdJYhcbmM8fA1niaDOSWoyAZEjlpye090YJKxMlOVoIUizZm g/tOkCtKziUA2Pbl4MXvi5mTauyvrWCE5Af3Np2AkR7g9XHXr4szZ8GO0Jp0jAr2AAKir79si9W88 XjcwKvc8g==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1legHo-004gCK-Jm; Thu, 06 May 2021 15:51:37 +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 1lefzt-004a7h-3B for linux-arm-kernel@desiato.infradead.org; Thu, 06 May 2021 15:33:05 +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=xz2CkKmA+jZnDEMXKDUCUSZ8ttrFIJFE6HkNVhxsE0U=; b=vhRjlLrvPrvq/IM/eQYNC2lszQ YSrTrcGnLaGWVFweQ5fxjNjlAwtXYhNDrjHR7ACfmDA90ezzvNF6o3VC9zeb2oSm8kvIF4SFDse/1 YUwsVMxcuYFtAq5UFNGiJEYduo1zVrhwcL0/LP2iXuWkEfnUIxppP/NSjmmzd0yKZMFNdNu0rNM0l f1bTvvjODDjPMuTJ/gTonJeTlunWvJO2anNxDcqpyvUQvg1yVCZkKUyAt/FESFW7xtnthjoIjwo4W //HXXzkG39EBEXWhKMBOiHNDZFnM3jRVWOLmNa1Q+jOEtceVaWagJ4LisDtmj3/fy9zzIlpdFdojp C4P1pUrw==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lefzm-0069kO-HH for linux-arm-kernel@lists.infradead.org; Thu, 06 May 2021 15:33:03 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8FC526191A; Thu, 6 May 2021 15:32:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620315175; bh=xaJINrTisG+I3HDxwk8CIe8zyar1r6u5T6BaI1VDI0I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tK+CMKcyNSHhKgWk2uetW7ilhmLdAZtALw4CNQm1trc6O55IcNW51XC0hhEhGsZEw 7bAvK5prQGM9NQypqQ/E2Qf4yc2KTUUzXkoeUSlTMAr3IBXjbmjZG2dOPEW8l/0nk6 ppMgRI7ONj8LYtqgCBwnRuyJy/Y0k38QkHsw5C4VCkiNowqyDaS+l1iTZISd6qssUR dHjLTIJAZuJkms3KU9H/2lo5K8R9/PXgyST4uqNQy3In/gwFJEF9+4hyX4cjD5nluQ 34NYrhGS7sqKNIZe1HgbeQ9pTTlQUWWdg+MBt5RtyMHiNukxNKKbfhK6IO9NhtojLB SQLf271YPE0wQ== Received: by pali.im (Postfix) id 482E38A1; Thu, 6 May 2021 17:32:55 +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 38/42] PCI: aardvark: Cleanup some register macros Date: Thu, 6 May 2021 17:31:49 +0200 Message-Id: <20210506153153.30454-39-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_083258_677849_8047CF4F X-CRM114-Status: GOOD ( 13.70 ) 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 Define SPEED_GEN_* macros with correct PCIE_GEN_SEL_SHIFT. Simplify macro for setting root complex mode (use BIT instead of MSK+SHIFT). Rename PCIE_MSG_PM_PME_MASK to PCIE_ISR0_MSG_PM_PME to match existing naming convention, rename PCIE_ISR0_MSI_INT_PENDING to PCIE_ISR0_MSI_INT as it is used for both interrupt mask and pending bit. Change the code which disables strict ordering by doing it explicitly (instead of not specifying *_STRICT_ORDER_ENABLE macro, specify bitwise negation of that macro). Signed-off-by: Pali Rohár Reviewed-by: Marek Behún --- drivers/pci/controller/pci-aardvark.c | 34 +++++++++++++-------------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index 2258b9ae1084..3c18e139b095 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -63,11 +63,10 @@ #define PCIE_CORE_CTRL0_REG (CONTROL_BASE_ADDR + 0x0) #define PCIE_GEN_SEL_MSK 0x3 #define PCIE_GEN_SEL_SHIFT 0x0 -#define SPEED_GEN_1 0 -#define SPEED_GEN_2 1 -#define SPEED_GEN_3 2 -#define IS_RC_MSK 1 -#define IS_RC_SHIFT 2 +#define SPEED_GEN_1 (0 << PCIE_GEN_SEL_SHIFT) +#define SPEED_GEN_2 (1 << PCIE_GEN_SEL_SHIFT) +#define SPEED_GEN_3 (2 << PCIE_GEN_SEL_SHIFT) +#define IS_RC BIT(2) #define LANE_CNT_MSK 0x18 #define LANE_CNT_SHIFT 0x3 #define LANE_COUNT_1 (0 << LANE_CNT_SHIFT) @@ -91,15 +90,15 @@ #define PCIE_CORE_REF_CLK_TX_ENABLE BIT(1) #define PCIE_MSG_LOG_REG (CONTROL_BASE_ADDR + 0x30) #define PCIE_ISR0_REG (CONTROL_BASE_ADDR + 0x40) -#define PCIE_MSG_PM_PME_MASK BIT(7) #define PCIE_ISR0_MASK_REG (CONTROL_BASE_ADDR + 0x44) -#define PCIE_ISR0_MSI_INT_PENDING BIT(24) +#define PCIE_ISR0_MSG_PM_PME BIT(7) #define PCIE_ISR0_CORR_ERR BIT(11) #define PCIE_ISR0_NFAT_ERR BIT(12) #define PCIE_ISR0_FAT_ERR BIT(13) #define PCIE_ISR0_INTX_ASSERT(val) BIT(16 + (val)) #define PCIE_ISR0_INTX_DEASSERT(val) BIT(20 + (val)) -#define PCIE_ISR0_ALL_MASK GENMASK(26, 0) +#define PCIE_ISR0_MSI_INT BIT(24) +#define PCIE_ISR0_ALL_MASK GENMASK(26, 0) #define PCIE_ISR1_REG (CONTROL_BASE_ADDR + 0x48) #define PCIE_ISR1_MASK_REG (CONTROL_BASE_ADDR + 0x4C) #define PCIE_ISR1_POWER_STATE_CHANGE BIT(4) @@ -345,7 +344,7 @@ static void advk_pcie_setup_hw(struct advk_pcie *pcie) /* Set PCI global control register to RC mode */ reg = advk_readl(pcie, PCIE_CORE_CTRL0_REG); - reg |= (IS_RC_MSK << IS_RC_SHIFT); + reg |= IS_RC; advk_writel(pcie, reg, PCIE_CORE_CTRL0_REG); /* @@ -379,8 +378,8 @@ static void advk_pcie_setup_hw(struct advk_pcie *pcie) advk_writel(pcie, reg, PCIE_CORE_PCIEXP_CAP + PCI_EXP_DEVCTL); /* Program PCIe Control 2 to disable strict ordering */ - reg = PCIE_CORE_CTRL2_RESERVED | - PCIE_CORE_CTRL2_TD_ENABLE; + reg = advk_readl(pcie, PCIE_CORE_CTRL2_REG); + reg &= ~PCIE_CORE_CTRL2_STRICT_ORDER_ENABLE; advk_writel(pcie, reg, PCIE_CORE_CTRL2_REG); /* Set lane X1 */ @@ -412,7 +411,7 @@ static void advk_pcie_setup_hw(struct advk_pcie *pcie) /* Unmask summary MSI interrupt */ reg = advk_readl(pcie, PCIE_ISR0_MASK_REG); - reg &= ~PCIE_ISR0_MSI_INT_PENDING; + reg &= ~PCIE_ISR0_MSI_INT; advk_writel(pcie, reg, PCIE_ISR0_MASK_REG); /* Unmask bits for ERR interrupt */ @@ -422,7 +421,7 @@ static void advk_pcie_setup_hw(struct advk_pcie *pcie) /* Unmask PME interrupt for processing of PME requester */ reg = advk_readl(pcie, PCIE_ISR0_MASK_REG); - reg &= ~PCIE_MSG_PM_PME_MASK; + reg &= ~PCIE_ISR0_MSG_PM_PME; advk_writel(pcie, reg, PCIE_ISR0_MASK_REG); /* Enable summary interrupt for GIC SPI source */ @@ -1265,8 +1264,7 @@ static void advk_pcie_handle_msi(struct advk_pcie *pcie) generic_handle_irq(virq); } - advk_writel(pcie, PCIE_ISR0_MSI_INT_PENDING, - PCIE_ISR0_REG); + advk_writel(pcie, PCIE_ISR0_MSI_INT, PCIE_ISR0_REG); } static void advk_pcie_handle_int(struct advk_pcie *pcie) @@ -1290,8 +1288,8 @@ static void advk_pcie_handle_int(struct advk_pcie *pcie) return; /* Process PME interrupt as the first one to do not miss PME requester id */ - if (isr0_status & PCIE_MSG_PM_PME_MASK) { - advk_writel(pcie, PCIE_MSG_PM_PME_MASK, PCIE_ISR0_REG); + if (isr0_status & PCIE_ISR0_MSG_PM_PME) { + advk_writel(pcie, PCIE_ISR0_MSG_PM_PME, PCIE_ISR0_REG); /* * PCIE_MSG_LOG_REG contains the last inbound message, * so store requester id only when PME was not asserted yet. @@ -1326,7 +1324,7 @@ static void advk_pcie_handle_int(struct advk_pcie *pcie) } /* Process MSI interrupts */ - if (isr0_status & PCIE_ISR0_MSI_INT_PENDING) + if (isr0_status & PCIE_ISR0_MSI_INT) advk_pcie_handle_msi(pcie); /* Process legacy interrupts */ From patchwork Thu May 6 15:31:50 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: 12242655 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 EDBA9C43460 for ; Thu, 6 May 2021 16:03:30 +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 8056861078 for ; Thu, 6 May 2021 16:03:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8056861078 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=TaTTGLwduEJ1dXRb2R3nZT0DQAJA3+R8Py975pPC2q0=; b=XaLl6vHNLrWJr+c2NOEfFlo+r Fn2fFzHu6Ru6uhd4Bvm7MJXyB2sKOrs+yaOk115Sp9q+YEBkd3/8Tcat2UIgCT60XsfXYqz4aIn0Y kNoSkvwBY7CYqnsdiDvnGn7wLtF3ovY256X9eju8WgUdVVUC21iGTgRu5fzJQEwBgyB4RjDR1/V+q fUqIz/IncM8v1/wwVWXMmd/cSKAFDHuOchHOjAsFOLYOdE09oRrRd3Z0ysdCKjQhsT9D4kC5SHhCP ESCpP9OyhNG5laFoR32GdvEmHNfdcNj868faLW1F0jCvif5+NOW9V1SSCebKQH76hWa5oufJUuNoq bGw+s02jA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1legIt-004gYU-JV; Thu, 06 May 2021 15:52:43 +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 1lefzs-004a7A-To for linux-arm-kernel@desiato.infradead.org; Thu, 06 May 2021 15:33:05 +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=d5jGENM11sT8wW6ogxoaP8ZbexlWVNDoUrht1v3YypE=; b=BL3GcYyBRBinhmJ2bMkszQZrw7 jlGILSibKuLzWJ/ym2MqYHwNA+QQH27xBLLSRaVcweRIOoWwt2WRzneWBrw17GgHqWgDm4F3kFB2V 4YCQ9kXnK0sihIj+2Nkyl3yl2UQJQYIu8z1ZR8m4UVka4a/M5gKnaez0sk95smpLmuJFocKYDzcHF lJF5EeylB+zuijw6rwt7TP20ezOsLFPE529mYqKkNHZMfWVlkACouolhKRQy1axYj4R1sPNQOkVOn U5Q1byY5uY1AvpzocM6XInn/7vCjwano4sPYMjiFe76SNSLPF8mLgDEL8/dI3HOdLPnl3hZObxl9I pmFVp79Q==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lefzm-0069hb-VD for linux-arm-kernel@lists.infradead.org; Thu, 06 May 2021 15:33:03 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id BE35E616EC; Thu, 6 May 2021 15:32:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620315175; bh=/+gs0ZSRDihhAytQvQhC3JU9pmLLRIVi8fOcngMUlsQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BBQZNg72+zIsTIei99cO7gRYKbGHxRUVBO5CGID3UxRoGYu+U85fMo2ixcw6GtMSZ +AJYhmcwD+5KVQJK6NAVIB2WZ2eMp91Y6fiY8/Gja5yIJ9QF/CSWZ2EUT8BfQtgX9J pvpjak348W8hfbPmhJa8KwXcv/XVWB8+3BTdCyvPn3wHrRojMRZncLBtANVl3fjGpJ sq54wrNotp0r3s9rKeERiwtQuwt7lMX6xJBL1alUyiltzld8XyRmfOzUx5xeJn5j0A GetZtoMwAO2cHe9UixL4dihnIMJcTEn3U9dkAp0BBmx0n8MvQkxBR6jg5a9wGIFEsc lKyZtsV/I0IaQ== Received: by pali.im (Postfix) id 75174BF9; Thu, 6 May 2021 17:32:55 +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 39/42] PCI: aardvark: Add comments for OB_WIN_ENABLE and ADDR_WIN_DISABLE Date: Thu, 6 May 2021 17:31:50 +0200 Message-Id: <20210506153153.30454-40-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_083259_056542_DB13FC4E X-CRM114-Status: GOOD ( 12.31 ) 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 Add a comment with explanation of these two bits. These comments are taken from U-Boot 2020.10 PCI aardvark driver. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún --- drivers/pci/controller/pci-aardvark.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index 3c18e139b095..ac3ee48e69d7 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -428,11 +428,24 @@ static void advk_pcie_setup_hw(struct advk_pcie *pcie) reg = PCIE_IRQ_ALL_MASK & (~PCIE_IRQ_ENABLE_INTS_MASK); advk_writel(pcie, reg, HOST_CTRL_INT_MASK_REG); + /* + * Enable AXI address window location generation: + * When it is enabled, the default outbound window + * configurations (Default User Field: 0xD0074CFC) + * are used to transparent address translation for + * the outbound transactions. Thus, PCIe address + * windows are not required. + */ reg = advk_readl(pcie, PCIE_CORE_CTRL2_REG); reg |= PCIE_CORE_CTRL2_OB_WIN_ENABLE; advk_writel(pcie, reg, PCIE_CORE_CTRL2_REG); - /* Bypass the address window mapping for PIO */ + /* + * Bypass the address window mapping for PIO: + * Since PIO access already contains all required + * info over AXI interface by PIO registers, the + * address window is not required. + */ reg = advk_readl(pcie, PIO_CTRL); reg |= PIO_CTRL_ADDR_WIN_DISABLE; advk_writel(pcie, reg, PIO_CTRL); From patchwork Thu May 6 15:31:51 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: 12242651 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 42671C433B4 for ; Thu, 6 May 2021 16:03:27 +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 CFAB26113E for ; Thu, 6 May 2021 16:03:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CFAB26113E 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=OeTlmjspXJAJuaj4L/55TpRxaV7ClavdCZsHYmailSE=; b=GgdzzY5YYwvN4crX4TyzA3Ujq FO73nsfWcULtV2FNLtnkbb4HUj64MugkP6yiFNyN0v+tqxs0DJFUKFhmycG0t3p3Vmdztsjmw+sLe K8Fnv+XvGiGporEbZlIFD6zbp919MP718iHpHG66kMnCf7QKr1XY/cM1sxDtOTw7KnwQIef7MwMT3 IWCTMRFDit/FOoQvdUGx4REWSGCV0RTvF+7R8eos5syY7u0HDh1lio/pIkWNOj/rvKS7ft6zsQ4gb vS1hOeXY+duwgMlM8oUVKyasWNax0tTn/ZEowoLsc6M/H3UlhXwvsZTg3bhFAaNR+0UvopNpX+srz W4S70Nflg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1legK5-004gvG-P6; Thu, 06 May 2021 15:53:58 +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 1lefzs-004a7V-Ts for linux-arm-kernel@desiato.infradead.org; Thu, 06 May 2021 15:33:05 +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=9JBTP11XCQPzCCagHeT8obFSVkAV5Qid1/AnkayMc6c=; b=JWLo/NMxFun5rlREgCQrG6fW+N 0TEwOkickL5MItMHVxsTsK982UJ6oTdnCNwmxPyRlIDZGrrQAVzPec5Qv0UE1z0Q8qn1/bAXe1G6l uvMqUm6eAfTDLvFvjBeuCoyiG/rzpKPPPHl1JmV02f476dIeCYsnMPxX3AdyyBSYwy429bT7r9wUn hJcwggRKNZ6gATJYn4n8DanPZtXZZPt8izhp7qOpVaFg9qS3V9QH4S/DqZgz7EVSWGM8sL69pzK81 4f77CyP/KI+uB9ABeIrs0qPku43UDumWZLYseIl/M7iwEELIO3jYRBH/bq0OYpuvAABRvn4/+TXzu xVWiPr1A==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lefzn-0069ha-Ab for linux-arm-kernel@lists.infradead.org; Thu, 06 May 2021 15:33:03 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0585F6192B; Thu, 6 May 2021 15:32:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620315176; bh=REF2cZ76zLLt5itdjPFPEdxTt802EyaUEpYkfKBXnp0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bymXLmxPOCNDiGCwPxOj9Ki5Mh1U6YrCM+T34IowpaRXqHyKJzzFPG7dpzU2x029r 2t4BZmAzPudvus95KmfRSke7U0/JAgR+LnWhsGFKZFMX7AMomrx6hf+Y/1JKgGAYdI pNhJWPlEIHhriq/ATU/Cah1LOf/e9EACgvlN0KzoQMgH8vKVEZ2WgAtSL/QoKsYw7e PKHlSdx7IAswcp6n1dpK/QsrO4W8NfyhpatlE/+iosj+WqTGHlfDclBD4xzyYc0FS0 N1EHXcqOdpLUxDFnXpPeH2G4Bl5wII6kTXNZFv6PuYw8Qw4Ca6/G2+ZfPHlE0QH7rY xx1oUB2YGeHaw== Received: by pali.im (Postfix) id A8AD1732; Thu, 6 May 2021 17:32:55 +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 40/42] PCI: pci-bridge-emul: re-arrange register tests Date: Thu, 6 May 2021 17:31:51 +0200 Message-Id: <20210506153153.30454-41-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_083259_452034_0E5EAA60 X-CRM114-Status: GOOD ( 14.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 From: Russell King Re-arrange the tests for which sets of registers are being accessed so that it is easier to add further regions later. No functional change. Signed-off-by: Russell King [pali: Fix reading old value in pci_bridge_emul_conf_write] Signed-off-by: Pali Rohár --- drivers/pci/pci-bridge-emul.c | 61 ++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/drivers/pci/pci-bridge-emul.c b/drivers/pci/pci-bridge-emul.c index 5f8398f8d039..63959e4b188a 100644 --- a/drivers/pci/pci-bridge-emul.c +++ b/drivers/pci/pci-bridge-emul.c @@ -370,25 +370,25 @@ int pci_bridge_emul_conf_read(struct pci_bridge_emul *bridge, int where, __le32 *cfgspace; const struct pci_bridge_reg_behavior *behavior; - if (bridge->has_pcie && reg >= PCI_CAP_PCIE_END) { - *value = 0; - return PCIBIOS_SUCCESSFUL; - } - - if (!bridge->has_pcie && reg >= PCI_BRIDGE_CONF_END) { + if (reg < PCI_BRIDGE_CONF_END) { + /* Emulated PCI space */ + read_op = bridge->ops->read_base; + cfgspace = (__le32 *) &bridge->conf; + behavior = bridge->pci_regs_behavior; + } else if (!bridge->has_pcie) { + /* PCIe space is not implemented, and no PCI capabilities */ *value = 0; return PCIBIOS_SUCCESSFUL; - } - - if (bridge->has_pcie && reg >= PCI_CAP_PCIE_START) { + } else if (reg < PCI_CAP_PCIE_END) { + /* Our emulated PCIe capability */ reg -= PCI_CAP_PCIE_START; read_op = bridge->ops->read_pcie; cfgspace = (__le32 *) &bridge->pcie_conf; behavior = bridge->pcie_cap_regs_behavior; } else { - read_op = bridge->ops->read_base; - cfgspace = (__le32 *) &bridge->conf; - behavior = bridge->pci_regs_behavior; + /* Beyond our PCIe space */ + *value = 0; + return PCIBIOS_SUCCESSFUL; } if (read_op) @@ -432,11 +432,27 @@ int pci_bridge_emul_conf_write(struct pci_bridge_emul *bridge, int where, __le32 *cfgspace; const struct pci_bridge_reg_behavior *behavior; - if (bridge->has_pcie && reg >= PCI_CAP_PCIE_END) - return PCIBIOS_SUCCESSFUL; + ret = pci_bridge_emul_conf_read(bridge, reg, 4, &old); + if (ret != PCIBIOS_SUCCESSFUL) + return ret; - if (!bridge->has_pcie && reg >= PCI_BRIDGE_CONF_END) + if (reg < PCI_BRIDGE_CONF_END) { + /* Emulated PCI space */ + write_op = bridge->ops->write_base; + cfgspace = (__le32 *) &bridge->conf; + behavior = bridge->pci_regs_behavior; + } else if (!bridge->has_pcie) { + /* PCIe space is not implemented, and no PCI capabilities */ return PCIBIOS_SUCCESSFUL; + } else if (reg < PCI_CAP_PCIE_END) { + /* Our emulated PCIe capability */ + reg -= PCI_CAP_PCIE_START; + write_op = bridge->ops->write_pcie; + cfgspace = (__le32 *) &bridge->pcie_conf; + behavior = bridge->pcie_cap_regs_behavior; + } else { + return PCIBIOS_SUCCESSFUL; + } shift = (where & 0x3) * 8; @@ -449,21 +465,6 @@ int pci_bridge_emul_conf_write(struct pci_bridge_emul *bridge, int where, else return PCIBIOS_BAD_REGISTER_NUMBER; - ret = pci_bridge_emul_conf_read(bridge, reg, 4, &old); - if (ret != PCIBIOS_SUCCESSFUL) - return ret; - - if (bridge->has_pcie && reg >= PCI_CAP_PCIE_START) { - reg -= PCI_CAP_PCIE_START; - write_op = bridge->ops->write_pcie; - cfgspace = (__le32 *) &bridge->pcie_conf; - behavior = bridge->pcie_cap_regs_behavior; - } else { - write_op = bridge->ops->write_base; - cfgspace = (__le32 *) &bridge->conf; - behavior = bridge->pci_regs_behavior; - } - /* Keep all bits, except the RW bits */ new = old & (~mask | ~behavior[reg / 4].rw); From patchwork Thu May 6 15:31:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 12242661 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=unavailable 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 621D9C433ED for ; Thu, 6 May 2021 16:03:36 +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 EF34E61078 for ; Thu, 6 May 2021 16:03:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EF34E61078 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=+bW1T7SP9EYJiKyuQ5QW/55i9SMAJUBWKhfVzJh3WM4=; b=obcEqf4nFqvpMrhdtnqnoV2ho RYcjPSjBWIM4NfbOWUmoRzymPM9vveDvKCQmSXK21aZqieh21aDWtBi4e82JFX54FZG/U4hHrqORF DawAiPAFjuKZ9Kbl57NnjZAyeR8K9pdtRUDkeyn1idxJpRS2qCq4ptvOnX/r31L20JwmTNHDregDc br71x/lQdc2W1XPpgL/bfQZIbLavxc2KGDKIMw5hTqaILPd7wEqOMjDVaYoKzulh4G16hsDzgNjte SgT/i+/3XN9ShQF4qgGsR2KAJHlSoVQvGxIe93voHFG/9oSP0nkbIlVJSVYS+OEcWWFLNarbCWTE/ SFCjZ/qrg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1legHI-004g1U-M2; Thu, 06 May 2021 15:51:04 +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 1lefzs-004a7F-OD for linux-arm-kernel@desiato.infradead.org; Thu, 06 May 2021 15:33:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=rVsyvk/wDz+Qse+xC55/mo9JAyVxLTxGMY+/XCFso9c=; b=Mv43crVTlhMQdHW66sNiuIkzT8 6H+8RM5JoXlCPKchNWYmUCzTKwIToLTGARmFtdFqRslsZnC0S1b/yddZFQOWpafBZohamzE2oNWXK dbMMPnstvq0RrbLZhN2GFxpODkl51dbGKdcw8O/0+Wj9OCETjzoWViZtymf7JbECScIcmDft1v2IX yb1cdp21r4vzk0WQpRk2UT3nHcPSDOImQo0heq4VWDhY+uF8wexPwddtglaRwP8J/6kxRSFpnEz2c V/r1L0o4ngVmnSp1JyucLb/Hg5n2VOn7MboLXfAJYahGNhM6WTHuPuREvW39YoXEW156QFI3tgWl6 iXM5Oiow==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lefzn-0069hi-Pc for linux-arm-kernel@lists.infradead.org; Thu, 06 May 2021 15:33:04 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 35EFD61919; Thu, 6 May 2021 15:32:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620315176; bh=hjo0BAh8/TrXrQZkushaXu4N5LMhaWkVsVmV1/6ftDk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Dh1vhcJJYtbozzm9tYZuMVr3xW2todeA5yDuns656iomD3BgScMh9g4Cp5PbUmw38 7jbsRgj7iDlnpJ75OQ43qkrEbI7VgBraSEINnbkvhN3orBjYsjqhLStfl7yt4g3tXT 9zP6un2sviaI6VU/eWUEqoL2WC0nF8dlVgjEyc1eWrEdhCbPMqw9wfq/0yrJjm1zWJ mMZ2ytRlFECFuKySVamBgQdcWQ7L0e6XtMrXlRu0X8Gk7DJ4OTNheqAZ6513100vJR EksPYnhdly9pOg5a2g+WXCNguErI7b4nUKbyqEmwIAkRQGKMrb8YuiSBDaTAKs72s8 P7DIwL0F9ulvA== Received: by pali.im (Postfix) id E16FF89A; Thu, 6 May 2021 17:32:55 +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 41/42] PCI: pci-bridge-emul: add support for PCIe extended capabilities Date: Thu, 6 May 2021 17:31:52 +0200 Message-Id: <20210506153153.30454-42-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_083259_922760_A4B1E630 X-CRM114-Status: GOOD ( 17.69 ) 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 From: Russell King Add support for PCIe extended capabilities, which we just redirect to the emulating driver. Signed-off-by: Russell King --- drivers/pci/pci-bridge-emul.c | 52 +++++++++++++++++++++++++---------- drivers/pci/pci-bridge-emul.h | 15 ++++++++++ 2 files changed, 53 insertions(+), 14 deletions(-) diff --git a/drivers/pci/pci-bridge-emul.c b/drivers/pci/pci-bridge-emul.c index 63959e4b188a..236036fdeaa2 100644 --- a/drivers/pci/pci-bridge-emul.c +++ b/drivers/pci/pci-bridge-emul.c @@ -385,10 +385,16 @@ int pci_bridge_emul_conf_read(struct pci_bridge_emul *bridge, int where, read_op = bridge->ops->read_pcie; cfgspace = (__le32 *) &bridge->pcie_conf; behavior = bridge->pcie_cap_regs_behavior; - } else { - /* Beyond our PCIe space */ + } else if (reg < PCI_CFG_SPACE_SIZE) { + /* Rest of PCI space not implemented */ *value = 0; return PCIBIOS_SUCCESSFUL; + } else { + /* PCIe extended capability space */ + reg -= PCI_CFG_SPACE_SIZE; + read_op = bridge->ops->read_ext; + cfgspace = NULL; + behavior = NULL; } if (read_op) @@ -396,15 +402,20 @@ int pci_bridge_emul_conf_read(struct pci_bridge_emul *bridge, int where, else ret = PCI_BRIDGE_EMUL_NOT_HANDLED; - if (ret == PCI_BRIDGE_EMUL_NOT_HANDLED) - *value = le32_to_cpu(cfgspace[reg / 4]); + if (ret == PCI_BRIDGE_EMUL_NOT_HANDLED) { + if (cfgspace) + *value = le32_to_cpu(cfgspace[reg / 4]); + else + *value = 0; + } /* * Make sure we never return any reserved bit with a value * different from 0. */ - *value &= behavior[reg / 4].ro | behavior[reg / 4].rw | - behavior[reg / 4].w1c; + if (behavior) + *value &= behavior[reg / 4].ro | behavior[reg / 4].rw | + behavior[reg / 4].w1c; if (size == 1) *value = (*value >> (8 * (where & 3))) & 0xff; @@ -450,8 +461,15 @@ int pci_bridge_emul_conf_write(struct pci_bridge_emul *bridge, int where, write_op = bridge->ops->write_pcie; cfgspace = (__le32 *) &bridge->pcie_conf; behavior = bridge->pcie_cap_regs_behavior; - } else { + } else if (reg < PCI_CFG_SPACE_SIZE) { + /* Rest of PCI space not implemented */ return PCIBIOS_SUCCESSFUL; + } else { + /* PCIe extended capability space */ + reg -= PCI_CFG_SPACE_SIZE; + write_op = bridge->ops->write_ext; + cfgspace = NULL; + behavior = NULL; } shift = (where & 0x3) * 8; @@ -465,16 +483,22 @@ int pci_bridge_emul_conf_write(struct pci_bridge_emul *bridge, int where, else return PCIBIOS_BAD_REGISTER_NUMBER; - /* Keep all bits, except the RW bits */ - new = old & (~mask | ~behavior[reg / 4].rw); + if (behavior) { + /* Keep all bits, except the RW bits */ + new = old & (~mask | ~behavior[reg / 4].rw); - /* Update the value of the RW bits */ - new |= (value << shift) & (behavior[reg / 4].rw & mask); + /* Update the value of the RW bits */ + new |= (value << shift) & (behavior[reg / 4].rw & mask); - /* Clear the W1C bits */ - new &= ~((value << shift) & (behavior[reg / 4].w1c & mask)); + /* Clear the W1C bits */ + new &= ~((value << shift) & (behavior[reg / 4].w1c & mask)); + } else { + new = old & ~mask; + new |= (value << shift) & mask; + } - cfgspace[reg / 4] = cpu_to_le32(new); + if (cfgspace) + cfgspace[reg / 4] = cpu_to_le32(new); if (write_op) write_op(bridge, reg, old, new, mask); diff --git a/drivers/pci/pci-bridge-emul.h b/drivers/pci/pci-bridge-emul.h index 49bbd37ee318..2552ab660b08 100644 --- a/drivers/pci/pci-bridge-emul.h +++ b/drivers/pci/pci-bridge-emul.h @@ -90,6 +90,14 @@ struct pci_bridge_emul_ops { */ pci_bridge_emul_read_status_t (*read_pcie)(struct pci_bridge_emul *bridge, int reg, u32 *value); + + /* + * Same as ->read_base(), except it is for reading from the + * PCIe extended capability configuration space. + */ + pci_bridge_emul_read_status_t (*read_ext)(struct pci_bridge_emul *bridge, + int reg, u32 *value); + /* * Called when writing to the regular PCI bridge configuration * space. old is the current value, new is the new value being @@ -105,6 +113,13 @@ struct pci_bridge_emul_ops { */ void (*write_pcie)(struct pci_bridge_emul *bridge, int reg, u32 old, u32 new, u32 mask); + + /* + * Same as ->write_base(), except it is for writing from the + * PCIe extended capability configuration space. + */ + void (*write_ext)(struct pci_bridge_emul *bridge, int reg, + u32 old, u32 new, u32 mask); }; struct pci_bridge_reg_behavior; From patchwork Thu May 6 15:31:53 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: 12242653 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 077D2C433ED for ; Thu, 6 May 2021 16:03:28 +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 8AF6A610E7 for ; Thu, 6 May 2021 16:03:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8AF6A610E7 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=qzKSyvJIFb/0gK5ickT4UmaWs9UEnUtHC31wl92lVB4=; b=Gx+dT1mrkuHR7GClDh2OexQcf QfhoF4wILiOU2ipinBc8de+/jOtpbHimR3yw3ulxBYc66QDIq18FurwLYjKoxq8ga31lr4LRYRSCJ SIMN7ynnTwTY3FTWxfeYbf6d6PgYPR9a6NsUJg04iy31GocBfzNWzn+2311qWPe7OseE+zTq79zn5 CzvFLt33/yy3PvVoYyHg8DAKdA9yF4sazvYgPp/bCtImKQw0ytKWyw5ketKfut8VSC4hqrpEZRuMq /fhEWunW633Iosdq3NoY6wxIi+72AodRt7gIkz8NQsOW5QDEK6uginbBveesYGBa0kV9J1FOy0zlw zjwrNUvSA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1legJT-004gjl-El; Thu, 06 May 2021 15:53:19 +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 1lefzs-004a7c-Tf for linux-arm-kernel@desiato.infradead.org; Thu, 06 May 2021 15:33:05 +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=OckI2xdR+BgglL0reKoUNKh/12FM4WpkOqSKQqJyezg=; b=ZOsaS6AlZcWlrCWA2RSrq6y4MP UN29PVUB0lIYyyW+ub+NSEH7YhfsvxiIuTojTCIEVxCQtcdCV8FmFJ6OQqdA3/M6WaRh1R068i+TO RHvE1W5LAPg+uElKZuuae8cxCRlsaKW/xOWIc3XHnn44MbqDxCrfY9PALsNh18O0hVELsmA1K22kh CLMqZ9jOASCutan9SW+zUcV3a3VktWyPvvckNZ2mBvg7N0GyK/nDglzyLb//b9Z7egjDw0xePz9zX wF63sc6b3oQacQqFglmHrfwShMFx6rW1rheBnRVDHbuSYVkOPz1UxEHg4+Z14oE25cq0gFKe2pQl6 ytarMUYQ==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lefzn-0069lK-RL for linux-arm-kernel@lists.infradead.org; Thu, 06 May 2021 15:33:04 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6ABBD613C2; Thu, 6 May 2021 15:32:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620315176; bh=YnX8Fz29kf60K0H0Lln7W4fAoz60MdG7mey2fziRxCc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pGwE/af0ZzxIt4YljcqEMGH5eX1G4XH0FH/wq+Wu6hGOXOHP5EeITwkQfvf51FGeC GCnpT701QVw8HwwEhHZFk1AaUsuuL8itj9fzS7YYndCijD17qAmaHdoKM3H1gGA+wu U0G3bzUuH3WT1bEes0ympfcQVARGKDmnkDuKV0tYxjJenwtxklvC4nBlL3+TwcpbPg XYLMT3gN3RovN8opGcjvQtwWdbSRUIQyV8irPJLXRtL1ZDC7gSt63FHQ+J65Nhxxx9 jyBmvDS/SwzxblHuMWGp4e5Wigf/8tMtSQy85leCb1ECXTDpXX6joQ3eOe6sgkJeoM yJzLTerKqCSjQ== Received: by pali.im (Postfix) id 249398A1; Thu, 6 May 2021 17:32:56 +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 42/42] PCI: aardvark: Add support for Advanced Error Reporting registers on emulated bridge Date: Thu, 6 May 2021 17:31:53 +0200 Message-Id: <20210506153153.30454-43-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_083259_973427_3CF66120 X-CRM114-Status: GOOD ( 13.54 ) 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 PCI aardvark hardware supports access to Advanced Error Reporting configuration registers of PCIe core via PCIE_CORE_PCIERR_CAP. Export them via emulated software root bridge through the new .read_ext and .write_ext emulated bridge callbacks. Note that in Advanced Error Reporting Capability header, the offset to the next Extended Capability header is set, but it is not documented in Armada 3700 Functional Specification. As this change adds support only for Advanced Error Reporting, explicitly clear PCI_EXT_CAP_NEXT bits in AER capability header. After this change, pcieport driver correctly detects AER support and allows PCIe AER driver to start receiving ERR interrupts. It prints into dmesg: [ 4.358401] pcieport 0000:00:00.0: AER: enabled with IRQ 52 Signed-off-by: Pali Rohár Reviewed-by: Marek Behún --- drivers/pci/controller/pci-aardvark.c | 74 +++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index ac3ee48e69d7..8914af62ccc3 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -683,11 +683,85 @@ advk_pci_bridge_emul_pcie_conf_write(struct pci_bridge_emul *bridge, } } +static pci_bridge_emul_read_status_t +advk_pci_bridge_emul_ext_conf_read(struct pci_bridge_emul *bridge, + int reg, u32 *value) +{ + struct advk_pcie *pcie = bridge->data; + + switch (reg) { + case 0: + *value = advk_readl(pcie, PCIE_CORE_PCIERR_CAP + reg); + /* + * Clear PCI_EXT_CAP_NEXT bits as they are set to 0x150 offset. + * Armada 3700 Functional Specification does not contain any + * documentation about registers at that address, so explicitly + * mark Advanced Error Reporting Capability header as the end of + * Extended Capabilities. + */ + *value &= 0x000fffff; + return PCI_BRIDGE_EMUL_HANDLED; + + case PCI_ERR_UNCOR_STATUS: + case PCI_ERR_UNCOR_MASK: + case PCI_ERR_UNCOR_SEVER: + case PCI_ERR_COR_STATUS: + case PCI_ERR_COR_MASK: + case PCI_ERR_CAP: + case PCI_ERR_HEADER_LOG+0: + case PCI_ERR_HEADER_LOG+4: + case PCI_ERR_HEADER_LOG+8: + case PCI_ERR_HEADER_LOG+12: + case PCI_ERR_ROOT_COMMAND: + case PCI_ERR_ROOT_STATUS: + case PCI_ERR_ROOT_ERR_SRC: + *value = advk_readl(pcie, PCIE_CORE_PCIERR_CAP + reg); + return PCI_BRIDGE_EMUL_HANDLED; + + default: + return PCI_BRIDGE_EMUL_NOT_HANDLED; + } +} + +static void +advk_pci_bridge_emul_ext_conf_write(struct pci_bridge_emul *bridge, + int reg, u32 old, u32 new, u32 mask) +{ + struct advk_pcie *pcie = bridge->data; + + switch (reg) { + /* These are W1C registers, so clear other bits */ + case PCI_ERR_UNCOR_STATUS: + case PCI_ERR_COR_STATUS: + case PCI_ERR_ROOT_STATUS: + new &= mask; + fallthrough; + + case PCI_ERR_UNCOR_MASK: + case PCI_ERR_UNCOR_SEVER: + case PCI_ERR_COR_MASK: + case PCI_ERR_CAP: + case PCI_ERR_HEADER_LOG+0: + case PCI_ERR_HEADER_LOG+4: + case PCI_ERR_HEADER_LOG+8: + case PCI_ERR_HEADER_LOG+12: + case PCI_ERR_ROOT_COMMAND: + case PCI_ERR_ROOT_ERR_SRC: + advk_writel(pcie, new, PCIE_CORE_PCIERR_CAP + reg); + break; + + default: + break; + } +} + static struct pci_bridge_emul_ops advk_pci_bridge_emul_ops = { .read_base = advk_pci_bridge_emul_base_conf_read, .write_base = advk_pci_bridge_emul_base_conf_write, .read_pcie = advk_pci_bridge_emul_pcie_conf_read, .write_pcie = advk_pci_bridge_emul_pcie_conf_write, + .read_ext = advk_pci_bridge_emul_ext_conf_read, + .write_ext = advk_pci_bridge_emul_ext_conf_write, }; /*