From patchwork Sun Feb 13 14:42:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sander Vanheule X-Patchwork-Id: 1592110 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=CdXw4RjK; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=svanheule.net header.i=@svanheule.net header.a=rsa-sha256 header.s=mail1707 header.b=YX8p6A9h; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JxVWs5yM5z9s09 for ; Mon, 14 Feb 2022 01:45:29 +1100 (AEDT) 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=/U6Gr2Tvyd9eQ1YX42tZqFlFV+CrqD4bxoBiSV2RfLs=; b=CdXw4RjKRUHMuX dvtrE75q4YQLvmlKN5czt8bVG6rHLy6aQsSDn1YshnlUMBiRjnGiAJo+S3rgd+ZeuESboqNPaxpjJ NWq/AYWBnve9mw+xsimpZGm2X2InwQyPw27oSxONT3fOOR5caRsdLaW00jsX0lOOBBTYNajqNiyGU OtNiaGqq4YYSBsYxVo9XI4E1HR7ZDJE0EEEO8G3/+8Tl2pzCAZbeKEIx1sZRt0W9TYX3OGEhL2quA M6RdH++9cwsKOw7lX8wNuVMt7XEhi+j9sp6YLS6og5pK2iU+fZSbmhLluJIFulqCwfoy0EZY+EiMr 31JdG7n/r7T47w3FmK0g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nJG6T-00Bpe1-4n; Sun, 13 Feb 2022 14:43:53 +0000 Received: from polaris.svanheule.net ([84.16.241.116]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nJG5n-00BpY9-GA for openwrt-devel@lists.openwrt.org; Sun, 13 Feb 2022 14:43:14 +0000 Received: from terra.local.svanheule.net (104.153-136-217.adsl-dyn.isp.belgacom.be [217.136.153.104]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: sander@svanheule.net) by polaris.svanheule.net (Postfix) with ESMTPSA id AABC02A1B80; Sun, 13 Feb 2022 15:43:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=svanheule.net; s=mail1707; t=1644763389; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ptz3Cp8rNSTMJdYso8un/zDn/FUCJcgyOXOevGpjhIg=; b=YX8p6A9h/dn0Qbfn+iChdIjnJst2vzwYGawOFN+KdvLEB34Md4rlY1//+pTMBhw7T7TvXy dVPzy4P3L5pmHM1Jr8xDyeBbuSg8sBwjIfDNvKanQUan+eBh/M0j8aYusua8QgzasDjqd3 y9a4XxpLQmJRh8Emh4kO59ZUnqluB28McVlmZQLGmquC82yenCLZV5vls8jK0/FbAx8Dmh C3i/skY8qdwp0ik+2KwiLg++s/6xQCVbWOG9YfOJWMjGllKrKoNQXnB9eezNPkH2vUBiG5 5eSqbkYvDlcEibMrsNQaXhVsED5N7/bLcoH2gc/TOADFj78MP+BYIj1AqVa/Ng== From: Sander Vanheule To: openwrt-devel@lists.openwrt.org Cc: Sander Vanheule Subject: [PATCH v1 2/3] realtek: backport SoC IRQ off-by-one fix Date: Sun, 13 Feb 2022 15:42:56 +0100 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220213_064311_868556_FF8AAA9C X-CRM114-Status: GOOD ( 19.27 ) X-Spam-Score: -0.9 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: The off-by-one error in the interrupt routing table caused the interrupt handlers to be attached to the wrong parent interrupt, but this was hidden by the fact that there was an unrelated interrupt ro [...] Content analysis details: (-0.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [84.16.241.116 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org The off-by-one error in the interrupt routing table caused the interrupt handlers to be attached to the wrong parent interrupt, but this was hidden by the fact that there was an unrelated interrupt routing for every used interrupt. The SoC DTS includes are updated to correctly reflect the SoC to CPU interrupt routing. Signed-off-by: Sander Vanheule --- target/linux/realtek/dts-5.10/rtl838x.dtsi | 14 ++--- target/linux/realtek/dts-5.10/rtl930x.dtsi | 24 ++++---- ...ealtek-rtl-fix-off-by-one-in-routing.patch | 60 +++++++++++++++++++ 3 files changed, 79 insertions(+), 19 deletions(-) create mode 100644 target/linux/realtek/patches-5.10/009-5.15.19-irqchip-realtek-rtl-fix-off-by-one-in-routing.patch diff --git a/target/linux/realtek/dts-5.10/rtl838x.dtsi b/target/linux/realtek/dts-5.10/rtl838x.dtsi index a5713748a9ea..50be0d8967c2 100644 --- a/target/linux/realtek/dts-5.10/rtl838x.dtsi +++ b/target/linux/realtek/dts-5.10/rtl838x.dtsi @@ -94,13 +94,13 @@ #interrupt-cells = <1>; interrupt-controller; interrupt-map = - <31 &cpuintc 2>, /* UART0 */ - <30 &cpuintc 1>, /* UART1 */ - <24 &cpuintc 4>, /* NIC */ - <23 &cpuintc 4>, /* GPIO_ABCD */ - <20 &cpuintc 3>, /* SWCORE */ - <19 &cpuintc 4>, /* WDT_IP1 */ - <18 &cpuintc 5>; /* WDT_IP2 */ + <31 &cpuintc 3>, /* UART0 */ + <30 &cpuintc 2>, /* UART1 */ + <24 &cpuintc 5>, /* NIC */ + <23 &cpuintc 5>, /* GPIO_ABCD */ + <20 &cpuintc 4>, /* SWCORE */ + <19 &cpuintc 5>, /* WDT_IP1 */ + <18 &cpuintc 6>; /* WDT_IP2 */ }; spi0: spi@1200 { diff --git a/target/linux/realtek/dts-5.10/rtl930x.dtsi b/target/linux/realtek/dts-5.10/rtl930x.dtsi index 38630bb6c26a..bce982739a13 100644 --- a/target/linux/realtek/dts-5.10/rtl930x.dtsi +++ b/target/linux/realtek/dts-5.10/rtl930x.dtsi @@ -99,18 +99,18 @@ #interrupt-cells = <1>; interrupt-controller; interrupt-map = - <31 &cpuintc 1>, /* UART1 */ - <30 &cpuintc 2>, /* UART0 */ - <24 &cpuintc 4>, /* NIC */ - <23 &cpuintc 3>, /* SWCORE */ - <13 &cpuintc 4>, /* GPIO_ABCD */ - <11 &cpuintc 1>, /* TC4 */ - <10 &cpuintc 1>, /* TC3 */ - <9 &cpuintc 1>, /* TC2 */ - <8 &cpuintc 1>, /* TC1 */ - <7 &cpuintc 5>, /* TC0 */ - <6 &cpuintc 5>, /* WDT_IP2 */ - <5 &cpuintc 4>; /* WDT_IP1 */ + <31 &cpuintc 2>, /* UART1 */ + <30 &cpuintc 3>, /* UART0 */ + <24 &cpuintc 5>, /* NIC */ + <23 &cpuintc 4>, /* SWCORE */ + <13 &cpuintc 5>, /* GPIO_ABCD */ + <11 &cpuintc 2>, /* TC4 */ + <10 &cpuintc 2>, /* TC3 */ + <9 &cpuintc 2>, /* TC2 */ + <8 &cpuintc 2>, /* TC1 */ + <7 &cpuintc 6>, /* TC0 */ + <6 &cpuintc 6>, /* WDT_IP2 */ + <5 &cpuintc 5>; /* WDT_IP1 */ }; timer: timer@3200 { diff --git a/target/linux/realtek/patches-5.10/009-5.15.19-irqchip-realtek-rtl-fix-off-by-one-in-routing.patch b/target/linux/realtek/patches-5.10/009-5.15.19-irqchip-realtek-rtl-fix-off-by-one-in-routing.patch new file mode 100644 index 000000000000..4d194b682b4f --- /dev/null +++ b/target/linux/realtek/patches-5.10/009-5.15.19-irqchip-realtek-rtl-fix-off-by-one-in-routing.patch @@ -0,0 +1,60 @@ +From 91351b5dd0fd494eb2d85e1bb6aca77b067447e0 Mon Sep 17 00:00:00 2001 +From: Sander Vanheule +Date: Sun, 9 Jan 2022 15:54:33 +0100 +Subject: irqchip/realtek-rtl: Fix off-by-one in routing + +From: Sander Vanheule + +commit 91351b5dd0fd494eb2d85e1bb6aca77b067447e0 upstream. + +There is an offset between routing values (1..6) and the connected MIPS +CPU interrupts (2..7), but no distinction was made between these two +values. + +This issue was previously hidden during testing, because an interrupt +mapping was used where for each required interrupt another (unused) +routing was configured, with an offset of +1. + +Offset the CPU IRQ numbers by -1 to retrieve the correct routing value. + +Fixes: 9f3a0f34b84a ("irqchip: Add support for Realtek RTL838x/RTL839x interrupt controller") +Signed-off-by: Sander Vanheule +Signed-off-by: Marc Zyngier +Link: https://lore.kernel.org/r/177b920aa8d8610615692d0e657e509f363c85ca.1641739718.git.sander@svanheule.net +Signed-off-by: Greg Kroah-Hartman +Signed-off-by: Sasha Levin +--- + drivers/irqchip/irq-realtek-rtl.c | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +--- a/drivers/irqchip/irq-realtek-rtl.c ++++ b/drivers/irqchip/irq-realtek-rtl.c +@@ -95,7 +95,8 @@ out: + * SoC interrupts are cascaded to MIPS CPU interrupts according to the + * interrupt-map in the device tree. Each SoC interrupt gets 4 bits for + * the CPU interrupt in an Interrupt Routing Register. Max 32 SoC interrupts +- * thus go into 4 IRRs. ++ * thus go into 4 IRRs. A routing value of '0' means the interrupt is left ++ * disconnected. Routing values {1..15} connect to output lines {0..14}. + */ + static int __init map_interrupts(struct device_node *node, struct irq_domain *domain) + { +@@ -134,7 +135,7 @@ static int __init map_interrupts(struct + of_node_put(cpu_ictl); + + cpu_int = be32_to_cpup(imap + 2); +- if (cpu_int > 7) ++ if (cpu_int > 7 || cpu_int < 2) + return -EINVAL; + + if (!(mips_irqs_set & BIT(cpu_int))) { +@@ -143,7 +144,8 @@ static int __init map_interrupts(struct + mips_irqs_set |= BIT(cpu_int); + } + +- regs[(soc_int * 4) / 32] |= cpu_int << (soc_int * 4) % 32; ++ /* Use routing values (1..6) for CPU interrupts (2..7) */ ++ regs[(soc_int * 4) / 32] |= (cpu_int - 1) << (soc_int * 4) % 32; + imap += 3; + } +