Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98944C433F5 for ; Mon, 27 Dec 2021 10:16:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235977AbhL0KQB (ORCPT ); Mon, 27 Dec 2021 05:16:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235931AbhL0KQA (ORCPT ); Mon, 27 Dec 2021 05:16:00 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97930C06173E; Mon, 27 Dec 2021 02:16:00 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 62823B80E66; Mon, 27 Dec 2021 10:15:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2C509C36AEA; Mon, 27 Dec 2021 10:15:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1640600158; bh=4RiHKxZjxpjsHwek5qKC1q/jLc8UAYKeJ68vjH604EA=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=PT7cHvOkTdvB0IAUbDUnmF3SzF1E31PObIaToOo+bcmDNWeYxZKRIQ5fThOg/R0+h MYcDBMV+RDTq1156vfzSEm/jyX6xYnbVMPZwuC9f9CoZixklnESiErNQgqn5PV7G8o yYaDGXw/z4ac6iPHZyJPguSPRAOPXxvM2hR2+AxwQfmq7fUgTjhPxbn6jc/UMOKMPl kC2G2wWw+dRqU3nzAVqzINLFQmehCcqShAGDMzXux91jZnx9g1qtl4oGsvtzVq6WP4 e4wO56HuqzbhRv+ULipKKn/poq2NPkSaQWScv0gVaVKLGw0t/SgcCsUQPaRO+2TGV6 k6OZBtiqQOGdA== Received: from cfbb000407.r.cam.camfibre.uk ([185.219.108.64] helo=wait-a-minute.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1n1n2q-00EX0L-1n; Mon, 27 Dec 2021 10:15:56 +0000 Date: Mon, 27 Dec 2021 10:16:01 +0000 Message-ID: <87tueuz732.wl-maz@kernel.org> From: Marc Zyngier To: Sander Vanheule Cc: Thomas Gleixner , Rob Herring , devicetree@vger.kernel.org, Birger Koblitz , Bert Vermeulen , John Crispin , linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH v2 2/5] irqchip/realtek-rtl: fix off-by-one in routing In-Reply-To: <2235a7748b8f7689a96b1e0f91461e36a946a4ef.1640548009.git.sander@svanheule.net> References: <2235a7748b8f7689a96b1e0f91461e36a946a4ef.1640548009.git.sander@svanheule.net> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: sander@svanheule.net, tglx@linutronix.de, robh+dt@kernel.org, devicetree@vger.kernel.org, mail@birger-koblitz.de, bert@biot.com, john@phrozen.org, linux-kernel@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 26 Dec 2021 19:59:25 +0000, Sander Vanheule wrote: > > 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. Where does this 'other routing' come from? > > 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 > --- > drivers/irqchip/irq-realtek-rtl.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/drivers/irqchip/irq-realtek-rtl.c b/drivers/irqchip/irq-realtek-rtl.c > index d6788dd93c7b..568614edd88f 100644 > --- a/drivers/irqchip/irq-realtek-rtl.c > +++ b/drivers/irqchip/irq-realtek-rtl.c > @@ -95,7 +95,8 @@ static void realtek_irq_dispatch(struct irq_desc *desc) > * 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 device_node *node, struct irq_domain *do > of_node_put(cpu_ictl); > > cpu_int = be32_to_cpup(imap + 2); > - if (cpu_int > 7) > + if (cpu_int > 7 || cpu_int < 2) How many output lines do you have? The comment above says something about having 15 output lines, but you limit it to 7... > return -EINVAL; > > if (!(mips_irqs_set & BIT(cpu_int))) { > @@ -143,7 +144,8 @@ static int __init map_interrupts(struct device_node *node, struct irq_domain *do > 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; > } > What I don't understand is how this worked so far if all mappings were off my one. Or the mapping really doesn't matter, because this is all under SW control? M. -- Without deviation from the norm, progress is not possible.