From patchwork Wed Jan 10 08:04:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryder Lee X-Patchwork-Id: 10154483 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B03CA602D8 for ; Wed, 10 Jan 2018 08:15:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A2BB522701 for ; Wed, 10 Jan 2018 08:15:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9553B237F1; Wed, 10 Jan 2018 08:15:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id F0A9D22701 for ; Wed, 10 Jan 2018 08:15:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=wuMUrJGtMvLpwD9OcKACRcdUvX3Udk986BzRY2sGqzQ=; b=Dp2qrdcgMivSLa 9ONpR/qeG3Q9pjPIhoyYeqatdsF79bZN86dmvSvfG9MQ1OJBb7dwQgm5PpxDElY+ckdqaZKhfLyx3 sC9WjPE/Ml/K1Nawd6PZAet2APIuNmmWa1Zzuc3DWaZLOf2cfZHZc2w82eQiWGLelUL9czcucxdTl rSyQqN8Y3+Bo3nhC8eNuqhoAqLnZ0eZ0wnoyvbHsqiB9UhzZpLyZ11u4QCjCZb+R+DMKOstJhqBMx GACwGbD0+T16mAupnfIG+UEtkjzs591M4+w6H8KFSuNY1PwdUk2CsppxIkhDR0p+NpAh7JUeBsl5o 6fiJWc/3ypnf9snz3Ktg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eZBYC-0000qO-LG; Wed, 10 Jan 2018 08:15:56 +0000 Received: from [210.61.82.183] (helo=mailgw01.mediatek.com) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eZBT0-0000Tx-L2; Wed, 10 Jan 2018 08:11:25 +0000 X-UUID: a62a7be919a940d1abb22e86cc3e52b1-20180110 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] by mailgw01.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 552471267; Wed, 10 Jan 2018 16:04:36 +0800 Received: from mtkcas09.mediatek.inc (172.21.101.178) by mtkmbs08n2.mediatek.inc (172.21.101.56) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Wed, 10 Jan 2018 16:04:35 +0800 Received: from mtkslt306.mediatek.inc (10.21.14.136) by mtkcas09.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1210.3 via Frontend Transport; Wed, 10 Jan 2018 16:04:35 +0800 From: Ryder Lee To: Arnd Bergmann Subject: [RFC PATCH] of_pci_irq: add a check to fallback to device tree parsing Date: Wed, 10 Jan 2018 16:04:28 +0800 Message-ID: <3fcf63d1ac22f1ed5f53cc16cd2d06a849684e08.1515570774.git.ryder.lee@mediatek.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180110_001035_352572_D122C884 X-CRM114-Status: GOOD ( 11.93 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lorenzo Pieralisi , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Ryder Lee , linux-mediatek@lists.infradead.org, Bjorn Helgaas , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP A root complex normally consist of a host/PCI bridge and multiple P2P bridges. It will get mismatched results if we implement the bindings in the form of a root node with multiple subnodes (P2P bridge) and list all interrupt-map properties for each slot in the parent - It maens that we want to propagate IRQs from a root port to the devices in the hierarchy below it. If we have a PCIe device which is connected to slot 1, and will get something like this: pcieport 0000:00:01.0: assign IRQ: got 213 --> igb 0000:01:00.0: assign IRQ: got 212 The reason is that we use the subordinate 'devfn' but didn't obtain the actual slot numbers from device tree, this patch add a check to fallback to use device tree parsing if needed. Signed-off-by: Ryder Lee --- Discussion thread: https://patchwork.ozlabs.org/patch/829108/ --- drivers/of/of_pci_irq.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/of/of_pci_irq.c b/drivers/of/of_pci_irq.c index 3a05568..e445866 100644 --- a/drivers/of/of_pci_irq.c +++ b/drivers/of/of_pci_irq.c @@ -86,8 +86,18 @@ int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq out_irq->np = ppnode; out_irq->args_count = 1; out_irq->args[0] = pin; - laddr[0] = cpu_to_be32((pdev->bus->number << 16) | (pdev->devfn << 8)); - laddr[1] = laddr[2] = cpu_to_be32(0); + + if (!dn && ppnode) { + const __be32 *addr; + + addr = of_get_property(ppnode, "reg", NULL); + if (addr) + memcpy(laddr, addr, 3); + } else { + laddr[0] = cpu_to_be32((pdev->bus->number << 16) | (pdev->devfn << 8)); + laddr[1] = laddr[2] = cpu_to_be32(0); + } + rc = of_irq_parse_raw(laddr, out_irq); if (rc) goto err;