From patchwork Tue Mar 11 20:15:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 3814131 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id AE148BF540 for ; Tue, 11 Mar 2014 20:21:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D79DF201F0 for ; Tue, 11 Mar 2014 20:21:18 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D9E2020181 for ; Tue, 11 Mar 2014 20:21:17 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WNTAi-0002Dk-Jx; Tue, 11 Mar 2014 20:21:08 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WNT5q-0002s4-LW; Tue, 11 Mar 2014 20:16:06 +0000 Received: from quartz.orcorp.ca ([184.70.90.242]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WNT5n-0002rC-Cp for linux-arm-kernel@lists.infradead.org; Tue, 11 Mar 2014 20:16:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=obsidianresearch.com; s=rsa1; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date; bh=FZjjDQAPm7NJAJeZllstZpll+lCTL0GcjoRfrMH5kdc=; b=ZGYABnonNMM1emjwwAc9aBmn3aVUJ25KiWwBNcEvLTVJcSldeWu6K+CDmLAqwErqFRL8+64XGSYAtKoElCyrk4skQJq0cftmSCLpJRVADexRVBURGA1eumOxJMiDpbZ4rc3QCKRUGSpIbc0AxJl0reK62DMZHdNF3viXDSKFTlI=; Received: from [10.0.0.161] (helo=jggl.edm.orcorp.ca) by quartz.orcorp.ca with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1WNT5J-0003iU-PW; Tue, 11 Mar 2014 14:15:33 -0600 Received: from jgg by jggl.edm.orcorp.ca with local (Exim 4.80) (envelope-from ) id 1WNT5J-0000YL-C4; Tue, 11 Mar 2014 14:15:33 -0600 Date: Tue, 11 Mar 2014 14:15:33 -0600 From: Jason Gunthorpe To: Tim Harvey Subject: Re: [PATCH 1/2] of/irq: Fix irq-mapping in of_irq_parse_raw() Message-ID: <20140311201533.GF31835@obsidianresearch.com> References: <1393944864-28113-1-git-send-email-tharvey@gateworks.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1393944864-28113-1-git-send-email-tharvey@gateworks.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Broken-Reverse-DNS: no host name found for IP address 10.0.0.161 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140311_161603_595583_A416D0BB X-CRM114-Status: GOOD ( 14.57 ) X-Spam-Score: -2.0 (--) Cc: Mark Rutland , Richard Zhu , linux-samsung-soc , Grant Likely , Ben Dooks , Arnd Bergmann , Stephen Warren , linux-pci@vger.kernel.org, Jingoo Han , linux-tegra , Simon Horman , Thierry Reding , Sascha Hauer , Bjorn Helgaas , Kukjin Kim , Shawn Guo , linux-arm-kernel@lists.infradead.org, Lucas Stach X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Tue, Mar 04, 2014 at 06:54:24AM -0800, Tim Harvey wrote: > When an interrupt-map contains multiple entries an imap pointer arithmetic > bug can cause only the first entry to be properly evaluated and causes > the out_irq parameters to be incorrect depending on the #interrupt-cells > and #address-cells of the parent interrupt controller. Tim, I took a bit closer look at this for you, and I suspect the root fix is this: (plus the corresponding purge from the .dt files) It looks like the implementation does follow the OF specification: Each mapping entry consists of a 3-tuple of (child-interrupt, interrupt-parent, parent-interrupt). The number of cells for the child-interrupt specifier is determined by the "#address-cells" and "#interrupt-cells"property of this node. The number of cells for the parent-interrupt value is determined by the "#address-cells"and "#interrupt-cells"property values of this node's interrupt-parent. So by specifying interrupt-cells = 3, address-cells = 1, the GIC is requiring 4 DWs for its interrupt specifier. I see no reason why it doesn't have an address-cells = 0 like other interrupt controllers.. Setting #address-cells to 0 in the GIC node should be functionally equivalent to your patch below, since newaddrsize will == 0. Regards, Jason > diff --git a/drivers/of/irq.c b/drivers/of/irq.c > index 9bcf2cf..8829197 100644 > +++ b/drivers/of/irq.c > @@ -237,11 +237,11 @@ int of_irq_parse_raw(const __be32 *addr, struct of_phandle_args *out_irq) > /* Check for malformed properties */ > if (WARN_ON(newaddrsize + newintsize > MAX_PHANDLE_ARGS)) > goto fail; > - if (imaplen < (newaddrsize + newintsize)) > + if (imaplen < newintsize) > goto fail; > > - imap += newaddrsize + newintsize; > - imaplen -= newaddrsize + newintsize; > + imap += newintsize; > + imaplen -= newintsize; > > pr_debug(" -> imaplen=%d\n", imaplen); > } --- a/Documentation/devicetree/bindings/arm/gic.txt +++ b/Documentation/devicetree/bindings/arm/gic.txt @@ -55,7 +55,6 @@ Example: intc: interrupt-controller@fff11000 { compatible = "arm,cortex-a9-gic"; #interrupt-cells = <3>; - #address-cells = <1>; interrupt-controller; reg = <0xfff11000 0x1000>, <0xfff10100 0x100>;