From patchwork Tue Oct 1 16:46:10 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep KarkadaNagesha X-Patchwork-Id: 2971091 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A006C9F288 for ; Tue, 1 Oct 2013 16:45:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 534C920424 for ; Tue, 1 Oct 2013 16:45:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 045482041C for ; Tue, 1 Oct 2013 16:45:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752223Ab3JAQpv (ORCPT ); Tue, 1 Oct 2013 12:45:51 -0400 Received: from service87.mimecast.com ([91.220.42.44]:38832 "EHLO service87.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751095Ab3JAQpu convert rfc822-to-8bit (ORCPT ); Tue, 1 Oct 2013 12:45:50 -0400 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Tue, 01 Oct 2013 17:45:48 +0100 Received: from [10.1.207.34] ([10.1.255.212]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.0); Tue, 1 Oct 2013 17:45:46 +0100 Message-ID: <524AFC52.8080201@arm.com> Date: Tue, 01 Oct 2013 17:46:10 +0100 From: Sudeep KarkadaNagesha User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.0 MIME-Version: 1.0 To: "cpufreq@vger.kernel.org" , "linux-pm@vger.kernel.org" , "devicetree@vger.kernel.org" CC: Sudeep KarkadaNagesha , "rob.herring@calxeda.com" , Pawel Moll , Mark Rutland , Stephen Warren , "Rafael J. Wysocki" , Nishanth Menon Subject: Re: [PATCH v2 2/5] PM / OPP: add support to specify phandle of another node for OPP References: <1380634382-15609-1-git-send-email-Sudeep.KarkadaNagesha@arm.com> <1380634382-15609-3-git-send-email-Sudeep.KarkadaNagesha@arm.com> In-Reply-To: <1380634382-15609-3-git-send-email-Sudeep.KarkadaNagesha@arm.com> X-OriginalArrivalTime: 01 Oct 2013 16:45:46.0287 (UTC) FILETIME=[AD2263F0:01CEBEC5] X-MC-Unique: 113100117454800301 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.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 On 01/10/13 14:32, Sudeep KarkadaNagesha wrote: > From: Sudeep KarkadaNagesha > > Currently we need to replicate the OPP entries in all the nodes even > though they share OPPs being in the same clock domain. > > Few drivers like cpufreq depend on physical cpu0 node to specify the > OPPs and only that node is referred irrespective of the logical cpu > accessing it. Alternatively to support cpuhotplug path, few drivers > parse all the cpu nodes for OPPs. Instead we can specify the phandle > of the node which contains the OPP tuples. > > This patch adds support to the new property 'operating-points-phandle' > which specifies the phandle pointing to another node which contains the > actual OPP tuples. > > Cc: Rob Herring > Cc: Pawel Moll > Cc: Mark Rutland > Cc: Stephen Warren > Cc: "Rafael J. Wysocki" > Cc: Nishanth Menon > Signed-off-by: Sudeep KarkadaNagesha > --- > drivers/base/power/opp.c | 15 +++++++++++++-- > 1 file changed, 13 insertions(+), 2 deletions(-) > > diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c > index ef89897..bb6ff64 100644 > --- a/drivers/base/power/opp.c > +++ b/drivers/base/power/opp.c > @@ -708,12 +708,20 @@ struct srcu_notifier_head *opp_get_notifier(struct device *dev) > int of_init_opp_table(struct device *dev) > { > const struct property *prop; > + struct device_node *opp_node; > const __be32 *val; > int nr; > > - prop = of_find_property(dev->of_node, "operating-points", NULL); > - if (!prop) > + opp_node = of_parse_phandle(dev->of_node, > + "operating-points-phandle", 0); > + if (!opp_node) /* if no OPP phandle, search for OPPs in current node */ > + opp_node = dev->of_node; > + prop = of_find_property(opp_node, "operating-points", NULL); > + if (!prop) { > + dev_warn(dev, "node %s missing operating-points property\n", > + opp_node->full_name); > return -ENODEV; > + } > if (!prop->value) > return -ENODATA; > > @@ -740,6 +748,9 @@ int of_init_opp_table(struct device *dev) > nr -= 2; > } > > + if (opp_node != dev->of_node) > + of_node_put(opp_node); > + There are several exit paths on error conditions where we need to do this. I missed them all. Here is the updated patch: -->8-- From: Sudeep KarkadaNagesha Currently we need to replicate the OPP entries in all the nodes even though they share OPPs being in the same clock domain. Few drivers like cpufreq depend on physical cpu0 node to specify the OPPs and only that node is referred irrespective of the logical cpu accessing it. Alternatively to support cpuhotplug path, few drivers parse all the cpu nodes for OPPs. Instead we can specify the phandle of the node which contains the OPP tuples. This patch adds support to the new property 'operating-points-phandle' which specifies the phandle pointing to another node which contains the actual OPP tuples. Cc: Rob Herring Cc: Pawel Moll Cc: Mark Rutland Cc: Stephen Warren Cc: "Rafael J. Wysocki" Cc: Nishanth Menon Signed-off-by: Sudeep KarkadaNagesha Acked-by: Nishanth Menon --- drivers/base/power/opp.c | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) * Each OPP is a set of tuples consisting of frequency and @@ -724,7 +735,8 @@ int of_init_opp_table(struct device *dev) nr = prop->length / sizeof(u32); if (nr % 2) { dev_err(dev, "%s: Invalid OPP list\n", __func__); - return -EINVAL; + ret = -EINVAL; + goto put_node; } val = prop->value; @@ -740,7 +752,11 @@ int of_init_opp_table(struct device *dev) nr -= 2; } - return 0; +put_node: + if (opp_node != dev->of_node) + of_node_put(opp_node); + + return ret; } EXPORT_SYMBOL_GPL(of_init_opp_table); #endif diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c index ef89897..cd4dbb3 100644 --- a/drivers/base/power/opp.c +++ b/drivers/base/power/opp.c @@ -708,14 +708,25 @@ struct srcu_notifier_head *opp_get_notifier(struct device *dev) int of_init_opp_table(struct device *dev) { const struct property *prop; + struct device_node *opp_node; const __be32 *val; - int nr; - - prop = of_find_property(dev->of_node, "operating-points", NULL); - if (!prop) - return -ENODEV; - if (!prop->value) - return -ENODATA; + int nr, ret = 0; + + opp_node = of_parse_phandle(dev->of_node, + "operating-points-phandle", 0); + if (!opp_node) /* if no OPP phandle, search for OPPs in current node */ + opp_node = dev->of_node; + prop = of_find_property(opp_node, "operating-points", NULL); + if (!prop) { + dev_warn(dev, "node %s missing operating-points property\n", + opp_node->full_name); + ret = -ENODEV; + goto put_node; + } + if (!prop->value) { + ret = -ENODATA; + goto put_node; + } /*