From patchwork Tue Jan 19 13:11:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Nowicki X-Patchwork-Id: 8061871 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 E1CF2BEEE5 for ; Tue, 19 Jan 2016 13:19:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E2D1F2039C for ; Tue, 19 Jan 2016 13:19:09 +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 F193320138 for ; Tue, 19 Jan 2016 13:19:08 +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 1aLWAQ-00017y-PZ; Tue, 19 Jan 2016 13:17:50 +0000 Received: from mail-wm0-x22a.google.com ([2a00:1450:400c:c09::22a]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aLW4k-0003Go-Rr for linux-arm-kernel@lists.infradead.org; Tue, 19 Jan 2016 13:12:00 +0000 Received: by mail-wm0-x22a.google.com with SMTP id 123so90852546wmz.0 for ; Tue, 19 Jan 2016 05:11:38 -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=ly010A5+oEyOncmGD3M6W5EC2sMX6D6QoMDnoKth5SA=; b=Ye85Mqg6MknSgA4dbKsBtOVDJq8Hh4XiwABrV55CJri4M6GNHMXYUcbCHNAu+QCecj Lph0kDKvtFR7JjQGgwaaDM7y8Qs7843Q0GlZl+PUhEWHOqVzflMdCvuSq1oyNh9wxB65 JnpF3AXcDy6fNSRzPBLfcHNjN3BB4leevjolSnu2mL2MwW6imok6BwoFeELeJeiE2Vby ZF6Wws5QYuLkLwyJXwSpdtrcmAdwNAJxE6bemZS6AwaNoHuiB+OQ18cKgmiW4gxcU/E/ e+0T/zF0NdmKEffzxunlDbNiwEfupao2VFNJRyS6B/RnrVNgU9w7EIQRZ2RCQK6484b7 Ypzg== 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=ly010A5+oEyOncmGD3M6W5EC2sMX6D6QoMDnoKth5SA=; b=Sy1ei7UF+SbCGmLyuCsFfu7DI42sAx8M3K8x2WmccMZhtSiL5znGEojsV0UuEBr+L3 44vmkneIGer46P47sw7igF3jTm6tHbRl+AsoJBg6fp0TkLwmaqmit9nuO98Xtg0Re2wb hGOfeRGiuN2lbilqZ71gpYKeUFwXUCjlvpmi8T3CMdgh5Ornfsttz6VBdElgsIcW2bWI NLzbmfomi69jgYJZHDXdVOSBP6NcFTwP4I0UKXVuvUNPt2Qpj13T1KDU2/nNJM+pWVuA EEFJ8gHLEZAn9eJZ+EFRa3W+75ro8gZzgYNk9lK0ir63zh+2z8Brn8zw5POb8PZevcev fAFA== X-Gm-Message-State: ALoCoQnG0M8Qv6JRa/pVaBYJoXVt7P+LRsM7ebeEt6ZTJ4hbExmt+PtSvCa7GFYAITcQ9LZmgefl1mGThNU2MxjigM2e/8/Vbw== X-Received: by 10.194.103.198 with SMTP id fy6mr35347080wjb.48.1453209097322; Tue, 19 Jan 2016 05:11:37 -0800 (PST) Received: from tn-HP-4.semihalf.local ([80.82.22.190]) by smtp.gmail.com with ESMTPSA id w194sm17762623wmd.0.2016.01.19.05.11.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 19 Jan 2016 05:11:36 -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 V3 08/10] irqchip, gicv3, its: Probe ITS in the ACPI way. Date: Tue, 19 Jan 2016 14:11:21 +0100 Message-Id: <1453209083-3358-9-git-send-email-tn@semihalf.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1453209083-3358-1-git-send-email-tn@semihalf.com> References: <1453209083-3358-1-git-send-email-tn@semihalf.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160119_051159_215508_0BD997CF X-CRM114-Status: GOOD ( 16.36 ) 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,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 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 | 57 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index fecb7a6..42f378a 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -15,10 +15,13 @@ * along with this program. If not, see . */ +#include #include #include #include #include +#include +#include #include #include #include @@ -1272,6 +1275,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 +1602,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 +1664,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");