From patchwork Tue Mar 4 14:54:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Harvey X-Patchwork-Id: 326350 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id EED2F2C01AB for ; Wed, 5 Mar 2014 01:54:41 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757383AbaCDOyk (ORCPT ); Tue, 4 Mar 2014 09:54:40 -0500 Received: from mail-pd0-f182.google.com ([209.85.192.182]:42879 "EHLO mail-pd0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757188AbaCDOyi (ORCPT ); Tue, 4 Mar 2014 09:54:38 -0500 Received: by mail-pd0-f182.google.com with SMTP id g10so5242606pdj.13 for ; Tue, 04 Mar 2014 06:54:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=M+8CZLsAHr4UylBqnsD32zuJkDsRe+0hKEUYnVJ8kQE=; b=KhUuiA/Q0XY9XVjoR7oi/TsGQwOfXqaVZFmRDth0E2MKT6XivpJcFS6ofI30rCPt1n SuQDqRmhiQiOnQj0Ne1sHW6VzBpszeuv073KaeEfgDKCIrwrBT1VcL7ACrK7ZC+TJTvt tmTEoxH2b7WvEMdlFrKtg/mx3raBX2zdEfney//tg2W2w9Wng43P+CRtpWHb5mf/Qf67 JztqmugoBioJbCYQ3F3RFJTC5ydfcA8YWKrit/wGak/E7Qhqr1VVSeqGGpdQHdIjoNzu IAeTEVgEZiAmWxHEJPgQvfMBsOeAlHdmeWSIFFtw/sqEXzFY2sE+puirKSxtXT5HyCQZ nXng== X-Gm-Message-State: ALoCoQl9sjCR8cQ2CwbiqL5woC/A3IzrDtr0qIDYrA/ony+i73OiCblS2YCW91/IvJHpXhBvlG4W X-Received: by 10.68.197.36 with SMTP id ir4mr33480pbc.46.1393944877887; Tue, 04 Mar 2014 06:54:37 -0800 (PST) Received: from localhost.localdomain (68-189-91-139.static.snlo.ca.charter.com. [68.189.91.139]) by mx.google.com with ESMTPSA id sy2sm48719975pbc.28.2014.03.04.06.54.35 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 04 Mar 2014 06:54:36 -0800 (PST) From: Tim Harvey To: linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org Cc: Jason Gunthorpe , Jingoo Han , Lucas Stach , Mark Rutland , linux-samsung-soc , Richard Zhu , Sascha Hauer , Arnd Bergmann , Stephen Warren , Bjorn Helgaas , Simon Horman , Thierry Reding , Ben Dooks , linux-tegra , Kukjin Kim , Shawn Guo , Grant Likely Subject: [PATCH 1/2] of/irq: Fix irq-mapping in of_irq_parse_raw() Date: Tue, 4 Mar 2014 06:54:24 -0800 Message-Id: <1393944864-28113-1-git-send-email-tharvey@gateworks.com> X-Mailer: git-send-email 1.8.3.2 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org 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. Specifically, the imap pointer into the interrupt-map table should be adjusted by the parent interrupt controller #interrupt-cells size only as at this point the only the parent unit interrupt specifier needs to be stepped over. This resolves an issue encountered when using the of_irq_parse_and_map_pci() for the imx6 pcie host controller driver map_irq function where a P2P bridge is on the bus and legacy PCI interrupts are to be used. Signed-off-by: Tim Harvey Cc: Jason Gunthorpe Cc: Jingoo Han Cc: Lucas Stach Cc: Mark Rutland Cc: linux-samsung-soc Cc: Richard Zhu Cc: Sascha Hauer Cc: Arnd Bergmann Cc: Stephen Warren Cc: Bjorn Helgaas Cc: Simon Horman Cc: Thierry Reding Cc: Ben Dooks Cc: linux-tegra Cc: Kukjin Kim Cc: Shawn Guo Cc: Grant Likely --- drivers/of/irq.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/of/irq.c b/drivers/of/irq.c index 9bcf2cf..8829197 100644 --- a/drivers/of/irq.c +++ 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); }