From patchwork Mon Jul 13 09:14:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suravee Suthikulpanit X-Patchwork-Id: 6776501 Return-Path: X-Original-To: patchwork-linux-acpi@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 AAD60C05AC for ; Mon, 13 Jul 2015 09:16:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 911482067A for ; Mon, 13 Jul 2015 09:16:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4AB1E2063C for ; Mon, 13 Jul 2015 09:16:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751117AbbGMJQV (ORCPT ); Mon, 13 Jul 2015 05:16:21 -0400 Received: from mail-bl2on0111.outbound.protection.outlook.com ([65.55.169.111]:38112 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751892AbbGMJPk (ORCPT ); Mon, 13 Jul 2015 05:15:40 -0400 Received: from BY2PR02CA0079.namprd02.prod.outlook.com (10.242.32.37) by CY1PR0201MB1497.namprd02.prod.outlook.com (10.163.139.155) with Microsoft SMTP Server (TLS) id 15.1.213.14; Mon, 13 Jul 2015 09:15:37 +0000 Received: from BN1AFFO11FD047.protection.gbl (2a01:111:f400:7c10::121) by BY2PR02CA0079.outlook.office365.com (2a01:111:e400:2c2a::37) with Microsoft SMTP Server (TLS) id 15.1.213.14 via Frontend Transport; Mon, 13 Jul 2015 09:15:36 +0000 Authentication-Results: spf=none (sender IP is 165.204.84.222) smtp.mailfrom=amd.com; arm.com; dkim=none (message not signed) header.d=none; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from atltwp02.amd.com (165.204.84.222) by BN1AFFO11FD047.mail.protection.outlook.com (10.58.53.62) with Microsoft SMTP Server id 15.1.213.8 via Frontend Transport; Mon, 13 Jul 2015 09:15:35 +0000 X-WSS-ID: 0NRF5PV-08-RVQ-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 2F30BD16026; Mon, 13 Jul 2015 05:15:30 -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; Mon, 13 Jul 2015 04:15:47 -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.195.1; Mon, 13 Jul 2015 05:15:30 -0400 From: Suravee Suthikulpanit To: , , , , CC: , , , , , , , , , , , Suravee Suthikulpanit Subject: [RFCv2 PATCH 7/8] gicv2m: Introducing gicv2m_acpi_init() Date: Mon, 13 Jul 2015 16:14:23 +0700 Message-ID: <1436778864-17645-8-git-send-email-Suravee.Suthikulpanit@amd.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1436778864-17645-1-git-send-email-Suravee.Suthikulpanit@amd.com> References: <1436778864-17645-1-git-send-email-Suravee.Suthikulpanit@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD047; 1:/jUdkdt7wpEZnfhp0BuAzlDJKvfGQGDx+PKUGIjXHzCzCp0l+Q+o6LHiV/GIbm2mRZ29kXnFVwtKCT6h7UWpVOBPbe/+tngmIkXmW/tS2ricRb2KiQd4HM24qg8Mlh1d5hhm1cKXIuUlEou/vN5cBuzsxMVWZSLLCg7m1rJ668dP2AanE7AFT3U39gjUJ7qpkiZvcVI+bkBpgjfkGjyBM7wjEBIS1VQOBXQq6CHNGOGFZqrkD2+AdmCGcsQV1hu8gfV4np8YJ/Tgq8cOnSewJx2vSaEdZ0ITg0kIgouQyjcansjNkguveSkkDKuW5oLBmSZO1PNEfXhmjV5Y6oS80DYDyjnnLxhZejvXQbe3P0bLlsu0b8CoUsj4+SvbZnWmfF576dfEuklZO01vnw2BywJDlNmOLB88r0xG9W5y8LU= X-Forefront-Antispam-Report: CIP:165.204.84.222; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(2980300002)(428002)(164054003)(189002)(199003)(189998001)(2950100001)(50226001)(5003940100001)(5001770100001)(229853001)(87936001)(77156002)(62966003)(46102003)(101416001)(86362001)(19580405001)(53416004)(77096005)(105586002)(19580395003)(50986999)(2201001)(48376002)(76176999)(36756003)(50466002)(5003600100002)(47776003)(92566002); DIR:OUT; SFP:1102; SCL:1; SRVR:CY1PR0201MB1497; H:atltwp02.amd.com; FPR:; SPF:None; MLV:sfv; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0201MB1497; 2:ohX7sgynfVhoxjuZKf+v7fhBmvBZW5MpKxo8HxKAJjNvh/5jL1E0HeEOTQbmumHn; 3:ikfvDbDoPQsbQ5F77VhqZhDRZeGX3YWw+d7VyumV/l8KzY4WJzMmGBE7h9o10jdvwZ5Ej5J2Ct56TvMEV7hLeiZ1milf75w8a11Fe8JD+6w2P9klLcm+H+h+a49hr5NIG6c0Zv9aEtg0eNyuPLnq79mMXifgXJ8w+37/t5GaegneD6/tf/SN8ZERN1VvBtA9BHdHrTyAPEmhkGfslJ0h11kvS0mjGTV5leGJwk0CxbrQnUuCNzRcE5cmeNgsoPIO; 25:eAG798XRJU132syrc1Uh2wBrvqGr5WCYEp+gsQ0CViXDHFWT5ghfDP5PsXHWnXjJoFaBqsSl6kSzd8PKauv5+eB4hdQwU80na68ES59rvsOk3uNMFA2/n5Cx8aZpIMJEaEU6CLnlGHMmcqnWuVpA6flj94FCqNOFk+ri4e0TUz387tncBxCZUb5VI7YBsKUKWoU0+hpnhf7YBtSZWPULgiKu+88S1e5pPe9ICLofeZ7uTS5024IBZn3Rg1EtV5C+IRa8RYy4c5KpxQoBq3Dq2g== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0201MB1497; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0201MB1497; 20:sMq3y3qeT0T7rOv/1UbN+F3C71gsuyGysSNwKejZ6c3jx8t4dlRxhviVT7Fp7/cAcMQqfFPximfYG8gGyuk4otEWAohFgWz1eKdjHyurx/bU/u38IlYGjVMQGZ5KgffjX+3gz37zpT8KcpvX34WXgUcXRG0UNoEFx1xAAm81K0bZlt7oop7qS/7BWUMCqQ5We+gJfK1tiQfxNV/Pzfc5qpTWrzEsDEPqNE2njj+J3K1YmifetQfooijzT9xEjnbu0rz+WJYqxlrylAwJOC882Klu9LvWTfSoaEz+1+uWJtdBFdfxvVOG5B76D8oXaLbx5ua8a0q4xlScWfxxfCLFufLBztbMgc+XjStx3XZCHK6pomjqfbfh4nqEb9T+11f0w/pQv/0TFr8GYx4VZtllL2X0g0f+njfsXxyDqzVRiz4R12S08hi7OiTTDQsv9fHiLlSG22AhtUEnVrFlzFlfBKtfsAj0HIQ63qrTNXi00pn+eDQISM5e43xEXzu40M/9; 4:R52bQH0SXKz7+C6dcIuWc4cl2oyOB/B/KjUCQDANcwiB5E64qzyJhfTP0MNwR6oO+JQtXaSzYocOtr5JsU/MEWmIE3WshBr7ji1Zj6EblEHj6tFcdAAJRoL2UPBN/IpQm+NB8RyAM61Idox9d8Nx4eOeX6++LQLgA/3BFnwIDPOxcG9RDcxG2Vra5Xq55pYpSFinQhVFtH1EucyaD+zinwcc0d40RSjTcGdEey17rO7HYKfpUduwgM9qROn6MzWlTpfnqFpPR17AMNTOvq1gA/nTKl5gn+GT+vTcSPYKyks= CY1PR0201MB1497: X-MS-Exchange-Organization-RulesExecuted X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5005006)(3002001); SRVR:CY1PR0201MB1497; BCL:0; PCL:0; RULEID:; SRVR:CY1PR0201MB1497; X-Forefront-PRVS: 0636271852 X-Microsoft-Exchange-Diagnostics: 1; CY1PR0201MB1497; 23:zT53+A8CFUBxwKGA8dVMJN2WTBl0vmEpSgSX96sDyzHgjPtPoEL+aTDIiTJUeBfIbmL0vRCMhhnUDiown9vDnzbNfMgQInuyySsn04gEjGLCh4Z0DjsP9VwyrZINocY6LVW5FDpcc5ZLNl/IeNWhXvdRddJgIkmTjKeiyJ62H/26M0gC94DPlMM0Bs3rbaMQsXnUk7FfajG6HjfuMch5pt85Js+lN5VVNA38mPF1QDsINTbtZSszotJ0gch2oJE6NMXzqvoG9S/0qjYT2hDiAtZrqBahWCrgdgWVHwZqS0DgRrKGIKY+oo7424IWbsPtPaYiDGqYacg8Jw8uBxAa5Ub2MM2mjLzop9amzr3HwC9mO+HJRIyS6Gj/x8bZNKVpB1O/Elaen4sxZc6nDwsNQHDAfcd3nmxY1HcjrYepCY/c9H37P5NKFgXskoW8BAGkuoqlbyDooihqT5YBU1S3bimzFbXBuPlu4kE6R7DUIn4lJUWJPOt/GSNK7QMkvfVKNwT5uYs2fjAfiTa3rzE8qYkvhMtWNKJsm89G/dGk36oSE+UVzR+bLxK4baIbE/uE2ovB9C7I5xKrtQK3hvjICM9ywlssRoN69owmOIKcnl0PkHSOdiaX7ll4EzENSlwU6+kUJlmwTXdxFpy0CAUTi1swwvHTlvUgOfbjV/9Ebxyd19quNdW0HpSyNScx1UImaTD/Y4lU3/RRV9ahxBST+JvgS8SuSSZNZLxZfjDlyuWoFsiH/gVlunyhV6HnNZ3D6YDQ7IJrqnizHbD8u+6wkJ87INkcfrOIU/VQ1AItJQqoLQRPMwRX+JlXEhC9nBjoglASzYT7ngO7hFELGUzBkEDl2d7rGj2DJaS4MGtAAV7qbXb9nfka3kUX63tfPPQP X-Microsoft-Exchange-Diagnostics: 1; CY1PR0201MB1497; 5:fLO64EZNoZWek0ivmSOWfDUVs4DdT53QPSRx8VsE1ZMqtVA5TK/YcSFBfXj8MPlZZS0UQysYwZPbBTwy2weezVJ6Dvgy+DfWifORR2dSk63A4Zo9n7pDg2Wor4MqNHDb0HMTGAwWUZWpS3Fl8dgPdA==; 24:9h3FNkPU8N2W6VMAaVcWKbE9rk9GhtBJ+cJXFC2IbKbOzeXK0pKXcuNjOi46gLc7Ulifeym7K9TmNlo0oJYqeCtRPkGr9IfytdtSHGymQqo=; 20:fhIwHJ6wbcm+nJyBnDnldCikRPzQTJ4d5Y068j/qwAYUjhsrqdgSa046XOstLPtlDXzCTfly4zu8cpc2+PymIA== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jul 2015 09:15:35.1966 (UTC) X-MS-Exchange-CrossTenant-Id: fde4dada-be84-483f-92cc-e026cbee8e96 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=fde4dada-be84-483f-92cc-e026cbee8e96; Ip=[165.204.84.222]; Helo=[atltwp02.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0201MB1497 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 parse MADT GIC MSI frames, and use information to initialize GICv2m. It also refactors gicv2m_init_one() to handle both DT and ACPI initialization path. Signed-off-by: Suravee Suthikulpanit --- NOTE: Now that we are setting v2m->domain->bus_token to DOMAIN_BUS_PCI_MSI, this limits the scope of this particular domain to just PCI-MSI-related stuff. I am not sure if it would be acceptable to use MSI frame handle as a reference to assign to v2m->domain->of_node. This same concern is also applied to patch 8 where we bind the GIC MSI frame to PCI host bridge. Any suggestions/feedbacks are welcomed. Thanks, Suravee drivers/irqchip/irq-gic-v2m.c | 106 +++++++++++++++++++++++++++++++++------- drivers/irqchip/irq-gic.c | 3 ++ include/linux/irqchip/arm-gic.h | 13 +++++ 3 files changed, 104 insertions(+), 18 deletions(-) diff --git a/drivers/irqchip/irq-gic-v2m.c b/drivers/irqchip/irq-gic-v2m.c index e4e2a92..c0417e1 100644 --- a/drivers/irqchip/irq-gic-v2m.c +++ b/drivers/irqchip/irq-gic-v2m.c @@ -15,6 +15,7 @@ #define pr_fmt(fmt) "GICv2m: " fmt +#include #include #include #include @@ -219,8 +220,14 @@ static bool is_msi_spi_valid(u32 base, u32 num) return true; } -static int __init gicv2m_init_one(struct device_node *node, - struct irq_domain *parent) +char gicv2m_domain_name[] = "GICV2M"; +char gicv2m_msi_domain_name[] = "V2M-MSI"; + +static int __init gicv2m_init_one(struct irq_domain *parent, + u32 *spi_start, u32 *nr_spis, + struct resource *res, + struct device_node *node, + void *msi_frame) { int ret; struct v2m_data *v2m; @@ -232,23 +239,17 @@ static int __init gicv2m_init_one(struct device_node *node, return -ENOMEM; } - ret = of_address_to_resource(node, 0, &v2m->res); - if (ret) { - pr_err("Failed to allocate v2m resource.\n"); - goto err_free_v2m; - } - - v2m->base = ioremap(v2m->res.start, resource_size(&v2m->res)); + v2m->base = ioremap(res->start, resource_size(res)); if (!v2m->base) { pr_err("Failed to map GICv2m resource\n"); ret = -ENOMEM; goto err_free_v2m; } + memcpy(&v2m->res, res, sizeof(struct resource)); - if (!of_property_read_u32(node, "arm,msi-base-spi", &v2m->spi_start) && - !of_property_read_u32(node, "arm,msi-num-spis", &v2m->nr_spis)) { - pr_info("Overriding V2M MSI_TYPER (base:%u, num:%u)\n", - v2m->spi_start, v2m->nr_spis); + if (*spi_start && *nr_spis) { + v2m->spi_start = *spi_start; + v2m->nr_spis = *nr_spis; } else { u32 typer = readl_relaxed(v2m->base + V2M_MSI_TYPER); @@ -277,6 +278,8 @@ static int __init gicv2m_init_one(struct device_node *node, inner_domain->bus_token = DOMAIN_BUS_PLATFORM_MSI; inner_domain->parent = parent; + inner_domain->name = gicv2m_domain_name; + v2m->domain = pci_msi_create_irq_domain(node, &gicv2m_msi_domain_info, inner_domain); if (!v2m->domain) { @@ -285,11 +288,11 @@ static int __init gicv2m_init_one(struct device_node *node, goto err_free_domains; } - spin_lock_init(&v2m->msi_cnt_lock); + v2m->domain->name = gicv2m_msi_domain_name; + if (!acpi_disabled) + v2m->domain->of_node = msi_frame; - pr_info("Node %s: range[%#lx:%#lx], SPI[%d:%d]\n", node->name, - (unsigned long)v2m->res.start, (unsigned long)v2m->res.end, - v2m->spi_start, (v2m->spi_start + v2m->nr_spis)); + spin_lock_init(&v2m->msi_cnt_lock); return 0; @@ -319,15 +322,82 @@ int __init gicv2m_of_init(struct device_node *node, struct irq_domain *parent) for (child = of_find_matching_node(node, gicv2m_device_id); child; child = of_find_matching_node(child, gicv2m_device_id)) { + u32 spi_start = 0, nr_spis = 0; + struct resource res; + if (!of_find_property(child, "msi-controller", NULL)) continue; - ret = gicv2m_init_one(child, parent); + ret = of_address_to_resource(child, 0, &res); + if (ret) { + pr_err("Failed to allocate v2m resource.\n"); + break; + } + + if (!of_property_read_u32(child, "arm,msi-base-spi", &spi_start) && + !of_property_read_u32(child, "arm,msi-num-spis", &nr_spis)) + pr_info("Overriding V2M MSI_TYPER (base:%u, num:%u)\n", + spi_start, nr_spis); + + ret = gicv2m_init_one(parent, &spi_start, &nr_spis, &res, + child, NULL); if (ret) { of_node_put(node); break; } + + pr_info("Node %s: range[%#lx:%#lx], SPI[%d:%d]\n", child->name, + (unsigned long)res.start, (unsigned long)res.end, + spi_start, (spi_start + nr_spis)); } return ret; } + +#ifdef CONFIG_ACPI +int __init gicv2m_acpi_init(struct acpi_table_header *table, + struct irq_domain *parent) +{ + int ret = 0; + int num, i; + struct acpi_madt_generic_msi_frame *cur, *msi_frame; + + ret = acpi_madt_msi_frame_init(table); + if (ret) + return ret; + + ret = acpi_get_msi_frame(0, &msi_frame); + if (ret) + return ret; + + num = acpi_get_num_msi_frames(); + + for (i = 0, cur = msi_frame; i < num; i++, cur++) { + struct resource res; + u32 spi_start = 0, nr_spis = 0; + + res.start = cur->base_address; + res.end = cur->base_address + 0x1000; + + if (cur->flags & ACPI_MADT_OVERRIDE_SPI_VALUES) { + spi_start = cur->spi_base; + nr_spis = cur->spi_count; + + pr_info("ACPI overriding V2M MSI_TYPER (base:%u, num:%u)\n", + spi_start, nr_spis); + } + + ret = gicv2m_init_one(parent, &spi_start, &nr_spis, &res, + NULL, msi_frame); + if (ret) + break; + + pr_info("MSI frame ID %u: range[%#lx:%#lx], SPI[%d:%d]\n", + cur->msi_frame_id, + (unsigned long)res.start, (unsigned long)res.end, + spi_start, (spi_start + nr_spis)); + } + return ret; +} + +#endif /* CONFIG_ACPI */ diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c index 8ac8ec4..5630e16 100644 --- a/drivers/irqchip/irq-gic.c +++ b/drivers/irqchip/irq-gic.c @@ -1195,6 +1195,9 @@ gic_v2_acpi_init(struct acpi_table_header *table) gic_init_bases(0, -1, dist_base, cpu_base, 0, NULL); set_acpi_irq_domain(gic_data[0].domain); + if (IS_ENABLED(CONFIG_ARM_GIC_V2M)) + gicv2m_acpi_init(table, gic_data[0].domain); + acpi_irq_model = ACPI_IRQ_MODEL_GIC; return 0; } diff --git a/include/linux/irqchip/arm-gic.h b/include/linux/irqchip/arm-gic.h index 4808514..de1bd1e 100644 --- a/include/linux/irqchip/arm-gic.h +++ b/include/linux/irqchip/arm-gic.h @@ -118,6 +118,19 @@ static inline void gic_init(unsigned int nr, int start, gic_init_bases(nr, start, dist, cpu, 0, NULL); } +#ifdef CONFIG_ACPI +#include + +int gicv2m_acpi_init(struct acpi_table_header *table, + struct irq_domain *parent); +#else +int gicv2m_acpi_init(struct acpi_table_header *table, + struct irq_domain *parent); +{ + return 0; +} +#endif + int gicv2m_of_init(struct device_node *node, struct irq_domain *parent); void gic_send_sgi(unsigned int cpu_id, unsigned int irq);