From patchwork Mon Apr 4 08:52:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Nowicki X-Patchwork-Id: 8738931 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 BCB2A9F39A for ; Mon, 4 Apr 2016 08:55:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D0EB42022D for ; Mon, 4 Apr 2016 08:55: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 DC6562021F for ; Mon, 4 Apr 2016 08:55: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 1an0Gz-0000Wb-Dd; Mon, 04 Apr 2016 08:54:13 +0000 Received: from mail-lf0-x230.google.com ([2a00:1450:4010:c07::230]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1an0GJ-0008V0-TB for linux-arm-kernel@lists.infradead.org; Mon, 04 Apr 2016 08:53:33 +0000 Received: by mail-lf0-x230.google.com with SMTP id c62so159105315lfc.1 for ; Mon, 04 Apr 2016 01:53:10 -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=n4gwIQhWgui72Y0lgCMOftn2Es70dB73kY6sREHJ60A=; b=vCyx76/rmm2PTe5bzoOueGQnVBqbhBUEDQz1pPdtmsm1uwOFiJBy80fG/49iiWQNlC KTDL44nLNh0pCTgoBXhaS1MkG8lkl8QoQlFfdUs9Wh4lHv7KK4pZNoNFMHae4atvPGAn FFxlBKJS11hUY+60SUE3SuGgmHGKjS9m5IsVzLs2+6hCYHSoujEz9rnj1YaDzUNV6ADP nl7zSp8FPf7/fm2sXZ+G33XAZnufQzccs0zCOfYsBr2QSnz6zFuReDBeiivu6/WEvy8l lSm9ACfUtAhc/vlmGkoOHDyPfWzSARn9N2w8zU0U8jOZJQbGVNTwhHHLSCFoExY9nz+V N/KA== 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=n4gwIQhWgui72Y0lgCMOftn2Es70dB73kY6sREHJ60A=; b=Wmkcx6PltLZNp+UyLjVeYxqlw/2gqrx6GPSKpDSNABxy4vhhgw0MuZcDoGERJ0Xbxq nf9R08ESJECihrtKLEOG6o/OMmUGjp5bgwVXl57HGMePfVfA9s3rn6Gl7nW+/GPVNFcj RlTkMiqBzw6vlFElOWwwYd2ffYb+QKBH+HDdUDsQ52IDKyzJ6tZKHemJCWUwEGfndRls HWUz46hR/q746Nef0fBxAmV4jdQ2LMI8P6bXqg2L7x5lFQdIq1aQgemmurOBT841sVfs /p/UrdTe7pGY6GlAdbt8cGIIdk53kYv0bODwQ02Zyi//r+Ts/pOz80opJJ8ayHb/rwAa BaXA== X-Gm-Message-State: AD7BkJJ0xrhdw/1dfPhEF1hTPLKQlcNxQoVxWsKwYKwrNG+umsEZT4Cq4eNLGoEnqiiKeA== X-Received: by 10.194.110.225 with SMTP id id1mr16877553wjb.45.1459759989191; Mon, 04 Apr 2016 01:53:09 -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.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 04 Apr 2016 01:53:08 -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 5/7] irqchip, gicv3, its: Probe ITS in the ACPI way. Date: Mon, 4 Apr 2016 10:52:53 +0200 Message-Id: <1459759975-24097-6-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_015332_289466_CDF1FE69 X-CRM114-Status: GOOD ( 14.02 ) 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 ITS is prepared for being initialized different than DT, therefore we can initialize it in ACPI way. We collect register base address from MADT table and pass mandatory info to firmware-agnostic ITS init call. Note that we are using here IORT lib to register ITS domain which then can be found and used to build another PCI MSI domain in hierarchical stack domain. Signed-off-by: Tomasz Nowicki --- drivers/irqchip/irq-gic-v3-its.c | 61 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 2dcc7b4..a277c9b 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 @@ -1277,6 +1280,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; } @@ -1617,6 +1625,57 @@ its_of_probe(struct device_node *node, struct irq_domain *parent) 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 GICv3 ITS domain token\n"); + return -ENOMEM; + } + + err = iort_register_domain_token(its_entry->translation_id, domain_handle); + if (err) { + irq_domain_free_fwnode(domain_handle); + goto out; + } + + err = its_probe_one(its_entry->base_address, ACPI_GICV3_ITS_MEM_SIZE, + its_parent, domain_handle); + if (err) { + iort_deregister_domain_token(its_entry->translation_id); + irq_domain_free_fwnode(domain_handle); + } +out: + return err; +} + +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 + int __init its_init(struct fwnode_handle *handle, struct rdists *rdists, struct irq_domain *parent_domain) { @@ -1625,6 +1684,8 @@ int __init its_init(struct fwnode_handle *handle, struct rdists *rdists, of_node = to_of_node(handle); if (of_node) its_of_probe(of_node, parent_domain); + else + its_acpi_probe(parent_domain); if (list_empty(&its_nodes)) { pr_warn("ITS: No ITS available, not enabling LPIs\n");