From patchwork Mon Jul 15 10:22:02 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep KarkadaNagesha X-Patchwork-Id: 2827356 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2DA56C0AB2 for ; Mon, 15 Jul 2013 10:22:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 101762017E for ; Mon, 15 Jul 2013 10:22:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2EB422017A for ; Mon, 15 Jul 2013 10:22:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755128Ab3GOKWY (ORCPT ); Mon, 15 Jul 2013 06:22:24 -0400 Received: from service87.mimecast.com ([91.220.42.44]:33619 "EHLO service87.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754923Ab3GOKWX (ORCPT ); Mon, 15 Jul 2013 06:22:23 -0400 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Mon, 15 Jul 2013 11:22:21 +0100 Received: from e103737-lin.cambridge.arm.com ([10.1.255.212]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.0); Mon, 15 Jul 2013 11:22:18 +0100 From: Sudeep.KarkadaNagesha@arm.com To: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: cpufreq@vger.kernel.org, arnd@arndb.de, olof@lixom.net, lorenzo.pieralisi@arm.com, rob.herring@calxeda.com, grant.likely@linaro.org, rjw@sisk.pl, viresh.kumar@linaro.org, gregkh@linuxfoundation.org, gregory.clement@free-electrons.com, kernel@pengutronix.de, shawn.guo@linaro.org, linux@arm.linux.org.uk, Sudeep KarkadaNagesha Subject: [RFC PATCH 01/11] driver/core: cpu: initialize of_node in cpu's device struture Date: Mon, 15 Jul 2013 11:22:02 +0100 Message-Id: <1373883732-26303-2-git-send-email-Sudeep.KarkadaNagesha@arm.com> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1373883732-26303-1-git-send-email-Sudeep.KarkadaNagesha@arm.com> References: <1373883732-26303-1-git-send-email-Sudeep.KarkadaNagesha@arm.com> X-OriginalArrivalTime: 15 Jul 2013 10:22:18.0331 (UTC) FILETIME=[2F1A6AB0:01CE8145] X-MC-Unique: 113071511222104101 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 From: Sudeep KarkadaNagesha CPUs are also registered as devices but the of_node in these cpu devices are not initialized. Currently different drivers requiring to access cpu device node are parsing the nodes themselves and initialising the of_node in cpu device. The of_node in all the cpu devices properly needs to be initialized properly and at one place. The best place to update this is CPU subsystem driver when registering the cpu devices. This patch introduces a new function arch_of_get_cpu_node and uses it to assign of_node. The definition of this function can be overridden by architecture specific implementation. Signed-off-by: Sudeep KarkadaNagesha --- drivers/base/cpu.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index a16d20e..4b3047a 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c @@ -28,6 +28,24 @@ static int cpu_subsys_match(struct device *dev, struct device_driver *drv) return 0; } +/** + * arch_of_get_cpu_node - Get device node associated with the given logical CPU + * @cpu: CPU number(logical index) for which device node is required + * + * The only purpose of this function is to retrieve the device node for the + * given logical CPU index. It should be used to intialise the of_node in + * cpu device. Once of_node in cpu device is populated, all the further + * references can use that instead. + * + * CPU logical to physical index mapping is architecure specific and is built + * before booting secondary cores. Hence this function is marked __weak and + * can be overridden by architecture specific implementation. + */ +struct device_node * __weak arch_of_get_cpu_node(int cpu) +{ + return NULL; +} + #ifdef CONFIG_HOTPLUG_CPU static void change_cpu_under_node(struct cpu *cpu, unsigned int from_nid, unsigned int to_nid) @@ -289,6 +307,7 @@ int __cpuinit register_cpu(struct cpu *cpu, int num) cpu->dev.release = cpu_device_release; cpu->dev.offline_disabled = !cpu->hotpluggable; cpu->dev.offline = !cpu_online(num); + cpu->dev.of_node = arch_of_get_cpu_node(num); #ifdef CONFIG_ARCH_HAS_CPU_AUTOPROBE cpu->dev.bus->uevent = arch_cpu_uevent; #endif