From patchwork Tue Dec 8 20:19:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suravee Suthikulpanit X-Patchwork-Id: 7802231 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 5A8F8BEEE1 for ; Tue, 8 Dec 2015 20:22:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6C3A120398 for ; Tue, 8 Dec 2015 20:22:43 +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 A0DC02040F for ; Tue, 8 Dec 2015 20:22:37 +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 1a6Okh-0003SO-47; Tue, 08 Dec 2015 20:20:47 +0000 Received: from mail-by2on0077.outbound.protection.outlook.com ([207.46.100.77] helo=na01-by2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1a6Ojk-0001kr-3Q for linux-arm-kernel@lists.infradead.org; Tue, 08 Dec 2015 20:19:50 +0000 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Suravee.Suthikulpanit@amd.com; Received: from ssuthiku-fedora-lt.amd.com (165.204.77.1) by CY1PR12MB0443.namprd12.prod.outlook.com (10.163.91.21) with Microsoft SMTP Server (TLS) id 15.1.337.19; Tue, 8 Dec 2015 20:19:26 +0000 From: Suravee Suthikulpanit To: , , , Subject: [PATCH v4 5/5] gicv2m: acpi: Introducing GICv2m ACPI support Date: Tue, 8 Dec 2015 12:19:05 -0800 Message-ID: <1449605945-10707-6-git-send-email-Suravee.Suthikulpanit@amd.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1449605945-10707-1-git-send-email-Suravee.Suthikulpanit@amd.com> References: <1449605945-10707-1-git-send-email-Suravee.Suthikulpanit@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: BLUPR01CA061.prod.exchangelabs.com (25.160.23.51) To CY1PR12MB0443.namprd12.prod.outlook.com (25.163.91.21) X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0443; 2:7PowcVtCzEpI1Xr0jTAzNrM1SBTzI6PQr9zxBLFwnPqoNuEk35imwOCLW3pvpJspCZqu34dTuyAQ5dWBGk7xlpVT0Urm9aJsr52kc8i9tyaYdT1dvEpcwWtA1ARCTqgWe0cIJZ+t1SY5Jz7PqTgyUg==; 3:vIDdHdZk1h06dQNTnFmkWjAuuXLDGdUqkwyXeP5N16fE7Q0Ozv12+JUBwfCSV3JLqZ2zaVmRS+BnDsddOlCiV8I8yyV9rcskKDIguKILMZhmpMa5I56kXQ+D63hKKJ1j; 25:blb4WMupg5FinRzsu7W/aN0pSS+ccodsJ+U4Fuw2wMV+JlBKrgmrdsm0npO+sIwV/4dcH+INRH6CFpqzVjldNfSxNyvMs8GBTNRVNmCL2LGYfYVS6Z3pXy5B1dzgoC4pHNQW7KpD0qSApmmkVgROqYqqzBHjtCPaVEarWJedqCkKHCpw+tgx/JysQqtnogYldDKw59fYTSwXulLbfhJbyDj9ab8UJL/sLQAVa+K3hveMYKOMKf1klQYiQnUzgpaskxkeOjAjcME//3ldhDDHgA== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR12MB0443; X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0443; 20:21qyl4Kfxo9YTDth4UzQbNRVPFRU+gbrcNHwFTmRMJm84KdheYowxogQsvfnaXg2Yqua9t0bsO85EBUZoL5EwZa7ijJrD5jQ/djy27fHfgp0KV15qxgz608G/6rMiB/0c+uBd4mdz9frQUzDotLwpGNPNvRhtrSV3Ok3oaTkhq2nri17Vxs7RRctu2drbMbjXTlLOcYtN2H/ibTEPUjNi5mS1nmtMPBGEmCZLT3PbCbGunaS7d9JCQ8c+JMd8OV+OkjqPiywAIHo6rxM9LpM8BYt+efriUubMwT89gQcPfu6+GbmnI+9ptlktZWK2d1IYNK1EYGB+/t2QEZ91nk9F2TQlQGtUcQ41PjncgQkz3Hm5hn4UAisqy6oXDnKpuwCCojh9sv/RM9bw6AUfCedAsqmlg7fHKJ4VgXfA88nnU6r62QKoIbPyX/ut+E0myAUzpsHG43fKF6zODhurP9IeEBubS6jK0bYFeA5AyOmSn2OyeIEPluno1QrvDqWCj1C; 4:RgcONn0yVwdOYW4+SD/4MU7t0LxQ55pH8SVP8wrzONjSsmYPKBMQ/zQjxt+387zy4NSdgmtf1Aol7Ece1DH1RK928pB6Roa4FTcDqn3B0XR4Xw5Vk6ypfwwidJMgnntwd5gaqoinQl2+vOucWB9iEAoBUMc/7Q1EcRAhueWbEF5Rr9yfUME2xvavCT0zk6iCeDuF2QelhEtVdk5B+xvgnA99QsR3ubDpNGHzsqUP73TucDdQTKiea6lHgsnT5/NIMLJ7kcvsVbgvhFFYKqwfwcrty3WmVdonYWqpyjgKqcKnUn2IKdNn25fZes927RNqkbhkwtmeePGpuleDxP1T6KdrX7hlblskVNzndOKXGAFrAW1PCFJcjmQ8Vf2WKU6CV41+9oYV8sBF7JfXkNPAGjVUeQG7/0a9Ac9un9JZZc8= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(520078)(3002001)(10201501046); SRVR:CY1PR12MB0443; BCL:0; PCL:0; RULEID:; SRVR:CY1PR12MB0443; X-Forefront-PRVS: 0784C803FD X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(189002)(199003)(76176999)(3846002)(6116002)(87976001)(5003940100001)(5008740100001)(48376002)(122386002)(189998001)(77096005)(2950100001)(586003)(5004730100002)(105586002)(229853001)(1096002)(5001770100001)(106356001)(19580405001)(53416004)(36756003)(42186005)(50986999)(50226001)(19580395003)(2201001)(97736004)(86362001)(47776003)(40100003)(50466002)(66066001)(101416001)(92566002); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR12MB0443; H:ssuthiku-fedora-lt.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR12MB0443; 23:AM6z7mrxANNBEHuf1Nbdb+Irm6Nimhc2XxpY4rt3M?= =?us-ascii?Q?ETDXsOBAeYVZuqRGNNnXyc633ukYk+zk0sH/gDXfncICxHMagpRuwmU0Nk9G?= =?us-ascii?Q?zZ12j1QZId1ogm6yUmPjxr4jcdUpnOZmvy8te+Vvohqk7zHQDAH6AT314jRD?= =?us-ascii?Q?JOXhh2K8yg23EX3jeVWZVqEjiUAI1ZQ1Rhw5QhbJIbj9Pv9gCd9Zu8uyFDqQ?= =?us-ascii?Q?1w/iv82DV6qkPwO8ipHgvFmhfQEMA7kCJ2Zb9GAo/cXvETV46HTmMN0D6gu/?= =?us-ascii?Q?TYfC6fTg299SImghStB4T8gfKsSE7XfveiRxGNJTLdKHeIynHnwyS1q2Vw8Z?= =?us-ascii?Q?mHnh8Vqzc9NaVtgi2MVymubsDUX0oRivAO1UAq0OWDgMcbWLk/DzzqkXPr1S?= =?us-ascii?Q?HpHLAS7JB1tLkDhTp3GZKjjoRW2lOzUxITqjA+o4cF7an7bxunuJ9PjJeNqF?= =?us-ascii?Q?vZWuspJJp2O6cd7lJPNKKFCU+4e1EMZnZhVHiiZYrTNMz63ZAMVXLt/4VIfl?= =?us-ascii?Q?Ru30FTTSejUp7yihCPHDXo17/9+pTY9UHe8TP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MGiGXuhoRVM5KlhO9UovRzdIHi7oNlbOGFt X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2015 20:19:26.9979 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR12MB0443 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151208_121948_269544_81D0CC30 X-CRM114-Status: GOOD ( 12.85 ) X-Spam-Score: -1.9 (-) 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: Lorenzo Pieralisi , graeme.gregory@linaro.org, Catalin Marinas , dhdang@apm.com, Will Deacon , linux-kernel@vger.kernel.org, tomasz.nowicki@linaro.org, linux-acpi@vger.kernel.org, hanjun.guo@linaro.org, Suravee Suthikulpanit , linux-arm-kernel@lists.infradead.org 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=BAD_ENC_HEADER,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 This patch introduces gicv2m_acpi_init(), which uses information in MADT GIC MSI frames structure to initialize GICv2m driver. Signed-off-by: Suravee Suthikulpanit Signed-off-by: Hanjun Guo --- drivers/irqchip/irq-gic-v2m.c | 95 +++++++++++++++++++++++++++++++++++++++++ drivers/irqchip/irq-gic.c | 3 ++ include/linux/irqchip/arm-gic.h | 4 ++ 3 files changed, 102 insertions(+) diff --git a/drivers/irqchip/irq-gic-v2m.c b/drivers/irqchip/irq-gic-v2m.c index 7e60f7e..4f52e9a 100644 --- a/drivers/irqchip/irq-gic-v2m.c +++ b/drivers/irqchip/irq-gic-v2m.c @@ -15,9 +15,11 @@ #define pr_fmt(fmt) "GICv2m: " fmt +#include #include #include #include +#include #include #include #include @@ -138,6 +140,11 @@ static int gicv2m_irq_gic_domain_alloc(struct irq_domain *domain, fwspec.param[0] = 0; fwspec.param[1] = hwirq - 32; 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; } @@ -255,6 +262,8 @@ static void gicv2m_teardown(void) kfree(v2m->bm); iounmap(v2m->base); of_node_put(to_of_node(v2m->fwnode)); + if (is_fwnode_irqchip(v2m->fwnode)) + irq_domain_free_fwnode(v2m->fwnode); kfree(v2m); } } @@ -359,6 +368,8 @@ static int __init gicv2m_init_one(struct fwnode_handle *fwnode, if (to_of_node(fwnode)) name = to_of_node(fwnode)->name; + else + name = irq_domain_get_irqchip_fwnode_name(fwnode); pr_info("Frame %s: range[%#lx:%#lx], SPI[%d:%d]\n", name, (unsigned long)res->start, (unsigned long)res->end, @@ -415,3 +426,87 @@ int __init gicv2m_of_init(struct device_node *node, struct irq_domain *parent) gicv2m_teardown(); return ret; } + +#ifdef CONFIG_ACPI +static int acpi_num_msi; + +static struct fwnode_handle *gicv2m_get_fwnode(struct device *dev) +{ + struct v2m_data *data; + + if (WARN_ON(acpi_num_msi <= 0)) + return NULL; + + /* We only return the fwnode of the first MSI frame. */ + data = list_first_entry_or_null(&v2m_nodes, struct v2m_data, entry); + if (!data) + return NULL; + + return data->fwnode; +} + +static int __init +acpi_parse_madt_msi(struct acpi_subtable_header *header, + const unsigned long end) +{ + int ret; + struct resource res; + u32 spi_start = 0, nr_spis = 0; + struct acpi_madt_generic_msi_frame *m; + struct fwnode_handle *fwnode = NULL; + + m = (struct acpi_madt_generic_msi_frame *)header; + if (BAD_MADT_ENTRY(m, end)) + return -EINVAL; + + res.start = m->base_address; + res.end = m->base_address + 0x1000; + + if (m->flags & ACPI_MADT_OVERRIDE_SPI_VALUES) { + spi_start = m->spi_base; + nr_spis = m->spi_count; + + pr_info("ACPI overriding V2M MSI_TYPER (base:%u, num:%u)\n", + spi_start, nr_spis); + } + + fwnode = irq_domain_alloc_fwnode((void *)m->base_address); + if (!fwnode) { + pr_err("Unable to allocate GICv2m domain token\n"); + return -EINVAL; + } + + ret = gicv2m_init_one(fwnode, spi_start, nr_spis, &res); + if (ret) + irq_domain_free_fwnode(fwnode); + + return ret; +} + +int __init gicv2m_acpi_init(struct irq_domain *parent) +{ + int ret; + + if (acpi_num_msi > 0) + return 0; + + acpi_num_msi = acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_MSI_FRAME, + acpi_parse_madt_msi, 0); + + if (acpi_num_msi <= 0) + goto err_out; + + ret = gicv2m_allocate_domains(parent); + if (ret) + goto err_out; + + pci_msi_register_fwnode_provider(&gicv2m_get_fwnode); + + return 0; + +err_out: + gicv2m_teardown(); + return -EINVAL; +} + +#endif /* CONFIG_ACPI */ diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c index fcd327f..e4463f7 100644 --- a/drivers/irqchip/irq-gic.c +++ b/drivers/irqchip/irq-gic.c @@ -1358,6 +1358,9 @@ static int __init gic_v2_acpi_init(struct acpi_subtable_header *header, __gic_init_bases(0, -1, dist_base, cpu_base, 0, domain_handle); + if (IS_ENABLED(CONFIG_ARM_GIC_V2M)) + gicv2m_acpi_init(gic_data[0].domain); + acpi_set_irq_model(ACPI_IRQ_MODEL_GIC, domain_handle); return 0; } diff --git a/include/linux/irqchip/arm-gic.h b/include/linux/irqchip/arm-gic.h index bae69e5..30b2ccb 100644 --- a/include/linux/irqchip/arm-gic.h +++ b/include/linux/irqchip/arm-gic.h @@ -108,6 +108,10 @@ void gic_init(unsigned int nr, int start, int gicv2m_of_init(struct device_node *node, struct irq_domain *parent); +#ifdef CONFIG_ACPI +int gicv2m_acpi_init(struct irq_domain *parent); +#endif + void gic_send_sgi(unsigned int cpu_id, unsigned int irq); int gic_get_cpu_id(unsigned int cpu); void gic_migrate_target(unsigned int new_cpu_id);