From patchwork Wed Oct 14 23:25:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suravee Suthikulpanit X-Patchwork-Id: 7399231 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 E298E9F443 for ; Wed, 14 Oct 2015 23:28:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E4733209D6 for ; Wed, 14 Oct 2015 23:28:38 +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 D9683209D4 for ; Wed, 14 Oct 2015 23:28: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 1ZmVRr-0006iu-Sw; Wed, 14 Oct 2015 23:27:07 +0000 Received: from mail-bl2on0088.outbound.protection.outlook.com ([65.55.169.88] helo=na01-bl2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZmVRP-0005xf-ID for linux-arm-kernel@lists.infradead.org; Wed, 14 Oct 2015 23:26:41 +0000 Received: from CY1PR1201CA0028.namprd12.prod.outlook.com (10.169.17.166) by BY2PR1201MB1080.namprd12.prod.outlook.com (10.164.168.12) with Microsoft SMTP Server (TLS) id 15.1.293.16; Wed, 14 Oct 2015 23:26:16 +0000 Received: from BY2NAM03FT008.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e4a::204) by CY1PR1201CA0028.outlook.office365.com (2a01:111:e400:5b9a::38) with Microsoft SMTP Server (TLS) id 15.1.300.14 via Frontend Transport; Wed, 14 Oct 2015 23:26:16 +0000 Authentication-Results: spf=none (sender IP is 165.204.84.222) smtp.mailfrom=amd.com; apm.com; dkim=none (message not signed) header.d=none; apm.com; dmarc=permerror action=none header.from=amd.com; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from atltwp02.amd.com (165.204.84.222) by BY2NAM03FT008.mail.protection.outlook.com (10.152.84.101) with Microsoft SMTP Server id 15.1.300.4 via Frontend Transport; Wed, 14 Oct 2015 23:26:15 +0000 X-WSS-ID: 0NW8H3H-08-IVO-02 X-M-MSG: Received: from satlvexedge01.amd.com (satlvexedge01.amd.com [10.177.96.28]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by atltwp02.amd.com (Axway MailGate 5.3.1) with ESMTPS id 2AD25BD88D4; Wed, 14 Oct 2015 19:26:05 -0400 (EDT) Received: from SATLEXDAG02.amd.com (10.181.40.5) by satlvexedge01.amd.com (10.177.96.28) with Microsoft SMTP Server (TLS) id 14.3.195.1; Wed, 14 Oct 2015 18:26:12 -0500 Received: from ssuthiku-fedora-lt.amd.com (10.180.168.240) by SATLEXDAG02.amd.com (10.181.40.5) with Microsoft SMTP Server id 14.3.266.1; Wed, 14 Oct 2015 19:26:08 -0400 From: Suravee Suthikulpanit To: , , , Subject: [PATCH V2 6/6] gicv2m: acpi: Introducing GICv2m ACPI support Date: Wed, 14 Oct 2015 16:25:56 -0700 Message-ID: <1444865156-9870-7-git-send-email-Suravee.Suthikulpanit@amd.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1444865156-9870-1-git-send-email-Suravee.Suthikulpanit@amd.com> References: <1444865156-9870-1-git-send-email-Suravee.Suthikulpanit@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:165.204.84.222; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(428002)(199003)(189002)(2201001)(19580405001)(5003940100001)(50466002)(106466001)(77096005)(97736004)(5001770100001)(48376002)(101416001)(189998001)(87936001)(86362001)(5007970100001)(11100500001)(19580395003)(5008740100001)(105586002)(50986999)(46102003)(5003600100002)(76176999)(2950100001)(229853001)(92566002)(53416004)(64706001)(36756003)(50226001)(47776003); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR1201MB1080; H:atltwp02.amd.com; FPR:; SPF:None; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2PR1201MB1080; 2:Hpwz3LO8ktLN9hkv3H+x6ud0k/eyiKQ/UgsZBC85ejvHi0qhiR/cB1ZqnRSyeAo7tYVXCPmllpZmEs4eBNr3cO6ACp77Ygb8D8VX7ceQJ20zFSuEoYqMFYnErHQAbQOr7AcJ3rk9SB3/GuUTQfVtSngmwqd6VJijmHVJK2NN7vA=; 3:OgQQ9wMZHDHGS4xdC1tlKMCs5CQNS3GX1P9blHskXQWc2eG3EuQ5HL04IRRrJTeTQQ2+O/tJs3rYLoIkrjNprrkEOLwzKuoOpS9RvVRjEqIQEt8pNkIP9QM94gzmh809ZRBsqNZtbXmBm3XxOwhx8wfJ3cGcy63tNUaeWGc4UGaUSq3DMLk3zzjNDh9clp1VH0NqRUQwECxLffTZB0BBtuHuC8beTiDVW9GhodTvzebPoi0wRNq85Hz0DKCuk0ev; 25:LIKGgxMSmtYPhmL4G1YaIQLoZl9H2LPdd8264SrSq7C5DOUg4q0OrebIsfIVldsVeZ0z3PrSt6qOLPX3MhsC2dONu1f/DV+OUtW06gsbSaxilr+6zB+EgcIY3Du3gnbsYJfIB0jrzNixLb/2N9gyeaaG58q6ibbEF0iV0Clf4JC+pBn1dD4ihlzSfHT07O4af64trhtsAvL4KZ5kMPjRFc4jgR+9KCFskfMsV7/aEtNDmppU9RV4TnP8DPysSxEv1gAAYb+EFpFEVhj9/4qDgw== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR1201MB1080; X-Microsoft-Exchange-Diagnostics: 1; BY2PR1201MB1080; 20:hfWFtO8uUCbpkJOMXPtiJP9j52RwdssfiwROOwx21cg9rhXeUqyqLhGz1f8uLNyDRZ4DXYAHic4hCNVp33SGTtvFilt2HIUpjTQdu/uy0dTec214lDSVOLr7ea9/0lW0wEWguyUNwhctj9eUpzui1yrPjTDoAnoggjJS/NV7vWXUPpZNZcIxU+MvCKPfbKXbGezpAGfjQp2D6TecoyiB6Jq1F54eXY2LVNVjFE7Yvq9XgQjdBnsyVMoctXQnsIBdLEPAEr8yOtO5YXM17YTTH1K1yzxVkzgH8Q747tQl/VutHdZPIN7nvDus4iW4QEAhpzD9iijlNl+osDhnZ82CzXdXBAmgdZTrS9gacUNEOQOORl2gfPbycibCVZLNq2eG2wK5jSkTDpaIZBQFjQQ9IjNBRfO/yVczb9DgxHLP8IiqzWWQtV4bQr+um9Xp2MkrkE7Pd77Qp35ogxbh9c8g+ZWbqM/wK6/OG+R1EFbGVfEoZHGD251uGtzWwqX79azp; 4:1obAh0ymR+OTYrMsa8HfzCM6SVnAXmbmpg3PNYNYermkUuXmvmykTPi+ebtsXTyZPG01nnzuSgWiU1IbGUEYkPkPRdf5VINDz7Xxo5HEtvewFG0Ox+FQ8iO62w6s41mSaKDeQAByIYNyPSy2rAW5XqhQDezG1sWeUQSN3K+c55kY5jSvc1sFW2Xv+/r1nAFgDfN8g8YlgKX/5bwEbNkje+cHGIZz56evmEzJ5SnvYrDobU1sf3Y6+5s5MwUscg3tJHM3zQ6bE2+ENd+0KhG/37ZyrEemGN82njUQ5SWo1H+dXIniGN9zgjYHocz6+iZjaKO918i3ck1qlSVaV+HYplDdfhNUWhfoYZwcZRA0gd0= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(520078)(3002001); SRVR:BY2PR1201MB1080; BCL:0; PCL:0; RULEID:; SRVR:BY2PR1201MB1080; X-Forefront-PRVS: 0729050452 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY2PR1201MB1080; 23:LN1d3jkGzPWrz6hqu4aLjHHpv03uZrANDN6Dx9J?= =?us-ascii?Q?eDsZkYnDlFutXqtCpfn2Aubr3RncW82039UfVyoTJCJlW+P1eaXIi+iyCS/X?= =?us-ascii?Q?b6G5g0Mwd2ypY/7t5eyU1a0DTDmnC4kwFEVuaTyIQeRS35QZ/5TxzyogZDBF?= =?us-ascii?Q?XYeXk92lLoij66f15Yig4gLnMcp7yAJv4XSnpv96he5hl2EYYD32vcrFVKS7?= =?us-ascii?Q?fSrI2oA+jI2c0qJzgRGPsyfVLc6pIWNZYyGphdy3RcQXc0y/gX0bhkvLfwFx?= =?us-ascii?Q?kLtTT49w66KN+zTcdyy8sGtGBr1z0hJcFWEmVdIXpSkYqHJW+TGejX2EDs8B?= =?us-ascii?Q?CAlux33ul+KR4SFEJNycCsY8eSMQM/sc+9d0dQCDpNoMJUnPVvovCZglHJaG?= =?us-ascii?Q?gPBLbpi5EhEGGGOODNKHUtn6Dm5PB7i9eUxMBQOExYhfOq501LcDK8dL/xnt?= =?us-ascii?Q?MZ4pQNiB4004DXTIuVa8iFtcg9mdgYSMq4kQ0yuCzim86Fg25Cda8LCQrr5z?= =?us-ascii?Q?kSFUQ/DaLhLQlg8/lutgQLmsCF2EJuI1wbbiHy603CSkBJ1yav72q8kLxgut?= =?us-ascii?Q?H9zAmhCnuibgdXTQrKKQF9MSqR0cCgbV6WIhVMXJLSQBm/SXuI2WRVrKlzBD?= =?us-ascii?Q?SevBWUGWpio5ZQrx7lRCPBVY/Hi6LbSnzOjV0gByos5+qLjV1xp3f/H0j4HR?= =?us-ascii?Q?SPmIDSJ1QzPdCJ5c34RHOvWHToX+0So31lKG0DWjgybRN7xp60DUHSIdvoQI?= =?us-ascii?Q?uwYLuNUaSZn4czM0pGIJi4VWMNZFEw8EwxCXiPIYDUMzwujTSxXycCtEv06q?= =?us-ascii?Q?+RSCRlqDeXQlKL04NSvTDffm9y5wXveHhcg57F/Dw44natgXKBvmwjGghqX3?= =?us-ascii?Q?p/zpB9qo7OjNF12cX5HI5+XvPq0Dpa0WObEVnk+W2fsVjIl8Xom1IeuuKbGG?= =?us-ascii?Q?89MXWeY9pv+LWLu7EHb1IuahKFN8s0GVY6zXulMA3D5R7UwsSiOORqQfzF7B?= =?us-ascii?Q?tS/I=3D?= X-Microsoft-Exchange-Diagnostics: 1; BY2PR1201MB1080; 5:8183bL07gCLJzxEElx7K5pfJUAjdgkvbF0RTaGoQEWGwIxR8kB5nhZ1E05ll63898GNOcqPj0iAijh+CevFNuXCSGuQA2GzIvU7XI3o0eKY1KUF1eovuvV23Bug8N1kR28m8FlcHUUM22g3DXAWcdA==; 24:Att42PCOBpxNQIi4sdyWkxCYAKKmt5Z7Gt5Kw7MQkFO3Z34ifii2vPbR6B0uDdnM40nLUha/o/jusNTvBFMpDpGVqXgpZdvMejFx9ukpXKE=; 20:Qz0o7EBk6bIDnc6lH7dXYa4HJunkaqY1JXKrX3aZq41YSFqHoyvgn5u/AosabKQrMT8/oIr6D6Vvhfzq1RAsz9Fepn/lVSQz4IfowAu64oMm9jMthV47Lg5H9WYkFe0gSEjBWiR/vkmcrSeJPs2sIfX6BuNUTL0vj6R2azPS7+ACnXThs/Kneki78xHig0Xr90iwmuJ9Hyw6FnSNJv8p6PX1qKSX/TDAol2LZxV+FiUWin4Ivw7Vq32o0xP7if97 SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Oct 2015 23:26:15.0099 (UTC) X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.222]; Helo=[atltwp02.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR1201MB1080 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151014_162639_951010_ED0383E0 X-CRM114-Status: GOOD ( 15.99 ) 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 | 94 +++++++++++++++++++++++++++++++++++++++++ drivers/irqchip/irq-gic.c | 3 ++ include/linux/irqchip/arm-gic.h | 6 +++ 3 files changed, 103 insertions(+) diff --git a/drivers/irqchip/irq-gic-v2m.c b/drivers/irqchip/irq-gic-v2m.c index 7e60f7e..290f5b3 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 & IRQ_TYPE_SENSE_MASK; } 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,86 @@ 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); + + 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 6685b33..bb3e1f2 100644 --- a/drivers/irqchip/irq-gic.c +++ b/drivers/irqchip/irq-gic.c @@ -1329,6 +1329,9 @@ gic_v2_acpi_init(struct acpi_table_header *table) __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..7398538 100644 --- a/include/linux/irqchip/arm-gic.h +++ b/include/linux/irqchip/arm-gic.h @@ -108,6 +108,12 @@ void gic_init(unsigned int nr, int start, int gicv2m_of_init(struct device_node *node, struct irq_domain *parent); +#ifdef CONFIG_ACPI +#include + +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);