From patchwork Tue Oct 13 20:46: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: 7388561 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 264D4BEEA4 for ; Tue, 13 Oct 2015 20:46:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0D3C0207C6 for ; Tue, 13 Oct 2015 20:46:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A17D120801 for ; Tue, 13 Oct 2015 20:46:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932144AbbJMUqr (ORCPT ); Tue, 13 Oct 2015 16:46:47 -0400 Received: from mail-bn1bon0095.outbound.protection.outlook.com ([157.56.111.95]:3904 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752979AbbJMUq0 (ORCPT ); Tue, 13 Oct 2015 16:46:26 -0400 Received: from SN1PR12MB0717.namprd12.prod.outlook.com (10.163.209.19) by SN1PR12MB0493.namprd12.prod.outlook.com (10.162.105.15) with Microsoft SMTP Server (TLS) id 15.1.293.16; Tue, 13 Oct 2015 20:46:24 +0000 Received: from CY1PR1201CA0020.namprd12.prod.outlook.com (10.169.17.158) by SN1PR12MB0717.namprd12.prod.outlook.com (10.163.209.19) with Microsoft SMTP Server (TLS) id 15.1.293.16; Tue, 13 Oct 2015 20:46:23 +0000 Received: from DM3NAM03FT011.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e49::202) by CY1PR1201CA0020.outlook.office365.com (2a01:111:e400:5b9a::30) with Microsoft SMTP Server (TLS) id 15.1.293.16 via Frontend Transport; Tue, 13 Oct 2015 20:46:23 +0000 Authentication-Results: spf=none (sender IP is 165.204.84.221) smtp.mailfrom=amd.com; arm.com; dkim=none (message not signed) header.d=none; arm.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 atltwp01.amd.com (165.204.84.221) by DM3NAM03FT011.mail.protection.outlook.com (10.152.82.88) with Microsoft SMTP Server id 15.1.300.4 via Frontend Transport; Tue, 13 Oct 2015 20:46:22 +0000 X-WSS-ID: 0NW6F18-07-6UJ-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 atltwp01.amd.com (Axway MailGate 5.3.1) with ESMTPS id 2489DCAE7C7; Tue, 13 Oct 2015 16:46:19 -0400 (EDT) Received: from SATLEXDAG03.amd.com (10.181.40.7) by satlvexedge01.amd.com (10.177.96.28) with Microsoft SMTP Server (TLS) id 14.3.195.1; Tue, 13 Oct 2015 15:46:21 -0500 Received: from ssuthiku-fedora-lt.amd.com (10.180.168.240) by satlexdag03.amd.com (10.181.40.7) with Microsoft SMTP Server id 14.3.266.1; Tue, 13 Oct 2015 16:46:19 -0400 From: Suravee Suthikulpanit To: , , , CC: Lorenzo Pieralisi , Will Deacon , Catalin Marinas , , , , , , , "Suravee Suthikulpanit" Subject: [PATCH 4/4] gicv2m: acpi: Introducing GICv2m ACPI support Date: Tue, 13 Oct 2015 13:46:23 -0700 Message-ID: <1444769183-12374-5-git-send-email-Suravee.Suthikulpanit@amd.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1444769183-12374-1-git-send-email-Suravee.Suthikulpanit@amd.com> References: <1444769183-12374-1-git-send-email-Suravee.Suthikulpanit@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:165.204.84.221; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(428002)(189002)(199003)(105586002)(50466002)(189998001)(47776003)(101416001)(229853001)(2201001)(50986999)(64706001)(106466001)(53416004)(2950100001)(19580405001)(5008740100001)(76176999)(92566002)(87936001)(86362001)(5003600100002)(575784001)(50226001)(19580395003)(46102003)(48376002)(11100500001)(36756003)(77096005)(97736004)(5003940100001)(5001770100001)(5007970100001)(473944003); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB0717; H:atltwp01.amd.com; FPR:; SPF:None; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0717; 2:eTfGd85K5cug5+KKrK0fH03XELa+Z5HnW9Y332pfIVpwYVQBv3Mg8euij7aMWID7HbHiJzAP1ByGeXz/nUvfpTZKR4fmpXqAKkWKy1nu68Q1RaSSqAdhp8a8rw+tIWSj8d6ZcmJF1GHeCK1xuH6sd568g26jPqeSpo5X6ipqHtM=; 3:Bx+JdEXvDTob7ZKsB+K3Kz9O2BCpAaqZrz6JbiZUX0L02i0aGMXFyCTdIVikR1oZ3i+hDi4FB6VZDO2lo6u+OfDEg5NBit9iWCewRfYaq+HqQmlBmN2nWzZ7OV5mubN8e+B6wZHT3Jb7hXP3HHGtTCRm2VP7AngMclipe+PdYc783rvI4KQ56n9a9picOTXJBQaBuhG17VtAogANZNqbBfjJsJZCqP+iHPTkuupISYjEofxZsDRkENagDxy5cwHP; 25:nkNDUoEjBDElUcxZdb5VHuLzHAIWEAyMmGy3plpsASdlFnHWyLAELxh8xyzmSxeDos7IwtSdgJGyK0IYz/B5yZipA5aQzj+SQd6ZuwBs7W9a/I/BTOyThjqUY1Zfun+hidUrYcn8YnjVHlL+HBwxgMpIVzCEAJFMhwQSv6lYU7mGow8Ff5nL2W2hOBlEacRQrP1pynj5Mox10jbkoGZUnaMD12WTUwkKq6/c8F1ou23qxKibDmeFSbx8B/vB71Fo X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SN1PR12MB0717; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0717; 20:KgLS53ac72qYHm4jXJDFVdnSIwKaHJIV3tBEiOg/MfmMC/W49sg9AX6+sE5wzWHJfxlOL3BIJxjJP6vytjfCJ9855hl8XZQZVG9dlSFNZx4sxJOhs+YBO+P5oRWRzmTq3PZN2kqP2762VFVeThnlKoWNX6QJHbwn1s8xNP1mqrD1Amv6VI5DbuTWUA2FJmXk9F/ALauFE7IyXH1X4xCO0P3sF1CkxT9bp4x+9FucmHJhwCXUvnKDdlpG2Eqeyng3+xsFx3GhIWEzN4Hsm/UTj/pea4WPafniRZFD81OPMZ/rnJPPc0F8uMoh/F16zMDDsWnrDv5dneXtNZy5IDh0pjQaqPtm2I8hYF7DcquQkjAOgv6t7sswRO9nPhWz7H2V/5eJUr2FOBX8zGIhnqCMcOfCJQ6YxZFZwx6HxCGnaShaWKG4NgZVt9DhqjEFIWRcTYGe37FdG+GuJlQF4eyCDY0YSVPwpo+XGqxHNZGQW8wdNFHH5POn4rFK3oVWf1us; 4:XDU+0P/01ctVP8JXfnE6X5PL3RshTy5aH9co3zz1I1oytLwq0wThIX7ng3aUTeHL2W0BsvxKnrnJWIYszqNHS8MqnOeY/lb6QKWy9lx0WnaQYZ41po1CXqYXMiaFgtJtvmBEetZzG3m4MRzytnM7u4QuJukkM4yJFaAz44VGFZ+9KIfBmb3yWFxtKOT3KAs31eeVXA/kSXQt+aZp1dNA05wSE23bSyy6QNnewY3KUeDu27tOF4ap3qOP0x0G7XTTAehO+7vgB8vCZBW1mw3ffLshXpFGdzNA5ZZJAVcKUmrxrUTBPAMRjzo7GA4s2k485BkL18QDbcatTgtGHbrKn6xnpiigN27PZCw3jxvjVcw= 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); SRVR:SN1PR12MB0717; BCL:0; PCL:0; RULEID:; SRVR:SN1PR12MB0717; X-Forefront-PRVS: 07283408BE X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN1PR12MB0717; 23:j8ZX04JcDiqQpTstx01pzCVlAA4JmNF4h/w4Oq7dG?= =?us-ascii?Q?XiinypAqMcgxxOJavL8ue0k8pedcolwSSx7Z09TgRVWH4/WD+1Z9fsqVMAcp?= =?us-ascii?Q?cS5iy8vLERC2vk0NJQYnmcR8tp6myNtJTWJSizU7urUDVFUb+JHL2K1vVwVM?= =?us-ascii?Q?LafCYmPyYmrzo1QGEHhmAc28mF0vamjLdgLnxHWzqwQXyl6QDdVFSzHraKf+?= =?us-ascii?Q?6/yumF+/hMnPiGbd/A2bUcnJTszcGLUkjJP85pzGmeBhr1TvyEKaYvCKGK9l?= =?us-ascii?Q?ilhH3oZDgSFVzXNnqs2WDf+/XVuBoRfVodOcD8+y0t15QbvMVD/8n7DkM03D?= =?us-ascii?Q?w9rwF5NI3ElBPp04GGMl9ucAHHwdRm8uZt9EQ51rIPVDxa22A8m42jTZende?= =?us-ascii?Q?xtg+JkC9mjnvX9tD/F9bxzk+C+ppkw0SvxiXTfAazeOybxFjDi9sTeVot2LD?= =?us-ascii?Q?zLuuXAEiWrqA0Dki/xLdGq+kW/e94VpvAVR2NKNb8LKxMgltXuiMMBqQ92JO?= =?us-ascii?Q?nQnVpbmk8PSbnHXxjtFkGGhEAYOmusuRP5Yy+HSYHyZOz+uHG4RuFZ4+ZQ46?= =?us-ascii?Q?NT9A/z5NGjIGQSYtmPEFwhrYJ0vvanvoXlv4qxztJyqnXBNGt3eZpXy5coBm?= =?us-ascii?Q?JEge+5n1bINM2nrh63/iGqRGn+K/S7IhixwqZTzCOgHtdDH8+qbce0B0UaVx?= =?us-ascii?Q?MA3ubEFmwmFAs3+Xe1xaNhknzvRkrDLveNLO91jh2uiznGj5xHmkRLRvw01u?= =?us-ascii?Q?Reoe28EBulmUYW0oZGJ8yk2hKtEImWr64WLvFM4g66ydMjYUY2ih/4ygpJvM?= =?us-ascii?Q?tfUSaf1WtsBpXHYiLb8XzUnjuFB0HDOGrnpm/OJDcyoSoX4hWfaKya+0RT+m?= =?us-ascii?Q?VQ6ivxMMAGksicEx4V/Hhf65Hqs22q5zHvSuTuYPucBayai7fy0D7R4MEyfF?= =?us-ascii?Q?hXxjDe++arhxtnNRcEud3N4ja2hnRteqkKhbXXGZLBXdqw00lnNxq/cb3+Bg?= =?us-ascii?Q?7I0qytHbNbvfNeMU0cQlzW/taUX6sZUhV70XPcCvYpgug=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0717; 5:qKIXVrzztuUoddpMMQCVXrRvuRCJdp9v4A/H6fT+tmrtT2lZVCyt83L+PWT4q81wkQRZSwsF1eE/zoTaPmIzI6B29iHG8FFOEFF6+rY8nUeuJsib3/kox9aoHdZ0jesjIqRqXyTTthozN9X8s1OJLg==; 24:/b9XasOJHXSTSkiNvtVzwo7uEnOxo/aHFOiRyU9wc0wFyaUYwoPmhIwYN7UAH+02bq2Q/+wVxoGL6CIWLDHt8h+tXN2cSLVw1vAhRlvLcO4=; 20:Whoowu6spdTSqDyD8S0SVmvPwremRL43kBEn9Oi6J/CdLT5RMUriYiIYtbiiXgHhFqXx5+PDSnsK40NobYwR8y1dGZTICW+PEQaSV2tvNjBVws4v1LCyzbHohH8/BLMeb3LehMhBJQfBkAdInOvDwR4omCJmbFYHEgV8FCT66rG78y11sIxF4V9M/z4KgyeoZm+6Vp0IkRrxAIKv0zaWfsvbHYj9D1LiBJRMYRpEpOspSM/6+OFcnNXCocDPd7mM SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Oct 2015 20:46:22.1329 (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.221]; Helo=[atltwp01.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB0717 X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0493; 2:B4zdwfSzHP7VAsn3OdhTwYtCszxoRv5YTmbtKhtbKM3eicoQiMkkKLHTt4F8XT8ngjJa8ZFqlUmkmQ1TFSmkCsQRkJ8pf/aQCP/IM0U6UqiZRryTDEjkoIxq9OnBoKt9ZhvIeWp9ydCTpK3k4RMPblQO1PI4f621vlyyE0w+ZEU=; 23:8QjF1xGia6lEqbKdnlfvaA68jwLocWftM1iFrj5TjutW3hjtdLHyY8fFGl+zymIw6RFXorP4wAgk+hJLDYn6Gchjb/lHfKNZxOdmzrHRVU3ZgREuGoYP5lxNNW1NyYFtXxnblb6MTzf6Lyo9/ompff9zt8yti6x1EjzDgnalUCS9tSL9TF7T802macog6TuX X-OriginatorOrg: amd.com Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 | 106 ++++++++++++++++++++++++++++++++++++++++ drivers/irqchip/irq-gic.c | 3 ++ include/linux/irqchip/arm-gic.h | 6 +++ 3 files changed, 115 insertions(+) diff --git a/drivers/irqchip/irq-gic-v2m.c b/drivers/irqchip/irq-gic-v2m.c index 97d1bf4..b52560b 100644 --- a/drivers/irqchip/irq-gic-v2m.c +++ b/drivers/irqchip/irq-gic-v2m.c @@ -15,7 +15,10 @@ #define pr_fmt(fmt) "GICv2m: " fmt +#include #include +#include +#include #include #include #include @@ -51,6 +54,7 @@ #define GICV2M_NEEDS_SPI_OFFSET 0x00000001 struct v2m_data { + struct list_head list; spinlock_t msi_cnt_lock; struct resource res; /* GICv2m resource */ void __iomem *base; /* GICv2m virt address */ @@ -58,8 +62,11 @@ struct v2m_data { u32 nr_spis; /* The number of SPIs for MSIs */ unsigned long *bm; /* MSI vector bitmap */ u32 flags; /* v2m flags for specific implementation */ + struct fwnode_handle *fwnode; }; +static LIST_HEAD(v2m_data_list); + static void gicv2m_mask_msi_irq(struct irq_data *d) { pci_msi_mask_irq(d); @@ -134,6 +141,12 @@ 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 (domain->parent->fwnode->type == FWNODE_IRQCHIP) { + /* Note: This is mainly for GICv2m ACPI. */ + 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; } @@ -317,6 +330,8 @@ static int __init gicv2m_init_one(struct irq_domain *parent, } spin_lock_init(&v2m->msi_cnt_lock); + v2m->fwnode = fwnode; + list_add(&v2m->list, &v2m_data_list); pr_info("range[%#lx:%#lx], SPI[%d:%d]\n", (unsigned long)res->start, (unsigned long)res->end, @@ -379,3 +394,94 @@ int __init gicv2m_of_init(struct device_node *node, struct irq_domain *parent) return ret; } + +#ifdef CONFIG_ACPI +static int acpi_num_msi; + +/** + * Note: + * This is used as a temporary variable since we cannot + * pass args into acpi_parse_masdt_msi() when calling + * acpi_parse_entries(), + */ +struct irq_domain *acpi_parent_domain; + +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 *domain_handle = 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); + } + + domain_handle = irq_domain_alloc_fwnode((void *)m->base_address); + if (!domain_handle) { + pr_err("Unable to allocate GICv2m domain token\n"); + return -EINVAL; + } + + if (gicv2m_init_one(acpi_parent_domain, spi_start, nr_spis, &res, + domain_handle)) { + ret = -EINVAL; + goto err_out; + } + + return 0; +err_out: + if (domain_handle) + irq_domain_free_fwnode(domain_handle); + return ret; +} + +static struct fwnode_handle *gicv2m_get_fwnode(struct device *dev) +{ + struct v2m_data *data; + + if (!acpi_num_msi) + return NULL; + + /* We only support one MSI frame at the moment. */ + data = list_first_entry_or_null(&v2m_data_list, + struct v2m_data, list); + if (!data) + return NULL; + + return data->fwnode; +} + +int __init gicv2m_acpi_init(struct irq_domain *parent) +{ + if (acpi_num_msi > 0) + return 0; + + acpi_parent_domain = parent; + + acpi_num_msi = acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_MSI_FRAME, + acpi_parse_madt_msi, 0); + + if (acpi_num_msi) + pci_msi_register_fwnode_provider(&gicv2m_get_fwnode); + else + pr_debug("No valid ACPI GIC MSI FRAME exist\n"); + + return 0; +} + +#endif /* CONFIG_ACPI */ diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c index 1d0e768..adfd1aa 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);