From patchwork Mon Apr 4 08:52:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Nowicki X-Patchwork-Id: 8738971 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id DBAF1C0553 for ; Mon, 4 Apr 2016 08:56:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 118F22022D for ; Mon, 4 Apr 2016 08:56:42 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4637E2021F for ; Mon, 4 Apr 2016 08:56:41 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1an0Hu-0001Oh-Uq; Mon, 04 Apr 2016 08:55:10 +0000 Received: from mail-lf0-x22c.google.com ([2a00:1450:4010:c07::22c]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1an0GK-0008VB-Qa for linux-arm-kernel@lists.infradead.org; Mon, 04 Apr 2016 08:53:36 +0000 Received: by mail-lf0-x22c.google.com with SMTP id c62so159106540lfc.1 for ; Mon, 04 Apr 2016 01:53:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=21NmbJNuWAbNNAcBso8tYks+E7AkbWrSigOrZXdSfuo=; b=I01ppB+QnhdSCqBPcXx0fylKj2fV82zlQ41BKiaetZg18gPcwosFRA+84xgMmROzDR Y35JRO2KGO/Wo0Gfu/+mXoSviYGc7LEFlbPLzyMo7VvnyofyRiV9OH8LBlryPd43H4rt ZLnsDb/7LhO4D3moteqCrgcoNvHABwclXMtJHAO5ujKNYJGb1uC1+qWUe8xSn3Z05Ayu AE1AgIjK+EPB8UrJX9YwXyBK9cq5vzGb44U1hgXc1vcD4TYyqGTGR8HYANO8o/R00tNM GzgNMVCJjIB2MnRPEu1fp+AbmerKwq5wDw7CAkaBT2jZ1QePIeA7kDv5NC7OEKqQlIsP IKvg== 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:in-reply-to :references; bh=21NmbJNuWAbNNAcBso8tYks+E7AkbWrSigOrZXdSfuo=; b=UK4kQP2mMgVgWVREB3IAAmuU4Lov0PBAObhOvXjfFdr6+fC6Lqyw64raNr2zWm7PJ4 OW7YIFYtjmECuOh8/x7QXjm6WwVWEhcq7t6iSpk6NcY73giqzduS+HXlobd/7hYF05dS rJ615lFul5QhSy5Fh8gRgw7mnzjhWUD/dT2WILdvpeq/gnxxz+H1f2F3B80EwHQJvRGb 5KCJOuIDlITzEy6RxLEsN8BzuaOcNUChG+GA4rHi/2KBYIDYKlS/8YzniMItLB15YV+a Eb2xWBqvk32ssQJKOZ1dFwUxQ13ugWnczItG+jsY0idpG4SWq9/jhw7a/znh1tXVhd69 gqNg== X-Gm-Message-State: AD7BkJJtQMtDFCovU70AdRafK7cfOK15y/1B+wqBhN3xE9yRSk+E+q9IKS1AwpQp7YhTiw== X-Received: by 10.194.82.199 with SMTP id k7mr8873573wjy.63.1459759991032; Mon, 04 Apr 2016 01:53:11 -0700 (PDT) Received: from tn-HP-4.semihalf.local (cardhu.semihalf.com. [213.17.239.108]) by smtp.gmail.com with ESMTPSA id js8sm27765096wjc.37.2016.04.04.01.53.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 04 Apr 2016 01:53:10 -0700 (PDT) From: Tomasz Nowicki To: marc.zyngier@arm.com, tglx@linutronix.de, jason@lakedaemon.net, rjw@rjwysocki.net, lorenzo.pieralisi@arm.com, robert.richter@caviumnetworks.com, shijie.huang@arm.com, Suravee.Suthikulpanit@amd.com, hanjun.guo@linaro.org Subject: [PATCH V4 6/7] its, pci, msi: Factor out code that might be reused for ACPI. Date: Mon, 4 Apr 2016 10:52:54 +0200 Message-Id: <1459759975-24097-7-git-send-email-tn@semihalf.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1459759975-24097-1-git-send-email-tn@semihalf.com> References: <1459759975-24097-1-git-send-email-tn@semihalf.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160404_015333_160293_ADB006E8 X-CRM114-Status: GOOD ( 13.45 ) X-Spam-Score: -2.6 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: al.stone@linaro.org, graeme.gregory@linaro.org, Catalin.Marinas@arm.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, okaya@codeaurora.org, linux-acpi@vger.kernel.org, ddaney.cavm@gmail.com, Tomasz Nowicki , mw@semihalf.com, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,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 Firmware agnostic code lands in common functions which do necessary domain initialization based on unique domain handler. DT specific code goes to DT specific init call. Signed-off-by: Tomasz Nowicki --- drivers/irqchip/irq-gic-v3-its-pci-msi.c | 43 +++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3-its-pci-msi.c b/drivers/irqchip/irq-gic-v3-its-pci-msi.c index aee60ed..06165cb 100644 --- a/drivers/irqchip/irq-gic-v3-its-pci-msi.c +++ b/drivers/irqchip/irq-gic-v3-its-pci-msi.c @@ -106,34 +106,47 @@ static struct of_device_id its_device_id[] = { {}, }; -static int __init its_pci_msi_init(void) +static int __init its_pci_msi_init_one(struct fwnode_handle *handle) { - struct device_node *np; struct irq_domain *parent; + parent = irq_find_matching_fwnode(handle, DOMAIN_BUS_NEXUS); + if (!parent || !msi_get_domain_info(parent)) { + pr_err("Unable to locate ITS domain\n"); + return -ENXIO; + } + + if (!pci_msi_create_irq_domain(handle, &its_pci_msi_domain_info, + parent)) { + pr_err("Unable to create PCI domain\n"); + return -ENOMEM; + } + + return 0; +} + +static int __init its_pci_of_msi_init(void) +{ + struct device_node *np; + for (np = of_find_matching_node(NULL, its_device_id); np; np = of_find_matching_node(np, its_device_id)) { if (!of_property_read_bool(np, "msi-controller")) continue; - parent = irq_find_matching_host(np, DOMAIN_BUS_NEXUS); - if (!parent || !msi_get_domain_info(parent)) { - pr_err("%s: unable to locate ITS domain\n", - np->full_name); + if (its_pci_msi_init_one(of_node_to_fwnode(np))) continue; - } - - if (!pci_msi_create_irq_domain(of_node_to_fwnode(np), - &its_pci_msi_domain_info, - parent)) { - pr_err("%s: unable to create PCI domain\n", - np->full_name); - continue; - } pr_info("PCI/MSI: %s domain created\n", np->full_name); } return 0; } + +static int __init its_pci_msi_init(void) +{ + its_pci_of_msi_init(); + return 0; +} + early_initcall(its_pci_msi_init);