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: 858045 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zGhQK6cNMz9s9Y for ; Wed, 10 Jan 2018 19:05:29 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933902AbeAJIFR (ORCPT ); Wed, 10 Jan 2018 03:05:17 -0500 Received: from mailgw01.mediatek.com ([210.61.82.183]:3799 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S932170AbeAJIEk (ORCPT ); Wed, 10 Jan 2018 03:04:40 -0500 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 CC: Bjorn Helgaas , Lorenzo Pieralisi , , , , , Ryder Lee 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 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org 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;