From patchwork Tue Dec 8 20:19:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Suthikulpanit, Suravee" X-Patchwork-Id: 57902 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp253613lbb; Tue, 8 Dec 2015 12:19:41 -0800 (PST) X-Received: by 10.98.17.131 with SMTP id 3mr7532115pfr.57.1449605981880; Tue, 08 Dec 2015 12:19:41 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h7si1194345pat.78.2015.12.08.12.19.41; Tue, 08 Dec 2015 12:19:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752456AbbLHUTb (ORCPT + 6 others); Tue, 8 Dec 2015 15:19:31 -0500 Received: from mail-by2on0067.outbound.protection.outlook.com ([207.46.100.67]:10432 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752661AbbLHUT3 (ORCPT ); Tue, 8 Dec 2015 15:19: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 CY1PR12MB0443.namprd12.prod.outlook.com (10.163.91.21) with Microsoft SMTP Server (TLS) id 15.1.337.19; Tue, 8 Dec 2015 20:19:25 +0000 From: Suravee Suthikulpanit To: , , , CC: Lorenzo Pieralisi , Will Deacon , Catalin Marinas , , , , , , , , Suravee Suthikulpanit Subject: [PATCH v4 4/5] gicv2m: Refactor to prepare for ACPI support Date: Tue, 8 Dec 2015 12:19:04 -0800 Message-ID: <1449605945-10707-5-git-send-email-Suravee.Suthikulpanit@amd.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1449605945-10707-1-git-send-email-Suravee.Suthikulpanit@amd.com> References: <1449605945-10707-1-git-send-email-Suravee.Suthikulpanit@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: BLUPR01CA061.prod.exchangelabs.com (25.160.23.51) To CY1PR12MB0443.namprd12.prod.outlook.com (25.163.91.21) X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0443; 2:1q5laiPdSiW0ok08GdQJxoJ31h8TnCP6CKAB4GheWMnY1ZEC3z8AZ4S//ehTkMYqoK821JxIbOVO3XxCwsuOXW0shreeYO/O+RrGXC+sdOBf/tUxNqqLdpVeCHUMzYJShazlvYHjIP7gfzkxPYb06g==; 3:DiPCu9tGsDKVVzcvHaOMa70HUnNi9cp5OorUetBYS0DzPZ9Xf3sbiLdP/vjtABn3gMpwTRf1MsIzbhr2D12T/LeaIYatpTvV0OJ44tV2qGUHsez0GVAT3i8LE3YhhywY; 25:BJswOdd5l+gYp0Lky9m6BIyE/WuKfLcL2onrHS+h+dC3gfJBTS1DItKF8QmVGLbO8b/QYlMsZ+ERlpL4I0+4AKP5Q2kTooaZZw7wJatWojqXJ6CZsfDdFilxrfN7zVa/39TocUuyP4MSTBaVbyTsu+FNFdnrQYPu3ru2EQj3DntyuzF07EwvL0ZZ3xadZ6UtLAD7meY6tcKt4k+Ulb/lPlTO6AOYEGe1ztFe6JyKOY8HYVpl5bv87Mk+yGe7ADAiar2fQEzSR0llNWxDquF7Ew== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR12MB0443; X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0443; 20:bpqGProsNuEXZqy4gh9Ja4gw90VQrdS9+puFR2+SZo+Ww7DmmjWHX8bPRddtgqVWD00mPkKu4GUR9tcRdiIQbm7RypWJ6V2rQNY2m3LzsJiCvoLCbEka3/u3+ejnBTYzV9xhSN9OP+te/hEwXpAzgdO93dCXgAySjFq9SJX4VP1TGxTiLqbyCwqOIp/LUq7V64sue0GdG4rdSsVt+t+zbynIP8T6sDQW6IkwbGNta5WIr6uHTOK9vbF/BPlIqCyz8nkqUPR8z6SWQKY4gz2jIkvV9aKXZPhDb+uEVZC6P+gQx4ldC3tkW1q2rGZYLNIXikdeaY3fXz0lW+WR+fRwG3e7v8QIaVHFCiNXpB2JhKfOkpwfolMBgTVQqpWiAGVhjbRRzVdSDLTv0MLL5aZFZoBQgNmYNpcGAi6hppMvE7rh3M7yEZW2g9GyrML3hhe2pz5m3otxrLPzURh5VopCDxrVj8cuqmSG3EVIlgSkAhGDp5f3nroPCf7lXRTI5Nkj; 4:nEBlrsOuUBd1HXYRDIlxSzI2/u0/E92kcWQ4GYEig/GHoE8yNDXhMl6mP0kt083w1QiCJissNfZHAmSzLCsOilJmUvpM1NOiZm327+gdZr/AhqgX1gPp3RZ47xM6bYfJ8yXEab+f7dY1mMiOFf0wHm33KB8CTtMuBUophyM/xz7mpwSWHdrKDkDPxD4GgLgFOvJ2Jfmaq1YMaRkBICVFNc67BcDsMjqjF16bSiSgL+UBjV485/M72atMD2DgjOLPyVzBHUw07CG9iqtNMD8wgiP1hl2XbadeYGYqeAl4cL9Qmc0VfBQ05efT9XL5zKqrFoVlZLozGM++pwYiSlDkU0F95RKe4aHNlHaPuJWqk4zFAnyLRPkbV2gW7SrZePb+iAS9IfBuILQjA4Ir159CkibsdJ3EOB7Tjbcq42lX/7s= 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)(10201501046); SRVR:CY1PR12MB0443; BCL:0; PCL:0; RULEID:; SRVR:CY1PR12MB0443; X-Forefront-PRVS: 0784C803FD X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(189002)(199003)(76176999)(3846002)(6116002)(87976001)(5003940100001)(5008740100001)(48376002)(122386002)(189998001)(77096005)(2950100001)(586003)(5004730100002)(105586002)(229853001)(1096002)(5001770100001)(106356001)(19580405001)(53416004)(36756003)(42186005)(50986999)(50226001)(19580395003)(2201001)(97736004)(86362001)(47776003)(40100003)(50466002)(66066001)(101416001)(92566002); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR12MB0443; H:ssuthiku-fedora-lt.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A: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; CY1PR12MB0443; 23:Tw9gYTzkxcqKQ9fWD7SpO3nw4OUz7Itju9KT6MdHu?= =?us-ascii?Q?w4LDRssCrb4G2H8hDZzml3J0+Cy0WgTKD66zn3dSYcqb6yekWGKWGtXyE+mx?= =?us-ascii?Q?6rSIxLRKc/iZDRTPg6DaR4ZdgJUl3LYpaMEq4tzj417pOK6nkibshDQKgYhD?= =?us-ascii?Q?+VTLYpDjKM8fSuCVThefYK1UHKoEDFTjsOWPCRqWuWNVKeJ5nXfPX9jquyKg?= =?us-ascii?Q?AJVM2xd9qmcWklY70A69g4DD+uzM8ez/ONVLhH5tyHoxpJ3eq/uco932HHBS?= =?us-ascii?Q?gBUpuHmsymkhUyFEI1MRzq2bbQk/mDYphmD8wf/few/PgCrLKoVkNgNNL+A1?= =?us-ascii?Q?XyBIoInTDz/HsUpZAevMcDP50544FpZYmYjPVuTJJoIK1jseQzFiX000T/BM?= =?us-ascii?Q?RJc6KHHVg5VBEAslBcpviL29V/UDUoyTt9eeAIx5MBgDZ5QHEr/M4g6WsrqP?= =?us-ascii?Q?DXTvVly3h204zNRm8liVsVtMqprgG4oTHRRrpwcawivIlfKFzt3HeQOI+XcP?= =?us-ascii?Q?Ilbu+FMjpe8/Q28zzgMT7/jKAp5UkdIXFaiBL8HwVbnBP1FK5XxG3n8AbaBo?= =?us-ascii?Q?dKJxOUh7N1el/6KQVR78ETQCVrRqBMTp5h0/84mStGlJCImc341iQvOHZp0/?= =?us-ascii?Q?DLuFjb9Afj00xJpYn31hgYbC6EfU48QjVR4Ku7HXVRsSjv3SboHSBecMSdO8?= =?us-ascii?Q?SiBLkEXiAtN3biS93AjFtge9HFYN3miZ/gIW3x57ZXmYnr9COw1sdPipuddv?= =?us-ascii?Q?X3EboCvE6DvBLI8deq/crvzmenDMweMhq8LzVo31oS6rESZ6s/+W0+6ek4Dn?= =?us-ascii?Q?Ke+qzV7BBUp5mCDpiwyNTWggdJPjefBiO/O7Fyho+M13p19RXonANMtye/fn?= =?us-ascii?Q?4rMC4hdG0tYwSzfRMzVJctjyro3mYosjx5nTCU7gKG0cFW+1tKQvr9jGybVe?= =?us-ascii?Q?9TmZx4V00KYqFYn+CwrmhgFeZWiTwcCX+AGxXCeBb+fP+ddw+wdb3w+0xZ8N?= =?us-ascii?Q?0w=3D?= X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0443; 5:Cj6lCEVbVjnIkPa6hZbxEEuG7xRSJ5Xa39W9yNAAaIWgrQVKCTVuUASDNESKCXb39BOmwCpjR8BpiUzErJ60TvmnrPWkT30SYxotC/nYHK7r2djKXzWrtY7LKHCBV2tXed4ovrET4/mtoJMh8uG71w==; 24:p67GvoFQraIcaxdFlhwONQipdxuJUi+4gj96IrO1x9oPZHkSAeAS73z24J1E5gi4VeHkK/R5t7avIf2ci+K8IEyur9UmHxwzFMHLvpwymK0=; 20:G3v3V7IsZqQZ83npnvlwqIK/xlqpITRUrkQAhncZKnBBCrZAFARn+Lrk4Jxe3zd0JC42pHpnCH82qm5Vl3cn9inO00JN8fCC3BcbFec2T6Scu57zCxqk4AiNvP69bSqGwpaHrePVIQ6tlomng9RXd1VpKDsxNMfhl7qNO1gjESbFoVpy42kuEcGKilzFNMzu4h8L47PcTdlbvA2uwb7cGMW0huQt3ViXOA+VkNPzE5G6ZXptWgfBrFoS0E9bYscr X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2015 20:19:25.1853 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR12MB0443 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 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. There should be no functional changes. Signed-off-by: Suravee Suthikulpanit --- drivers/irqchip/irq-gic-v2m.c | 57 +++++++++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 21 deletions(-) -- 2.1.0 -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/irqchip/irq-gic-v2m.c b/drivers/irqchip/irq-gic-v2m.c index 87f8d10..7e60f7e 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,11 +296,13 @@ 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; + const char *name = NULL; v2m = kzalloc(sizeof(struct v2m_data), GFP_KERNEL); if (!v2m) { @@ -309,13 +311,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 +322,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 +356,13 @@ 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)); + if (to_of_node(fwnode)) + name = to_of_node(fwnode)->name; + + pr_info("Frame %s: range[%#lx:%#lx], SPI[%d:%d]\n", name, + (unsigned long)res->start, (unsigned long)res->end, + v2m->spi_start, (v2m->spi_start + v2m->nr_spis)); return 0; err_iounmap: @@ -384,10 +384,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;