From patchwork Tue May 31 11:19:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Nowicki X-Patchwork-Id: 9144397 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 6A13060777 for ; Tue, 31 May 2016 11:22:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5CFAF281B4 for ; Tue, 31 May 2016 11:22:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 515F22820E; Tue, 31 May 2016 11:22:49 +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.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id DC985281B4 for ; Tue, 31 May 2016 11:22:48 +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 1b7hjV-00012y-SD; Tue, 31 May 2016 11:21:13 +0000 Received: from mail-lf0-x22e.google.com ([2a00:1450:4010:c07::22e]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1b7hiq-0000dL-Vz for linux-arm-kernel@lists.infradead.org; Tue, 31 May 2016 11:20:33 +0000 Received: by mail-lf0-x22e.google.com with SMTP id k98so88062701lfi.1 for ; Tue, 31 May 2016 04:20: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=vw2LF7KUw6IBSpMQG4NCsiagbggc7LOi1sRgkCFvUuQ=; b=QIZSnzmgJFUAF5GoyjVZC9vMdQxPNQS+5Fd6GSdb0ic0QZO0oeDp5xVxW9yg4a0tqs 6E63Z5GPbkX+NlnvQwctTdfvqjspESAiqsbWISzlou1AtsnaSB5mhoexQuHG5FtLLhr+ sBsv8Oz8kvfHWba/8sNLqzGYxWU/16+tRCwBsb/mer4+m4cfBM41JHHjL/m5tQlI8qDs /N0s3NuyrzfAdxhm86yHz5jlfW7vsaEa3+zpFoDpHAA6ma5VBu1q9ZV/5P60sgFlAb1O N4mEdBe2BjU7DOV+W3KafXsfgjxmLVnnVSkviDT35hs8IttiDg9Y+WSP45X4CJEeNwNs hbSg== 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=vw2LF7KUw6IBSpMQG4NCsiagbggc7LOi1sRgkCFvUuQ=; b=TKIUoy/lxEAOrRQ6Pycjxs6sf9nUghSe73L8dRKcdGPGAhr8rYVscmp+zzsYFLSbxX tkssRRiVbXGaWhIdHkFtxOwoVgDRNxAEg9yPfmStL0JDJKAW92lBlXEu8Mg1lltcj7p8 bss0tjzdDm8Fn0H4M7J1KXAHsmp9sTGNUN3+rqyve3EIZdIpNWlko285eLOt8jiOAWDM BLpVtJKMmrEecD15bUsyPmc6v0DKLLG0hsm84hpHqAKGKLL3M3sfU+oAQ9meBgv5qtzc W/HI3qqD5GIJpawYYfGzwyzNowC7w128p4bTM2Dq6WBCmnVwYMv0gD8Kw0/qzu4iajAt rmrg== X-Gm-Message-State: ALyK8tIyeD2qP9aHnllX/OIpkUU+yewvrMtf+3eRZC+J91/VQd6Dr3XggrKA61vRC5NOZg== X-Received: by 10.25.78.12 with SMTP id c12mr9522501lfb.174.1464693611027; Tue, 31 May 2016 04:20:11 -0700 (PDT) Received: from tn-HP-4.semihalf.local (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id 66sm5280056lfz.14.2016.05.31.04.20.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 31 May 2016 04:20: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 V5 6/7] its, pci, msi: Factor out code that might be reused for ACPI. Date: Tue, 31 May 2016 13:19:43 +0200 Message-Id: <1464693584-22343-7-git-send-email-tn@semihalf.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1464693584-22343-1-git-send-email-tn@semihalf.com> References: <1464693584-22343-1-git-send-email-tn@semihalf.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160531_042033_276642_2E5F6D54 X-CRM114-Status: GOOD ( 13.59 ) 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, andrea.gallo@linaro.org, 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-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 | 44 +++++++++++++++++++++----------- 1 file changed, 29 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..23679ae 100644 --- a/drivers/irqchip/irq-gic-v3-its-pci-msi.c +++ b/drivers/irqchip/irq-gic-v3-its-pci-msi.c @@ -106,34 +106,48 @@ 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, + const char *name) { - 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("%s: Unable to locate ITS domain\n", name); + return -ENXIO; + } + + if (!pci_msi_create_irq_domain(handle, &its_pci_msi_domain_info, + parent)) { + pr_err("%s: Unable to create PCI domain\n", name); + 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), np->full_name)) 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);