From patchwork Thu Mar 28 09:18:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 13608262 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 131C8C54E64 for ; Thu, 28 Mar 2024 09:20:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; 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=YQ4PrUPq5KpNd7CNuYrDa1Buf8id4VJZ98sDRYTpqT4=; b=eIrNmT54Q4Jxui ljXkHkquvq/JNQGmgap8nDDNG42sW6aIti5ORQmzLeOQIlLoA6DuRN2JBe9DiwaqOICrzNm3SwiOd rhVjxJLtCMTc96jUiRsWMaElMR84hCOeSRCo6cWGy7oQRY77XGTNFmvHCVm3B4L5oRd3z/beBka3Q +lap8Pvny3CPRM8xsvJuC5U7zo+hiyrWGTdraV4193oUKLRwJJGeHrFTi80N/IqbkQq7h9QBTAuST c0bmsNHJkRd3l0sGw7wA2tw6upU5OxroeWPfvZTU+SU2oKFkNM6fpR7Uc/QrK47ifDnJc3Ji9iH6U JqzPeNwaqaNWURHf5EuQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rplvQ-0000000DHqd-2usp; Thu, 28 Mar 2024 09:19:56 +0000 Received: from mail-sh0chn02on20727.outbound.protection.partner.outlook.cn ([2406:e500:4420:2::727] helo=CHN02-SH0-obe.outbound.protection.partner.outlook.cn) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpluk-0000000DHLN-2oXR for linux-riscv@lists.infradead.org; Thu, 28 Mar 2024 09:19:17 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d5NjOM+o9+M23JeQe4GVDGAAk49iIQlOog4PGhMzee5ygfb15McnoCp4beqcFB5vsuo4pd/Sl5Ovzu42bz5HKAWkBaFLCgwnsr9c7CXZSSG5cd5E/+AiNPN8ZNNVpnsYjeUq+rfiqVIxU68qGak0f1A67kMBpbxQS5p5MMwyj4eOqS3s63Sis64B86IsEX4xI/od1A+yI5bymDLmEqPMiqQgdKWMkIYGAzi9xwjtqwNAyIEmpnTiZ381kLq7UzHhF+hNp2TodH6sNOYXmzeuMb2cdCybDJ75PiQRWdMXdkDYx+b/SCKF5hSn9BnKJ5OTwlUKLQxiRv9rgZn8nfdRfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=K9fmnXQNrF0yUf6gsxFXvF0YjdiKzG9Fap6pladclgc=; b=TmfaJvVE8SjzVKjAQlKbNGwRghOAp38O9rgda7+QFxFVF/FykzAoPgHYpzEMGePS3+x4mi24cwVK5tI3JgboSB+Uf1k5XH7Pt4vGJwEm9Q2O2Pws+7WxI592CxFBxXMT9kP79t+2oM7TOMHPycmqatux85Kc8ZrVzlozN+DV3dcGVBUD/oV4XZhBi+fREBJgQf/CI+ch5DXZrtR43RRDtPHvsah5G4/G8RE4+309iPmqtxw4HJVGikgLotow/jKe+DHQA1Rs/DisKZBbmtOKonclTfhbxxa/mNV//Md01BVOn5kgMNVxRAjgb5azi+dEi4C/QyP/k9ymBZfWV5mKCA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) by SHXPR01MB0559.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:1d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.32; Thu, 28 Mar 2024 09:18:59 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::c738:9e6b:f92e:8bb9]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::c738:9e6b:f92e:8bb9%6]) with mapi id 15.20.7409.031; Thu, 28 Mar 2024 09:18:59 +0000 From: Minda Chen To: Lorenzo Pieralisi , Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Thomas Gleixner , Daire McNamara , Emil Renner Berthing , Krzysztof Kozlowski Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Kevin Xie , Minda Chen Subject: [PATCH v16 15/22] PCI: microchip: Add event irqchip field to host port and add PLDA irqchip Date: Thu, 28 Mar 2024 17:18:28 +0800 Message-Id: <20240328091835.14797-16-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240328091835.14797-1-minda.chen@starfivetech.com> References: <20240328091835.14797-1-minda.chen@starfivetech.com> X-ClientProxiedBy: NT0PR01CA0020.CHNPR01.prod.partner.outlook.cn (2406:e500:c510:c::16) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0559:EE_ X-MS-Office365-Filtering-Correlation-Id: d1ecffa9-bce7-4e1d-2623-08dc4f0819b0 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: A6Rv+6JUmLKzbvuFQJpv3A6Hmbw9ivjaW3PcslBBO496dzAi2i2RS0TTbmJa5FVq78NXXifBk0BSi++mB1TYF2QkubMshTxzjGnmLMXSBdP1U/tRoHoTKsu89gkMwMSFxsYy4KXd9TqiVJW/P5dy5RsKJIT4LIrWyk3zMnaviakcxO0E4VuaMljXXcrqFjXQgSMx3rbriNU0oWOeARBDmAOPO3A1FiADtSttwvW6a2jUad1JsSwTuJoeyCNtfBnDCSQVl/Q2o6BLfOeKAi3M6/i8KQynlCjZBa5gMrhbxJ7TgZ6kRzZAbhXICUCTvnkGf75uzq1TlthdCchX9UqJN9y2B3u5wXAfCjVySrQ0JkEkSZufTkmeBrDIXO2JuIgk2DX31bloKE/1bBmI3YDa53Gqe8oLgeeYCX9WOFz9+exlxh7bB+852MSXSrufS1pxFP5F+d48TiBFOgidBF0FhxYYA2tCyc+T0/bgvHiFbOnRufEAcH7pjXVVFm4o8qfm6BdW5gFbw3sSJlbQXy42rtc2L3P7GIzdWqpPGU+ImKoj78bKqDGPTTWXgJNHeKwMQ+84IOKow81PRF2mIkrFMwyJMNMqf28hcTVI0W1ZcRjuteqSEE+7A/+R2XeyC464 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230031)(1800799015)(52116005)(7416005)(41320700004)(366007)(38350700005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hsv6zU2PQykVCCXe/2GfBBuvg+WHBk6QpyBqsfFLl3luUxJD/uKYEZ5zl79BP9PEdNKihBuuq2mCI0ciuynC4i+9det0tCkQNszL2/Ybrx1dSpu64ShtIDety/w6Ce+yvXbUjv84F9QR3SsOps1fg2hzljzY0xKmT1o3PoJicb4YlCO3E8LeOC1MGLqY5y5P/ltbBcD34WYrAfz6hjLuyLvOimB2rwakNZuiAJupIc5eCJzeH3ewhaDdDgmhlCVFA/0rCLhQJMJxcbZo/FJO/va0lXIryHFXpwWTNP2WfOzLwe0yqDyRm7H34058uZMSAoo3JoS4AvsbiPulOTWrwGnvy66TLRby5znxkIjDuWtVJWT3uC8MwtDjdIOjCUaBBytnt+uxl1d84V1dSjp8+LXhC5FPfncb9ezAEtfbz5HcyRvRK9BThSC/O7oaUv+9JXAVrsZPN6qsoA4BBQ5h6fHNBSq2GJ2H28uSUQpsbedJ9tFvdwt0OEsYWK5DD7Irdz59mgCoBh5JJI/ph+NbPJV1fpdmEre8dtYgsvI/lwBZZyDNtOlI8l1aBUET9z3Bc+7g4iwenl1B5ZLAKcmxra0AcGVJziCzS5lfYFh4cYwqpQGKECDKDgM2WWhonjoTFHRDkzUeyic3D+cdFRJSu9lVgOpGGsugRUmLpzMKytade0GceiNrVZGd0qFTmhX0tZZKsLkwBnrld02RgKeY1xJmbhvkC7t4Guxx1JyXsiFDNkL3z+je3TbF69enC871XY8ZiLVoCzudYiVztAPVdW2Y6E0t5p0E+TblWdkDKWMVIwIUE2fbVq70/VLSpyogDx2sonQq2mUsgtdtsZ6j3RGHfWiNfvsFtHaimTzts9V5cspaLKfMNMoii/XofgjGfQRK1ZhIcjLPVK1EeDhJ1hCwNmeV0FkehgS0UnbspiMoOpeJ9VVjOUtHkTcdxJEaYOPmYkUOs64fbiojOOpEsSYORvj2j1l7sqh7ZL58U1vMimnY+rkKBk5k/hZMDz5BpPZtEBG+DLhBqd+yc6gJw2fkCvdMxYNY1l6r4RRWpiCTIiPb9qqztVLDeFzlUT05ZXen4cXgdZLYmQemxmyLqaQSFVwmpCRxA8Tv83id2fUvtsu8GIgUu87D7ZIs9xIZDByrYwYpKhsUU/+ta2ANX+7dtX7bL3xnm1gefz3jWpaGF1ECp60ka0w8f5bWAc6Jtfi33r48z6yYmAIfGhnLxLsFbLptuYfCULpnKuqV24iYTSYUlawdhRF7OgD2zdvFgPc+yXLNMUMtWQqhLM/dLJrrrLplun6IthyJ0wZ1kWM+l8PO8fy9mqdXznl7dbxAOJvbEldW+y2I9TvprEh3v8HD1ND0EkUXcwGFfp5WBeHQh/5xGZ23VFCkhGluzBwnC6mOoBxmB0aHGU6PUt1rnre+hq1WKJQkuZxUk47Tco1us/Lwdo5ya/2PE3Gbtk7rMq80ghXT4eRSNwh4ocXG3zGzLSCftSV/GUPQr0mShERNQF10RuT3ulRKn936lAkDM2kpRv+tzx5zp0wBfcpa/pHRHO0bWwWjS3jD/dPlWcT6i4csUXoSLfCN+zqiwoYjZgCsyDXEmOLoeiUZjwSQwA== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: d1ecffa9-bce7-4e1d-2623-08dc4f0819b0 X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Mar 2024 09:18:59.0169 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: XEWU4rXVQZIXMgS0vfYH4U6g91LZzzMgfWPeMSNhjmcScQigOhhc/MVHPuR3kdulWAAPcD9UyWqbQAF1EUaeVJXoVl97yODGx1VpdsBnncg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0559 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240328_021914_935812_E9C5DAF7 X-CRM114-Status: GOOD ( 15.83 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org As PLDA dts binding doc(Documentation/devicetree/bindings/pci/ plda,xpressrich3-axi-common.yaml) showed, PLDA PCIe contains an interrupt controller. Microchip PolarFire PCIE event IRQs includes PLDA interrupts and Polarfire additional interrupts. The interrupt irqchip ops includes ack/mask/unmask interrupt ops, which will write correct registers. Microchip Polarfire PCIe additional interrupts require to write Polarfire SoC self-defined registers. So Microchip PCIe event irqchip ops can not be re-used. Microchip Polarfire PCIe additional intrerrupts: (defined in drivers/pci/controller/plda/pcie-microchip-host.c) EVENT_PCIE_L2_EXIT EVENT_PCIE_HOTRST_EXIT EVENT_PCIE_DLUP_EXIT EVENT_SEC_TX_RAM_SEC_ERR EVENT_SEC_RX_RAM_SEC_ERR .... To support PLDA its own event IRQ process, implements PLDA irqchip ops and add event irqchip field to struct pcie_plda_rp. Signed-off-by: Minda Chen Acked-by: Conor Dooley --- .../pci/controller/plda/pcie-microchip-host.c | 66 ++++++++++++++++++- drivers/pci/controller/plda/pcie-plda.h | 34 +++++----- 2 files changed, 84 insertions(+), 16 deletions(-) diff --git a/drivers/pci/controller/plda/pcie-microchip-host.c b/drivers/pci/controller/plda/pcie-microchip-host.c index b3df373a2141..beaf5c27da84 100644 --- a/drivers/pci/controller/plda/pcie-microchip-host.c +++ b/drivers/pci/controller/plda/pcie-microchip-host.c @@ -770,6 +770,64 @@ static struct irq_chip mc_event_irq_chip = { .irq_unmask = mc_unmask_event_irq, }; +static u32 plda_hwirq_to_mask(int hwirq) +{ + u32 mask; + + /* hwirq 23 - 0 are the same with register */ + if (hwirq < EVENT_PM_MSI_INT_INTX) + mask = BIT(hwirq); + else if (hwirq == EVENT_PM_MSI_INT_INTX) + mask = PM_MSI_INT_INTX_MASK; + else + mask = BIT(hwirq + PCI_NUM_INTX - 1); + + return mask; +} + +static void plda_ack_event_irq(struct irq_data *data) +{ + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); + + writel_relaxed(plda_hwirq_to_mask(data->hwirq), + port->bridge_addr + ISTATUS_LOCAL); +} + +static void plda_mask_event_irq(struct irq_data *data) +{ + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); + u32 mask, val; + + mask = plda_hwirq_to_mask(data->hwirq); + + raw_spin_lock(&port->lock); + val = readl_relaxed(port->bridge_addr + IMASK_LOCAL); + val &= ~mask; + writel_relaxed(val, port->bridge_addr + IMASK_LOCAL); + raw_spin_unlock(&port->lock); +} + +static void plda_unmask_event_irq(struct irq_data *data) +{ + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); + u32 mask, val; + + mask = plda_hwirq_to_mask(data->hwirq); + + raw_spin_lock(&port->lock); + val = readl_relaxed(port->bridge_addr + IMASK_LOCAL); + val |= mask; + writel_relaxed(val, port->bridge_addr + IMASK_LOCAL); + raw_spin_unlock(&port->lock); +} + +static struct irq_chip plda_event_irq_chip = { + .name = "PLDA PCIe EVENT", + .irq_ack = plda_ack_event_irq, + .irq_mask = plda_mask_event_irq, + .irq_unmask = plda_unmask_event_irq, +}; + static const struct plda_event_ops plda_event_ops = { .get_events = plda_get_events, }; @@ -777,7 +835,9 @@ static const struct plda_event_ops plda_event_ops = { static int plda_pcie_event_map(struct irq_domain *domain, unsigned int irq, irq_hw_number_t hwirq) { - irq_set_chip_and_handler(irq, &mc_event_irq_chip, handle_level_irq); + struct plda_pcie_rp *port = (void *)domain->host_data; + + irq_set_chip_and_handler(irq, port->event_irq_chip, handle_level_irq); irq_set_chip_data(irq, domain->host_data); return 0; @@ -962,6 +1022,9 @@ static int plda_init_interrupts(struct platform_device *pdev, if (!port->event_ops) port->event_ops = &plda_event_ops; + if (!port->event_irq_chip) + port->event_irq_chip = &plda_event_irq_chip; + ret = plda_pcie_init_irq_domains(port); if (ret) { dev_err(dev, "failed creating IRQ domains\n"); @@ -1039,6 +1102,7 @@ static int mc_platform_init(struct pci_config_window *cfg) return ret; port->plda.event_ops = &mc_event_ops; + port->plda.event_irq_chip = &mc_event_irq_chip; /* Address translation is up; safe to enable interrupts */ ret = plda_init_interrupts(pdev, &port->plda, &mc_event); diff --git a/drivers/pci/controller/plda/pcie-plda.h b/drivers/pci/controller/plda/pcie-plda.h index e0e5e7cc8434..0e5157eb3a32 100644 --- a/drivers/pci/controller/plda/pcie-plda.h +++ b/drivers/pci/controller/plda/pcie-plda.h @@ -107,6 +107,8 @@ enum plda_int_event { #define PLDA_NUM_DMA_EVENTS 16 +#define EVENT_PM_MSI_INT_INTX (PLDA_NUM_DMA_EVENTS + PLDA_INTX) +#define EVENT_PM_MSI_INT_MSI (PLDA_NUM_DMA_EVENTS + PLDA_MSI) #define PLDA_MAX_EVENT_NUM (PLDA_NUM_DMA_EVENTS + PLDA_INT_EVENT_NUM) /* @@ -116,21 +118,22 @@ enum plda_int_event { * +--+--+--+-+------+-+-+-+-+-+-+-+-+-----------+-----------+ * |12|11|10|9| intx |7|6|5|4|3|2|1|0| DMA error | DMA end | * +--+--+--+-+------+-+-+-+-+-+-+-+-+-----------+-----------+ - * bit 0-7 DMA interrupt end : reserved for vendor implement - * bit 8-15 DMA error : reserved for vendor implement - * 0: AXI post error (PLDA_AXI_POST_ERR) - * 1: AXI fetch error (PLDA_AXI_FETCH_ERR) - * 2: AXI discard error (PLDA_AXI_DISCARD_ERR) - * 3: AXI doorbell (PLDA_PCIE_DOORBELL) - * 4: PCIe post error (PLDA_PCIE_POST_ERR) - * 5: PCIe fetch error (PLDA_PCIE_FETCH_ERR) - * 6: PCIe discard error (PLDA_PCIE_DISCARD_ERR) - * 7: PCIe doorbell (PLDA_PCIE_DOORBELL) - * 8: 4 INTx interruts (PLDA_INTX) - * 9: MSI interrupt (PLDA_MSI) - * 10: AER event (PLDA_AER_EVENT) - * 11: PM/LTR/Hotplug (PLDA_MISC_EVENTS) - * 12: System error (PLDA_SYS_ERR) + * event bit + * 0-7 (0-7) DMA interrupt end : reserved for vendor implement + * 8-15 (8-15) DMA error : reserved for vendor implement + * 16 (16) AXI post error (PLDA_AXI_POST_ERR) + * 17 (17) AXI fetch error (PLDA_AXI_FETCH_ERR) + * 18 (18) AXI discard error (PLDA_AXI_DISCARD_ERR) + * 19 (19) AXI doorbell (PLDA_PCIE_DOORBELL) + * 20 (20) PCIe post error (PLDA_PCIE_POST_ERR) + * 21 (21) PCIe fetch error (PLDA_PCIE_FETCH_ERR) + * 22 (22) PCIe discard error (PLDA_PCIE_DISCARD_ERR) + * 23 (23) PCIe doorbell (PLDA_PCIE_DOORBELL) + * 24 (27-24) INTx interruts (PLDA_INTX) + * 25 (28): MSI interrupt (PLDA_MSI) + * 26 (29): AER event (PLDA_AER_EVENT) + * 27 (30): PM/LTR/Hotplug (PLDA_MISC_EVENTS) + * 28 (31): System error (PLDA_SYS_ERR) */ struct plda_pcie_rp; @@ -155,6 +158,7 @@ struct plda_pcie_rp { raw_spinlock_t lock; struct plda_msi msi; const struct plda_event_ops *event_ops; + const struct irq_chip *event_irq_chip; void __iomem *bridge_addr; int num_events; };