From patchwork Thu Oct 15 14:05:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Nowicki X-Patchwork-Id: 7406691 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 323FF9F1D5 for ; Thu, 15 Oct 2015 14:09:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CD413207FD for ; Thu, 15 Oct 2015 14:09:35 +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 AF5192082D for ; Thu, 15 Oct 2015 14:09:31 +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 1ZmjC6-0004uG-LC; Thu, 15 Oct 2015 14:07:46 +0000 Received: from mail-lb0-f175.google.com ([209.85.217.175]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZmjAs-0003Gf-IF for linux-arm-kernel@lists.infradead.org; Thu, 15 Oct 2015 14:06:34 +0000 Received: by lbbwb3 with SMTP id wb3so7823019lbb.1 for ; Thu, 15 Oct 2015 07:06:09 -0700 (PDT) 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=Zou0MLV+7NToMeaqr2HVedqEis3+OcebRgJ/AHYCTis=; b=JExxiv6pY2VNxiYiwAcKGPyqclxxOOZghIInnUcJAMTrD4ojjgkKmXvWZLuAhGwwHF xxm/juQPDV4E6MMVSha8lXUkwoK69xBlAlSi1V0I8LiZreodcTvRGA6HC7EG6Tx1+GHm EeDEKsRZrPBviK1yFIKZ8iqwMrRtjmzDIsC1QEQ/cVNVBk27IBZxodcL7fwQ+yvA7V5H QJEJ1DVCHfyz6PL+ANqcavUVu/s/LZA2TdLHzw1hdimCWCJZlmKLghYaHWxPJsOba4WE e0PRhzznMVP91y+LMvkA0mdCzYOCs5pCgssmXW9tBmW8W+2wNMBg3QTduQBHIbyI+2Q5 HNjw== X-Gm-Message-State: ALoCoQkKgjKhD+C6PmM0/EqUujJPhx5MLb+nO6ApJJKUeuvYu4KsR6HCVyPHp8w2hhVrB6iaJ4v8 X-Received: by 10.112.163.131 with SMTP id yi3mr4638754lbb.36.1444917969002; Thu, 15 Oct 2015 07:06:09 -0700 (PDT) Received: from tn-HP-4.semihalf.local (cardhu.semihalf.com. [213.17.239.108]) by smtp.gmail.com with ESMTPSA id s126sm2105958lfe.3.2015.10.15.07.06.06 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 Oct 2015 07:06:06 -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 Subject: [PATCH V1 08/10] irqchip, gicv3, its: Probe ITS in the ACPI way. Date: Thu, 15 Oct 2015 16:05:17 +0200 Message-Id: <1444917919-21152-9-git-send-email-tn@semihalf.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1444917919-21152-1-git-send-email-tn@semihalf.com> References: <1444917919-21152-1-git-send-email-tn@semihalf.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151015_070630_899745_D07E1420 X-CRM114-Status: GOOD ( 16.88 ) 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: Suravee.Suthikulpanit@amd.com, 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 , 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.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 25926f2..061af36 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 @@ -1248,6 +1250,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; } @@ -1541,6 +1548,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", }, {}, @@ -1557,7 +1610,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");