From patchwork Thu Dec 17 11:52:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Nowicki X-Patchwork-Id: 7872611 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B0DCB9F1C2 for ; Thu, 17 Dec 2015 11:58:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1E07920268 for ; Thu, 17 Dec 2015 11:58:18 +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 DEFEC202AE for ; Thu, 17 Dec 2015 11:58:12 +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 1a9XAX-0005Hr-59; Thu, 17 Dec 2015 11:56:25 +0000 Received: from mail-wm0-x22b.google.com ([2a00:1450:400c:c09::22b]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1a9X7D-0001Fv-11 for linux-arm-kernel@lists.infradead.org; Thu, 17 Dec 2015 11:53:07 +0000 Received: by mail-wm0-x22b.google.com with SMTP id l126so19922459wml.1 for ; Thu, 17 Dec 2015 03:52:42 -0800 (PST) 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=KuRCiEdMNQpzU4yG+ewRcpPwqxX+NOGmPC1kaHt2M8o=; b=bPHM6/u6W9CtLf5cDLaxiw1iXc7aXllxoSDf9FDK4UVWxbOrK0UhbwGfVfW1dt0xt7 TBlo34U82CBIjQ8scGOsnsnN8umtYC6fnqmfzK4b0hEjD2j3C55BVZc77UIjCsncchGk PIeqoYJTv3qav9+SM9QY9DxLjEySjN843ZOCR/3P0pv7xhYdGgsiIDSXNmnUKlhvUi7Q dUZVouOt6Mq7HJ1j4EE4730gZKNxOy4DJTOPnVbhVFuRpNovbmDsUdBtK8BeB8GlY6jL Nrxmgem3YjLFhBd7sn8TGc17zaWfFE36BJpw7+/WKhdBKm9w5N8zu1FcXPD0d/j8+T1m Giaw== 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=KuRCiEdMNQpzU4yG+ewRcpPwqxX+NOGmPC1kaHt2M8o=; b=KCd7FTbtJWQAtvI76VKdo878phP+QtX15BZmcDUm7nYOjFTBJg9H7yI8wbj0NBHdx2 QIegRH+Ca2ATMCJqOFaMxid3mDfrfgbckzhOkih8CvVsHB2keV/K/jwPQu2Cu6RxLz9L 4/y5uy/329OtHTMjVjNCSizLzGze74ZFnYukcLW0xStBchSr2ypYxKv+EnSOt+rayHbH Vb2PPPa6IFbJAHVJUSA7qYde3DWB0uQ3XvlZ0rU2i9pPy16XY7txAXyFgq6JeiKMpQbD WhoSvmF0jyAz7ERC3TGcrYeISnf16Hqm/awP4RjX69voOyLR+W9KU58jsMcTF7Y4ClCr f6tQ== X-Gm-Message-State: ALoCoQlTtnKsWRoIKHEuVSwGXARbjtTYwKh93R2xDbxO6lX2OHfy+SG6igPpL7wgRUiR4I8izUfVsAvxf/5UW+0z6e0ylZqT5g== X-Received: by 10.28.68.133 with SMTP id r127mr3622219wma.71.1450353161225; Thu, 17 Dec 2015 03:52:41 -0800 (PST) Received: from tn-HP-4.semihalf.local (cardhu.semihalf.com. [213.17.239.108]) by smtp.gmail.com with ESMTPSA id kb5sm10137208wjc.20.2015.12.17.03.52.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 17 Dec 2015 03:52:40 -0800 (PST) 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, guohanjun@huawei.com, Suravee.Suthikulpanit@amd.com Subject: [PATCH V2 08/10] irqchip, gicv3, its: Probe ITS in the ACPI way. Date: Thu, 17 Dec 2015 12:52:11 +0100 Message-Id: <1450353133-15992-9-git-send-email-tn@semihalf.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1450353133-15992-1-git-send-email-tn@semihalf.com> References: <1450353133-15992-1-git-send-email-tn@semihalf.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151217_035259_550300_DEC643E8 X-CRM114-Status: GOOD ( 16.24 ) 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: graeme.gregory@linaro.org, Catalin.Marinas@arm.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, hanjun.guo@linaro.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=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, 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 Since we prepared ITS for being initialized different that via DT, it is now possible to parse MADT and pass mandatory info to firmware-agnostic ITS init call. Note that we are using here IORT lib to keep track of allocated domain handler which will be used to build PCI MSI domain on top in the later patches. Signed-off-by: Tomasz Nowicki Signed-off-by: Hanjun Guo --- drivers/irqchip/irq-gic-v3-its.c | 56 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index fecb7a6..2adb220 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -15,10 +15,12 @@ * along with this program. If not, see . */ +#include #include #include #include #include +#include #include #include #include @@ -1272,6 +1274,11 @@ static int its_irq_gic_domain_alloc(struct irq_domain *domain, fwspec.param[0] = GIC_IRQ_TYPE_LPI; fwspec.param[1] = hwirq; fwspec.param[2] = IRQ_TYPE_EDGE_RISING; + } else if (is_fwnode_irqchip(domain->parent->fwnode)) { + fwspec.fwnode = domain->parent->fwnode; + fwspec.param_count = 2; + fwspec.param[0] = hwirq; + fwspec.param[1] = IRQ_TYPE_EDGE_RISING; } else { return -EINVAL; } @@ -1594,6 +1601,52 @@ int its_cpu_init(void) return 0; } +#ifdef CONFIG_ACPI + +#define ACPI_GICV3_ITS_MEM_SIZE (2 * SZ_64K) + +static struct irq_domain *its_parent __initdata; + +static int __init +gic_acpi_parse_madt_its(struct acpi_subtable_header *header, + const unsigned long end) +{ + struct acpi_madt_generic_translator *its_entry; + struct fwnode_handle *domain_handle; + int err; + + its_entry = (struct acpi_madt_generic_translator *)header; + domain_handle = irq_domain_alloc_fwnode((void *)its_entry->base_address); + if (!domain_handle) { + pr_err("Unable to allocate GICv2m domain token\n"); + return -ENOMEM; + } + + /* ITS works as msi controller in ACPI case */ + err = its_probe_one(its_entry->base_address, ACPI_GICV3_ITS_MEM_SIZE, + its_parent, true, domain_handle); + if (err) { + irq_domain_free_fwnode(domain_handle); + return err; + } + iort_register_domain_token(its_entry->translation_id, domain_handle); + return 0; +} + +void __init its_acpi_probe(struct irq_domain *parent_domain) +{ + int count; + + its_parent = parent_domain; + count = acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_TRANSLATOR, + gic_acpi_parse_madt_its, 0); + if (count <= 0) + pr_info("No valid GIC ITS entries exist\n"); +} +#else +static inline void __init its_acpi_probe(struct irq_domain *parent_domain) { } +#endif + static struct of_device_id its_device_id[] = { { .compatible = "arm,gic-v3-its", }, {}, @@ -1610,7 +1663,8 @@ int __init its_init(struct fwnode_handle *handle, struct rdists *rdists, np = of_find_matching_node(np, its_device_id)) { its_of_probe(np, parent_domain); } - } + } else + its_acpi_probe(parent_domain); if (list_empty(&its_nodes)) { pr_warn("ITS: No ITS available, not enabling LPIs\n");