From patchwork Mon Jun 15 11:57:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 49857 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 03FCE205DE for ; Mon, 15 Jun 2015 11:58:38 +0000 (UTC) Received: by wifx6 with SMTP id x6sf20565238wif.1 for ; Mon, 15 Jun 2015 04:58:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:in-reply-to:references :sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=rwJs8/7uLO2SqM70aWqD9e9W3zaHL5ZcGp899/IzS0E=; b=G9dqyV0C7nvWeVZmVW3oPh3dNKah8v13jSHpzfa7Jai2RbtpetuLK3+QhnJF4+hp6l MXlP+Y/EzEus4SqrhmKbD//wYjyDiC8UIJMHnLthv+wvhNuJGZAY9YajiZr5RTpSQ5vD lbYoArKymTbBEzprgJAlBnFWfiYsxLNJzcw0Uu2qfWeoeJ8bfj+z6udwUApgW7LeK3yF KIUnUcM7FCXobttvjPnRy5Lv2pcwSaW5QdG/p2/r62GsFyjAiqGTgpZc4vWcie8IOeFV LjfFHIg5ZdSOaBylqYxfaXhqQjt+oROX/Ep/F9ne+mHHV2BegdL4f7R7iWJuLAy90N/I /sHQ== X-Gm-Message-State: ALoCoQm8EEBELbbfOSgXTBEXl+hoveeMLbg1rdc5b6iToHxZdgas8OcXANVaT9yMXU2nzXTS6S12 X-Received: by 10.112.14.101 with SMTP id o5mr29316505lbc.3.1434369517310; Mon, 15 Jun 2015 04:58:37 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.88.41 with SMTP id bd9ls884087lab.109.gmail; Mon, 15 Jun 2015 04:58:37 -0700 (PDT) X-Received: by 10.112.25.39 with SMTP id z7mr27402474lbf.102.1434369517159; Mon, 15 Jun 2015 04:58:37 -0700 (PDT) Received: from mail-lb0-f170.google.com (mail-lb0-f170.google.com. [209.85.217.170]) by mx.google.com with ESMTPS id b3si10310766lbd.117.2015.06.15.04.58.37 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Jun 2015 04:58:37 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.170 as permitted sender) client-ip=209.85.217.170; Received: by lbbti3 with SMTP id ti3so14436337lbb.1 for ; Mon, 15 Jun 2015 04:58:37 -0700 (PDT) X-Received: by 10.112.209.106 with SMTP id ml10mr26364119lbc.112.1434369517037; Mon, 15 Jun 2015 04:58:37 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp1363782lbb; Mon, 15 Jun 2015 04:58:35 -0700 (PDT) X-Received: by 10.70.89.199 with SMTP id bq7mr47115438pdb.168.1434369515231; Mon, 15 Jun 2015 04:58:35 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gu10si258184pbc.26.2015.06.15.04.58.34; Mon, 15 Jun 2015 04:58:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754080AbbFOL6d (ORCPT + 11 others); Mon, 15 Jun 2015 07:58:33 -0400 Received: from mail-pa0-f48.google.com ([209.85.220.48]:35729 "EHLO mail-pa0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754045AbbFOL6d (ORCPT ); Mon, 15 Jun 2015 07:58:33 -0400 Received: by pacyx8 with SMTP id yx8so64443319pac.2 for ; Mon, 15 Jun 2015 04:58:32 -0700 (PDT) X-Received: by 10.70.134.70 with SMTP id pi6mr47380218pdb.100.1434369512716; Mon, 15 Jun 2015 04:58:32 -0700 (PDT) Received: from localhost ([122.167.70.98]) by mx.google.com with ESMTPSA id mq2sm12042991pbb.16.2015.06.15.04.58.31 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 15 Jun 2015 04:58:32 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , rob.herring@linaro.org, nm@ti.com Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, arnd.bergmann@linaro.org, broonie@kernel.org, mike.turquette@linaro.org, sboyd@codeaurora.org, Sudeep.Holla@arm.com, viswanath.puttagunta@linaro.org, l.stach@pengutronix.de, thomas.petazzoni@free-electrons.com, linux-arm-kernel@lists.infradead.org, ta.omasab@gmail.com, kesavan.abhilash@gmail.com, khilman@linaro.org, santosh.shilimkar@oracle.com, Viresh Kumar Subject: [PATCH 10/10] cpufreq-dt: Add support for operating-points-v2 bindings Date: Mon, 15 Jun 2015 17:27:36 +0530 Message-Id: X-Mailer: git-send-email 2.4.0 In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.170 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Support for parsing operating-points-v2 bindings is in place now, lets modify cpufreq-dt driver to use them. For backward compatibility we will continue to support earlier bindings. Special handling for that is required, to make sure OPPs are initialized for all the CPUs. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq-dt.c | 58 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 47 insertions(+), 11 deletions(-) diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c index bab67db54b7e..f7bb2976059a 100644 --- a/drivers/cpufreq/cpufreq-dt.c +++ b/drivers/cpufreq/cpufreq-dt.c @@ -184,7 +184,6 @@ static int allocate_resources(int cpu, struct device **cdev, static int cpufreq_init(struct cpufreq_policy *policy) { - struct cpufreq_dt_platform_data *pd; struct cpufreq_frequency_table *freq_table; struct device_node *np; struct private_data *priv; @@ -192,7 +191,8 @@ static int cpufreq_init(struct cpufreq_policy *policy) struct regulator *cpu_reg; struct clk *cpu_clk; unsigned long min_uV = ~0, max_uV = 0; - unsigned int transition_latency; + unsigned int transition_latency = 0; + bool need_update = false; int ret; ret = allocate_resources(policy->cpu, &cpu_dev, &cpu_reg, &cpu_clk); @@ -208,8 +208,47 @@ static int cpufreq_init(struct cpufreq_policy *policy) goto out_put_reg_clk; } - /* OPPs might be populated at runtime, don't check for error here */ - of_init_opp_table(cpu_dev); + /* Get OPP-sharing information from "operating-points-v2" bindings */ + ret = of_get_cpus_sharing_opps(cpu_dev, policy->cpus); + if (ret) { + /* + * operating-points-v2 not supported, fallback to old method of + * finding shared-OPPs for backward compatibility. + */ + if (ret == -ENOENT) + need_update = true; + else + goto out_node_put; + } + + /* + * Initialize OPP tables for all policy->cpus. They will be shared by + * all CPUs which have marked their CPUs shared with OPP bindings. + * + * For platforms not using operating-points-v2 bindings, we do this + * before updating policy->cpus. Otherwise, we will end up creating + * duplicate OPPs for policy->cpus. + * + * OPPs might be populated at runtime, don't check for error here + */ + of_cpumask_init_opp_table(policy->cpus); + + if (need_update) { + struct cpufreq_dt_platform_data *pd = cpufreq_get_driver_data(); + + if (!pd || !pd->independent_clocks) + cpumask_setall(policy->cpus); + + /* + * OPP tables are initialized only for policy->cpu, do it for + * others as well. + */ + set_cpus_sharing_opps(cpu_dev, policy->cpus); + + of_property_read_u32(np, "clock-latency", &transition_latency); + } else { + transition_latency = dev_pm_opp_get_max_clock_latency(cpu_dev); + } /* * But we need OPP table to function so if it is not there let's @@ -230,7 +269,7 @@ static int cpufreq_init(struct cpufreq_policy *policy) of_property_read_u32(np, "voltage-tolerance", &priv->voltage_tolerance); - if (of_property_read_u32(np, "clock-latency", &transition_latency)) + if (!transition_latency) transition_latency = CPUFREQ_ETERNAL; if (!IS_ERR(cpu_reg)) { @@ -293,10 +332,6 @@ static int cpufreq_init(struct cpufreq_policy *policy) policy->cpuinfo.transition_latency = transition_latency; - pd = cpufreq_get_driver_data(); - if (!pd || !pd->independent_clocks) - cpumask_setall(policy->cpus); - of_node_put(np); return 0; @@ -306,7 +341,8 @@ static int cpufreq_init(struct cpufreq_policy *policy) out_free_priv: kfree(priv); out_free_opp: - of_free_opp_table(cpu_dev); + of_cpumask_free_opp_table(policy->cpus); +out_node_put: of_node_put(np); out_put_reg_clk: clk_put(cpu_clk); @@ -322,7 +358,7 @@ static int cpufreq_exit(struct cpufreq_policy *policy) cpufreq_cooling_unregister(priv->cdev); dev_pm_opp_free_cpufreq_table(priv->cpu_dev, &policy->freq_table); - of_free_opp_table(priv->cpu_dev); + of_cpumask_free_opp_table(policy->related_cpus); clk_put(policy->clk); if (!IS_ERR(priv->cpu_reg)) regulator_put(priv->cpu_reg);