From patchwork Thu Dec 10 16:55:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suravee Suthikulpanit X-Patchwork-Id: 7820431 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@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 CB23B9F387 for ; Thu, 10 Dec 2015 17:10:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C216B205BE for ; Thu, 10 Dec 2015 17:10:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7DD1920585 for ; Thu, 10 Dec 2015 17:10:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754217AbbLJRKc (ORCPT ); Thu, 10 Dec 2015 12:10:32 -0500 Received: from mail-bn1on0058.outbound.protection.outlook.com ([157.56.110.58]:23035 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754003AbbLJRK3 (ORCPT ); Thu, 10 Dec 2015 12:10:29 -0500 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:56 +0000 From: Suravee Suthikulpanit To: , , , , CC: Lorenzo Pieralisi , Will Deacon , Catalin Marinas , , , , , , , , , "Suravee Suthikulpanit" Subject: [PATCH v7 3/4] gicv2m: Refactor to prepare for ACPI support Date: Thu, 10 Dec 2015 08:55:29 -0800 Message-ID: <1449766530-16935-4-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:DOtmwUvmgrvqov3mw5C1+rBfXzphrOQ8dZpzecr9enmPXpOKHYg9Vvs2k5mhQwvqVZ2CHksPoG3vdIe6h+OH/NBGkzPfAZPkW/4fWT3Sk1Ce5kDlnvpbbY8Vv/BK2nNucRu4FvBmtff5q5rqRSH3rw==; 3:uIp5mb4RJP6YuRdfJGZ6FOVBxg6G20e90sMG9ufKgAsKdIcr32y13bia+EcNLO9pZMsK3jEHol4tw0EtcLLZmdmOF87OgR1HfSbniXQE9x6XE6SFYsmaE6bLAfzbsWY6; 25:dUuowni5HoNkVF1T6CCwwj/h0hFeMyo+a65aeuyJuCPOBDNianv9jq+22JEKjAUdOo/yrnV5RTNGzgJU1wibl5DdVrnuYxnI/2iApY6ZNOsuVHBmgPDRHyxuPnZ1qvT2JkZj34i2WrrLsDsGgXD5n2CqiskqVD44xLuNhV+LMBxjSnYCC6hRsH2a8FPiRfkbMp5b+QUB3kXAwrfX3/Qecj5rkFSWcxCiaPi4jDxoc4Np/aIOaavNos3srCNk8P34kXnmUpsEaSsYtKqcMmAuhA== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR12MB0433; X-Microsoft-Exchange-Diagnostics: 1; BLUPR12MB0433; 20:ggG10eYnK8Iu6XkmvnoGymGvMXT29UqQ8cwOO8utGVD78kRDjuR2ppa/fl0xWzDkNjgldmjgDoe8Y3msweKyR24Gtzvyatmzsu8oRvRH6tkXikjy1S2kQxrkAHKS4CzRQuihBy4nSj4Yrr2JgZL+x2KuO4LCiz/FnVy0B2AEg+ugcVxciaTRaEfsB0Pym1NEwSVnrn/GHfXHovDleK2clcIRED4yD/Ghga60M3n8IwdIxsT/aDGO5WVOHV/Cxt3iBKB9+bC0NWbOiCX30TlB/yVsJRiaxJBniNyckjFWAEhD8T6C9IeFJsTOSui2Cca6ZePpsBJS7jgbOtpyCLDwH8a7Q8YKi678oEMg6jHHcGJJj+3DWuyRH4tCsHlmXuWUybQpojX/dT8RCIOebhDPfXNrWy+SiVVjp3bIVmRGKNvSDA7BU90325NmGQHZgWOZ770tP61sZpnqwh7xsTk4RcYi0JRvEPPVjCbkS+V9BHTxu7OBGoZtJHkPNTNxub+O 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:jkXLWURY+eR6JLMkAnN5TZXMchG1GFdUmLmf04v5/pYodbOwpvXoAaB4pEjmypjbhkMUhiAc5Z7Dh4DqODCfDeTTrNHMwgiTDincqdAfIwDrWejlhne6gPRxjrc5xVRT2JQEHYgVJZ5/ZHMQ7ax8R8QCTYR+RhwjEOK1gApvY32X+s3XpQMAj59ywyBOM7RzvclUSFNKjhFhJonEbRDTd4SC1gm55v8/3x7+QZTboCnQk+B/D6MD8oPNAajF+G6Ei+5vDvJC3OgpzwEk8YBgAiWGU8ztjzE/ccQRwAUwL4lPUdCDmatd6uB36VPaoYBY5D/ItIf+26oEXbR741x86lfjlbK4tw7ErHfNZc6vVp7gG5fqgiHp5pRyO7jfZVmshaTAdJ7PKcsiNXzu2+AM06mJxbi9rEiWiHuT5VUptLM02r+nzPRrT5yaOToCKwPipRSwyIztW/NjWWmxB5WKsg== 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:pD+Fhv7n9FSX6hFftw8mOWNKf4RTZSRZvsGFSV7Ms?= =?us-ascii?Q?svnONL8jREFJW8h5HphO9lvN3EapHsAuIMSBprYbOtTMpi5ZYcp/mHQ9CgYr?= =?us-ascii?Q?7wCJZ36xK99uSX7wHTiOngllhwAXZjgWqhvmA6btfLXOOSFF9o0HQ6mhrmqA?= =?us-ascii?Q?P7Rqoc4jijjA9e9ETRhPgwKh9iSI+F4hiofE1YRNqE9b0BowAQ8KKh3mXC7C?= =?us-ascii?Q?yIpgWcGaEugew9nX4uUsXGmJXoJWhjBqzmfSeY62u6SNlr4+3fxesPEreI9t?= =?us-ascii?Q?FHQU0e7YiRsy8yYpDQPSZL7DWGB6sZouY5KK6PaB5FgUkT2Xw+UrJ/QjlQ8a?= =?us-ascii?Q?JpvkzPJAplsJPr7646gOy6+cfpnlvnoWgl4gK+t9MXRCsFRg0N0G50lshVEe?= =?us-ascii?Q?BGOQW1RzqU4aIMiFEPkBzPyfCLnFxP4eT+orHVBhpM17EEw8yiTwFs7BlWWW?= =?us-ascii?Q?ZckmXoL3naxBdkgQGmeUoOnhK6TrReiItQQlpn2cYj7ydnQQK24auB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bpi8y51HXakhwAZ7hOqL2hbxowCDBbtZdgsFqwbGrt5RISxXcOUVjy7JjOyDtXGR/tQ+UcPlUrXLFT/Hy6EAOE0Ie78HrLz3l X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Dec 2015 16:55:56.0313 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR12MB0433 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@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=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 replaces the struct device_node with struct fwnode_handle since this structure is common between DT and ACPI. It also refactors gicv2m_init_one() to prepare for ACPI support. The only functional change is removing the node name from pr_info. Reviewed-by: Marc Zyngier Signed-off-by: Suravee Suthikulpanit --- drivers/irqchip/irq-gic-v2m.c | 53 ++++++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/drivers/irqchip/irq-gic-v2m.c b/drivers/irqchip/irq-gic-v2m.c index 87f8d10..779c390 100644 --- a/drivers/irqchip/irq-gic-v2m.c +++ b/drivers/irqchip/irq-gic-v2m.c @@ -55,7 +55,7 @@ static DEFINE_SPINLOCK(v2m_lock); struct v2m_data { struct list_head entry; - struct device_node *node; + struct fwnode_handle *fwnode; struct resource res; /* GICv2m resource */ void __iomem *base; /* GICv2m virt address */ u32 spi_start; /* The SPI number that MSIs start */ @@ -254,7 +254,7 @@ static void gicv2m_teardown(void) list_del(&v2m->entry); kfree(v2m->bm); iounmap(v2m->base); - of_node_put(v2m->node); + of_node_put(to_of_node(v2m->fwnode)); kfree(v2m); } } @@ -268,7 +268,7 @@ static int gicv2m_allocate_domains(struct irq_domain *parent) if (!v2m) return 0; - inner_domain = irq_domain_create_tree(of_node_to_fwnode(v2m->node), + inner_domain = irq_domain_create_tree(v2m->fwnode, &gicv2m_domain_ops, v2m); if (!inner_domain) { pr_err("Failed to create GICv2m domain\n"); @@ -277,10 +277,10 @@ static int gicv2m_allocate_domains(struct irq_domain *parent) inner_domain->bus_token = DOMAIN_BUS_NEXUS; inner_domain->parent = parent; - pci_domain = pci_msi_create_irq_domain(of_node_to_fwnode(v2m->node), + pci_domain = pci_msi_create_irq_domain(v2m->fwnode, &gicv2m_msi_domain_info, inner_domain); - plat_domain = platform_msi_create_irq_domain(of_node_to_fwnode(v2m->node), + plat_domain = platform_msi_create_irq_domain(v2m->fwnode, &gicv2m_pmsi_domain_info, inner_domain); if (!pci_domain || !plat_domain) { @@ -296,8 +296,9 @@ static int gicv2m_allocate_domains(struct irq_domain *parent) return 0; } -static int __init gicv2m_init_one(struct device_node *node, - struct irq_domain *parent) +static int __init gicv2m_init_one(struct fwnode_handle *fwnode, + u32 spi_start, u32 nr_spis, + struct resource *res) { int ret; struct v2m_data *v2m; @@ -309,13 +310,9 @@ static int __init gicv2m_init_one(struct device_node *node, } INIT_LIST_HEAD(&v2m->entry); - v2m->node = node; + v2m->fwnode = fwnode; - ret = of_address_to_resource(node, 0, &v2m->res); - if (ret) { - pr_err("Failed to allocate v2m resource.\n"); - goto err_free_v2m; - } + memcpy(&v2m->res, res, sizeof(struct resource)); v2m->base = ioremap(v2m->res.start, resource_size(&v2m->res)); if (!v2m->base) { @@ -324,10 +321,9 @@ static int __init gicv2m_init_one(struct device_node *node, goto err_free_v2m; } - 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); @@ -359,10 +355,10 @@ static int __init gicv2m_init_one(struct device_node *node, } list_add_tail(&v2m->entry, &v2m_nodes); - 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)); + pr_info("range[%#lx:%#lx], SPI[%d:%d]\n", + (unsigned long)res->start, (unsigned long)res->end, + v2m->spi_start, (v2m->spi_start + v2m->nr_spis)); return 0; err_iounmap: @@ -384,10 +380,25 @@ 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("DT overriding V2M MSI_TYPER (base:%u, num:%u)\n", + spi_start, nr_spis); + + ret = gicv2m_init_one(&child->fwnode, spi_start, nr_spis, &res); if (ret) { of_node_put(node); break;