From patchwork Thu Dec 10 16:55:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suravee Suthikulpanit X-Patchwork-Id: 7820041 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 4141FBEEE1 for ; Thu, 10 Dec 2015 16:59:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 350B22041F for ; Thu, 10 Dec 2015 16:59:17 +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 8B496205C4 for ; Thu, 10 Dec 2015 16:59:15 +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 1a74XG-0004S3-EH; Thu, 10 Dec 2015 16:57:42 +0000 Received: from mail-bn1bon0072.outbound.protection.outlook.com ([157.56.111.72] helo=na01-bn1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1a74W3-00033C-Mp for linux-arm-kernel@lists.infradead.org; Thu, 10 Dec 2015 16:56:34 +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 BLUPR12MB0433.namprd12.prod.outlook.com (10.162.92.139) with Microsoft SMTP Server (TLS) id 15.1.355.16; Thu, 10 Dec 2015 16:55:58 +0000 From: Suravee Suthikulpanit To: , , , , Subject: [PATCH v7 4/4] gicv2m: acpi: Introducing GICv2m ACPI support Date: Thu, 10 Dec 2015 08:55:30 -0800 Message-ID: <1449766530-16935-5-git-send-email-Suravee.Suthikulpanit@amd.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1449766530-16935-1-git-send-email-Suravee.Suthikulpanit@amd.com> References: <1449766530-16935-1-git-send-email-Suravee.Suthikulpanit@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: CY1PR14CA0031.namprd14.prod.outlook.com (25.163.13.169) To BLUPR12MB0433.namprd12.prod.outlook.com (25.162.92.139) X-Microsoft-Exchange-Diagnostics: 1; BLUPR12MB0433; 2:0aRGxddvKGFtmYRoEgzVDj9EUbHPRLhwstsM9lGxDfalciGv9b50OLd5IErV5P2v9A49y39lS15clSMrhcB4J0n484L5ygywOajFBuMaSzfMRscnRUvEO5qw2IPU0cX/LrvWT8XonOPxxjVQntsUkA==; 3:fNpnrORRZGB8mmQMpamytHj7uixb4t9lW3eLlyQ0p9odNP+6dxUgADhAe+btxb//CdBtM/M9ZdkgV+h9c41vpsejVqGTAjadm+ag4R7JSTfQNV3zanAuNGdxunghBMc2; 25:LZNGvtqENR1SxJtVCcq7CLnkhksGcuYwNLyIHAYII+iJqr2nexpQzpKC3uM0hLWcO0h53csfwlP0nCazPEgH/6ZD3Md3GLo/iaoSMsFiGZRo4N6dhbBu0I73Yx07JCuFfCB6ng2aePQ/1rIlUNw44gBJWGYq+XdTNn8ObC36t6qQBbw5bIPaG5SuxN4cHpVneq/HfxSpKT4OaIsQxEf1+4lSQJ3PTUQ005+W2SrZGCZSASHbtFRJtq3TGDnHK33p9bfI3KXZyT6353SDPDcsUA== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR12MB0433; X-Microsoft-Exchange-Diagnostics: 1; BLUPR12MB0433; 20:aSrhXpv/ru5ZXDPeNW/Mu0vKzFlBkLHYmXAcfg/MrHpjZaIc27W9KgFW7LQcttoHmgtvUjFeUiclKt+NH/G1Fu15Dcn8TY51U/sZFToY1Ryh2ALhfMCc2t6qbCHai4MTji6FK5T/Aru/sjswnZIF9O3o2HrHanInJ22fv15+Q5m9Cir/ZcQvWDzbwzU0CyUnljAJUXNG9prRIUc+fbU6dDm5LkK5lU143TvqzAMSGBu4AsPJsCfVCzheDA6kiANH82C1gK3fzMvY7B48B1p+It+11ABaOnZbs6PHQeSuogBqGWeCNOIHOAiIcpAmI5WB+lMpZ09XNwoeP0kmwI0LOwgPZ0nmA9rgQTc641aD0jxCzZ/YFL3sxT+MgSzEaeLJd5OEkQ3egbOfWRdx2v26i3zFVHJPsrHVvClz2Jzxfe8Hj2sIe8BSNT0DtFAfKYLVsgvZAB+7ktyBz76okJ3qKWuFfLo+NRJ4L1Dx7SCx3l3bonC1dfjQOyV/JXsdDzOj X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110)(180628864354917); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(520078)(8121501046)(5005006)(10201501046)(3002001); SRVR:BLUPR12MB0433; BCL:0; PCL:0; RULEID:; SRVR:BLUPR12MB0433; X-Microsoft-Exchange-Diagnostics: 1; BLUPR12MB0433; 4:/uQEo+rdPbjmH2p4uGv9g87aF+5Z6TuBb4Ni4dyUnrya8Paeyg6QnAw64R+nB+ASRVHMY1ao+NeBsg6qGo6NLQFQqFhTWYSGl89MpONPI9owS9A1ZJIs2nnLM3Zs9cLso/8XEYd6j5rVgh3DMYZMM+Q5l5IeDtmvPXk3paLzuD7Bn/sPUHws2Fdx0se3OzsDQ3okFpRaYhOQnWyp9R5Snatk4coOz9Gip2FcEOpShoe0gNiqywwy6KAGI9DppSA78j8+WJA4FVC54dF6bPLxAjyJahmiyPwjaFKyT5ce1uPMwGIFZ22s82fNDuJXQlpYC4U9Tw2EVVcx1llxkFEOvAiCUenkR0vZc3cEQDXJFbng1K0nnK55dp2l/u8niSHxafqdSHK75gonshbP7BROjfGqg5R7RensARgmmNegmqHFzsoMITo+qfjIi+JEZQevHVqCaURWH9lEMAcs7QuJCg== X-Forefront-PRVS: 078693968A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(199003)(189002)(97736004)(50226001)(122386002)(5001770100001)(42186005)(229853001)(36756003)(106356001)(47776003)(2201001)(66066001)(5004730100002)(105586002)(53416004)(86362001)(5003940100001)(189998001)(5008740100001)(76176999)(586003)(101416001)(50986999)(50466002)(40100003)(3846002)(1096002)(2950100001)(77096005)(48376002)(6116002)(87976001)(19580395003)(19580405001)(92566002); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR12MB0433; H:ssuthiku-fedora-lt.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX: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; BLUPR12MB0433; 23:X4HB+ITrelMSuHppg1I/aWUNFJ28P7wjZKJaZ53mM?= =?us-ascii?Q?wNmw+TUsKGVK+eVfDhBhvlnMYHZBR5zU9jgXnwhjhIrYDS8BJP62K2bUnoqg?= =?us-ascii?Q?pEAlSjDAMBvkJjmzS68SrEeaobe1o1jzaQqdlJWsLrlfNn8oif1jehu4dqYf?= =?us-ascii?Q?a+hIdxbO1JuVZ+HG0N7nRhAgYOVKNQg9vobAjYBVlqmmft6ZKvkOs0jxvusS?= =?us-ascii?Q?/4Z13N9nXR4/Of/H30e8qNyOtwNVnskzEJdzZcAPsT3lismWO0F1czoAl3Qe?= =?us-ascii?Q?4ilgFWb5aJTP9belfW6Nvm4xLMstvBeC7NDPMh76wmuT9jP+YuiCRn3uGKS/?= =?us-ascii?Q?U//kyUHxo7zvOtvLoQAuQwY02IW4Vox9WqalmhMCr2p8enM9aXiiUfD3sK3R?= =?us-ascii?Q?J+m60Y4A5xwopVVc/5EFGX51p7VQ2EZfzpRFV8gWmskgO+wWHY53zdbzxz1o?= =?us-ascii?Q?aFAVWOKPvQNpGyqZcI8pR2/SWUe7UAKPlV3nzZNOmUX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tsws0a9WY/6a4SK+nV7ceKSko0XkTPFQFxLsmTUi5n0Qn1EK2sDWRQEqF6gnBS+DfMIwYBmzmDexLPoEoHs+so0gpeqWkr3aph4+A2PXTRPW6SzbBhy X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Dec 2015 16:55:58.5627 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR12MB0433 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151210_085628_281201_A7F9EA2F X-CRM114-Status: GOOD ( 13.73 ) 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-pci@vger.kernel.org, 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. It also exposes gicv2m_init() function, which simplifies callers to a single GICv2m init function. Reviewed-by: Marc Zyngier Tested-by: Duc Dang Signed-off-by: Suravee Suthikulpanit Signed-off-by: Hanjun Guo --- drivers/irqchip/irq-gic-v2m.c | 110 +++++++++++++++++++++++++++++++++++++++- drivers/irqchip/irq-gic.c | 6 ++- include/linux/irqchip/arm-gic.h | 3 +- 3 files changed, 116 insertions(+), 3 deletions(-) diff --git a/drivers/irqchip/irq-gic-v2m.c b/drivers/irqchip/irq-gic-v2m.c index 779c390..7e2975d 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); } } @@ -373,9 +382,11 @@ static struct of_device_id gicv2m_device_id[] = { {}, }; -int __init gicv2m_of_init(struct device_node *node, struct irq_domain *parent) +static int __init gicv2m_of_init(struct fwnode_handle *parent_handle, + struct irq_domain *parent) { int ret = 0; + struct device_node *node = to_of_node(parent_handle); struct device_node *child; for (child = of_find_matching_node(node, gicv2m_device_id); child; @@ -411,3 +422,100 @@ 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; + + 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 + SZ_4K; + + 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; +} + +static 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; +} +#else /* CONFIG_ACPI */ +static int __init gicv2m_acpi_init(struct irq_domain *parent) +{ + return -EINVAL; +} +#endif /* CONFIG_ACPI */ + +int __init gicv2m_init(struct fwnode_handle *parent_handle, + struct irq_domain *parent) +{ + if (is_of_node(parent_handle)) + return gicv2m_of_init(parent_handle, parent); + + return gicv2m_acpi_init(parent); +} diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c index fcd327f..644e8bb 100644 --- a/drivers/irqchip/irq-gic.c +++ b/drivers/irqchip/irq-gic.c @@ -1234,7 +1234,7 @@ gic_of_init(struct device_node *node, struct device_node *parent) } if (IS_ENABLED(CONFIG_ARM_GIC_V2M)) - gicv2m_of_init(node, gic_data[gic_cnt].domain); + gicv2m_init(&node->fwnode, gic_data[gic_cnt].domain); gic_cnt++; return 0; @@ -1359,6 +1359,10 @@ static int __init gic_v2_acpi_init(struct acpi_subtable_header *header, __gic_init_bases(0, -1, dist_base, cpu_base, 0, domain_handle); acpi_set_irq_model(ACPI_IRQ_MODEL_GIC, domain_handle); + + if (IS_ENABLED(CONFIG_ARM_GIC_V2M)) + gicv2m_init(NULL, gic_data[0].domain); + return 0; } IRQCHIP_ACPI_DECLARE(gic_v2, ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR, diff --git a/include/linux/irqchip/arm-gic.h b/include/linux/irqchip/arm-gic.h index bae69e5..febc6c3 100644 --- a/include/linux/irqchip/arm-gic.h +++ b/include/linux/irqchip/arm-gic.h @@ -106,7 +106,8 @@ int gic_cpu_if_down(unsigned int gic_nr); void gic_init(unsigned int nr, int start, void __iomem *dist , void __iomem *cpu); -int gicv2m_of_init(struct device_node *node, struct irq_domain *parent); +int gicv2m_init(struct fwnode_handle *parent_handle, + struct irq_domain *parent); void gic_send_sgi(unsigned int cpu_id, unsigned int irq); int gic_get_cpu_id(unsigned int cpu);