From patchwork Wed Jun 19 14:11:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 13703882 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 AEFC8C27C53 for ; Wed, 19 Jun 2024 14:12: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:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type: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=RK8w32QGYAWMT7m9JYkUXMurfHp/XgZwlTicXsJhoUk=; b=AzVjXkTmcDtJew5v11n38j5oAj tEqO8atKCMHq0kaDULPWS++wT6xHLOt0x694qUNnS1n4r8OgqjIZry7xjnODU8GG3s0NKL8zyh5Kc lWSgTQ3cE1E6+F1nWdehNpOqxsW7TheEiZ6qLV1IahAVNJLnk1b8yyO1KCFKuPtYIzRAIdp5zhzf7 VjXRiyKNHwRYJh4c2SvKXfT8xVQ9VEUlKn81PCDWmhRAp4Y3HrXyfLGICiJV41jv+j7yeaPuGT8kz meOXNnGg1lkMfGlCMlg82eX229oRuvQKcyexo4ScU30ZHWCQFPPFhikn5vkPSridyJelezwt2wH22 54LQDWRA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sJw2T-00000001SQy-2qvO; Wed, 19 Jun 2024 14:11:53 +0000 Received: from sin.source.kernel.org ([145.40.73.55]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sJw2M-00000001SMm-2XQt for linux-arm-kernel@lists.infradead.org; Wed, 19 Jun 2024 14:11:48 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 5A388CE1FAA; Wed, 19 Jun 2024 14:11:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 69844C2BBFC; Wed, 19 Jun 2024 14:11:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718806302; bh=LPfDYE9q8FmeO4Pc8rrdcE/gT77TUCiNnKjpEwrsEPM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JVuOF9N9anGjHe9+bcYHi+bygccJhJ2ykldq9zkoAU6EgLJ/GxbVeSNQeYUoDOnkj J72H7YG5H7pQK2++jC3voXFyyaswPC82zvAakV4Yca0eRILKiO0OTFB6t/viIg1cZt MYNlbrG/xUB8VWzEvk0svTXIokTNFSMyNY1AVgKei7Fyp0uJOElyN9Z1psMKMpwe34 +q8gTn03TpHf6/4Z+AjnRY/B8gP89DFvDxeMXSw9WZwWW8OLClZnG0RllIZMAIuNgj zdAGpHT4hqVVaCoJ8mmkkP+9Jg+/FRqYADjQj/GvZ+JQ5Di2HwNPCsALtfMcY4GZ+G asy1ftI7oWZ/A== From: =?utf-8?q?Marek_Beh=C3=BAn?= To: Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, arm@kernel.org, Andy Shevchenko , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Cc: =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?Marek_Beh=C3=BA?= =?utf-8?q?n?= Subject: [PATCH 1/4] irqchip/armada-370-xp: Do not allow mapping IRQ 0 and 1 Date: Wed, 19 Jun 2024 16:11:31 +0200 Message-ID: <20240619141134.30900-2-kabel@kernel.org> X-Mailer: git-send-email 2.44.2 In-Reply-To: <20240619141134.30900-1-kabel@kernel.org> References: <20240619141134.30900-1-kabel@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240619_071146_971862_0B639517 X-CRM114-Status: GOOD ( 12.35 ) 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: Pali Rohár IRQs 0 (IPI) and 1 (MSI) are handled internally by this driver, generic_handle_domain_irq() is never called for these IRQs. Disallow mapping these IRQs. Fixes: 344e873e5657 ("arm: mvebu: Add IPI support via doorbells") Fixes: 31f614edb726 ("irqchip: armada-370-xp: implement MSI support") Signed-off-by: Pali Rohár [ changed commit message, added Fixes tags ] Signed-off-by: Marek Behún --- drivers/irqchip/irq-armada-370-xp.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/irqchip/irq-armada-370-xp.c b/drivers/irqchip/irq-armada-370-xp.c index 4b021a67bdfe..f488c35d9130 100644 --- a/drivers/irqchip/irq-armada-370-xp.c +++ b/drivers/irqchip/irq-armada-370-xp.c @@ -566,6 +566,10 @@ static struct irq_chip armada_370_xp_irq_chip = { static int armada_370_xp_mpic_irq_map(struct irq_domain *h, unsigned int virq, irq_hw_number_t hw) { + /* IRQs 0 and 1 cannot be mapped, they are handled internally */ + if (hw <= 1) + return -EINVAL; + armada_370_xp_irq_mask(irq_get_irq_data(virq)); if (!is_percpu_irq(hw)) writel(hw, per_cpu_int_base + From patchwork Wed Jun 19 14:11:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 13703883 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 60739C27C53 for ; Wed, 19 Jun 2024 14:12:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type: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=BqsGJV7ziJRYWU672VmHEezeGO1FWZ50e4TV4YLulWA=; b=pZGuXW4hqr6b5kBWS70Z8CFAuA iy7GsnGGO1HpwRHoK6LHDoRsFSIEZxzfi6fUrC/6BDaja4Ef35yW93MDwhgc2PYesYZQjRFYacmFn BgFMH/5/TH2JWjQMjvxVJubKjVSrOFvRzuQXUmmZc7yi0ZrOb/hbSi3xya/XYxr3zbBUqYO8DM6J/ Tap8JymQfeSwdX4dlIfmHJbanYzO7lT7aFImkTUGODbH0u1sEMHDJxy7QJ7UnaGFf7T4ESE7EV1n3 M/5ichs3qQgN/NlbXEMGPkKqzzO/GQuM9FZgc0psOM7QW/BWaRiI73bNvIK6boKDe/rGej2pbTH4D fliLoCgA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sJw2V-00000001SRj-0lVn; Wed, 19 Jun 2024 14:11:55 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sJw2M-00000001SMn-2A8T for linux-arm-kernel@lists.infradead.org; Wed, 19 Jun 2024 14:11:48 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 993FD61CDF; Wed, 19 Jun 2024 14:11:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 13DE6C32786; Wed, 19 Jun 2024 14:11:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718806305; bh=kBGr9a9MUg3G0YmfdKHBOVqASqNlFW6ClmDlN9ZGsH0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E1JdzbZoQ2iqPLv9q0386ChyzeVwiRVa9hjd1m5VqGXEjr9tqk+Ort9Hxk+QFi4gM snDzm85gFHzGsOniqm487i8lN09ZJHv53BBRDV98i/sOiYyndUcXuquFjI1N2YQnkf XBLf3TvV6A5qtS6QobMyQaK2N9FqUFnED9bUbMrJ+aagbFkahK2BCfrMgOW2cB4qQR KTnFJX27TP94VqgI5H7HfUtp/lEvTBwCADywF4ztrwNWBD2agI5Pv1YR490UGnhNNq +mPIGLzA9LTbDkF3bLJUfPD4dL2O5nIZDWFSrqfP+3+/ipi0BtUpNfleqYtlYqT8mT FwN65GdOCHbKQ== From: =?utf-8?q?Marek_Beh=C3=BAn?= To: Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, arm@kernel.org, Andy Shevchenko , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Cc: =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?Marek_Beh=C3=BA?= =?utf-8?q?n?= Subject: [PATCH 2/4] irqchip/armada-370-xp: Exit ipi_resume() early if IPI is not used Date: Wed, 19 Jun 2024 16:11:32 +0200 Message-ID: <20240619141134.30900-3-kabel@kernel.org> X-Mailer: git-send-email 2.44.2 In-Reply-To: <20240619141134.30900-1-kabel@kernel.org> References: <20240619141134.30900-1-kabel@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240619_071146_688737_812E1BE9 X-CRM114-Status: GOOD ( 13.48 ) 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: Pali Rohár Exit ipi_resume() early if IPI is not used. IPI is used only on systems where the mpic controller does not have a parent GIC IRQ (e.g. on Armada XP). Signed-off-by: Pali Rohár [ changed commit message and moved the code change into ipi_resume() ] Signed-off-by: Marek Behún --- drivers/irqchip/irq-armada-370-xp.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/irqchip/irq-armada-370-xp.c b/drivers/irqchip/irq-armada-370-xp.c index f488c35d9130..65f21624263e 100644 --- a/drivers/irqchip/irq-armada-370-xp.c +++ b/drivers/irqchip/irq-armada-370-xp.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -156,6 +157,12 @@ static DEFINE_MUTEX(msi_used_lock); static phys_addr_t msi_doorbell_addr; #endif +static inline bool is_ipi_available(void) +{ + /* IPI is used only if we do not have parent irq */ + return parent_irq <= 0; +} + static inline bool is_percpu_irq(irq_hw_number_t irq) { if (irq <= ARMADA_370_XP_MAX_PER_CPU_IRQS) @@ -429,6 +436,9 @@ static void ipi_resume(void) { int i; + if (!is_ipi_available()) + return; + for (i = 0; i < IPI_DOORBELL_END; i++) { int irq; From patchwork Wed Jun 19 14:11:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 13703884 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 39246C27C79 for ; Wed, 19 Jun 2024 14:12:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type: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=hOFevSG3lEvxJMtW0TzGg6Y79qrHfixEwz1OH57H5PA=; b=EMecO/8nYdMZqYl6vSm41NnXne ubA4wx8bD97YsUksb70iA9FP1M+QUXEUksrKwT3tPJbByFbWguf73LUogMADHiHlaFKqAh7EhXBR8 p4wpMpQVdnI9aoih4ezfJ3DRxr0a3W0Uk6oHaziSLZA6Ff3BJKwNGh3C/dIxfy0f3vyfSGIp3MrUM 3GEN9kpHzZEOcc2HX2hFkvcRfMPNIZYrF1VJGXNSWvaNdCk7XHAHBNY0LHwBGHXPUeR7cWwEaLdlL yIC5r5b4dFNGA5FRYc328uPxkYfIooUrYSsPGBOPq4+X2o5tWgtHKQ5iCD48i/VR8e82K+/xdtNfs 5wcPF/iA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sJw2i-00000001SWW-0JLn; Wed, 19 Jun 2024 14:12:08 +0000 Received: from sin.source.kernel.org ([145.40.73.55]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sJw2R-00000001SOz-2syF for linux-arm-kernel@lists.infradead.org; Wed, 19 Jun 2024 14:11:54 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id A6351CE1FAD; Wed, 19 Jun 2024 14:11:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B3CE9C2BBFC; Wed, 19 Jun 2024 14:11:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718806307; bh=IOV8pA+CU/RrS4OraGshOGNPba3K1YZfvxLKxSO4Xss=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FMGJBjoKc++pE0j59cmObQvXnD/0IGLiO91CLSlKpyH39Djj7+ITsLiwD0tEFCEHE 4y1IEqEvCNzUy73mF7JAlH3Fq6EhYRCqjBAOLKnlvUhuElVJSc662xxp2onG6XpMi/ VJrmKsfwNxQSpG3jQyG1Gefh2hmCcRvdbWuumeYcdvrO+/OPskyQc7xJFNtRYUIxkC 9dSju1J02mT0jKYc6FHY5vYW3CxbfTeIFcLmrZAkskUeVYAKbxYHgb5SKfwehlu0jS FOd5domRRplUwXYM5auCy8buAKouZWtH+oXCLM88Mm1vUZ7HnFA1/L4ru+WF1vPqNF aKs3tr7PjDl/A== From: =?utf-8?q?Marek_Beh=C3=BAn?= To: Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, arm@kernel.org, Andy Shevchenko , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Cc: =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?Marek_Beh=C3=BA?= =?utf-8?q?n?= Subject: [PATCH 3/4] irqchip/armada-370-xp: Do not touch IPI registers on platforms without IPI Date: Wed, 19 Jun 2024 16:11:33 +0200 Message-ID: <20240619141134.30900-4-kabel@kernel.org> X-Mailer: git-send-email 2.44.2 In-Reply-To: <20240619141134.30900-1-kabel@kernel.org> References: <20240619141134.30900-1-kabel@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240619_071152_288059_2F0289A3 X-CRM114-Status: GOOD ( 15.73 ) 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: Pali Rohár IPI is not available on platforms where MPIC has a parent irq. On these platforms the IPI registers are used as additional set of MSI interrupts (currently unused by the driver). Do not touch these registers if IPI is not available. Signed-off-by: Pali Rohár [ refactored, changed commit message ] Signed-off-by: Marek Behún Reviewed-by: Andrew Lunn --- drivers/irqchip/irq-armada-370-xp.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/irqchip/irq-armada-370-xp.c b/drivers/irqchip/irq-armada-370-xp.c index 65f21624263e..0097f7dd36e7 100644 --- a/drivers/irqchip/irq-armada-370-xp.c +++ b/drivers/irqchip/irq-armada-370-xp.c @@ -506,6 +506,9 @@ static void armada_xp_mpic_smp_cpu_init(void) for (i = 0; i < nr_irqs; i++) writel(i, per_cpu_int_base + ARMADA_370_XP_INT_SET_MASK_OFFS); + if (!is_ipi_available()) + return; + /* Disable all IPIs */ writel(0, per_cpu_int_base + ARMADA_370_XP_IN_DRBEL_MSK_OFFS); @@ -755,7 +758,7 @@ static void armada_370_xp_mpic_resume(void) /* Reconfigure doorbells for IPIs and MSIs */ writel(doorbell_mask_reg, per_cpu_int_base + ARMADA_370_XP_IN_DRBEL_MSK_OFFS); - if (doorbell_mask_reg & IPI_DOORBELL_MASK) + if (is_ipi_available() && (doorbell_mask_reg & IPI_DOORBELL_MASK)) writel(0, per_cpu_int_base + ARMADA_370_XP_INT_CLEAR_MASK_OFFS); if (doorbell_mask_reg & PCI_MSI_DOORBELL_MASK) writel(1, per_cpu_int_base + ARMADA_370_XP_INT_CLEAR_MASK_OFFS); @@ -805,13 +808,18 @@ static int __init armada_370_xp_mpic_of_init(struct device_node *node, BUG_ON(!armada_370_xp_mpic_domain); irq_domain_update_bus_token(armada_370_xp_mpic_domain, DOMAIN_BUS_WIRED); + /* + * Initialize parent_irq before calling any other functions, since it is + * used to distinguish between IPI and non-IPI platforms. + */ + parent_irq = irq_of_parse_and_map(node, 0); + /* Setup for the boot CPU */ armada_xp_mpic_perf_init(); armada_xp_mpic_smp_cpu_init(); armada_370_xp_msi_init(node, main_int_res.start); - parent_irq = irq_of_parse_and_map(node, 0); if (parent_irq <= 0) { irq_set_default_host(armada_370_xp_mpic_domain); set_handle_irq(armada_370_xp_handle_irq); From patchwork Wed Jun 19 14:11:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 13703885 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 2B7C2C27C53 for ; Wed, 19 Jun 2024 14:12:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type: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=DheNp+qQ2KpOJqrEg0RKnVeETFSIl7lVNqoZ/PGOqqs=; b=WDVZuNAdaTEL/4nHVJVidnBBBQ WiBrt+xo34VG0krscenjbtS9BChmFKYa4IMPcjU+igt5bBQ9VkdIxOD0JpApRDF8d2tRtIUHZHHy4 jVzLTJVXKWNLrDiveBZMkbQxC857HJ1ye5dSh96gC0eH7RFKgCniob70mweNyG/ItLp+fsB7CLkKe pR8HHHOfUultRqjDD0ouI8c4mQ5wur+K4AmYk8AxVOCddc/5nNxV4XYDGXMrJtxGeedq/pxe8L2LP i9ID05Xe5NaUSGrvXcpQiP/24gXbLU1vUSnc2LzZ4JbwOziv1JRvDObPiIyxX9I0h36kK74PKB+2y LkY+u19A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sJw2j-00000001SXD-3OXW; Wed, 19 Jun 2024 14:12:09 +0000 Received: from sin.source.kernel.org ([145.40.73.55]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sJw2S-00000001SPg-3tWB for linux-arm-kernel@lists.infradead.org; Wed, 19 Jun 2024 14:11:54 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 50F25CE1FAC; Wed, 19 Jun 2024 14:11:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5EFD4C32781; Wed, 19 Jun 2024 14:11:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718806310; bh=GeZ+s5jNAU4KTPTmnIY3QhuxD7vK5jh4b97HJWcda+I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OBgQV/C3YeFQkzoNyr1g5El4p7f+2lqRn1SYAVTKWoeP661VasvhVMNbUoyZ8Mpi8 edse4tWFYiToSJQ40fNMq9RW9BF2OWbtVgjp8ff84ci+7GwnM+RUCMksF9CyTBgCwK YaYkho8XALqLYAR20XJcEkZWVdxQdq/AMdLXfFl8QTfcHeVDB1KXNP2iyPM2N9N/sh UPbKSsz28dDrmm1nJNMSrf+z9w5qhuqhLhJCFPiP7Pn8ytTh9EZh0xbpzv9P/7wMRx duT4Q/jhhI7oOjnnZX3Yz7RIzbTYMP2perAXdjZSdCkr1XWpJDrm7sB2A0/DFok+qX 8W2O7JTqxqRZg== From: =?utf-8?q?Marek_Beh=C3=BAn?= To: Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, arm@kernel.org, Andy Shevchenko , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Cc: =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?Marek_Beh=C3=BA?= =?utf-8?q?n?= Subject: [PATCH 4/4] irqchip/armada-370-xp: Add support for 32 MSI interrupts on non-IPI platforms Date: Wed, 19 Jun 2024 16:11:34 +0200 Message-ID: <20240619141134.30900-5-kabel@kernel.org> X-Mailer: git-send-email 2.44.2 In-Reply-To: <20240619141134.30900-1-kabel@kernel.org> References: <20240619141134.30900-1-kabel@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240619_071153_384655_16ADD25F X-CRM114-Status: GOOD ( 19.96 ) 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: Pali Rohár The doorbell interrupts have the following layout on IPI vs no-IPI platforms: | 0...7 | 8...15 | 16...31 | ------------------+---------+----------+---------------------+ IPI platform | IPI | n/a | MSI | ------------------+---------+----------+---------------------+ non-IPI platform | MSI | ------------------+------------------------------------------+ Currently the driver only allows for the upper 16...31 interrupts for MSI domain (i.e. the MSI domain has only 16 interrupts). On platforms where IPI is not available, we can use whole 32 MSI interrupts. Implement support also for the lower 16 MSI interrupts on non-IPI platforms. Signed-off-by: Pali Rohár [ refactored, changed commit message ] Signed-off-by: Marek Behún Reviewed-by: Andrew Lunn --- drivers/irqchip/irq-armada-370-xp.c | 77 +++++++++++++++++++++++------ 1 file changed, 63 insertions(+), 14 deletions(-) diff --git a/drivers/irqchip/irq-armada-370-xp.c b/drivers/irqchip/irq-armada-370-xp.c index 0097f7dd36e7..f87c21cf5ec6 100644 --- a/drivers/irqchip/irq-armada-370-xp.c +++ b/drivers/irqchip/irq-armada-370-xp.c @@ -13,6 +13,7 @@ * warranty of any kind, whether express or implied. */ +#include #include #include #include @@ -136,6 +137,7 @@ #define ARMADA_370_XP_MAX_PER_CPU_IRQS (28) +/* IPI and MSI interrupt definitions for IPI platforms */ #define IPI_DOORBELL_START (0) #define IPI_DOORBELL_END (8) #define IPI_DOORBELL_MASK 0xFF @@ -144,6 +146,14 @@ #define PCI_MSI_DOORBELL_END (32) #define PCI_MSI_DOORBELL_MASK 0xFFFF0000 +/* MSI interrupt definitions for non-IPI platforms */ +#define PCI_MSI_FULL_DOORBELL_START 0 +#define PCI_MSI_FULL_DOORBELL_NR 32 +#define PCI_MSI_FULL_DOORBELL_END 32 +#define PCI_MSI_FULL_DOORBELL_MASK GENMASK(31, 0) +#define PCI_MSI_FULL_DOORBELL_SRC0_MASK GENMASK(15, 0) +#define PCI_MSI_FULL_DOORBELL_SRC1_MASK GENMASK(31, 16) + static void __iomem *per_cpu_int_base; static void __iomem *main_int_base; static struct irq_domain *armada_370_xp_mpic_domain; @@ -152,7 +162,7 @@ static int parent_irq; #ifdef CONFIG_PCI_MSI static struct irq_domain *armada_370_xp_msi_domain; static struct irq_domain *armada_370_xp_msi_inner_domain; -static DECLARE_BITMAP(msi_used, PCI_MSI_DOORBELL_NR); +static DECLARE_BITMAP(msi_used, PCI_MSI_FULL_DOORBELL_NR); static DEFINE_MUTEX(msi_used_lock); static phys_addr_t msi_doorbell_addr; #endif @@ -163,6 +173,30 @@ static inline bool is_ipi_available(void) return parent_irq <= 0; } +static inline u32 msi_doorbell_mask(void) +{ + return is_ipi_available() ? PCI_MSI_DOORBELL_MASK : + PCI_MSI_FULL_DOORBELL_MASK; +} + +static inline unsigned int msi_doorbell_start(void) +{ + return is_ipi_available() ? PCI_MSI_DOORBELL_START : + PCI_MSI_FULL_DOORBELL_START; +} + +static inline unsigned int msi_doorbell_size(void) +{ + return is_ipi_available() ? PCI_MSI_DOORBELL_NR : + PCI_MSI_FULL_DOORBELL_NR; +} + +static inline unsigned int msi_doorbell_end(void) +{ + return is_ipi_available() ? PCI_MSI_DOORBELL_END : + PCI_MSI_FULL_DOORBELL_END; +} + static inline bool is_percpu_irq(irq_hw_number_t irq) { if (irq <= ARMADA_370_XP_MAX_PER_CPU_IRQS) @@ -220,7 +254,7 @@ static void armada_370_xp_compose_msi_msg(struct irq_data *data, struct msi_msg msg->address_lo = lower_32_bits(msi_doorbell_addr); msg->address_hi = upper_32_bits(msi_doorbell_addr); - msg->data = BIT(cpu + 8) | (data->hwirq + PCI_MSI_DOORBELL_START); + msg->data = BIT(cpu + 8) | (data->hwirq + msi_doorbell_start()); } static int armada_370_xp_msi_set_affinity(struct irq_data *irq_data, @@ -253,7 +287,7 @@ static int armada_370_xp_msi_alloc(struct irq_domain *domain, unsigned int virq, int hwirq, i; mutex_lock(&msi_used_lock); - hwirq = bitmap_find_free_region(msi_used, PCI_MSI_DOORBELL_NR, + hwirq = bitmap_find_free_region(msi_used, msi_doorbell_size(), order_base_2(nr_irqs)); mutex_unlock(&msi_used_lock); @@ -290,9 +324,10 @@ static void armada_370_xp_msi_reenable_percpu(void) u32 reg; /* Enable MSI doorbell mask and combined cpu local interrupt */ - reg = readl(per_cpu_int_base + ARMADA_370_XP_IN_DRBEL_MSK_OFFS) - | PCI_MSI_DOORBELL_MASK; + reg = readl(per_cpu_int_base + ARMADA_370_XP_IN_DRBEL_MSK_OFFS); + reg |= msi_doorbell_mask(); writel(reg, per_cpu_int_base + ARMADA_370_XP_IN_DRBEL_MSK_OFFS); + /* Unmask local doorbell interrupt */ writel(1, per_cpu_int_base + ARMADA_370_XP_INT_CLEAR_MASK_OFFS); } @@ -304,7 +339,7 @@ static int armada_370_xp_msi_init(struct device_node *node, ARMADA_370_XP_SW_TRIG_INT_OFFS; armada_370_xp_msi_inner_domain = - irq_domain_add_linear(NULL, PCI_MSI_DOORBELL_NR, + irq_domain_add_linear(NULL, msi_doorbell_size(), &armada_370_xp_msi_domain_ops, NULL); if (!armada_370_xp_msi_inner_domain) return -ENOMEM; @@ -320,6 +355,10 @@ static int armada_370_xp_msi_init(struct device_node *node, armada_370_xp_msi_reenable_percpu(); + /* Unmask low 16 MSI irqs on non-IPI platforms */ + if (!is_ipi_available()) + writel(0, per_cpu_int_base + ARMADA_370_XP_INT_CLEAR_MASK_OFFS); + return 0; } #else @@ -616,20 +655,20 @@ static void armada_370_xp_handle_msi_irq(struct pt_regs *regs, bool is_chained) u32 msimask, msinr; msimask = readl_relaxed(per_cpu_int_base + - ARMADA_370_XP_IN_DRBEL_CAUSE_OFFS) - & PCI_MSI_DOORBELL_MASK; + ARMADA_370_XP_IN_DRBEL_CAUSE_OFFS); + msimask &= msi_doorbell_mask(); writel(~msimask, per_cpu_int_base + ARMADA_370_XP_IN_DRBEL_CAUSE_OFFS); - for (msinr = PCI_MSI_DOORBELL_START; - msinr < PCI_MSI_DOORBELL_END; msinr++) { + for (msinr = msi_doorbell_start(); + msinr < msi_doorbell_end(); msinr++) { unsigned int irq; if (!(msimask & BIT(msinr))) continue; - irq = msinr - PCI_MSI_DOORBELL_START; + irq = msinr - msi_doorbell_start(); generic_handle_domain_irq(armada_370_xp_msi_inner_domain, irq); } @@ -658,7 +697,7 @@ static void armada_370_xp_mpic_handle_cascade_irq(struct irq_desc *desc) if (!(irqsrc & ARMADA_370_XP_INT_IRQ_FIQ_MASK(cpuid))) continue; - if (irqn == 1) { + if (irqn == 0 || irqn == 1) { armada_370_xp_handle_msi_irq(NULL, true); continue; } @@ -719,6 +758,7 @@ static int armada_370_xp_mpic_suspend(void) static void armada_370_xp_mpic_resume(void) { + bool src0 = false, src1 = false; int nirqs; irq_hw_number_t irq; @@ -758,9 +798,18 @@ static void armada_370_xp_mpic_resume(void) /* Reconfigure doorbells for IPIs and MSIs */ writel(doorbell_mask_reg, per_cpu_int_base + ARMADA_370_XP_IN_DRBEL_MSK_OFFS); - if (is_ipi_available() && (doorbell_mask_reg & IPI_DOORBELL_MASK)) + + if (is_ipi_available()) { + src0 = doorbell_mask_reg & IPI_DOORBELL_MASK; + src1 = doorbell_mask_reg & PCI_MSI_DOORBELL_MASK; + } else { + src0 = doorbell_mask_reg & PCI_MSI_FULL_DOORBELL_SRC0_MASK; + src1 = doorbell_mask_reg & PCI_MSI_FULL_DOORBELL_SRC1_MASK; + } + + if (src0) writel(0, per_cpu_int_base + ARMADA_370_XP_INT_CLEAR_MASK_OFFS); - if (doorbell_mask_reg & PCI_MSI_DOORBELL_MASK) + if (src1) writel(1, per_cpu_int_base + ARMADA_370_XP_INT_CLEAR_MASK_OFFS); ipi_resume();