From patchwork Wed Dec 9 01:48:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Suthikulpanit, Suravee" X-Patchwork-Id: 57918 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp385450lbb; Tue, 8 Dec 2015 17:49:59 -0800 (PST) X-Received: by 10.98.13.25 with SMTP id v25mr9418804pfi.123.1449625799089; Tue, 08 Dec 2015 17:49:59 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 28si8854250pfk.134.2015.12.08.17.49.57; Tue, 08 Dec 2015 17:49:59 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752919AbbLIBtT (ORCPT + 28 others); Tue, 8 Dec 2015 20:49:19 -0500 Received: from mail-by2on0058.outbound.protection.outlook.com ([207.46.100.58]:8224 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752623AbbLIBse (ORCPT ); Tue, 8 Dec 2015 20:48:34 -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 BY1PR12MB0437.namprd12.prod.outlook.com (10.162.147.139) with Microsoft SMTP Server (TLS) id 15.1.337.19; Wed, 9 Dec 2015 01:48:29 +0000 From: Suravee Suthikulpanit To: , , , CC: Lorenzo Pieralisi , Will Deacon , Catalin Marinas , , , , , , , , Suravee Suthikulpanit Subject: [PATCH v5 4/5] gicv2m: Refactor to prepare for ACPI support Date: Tue, 8 Dec 2015 17:48:05 -0800 Message-ID: <1449625686-5594-5-git-send-email-Suravee.Suthikulpanit@amd.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1449625686-5594-1-git-send-email-Suravee.Suthikulpanit@amd.com> References: <1449625686-5594-1-git-send-email-Suravee.Suthikulpanit@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: BLUPR05CA0068.namprd05.prod.outlook.com (10.141.20.38) To BY1PR12MB0437.namprd12.prod.outlook.com (25.162.147.139) X-Microsoft-Exchange-Diagnostics: 1; BY1PR12MB0437; 2:zx7AU5NAezfhdrInvChi722y5J8RNa5Bq2FeEQ6vIl9vVCoRw1SakHfg8DwcflLmGHh7CKs7MB1YQVv7un0XW+KCpa6C2n2HYkLNKJjwjBjRYqrQeBKwv2ywxfNw3UtDKEaLt3bE8e+eGCmlc0uPRw==; 3:vkpN9lc2dYkDAx7ZCN/EMEN5dWcdi9D/wBT9YXsaBxrW54RPCTAjfQqL1xWbRI9yGUekMl8zNdLqjp4qPNLrdw5a9ARnO911urp8rNR4ywbfU/Q5scekindLVIb+hH+r; 25:axLYSWzJqCTkXT+CrorF5xFq3ED9spVj0LlXjkbRsq0eRuAKOwTOZFYX73Rx2YNzq7EyITIVLNik8zdQj5AoN0HBD7G4FMCvgmLJ6ySnvte8n7cSXA22uoyl5+FpAftmRqLxXqqSHXbgFZ9Q4RRXmlyPl9dh1VvYyhm7PXxS2CaHIy8z2Sj+pE7wSoS05JPPRKGrk2RwWJ1KpeHeO9ECdX4dzIGHjUplYmcYdv4WPqQBrZRtqH15ZXLFrDaBq695lgF0kels9h5RSUO1IkF4sQ== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY1PR12MB0437; X-Microsoft-Exchange-Diagnostics: 1; BY1PR12MB0437; 20:q5j7NN3NP/oY342BrLMWVNlPevEe8l0za7iY/I8wWSinkMFpIj2nv/VZEpFcy52k1fW4IwAvd6gX54hpO64Aw/3JlxZmOVX2UBbF/8BprjLDA1gGazHwmCiaNEEEGX0VkoRwL4zMc/rqLCYqKp2GL1dUtpoT+hCkl9L+Xtpzw2oAUQuF8Zpp25/nlbtdusjvKjIwbMb+sr9ykK+8C4OpVhTI3xALva9HUom2h3VxC0XFQLLOqSPOFrgVa8/PUZY47yiDXPxxvZnuctPaTopiMb97JrAMt93YR399o+6wcg7EYikOWZdcd5XTJVO/kvsBB3X9zsO07SFjn1cTtwaGd7gsSt1WAnM8pPgspiHte0jRLowcXnGNuZqwsHdww44uQ6llJFjUZULYdzdYXgUV0trkTCLRMh4t5ltk/bdroZacNI7AA2AIl0xipquHPdRbnxkkcZBJOAr2zAUqT5HTTOar1EG38g9ZwJKBb44IhAF3bMCnN2UnVHhENf0cmvzY; 4:eBUVULLku4MAIDeG//NQkvzJZX6/sxlcvObMvr49Zv0XI49mJ84Zqe/I/4zXH9oZuo489hVGQVlh/ZYhIqP6d+3I8Ws8Z8ubTZL5DPZCHxfmU49REprEzk9/T3DZZDcuuUUyk6DgGZM8NH3v60tLYSasLh+TvSfLIQLKMHysq/nxJDaKT924MQKrWO6esL2CmhVZHmt03XDIxKli6QHMMkV+kHpLN/3rKUaumWizPFOMEKsJcvv78YuMe2bmOb8DVR5Bu+7N89EATiOw+bh+vWdXBg9z7IKODlVuV+e6hrhjcjoucw8nbsG8q7FLVODUyPN6S/G9wng65AzxLE5EZxf/Hgy7FcpxWcMrQMnYj0hTdTmFFIiXBJDnUPRjeJROIZkEnFCpUVne2H7Rz0RF37gml1nO3a3asi9C48bxWVU= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(520078)(5005006)(8121501046)(3002001)(10201501046); SRVR:BY1PR12MB0437; BCL:0; PCL:0; RULEID:; SRVR:BY1PR12MB0437; X-Forefront-PRVS: 0785459C39 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(189002)(199003)(36756003)(77096005)(2950100001)(86362001)(229853001)(92566002)(101416001)(53416004)(122386002)(97736004)(2201001)(42186005)(87976001)(5001770100001)(19580405001)(5004730100002)(50226001)(48376002)(19580395003)(1096002)(47776003)(189998001)(50986999)(66066001)(5003940100001)(106356001)(5008740100001)(6116002)(50466002)(3846002)(586003)(76176999)(105586002)(40100003); DIR:OUT; SFP:1101; SCL:1; SRVR:BY1PR12MB0437; 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; BY1PR12MB0437; 23:wceuIUPS7Syht4WxoZxoBF27uaQOqVVe2XO/HETQZ?= =?us-ascii?Q?kdp4lzlMfQ61QemovGykHJLkldIit3XQCSLLRYEFwpp4m5ebgYobC9oLoGff?= =?us-ascii?Q?i/gUSbUYoKlV7Is2nR40rFiCxg4XvJo2EVdR9dbWmI3PRxllSCbuGCCHtfIV?= =?us-ascii?Q?0B3CcqDm/hsVxs8wGp6DssWjpJ0wXiRiYYlSbKwFJ3nOSApueTo7UUseZGhF?= =?us-ascii?Q?nzOcNc09QNFAyqU0WGd3xCNvreSj3kkAQCMUiedZtSq5Mfzgp0g4HivZh20U?= =?us-ascii?Q?2DMoPl+UsjGNBD/kIzkNi2gQmBJQ4kIFc/sfguJbGoh7BLxtzOv6pOroqTnp?= =?us-ascii?Q?fVYOfrfKT0XasDp9TsdebWrOV/PfNu1tO7i4SPmgLXBNsuppreAhtavPQi6I?= =?us-ascii?Q?+p5zDkrh+Oe+sMTJxG59aPVnfP8xcsijzsOAtLwhHtR/2vAitucQhTcTm3qx?= =?us-ascii?Q?to+9pUhh5w8KC9ZLvOCXXPz5bf3tX21x8L2TR5PQo7vsWRRB7PuQwqY2I2I7?= =?us-ascii?Q?XdzaInUNg3GQThIz30JKEqiCPo+IYXgP4vfOA7GwVlHC3YVTulovykAHpRkw?= =?us-ascii?Q?6+c2zxbVvu7AEqfA7t1nvR45mMCAvqnlJHcRxLbddaBSUO6+VoVyZI1as+KQ?= =?us-ascii?Q?gaNLmtKsURDged/Kawl2UginPHWtF+/pBdf6bZymHfrb6qqgE0czG3B9Lve/?= =?us-ascii?Q?HK3JPh5QA9VkioheRrOMTAIk8FCFSLUTJzg5OLOoY2redg/+BwVdOclSDpWQ?= =?us-ascii?Q?kJugiegMqKhQmVe4O/UBTmbrATaHHtNUc2QzdbeF7NnQm0UPS0gxoUil5jEx?= =?us-ascii?Q?N7Zcl9tPZsFxxi0giJXutXJoCzbTLL5+ZaMVh1lo+chJQwFhaDixgz0f0ATN?= =?us-ascii?Q?pGSQnnOvVp+41CKwtU40IG9bfJlN4J2pd4LhkvVLNIXp47RKf7ZCfHD8PSIR?= =?us-ascii?Q?ogoiWItq2ncR/G3loGBcoHateKX0iRko5eYI62aPvreoq2FMkK1A8/IgIlaf?= =?us-ascii?Q?7I=3D?= X-Microsoft-Exchange-Diagnostics: 1; BY1PR12MB0437; 5:ZtxpVea5yVHRbKJypOi4MngIaVhO5pxdUAxDF/v6qNWUFJmT64kqj9qVpFsS/PXyE9lKAiQBIKZdjXTjQqoze114feZF1JWP1G9hIyu1CIO3Kd3d8Vu2p9bNI1VL7TQgwOeYlvxL7uvK/U7HgSp7iA==; 24:DypBb1l1trYcr4PdJdM7hMKpuaBLojl5uH3l5K/XzP01yRMoZbE2ez9KYNCcRzC8NOB4TT87yf3OXVynWILXu476v0nqIW0fRy02wS5q72s=; 20:Bza3Ww+MA2mV2AyLapRdlnKtki1pER8TfzxBOYncMQEGdA+KbMrZuHUNr26bb9MA8ANSqcXjWiSQH1qaS03SUlsdiBx7RnV2L904rRk8zlHZT+7ncEAHmvknKCEegD0J//msv92dd93/YeGzZ9WR8fMWZ+2ivWyAYL8V9/yTag6sWLgj9PJtxjz+hbPBCLhuJJR/CeCLv2lMfeBv8q2K1mXR86PYxqWquOPRbITChswFmqhxEcds/NLI44FhPA6W X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Dec 2015 01:48:29.3505 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR12MB0437 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ 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;